Merge "Import revised translations.  DO NOT MERGE" into honeycomb
diff --git a/api/11.xml b/api/11.xml
index d79baf0..232f62c4 100644
--- a/api/11.xml
+++ b/api/11.xml
@@ -238854,7 +238854,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
@@ -240832,7 +240832,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
diff --git a/api/current.xml b/api/current.xml
index a1113ec..8b9f381 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -238864,7 +238864,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
@@ -240842,7 +240842,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
diff --git a/core/java/android/app/admin/package.html b/core/java/android/app/admin/package.html
new file mode 100644
index 0000000..1a81083
--- /dev/null
+++ b/core/java/android/app/admin/package.html
@@ -0,0 +1,12 @@
+<HTML>
+<BODY>
+<p>Provides device administration features at the system level, allowing you to create
+security-aware applications that are useful in enterprise settings, in which IT professionals
+require rich control over employee devices.</p>
+
+<p>For more information, see the <a
+href="{@docRoot}guide/topics/admin/device-admin.html">Device Administration</a> developer guide.</p>
+{@more}
+
+</BODY>
+</HTML>
diff --git a/core/java/android/app/backup/package.html b/core/java/android/app/backup/package.html
index e140349..56658f5 100644
--- a/core/java/android/app/backup/package.html
+++ b/core/java/android/app/backup/package.html
@@ -2,9 +2,10 @@
 <BODY>
 <p>Contains the backup and restore functionality available to
 applications. If a user wipes the data on their device or upgrades to a new Android-powered
-device, all applications that have enabled backup will restore the user's previous data.</p>
+device, all applications that have enabled backup can restore the user's previous data when the
+application is reinstalled.</p>
 
-<p>For a detailed guide to using the backup APIs, see the <a
+<p>For more information, see the <a
 href="{@docRoot}guide/topics/data/backup.html">Data Backup</a> developer guide.</p>
 {@more}
 
diff --git a/core/java/android/app/package.html b/core/java/android/app/package.html
index 048ee93..5137600 100644
--- a/core/java/android/app/package.html
+++ b/core/java/android/app/package.html
@@ -1,72 +1,43 @@
 <html>
-<head>
-<script type="text/javascript" src="http://www.corp.google.com/style/prettify.js"></script>
-<script src="http://www.corp.google.com/eng/techpubs/include/navbar.js" type="text/javascript"></script>
-</head>
 
 <body>
 
-<p>High-level classes encapsulating the overall Android application model.
-The central class is {@link android.app.Activity}, with other top-level
-application components being defined by {@link android.app.Service} and,
-from the {@link android.content} package, {@link android.content.BroadcastReceiver}
-and {@link android.content.ContentProvider}.  It also includes application
-tools, such as dialogs and notifications.</p>
+<p>Contains high-level classes encapsulating the overall Android application model.</p>
 
-<p>This package builds on top of the lower-level Android packages
-{@link android.widget}, {@link android.view}, {@link android.content},
-{@link android.text}, {@link android.graphics}, {@link android.os}, and
-{@link android.util}.</p>
+<p>An Android application is defined using one or more of Android's four core application
+components. Two such application components are defined in this package: {@link
+android.app.Activity} and {@link android.app.Service}. The other two components are from the {@link
+android.content} package: {@link android.content.BroadcastReceiver} and {@link
+android.content.ContentProvider}.</p>
 
-<p>An {@link android.app.Activity Activity} is a specific operation the
-user can perform, generally corresponding
-to one screen in the user interface.
-It is the basic building block of an Android application.
-Examples of activities are "view the
-list of people," "view the details of a person," "edit information about
-a person," "view an image," etc.  Switching from one activity to another
-generally implies adding a new entry on the navigation history; that is,
-going "back" means moving to the previous activity you were doing.</p>
+<p>An {@link android.app.Activity} is an application component that provides a screen with which
+users can interact in order to do something, such as dial the phone, take a photo, send an email, or
+view a map. An activity can start other activities, including activities that live in separate
+applications.</p>
 
-<p>A set of related activities can be grouped together as a "task".  Until
-a new task is explicitly specified, all activites you start are considered
-to be part of the current task.  While the only way to navigate between
-individual activities is by going "back" in the history stack, the group
-of activities in a task can be moved in relation to other tasks: for example
-to the front or the back of the history stack.  This mechanism can be used
-to present to the user a list of things they have been doing, moving
-between them without disrupting previous work.
-</p>
+<p>A {@link android.app.Service} is an application component that can perform
+long-running operations in the background without a user interface. For example, a service
+can handle network transactions, play music, or work with a content provider without the user being
+aware of the work going on.</p>
 
-<p>A complete "application" is a set of activities that allow the user to do a
-cohesive group of operations -- such as working with contacts, working with a
-calendar, messaging, etc.  Though there can be a custom application object
-associated with a set of activities, in many cases this is not needed --
-each activity provides a particular path into one of the various kinds of
-functionality inside of the application, serving as its on self-contained
-"mini application".
-</p>
+<p>The {@link android.app.Fragment} class is also an important part of an application's
+design&mdash;especially when designing for large screen devices, such as tablets. A fragment defines
+a distinct part of an activity's behavior, including the associated UI. It has its own lifecycle
+that is similar to that of the activity and can exist alongside other fragments that are embedded in
+the activity. While an activity is running, you can add and remove fragments and include each
+fragment in a back stack that's managed by the activity&mdash;allowing the user to navigate
+backwards through the fragment states, without leaving the activity.</p>
 
-<p>This approach allows an application to be broken into pieces, which
-can be reused and replaced in a variety of ways.  Consider, for example,
-a "camera application."  There are a number of things this application
-must do, each of which is provided by a separate activity: take a picture
-(creating a new image), browse through the existing images, display a
-specific image, etc.  If the "contacts application" then wants to let the
-user associate an image with a person, it can simply launch the existing
-"take a picture" or "select an image" activity that is part of the camera
-application and attach the picture it gets back.
-</p>
+<p>This package also defines application utilities, such as dialogs, notifications, and the
+action bar.</p>
 
-<p>Note that there is no hard relationship between tasks the user sees and
-applications the developer writes.  A task can be composed of activities from
-multiple applications (such as the contact application using an activity in 
-the camera application to get a picture for a person), and multiple active
-tasks may be running for the same application (such as editing e-mail messages
-to two different people).  The way tasks are organized is purely a UI policy
-decided by the system; for example, typically a new task is started when the
-user goes to the application launcher and selects an application.
-</p>
+<p>For information about using some the classes in this package, see the following
+documents: <a href="{@docRoot}guide/topics/fundamentals/index.html">Application
+Fundamentals</a> (for activities, services, and fragments), <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a>, <a
+href="{@docRoot}guide/topics/ui/dialogs.html">Creating Dialogs</a>, and <a
+href="{@docRoot}guide/topics/ui/notifiers/index.html">Notifying the User</a>.</p>
+
 
 </body>
 </html>
diff --git a/core/java/android/appwidget/package.html b/core/java/android/appwidget/package.html
index 2b85bd5..19fd2f7 100644
--- a/core/java/android/appwidget/package.html
+++ b/core/java/android/appwidget/package.html
@@ -1,32 +1,32 @@
 <body>
-<p>Android allows applications to publish views to be embedded in other applications.  These
-views are called widgets, and are published by "AppWidget providers."  The component that can
-contain widgets is called a "AppWidget host."
-</p>
-<p>For more information, see the 
-<a href="{@docRoot}guide/topics/appwidgets/index.html">AppWidgets</a> 
-documentation in the Dev Guide.</p>
-
+<p>Contains the components necessary to create "app widgets", which users can embed in other
+applications (such as the home screen) to quickly access application data and services without
+launching a new activity.</p>
+<p>For more information, see the
+<a href="{@docRoot}guide/topics/appwidgets/index.html">App Widgets</a>
+developer guide.</p>
 
 {@more}
+<p>The behavior of an app widget is published by an "app widget provider."  An "app widget host" is
+a component that can contain app widgets (such as the Home screen).</p>
 
+<p>Any application can publish app widgets (as an app widget provider).  All an application needs to
+do to publish an app widget is
+provide a {@link android.content.BroadcastReceiver} that receives the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE} intent
+and provide some metadata about the app widget.  Android provides the
+{@link android.appwidget.AppWidgetProvider} class, which extends {@link
+android.content.BroadcastReceiver}, as a convenience class to define the app widget behavrio and aid
+in handling the broadcasts.</p>
 
-<h2><a name="providers"></a>AppWidget Providers</h2>
-<p>Any application can publish widgets.  All an application needs to do to publish a widget is
-to have a {@link android.content.BroadcastReceiver} that receives the {@link
-android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} intent,
-and provide some meta-data about the widget.  Android provides the
-{@link android.appwidget.AppWidgetProvider} class, which extends BroadcastReceiver, as a convenience
-class to aid in handling the broadcasts.
-
-
-<h2>AppWidget Hosts</h3>
-<p>Widget hosts are the containers in which widgets can be placed.  Most of the look and feel
+<p>App widget hosts are the containers in which widgets can be placed.  Most of the look and feel
 details are left up to the widget hosts.  For example, the home screen has one way of viewing
 widgets, but the lock screen could also contain widgets, and it would have a different way of
 adding, removing and otherwise managing widgets.</p>
-<p>For more information on implementing your own widget host, see the
-{@link android.appwidget.AppWidgetHost AppWidgetHost} class.</p>
+
+<p>The <a href="{@docRoot}guide/topics/appwidgets/index.html">App Widgets</a>
+developer guide shows you how to create an app widget provider. For information about implementing
+an app widget host, see the {@link android.appwidget.AppWidgetHost} class.</p>
 
 </body>
 
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index 231f592..9246a10 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -56,7 +56,7 @@
      *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
      * </ul>
      *
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
      * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}.
      *
@@ -75,10 +75,10 @@
      * <ul>
      *   <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
      *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
-     *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. <li/>
+     *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
      * </ul>
      *
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING},
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java
index 768a6ff..fa55520 100644
--- a/core/java/android/bluetooth/BluetoothHeadset.java
+++ b/core/java/android/bluetooth/BluetoothHeadset.java
@@ -57,7 +57,7 @@
      *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
      *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
      * </ul>
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
      * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}.
      *
@@ -78,7 +78,7 @@
      *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
      *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
      * </ul>
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_AUDIO_CONNECTED}, {@link #STATE_AUDIO_DISCONNECTED},
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission
@@ -102,12 +102,12 @@
      *  <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE} - The AT
      *       command type which can be one of  {@link #AT_CMD_TYPE_READ},
      *       {@link #AT_CMD_TYPE_TEST}, or {@link #AT_CMD_TYPE_SET},
-     *       {@link #AT_CMD_TYPE_BASIC},{@link #AT_CMD_TYPE_ACTION}. <li/>
+     *       {@link #AT_CMD_TYPE_BASIC},{@link #AT_CMD_TYPE_ACTION}. </li>
      *  <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS} - Command
      *       arguments. </li>
      * </ul>
      *
-     * The category is the Company ID of the vendor defining the
+     *<p> The category is the Company ID of the vendor defining the
      * vendor-specific command. {@link BluetoothAssignedNumbers}
      *
      * For example, for Plantronics specific events
@@ -117,7 +117,7 @@
      * <ul>
      *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD = +XEVENT </li>
      *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE = AT_CMD_TYPE_SET </li>
-     *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3 <li>
+     *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3 </li>
      * </ul>
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission
      * to receive.
diff --git a/core/java/android/bluetooth/package.html b/core/java/android/bluetooth/package.html
index 9ac42dc..37505fd 100644
--- a/core/java/android/bluetooth/package.html
+++ b/core/java/android/bluetooth/package.html
@@ -3,7 +3,7 @@
 <p>Provides classes that manage Bluetooth functionality, such as scanning for
 devices, connecting with devices, and managing data transfer between devices.</p>
 
-<p>For a complete guide to using the Bluetooth APIs, see the <a
+<p>For more information, see the <a
 href="{@docRoot}guide/topics/wireless/bluetooth.html">Bluetooth</a> developer guide.</p>
 {@more}
 
@@ -25,6 +25,6 @@
 </p>
 
 <p class="note"><strong>Note:</strong>
-Not all Android devices are guaranteed to have Bluetooth functionality.</p>
+Not all Android-powered devices provide Bluetooth functionality.</p>
 </BODY>
 </HTML>
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 2fa2834..68cb2bc 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -1128,12 +1128,45 @@
                     pw.print(formatTime(status.initialFailureTime));
                     pw.print(" lastTime=");
                     pw.println(formatTime(status.lastFailureTime));
-                    pw.print("      message: "); pw.println(status.lastFailureMesg);
+                    int errCode = status.getLastFailureMesgAsInt(0);
+                    pw.print("      message: "); pw.println(
+                            getLastFailureMessage(errCode) + " (" + errCode + ")");
                 }
             }
         }
     }
 
+    private String getLastFailureMessage(int code) {
+        switch (code) {
+            case ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS:
+                return "sync already in progress";
+
+            case ContentResolver.SYNC_ERROR_AUTHENTICATION:
+                return "authentication error";
+
+            case ContentResolver.SYNC_ERROR_IO:
+                return "I/O error";
+
+            case ContentResolver.SYNC_ERROR_PARSE:
+                return "parse error";
+
+            case ContentResolver.SYNC_ERROR_CONFLICT:
+                return "conflict error";
+
+            case ContentResolver.SYNC_ERROR_TOO_MANY_DELETIONS:
+                return "too many deletions error";
+
+            case ContentResolver.SYNC_ERROR_TOO_MANY_RETRIES:
+                return "too many retries error";
+
+            case ContentResolver.SYNC_ERROR_INTERNAL:
+                return "internal error";
+
+            default:
+                return "unknown";
+        }
+    }
+
     private void dumpTimeSec(PrintWriter pw, long time) {
         pw.print(time/1000); pw.print('.'); pw.print((time/100)%10);
         pw.print('s');
diff --git a/core/java/android/content/package.html b/core/java/android/content/package.html
index eac679d..54086fe 100644
--- a/core/java/android/content/package.html
+++ b/core/java/android/content/package.html
@@ -1,649 +1,31 @@
 <html>
-<head>
-<script type="text/javascript" src="http://www.corp.google.com/style/prettify.js"></script>
-<script src="http://www.corp.google.com/eng/techpubs/include/navbar.js" type="text/javascript"></script>
-</head>
-
 <body>
 
-<p>Contains classes for accessing and publishing data
-on the device.  It includes three main categories of APIs:
-the {@link android.content.res.Resources Resources} for
-retrieving resource data associated with an application;
-{@link android.content.ContentProvider Content Providers} and
-{@link android.content.ContentResolver ContentResolver} for managing and
-publishing persistent data associated with an application; and
-the {@link android.content.pm.PackageManager Package Manager}
-for finding out information about the application packages installed
-on the device.</p>
+<p>Contains classes for accessing and publishing data on a device.  It includes three main
+categories of APIs:</p>
 
-<p>In addition, the {@link android.content.Context Context} abstract class
-is a base API for pulling these pieces together, allowing you to access
-an application's resources and transfer data between applications.</p>
+<ul>
+  <dt>Content sharing ({@link android.content})</dt>
+  <dd>For sharing content between application components. The most important classes are:
+    <ul>
+      <li>{@link android.content.ContentProvider} and {@link android.content.ContentResolver}
+  for managing and publishing persistent data associated with an application.</li>
+      <li>{@link android.content.Intent} and {@link android.content.IntentFilter}, for delivering
+  structured messages between different application components&mdash;allowing components to initiate
+  other components and return results.</li>
+    </ul>
+  </dd>
 
-<p>This package builds on top of the lower-level Android packages
-{@link android.database}, {@link android.text},
-{@link android.graphics.drawable}, {@link android.graphics},
-{@link android.os}, and {@link android.util}.</p>
+  <dt>Package management ({@link android.content.pm})</dt>
+  <dd>For accessing information about an Android package (an {@code .apk}), including information
+about its activities, permissions, services, signatures, and providers. The most important class for
+accessing this information is {@link android.content.pm.PackageManager}.</dd>
 
-<ol>
-	<li> <a href="#Resources">Resources</a>
-		<ol>
-			<li> <a href="#ResourcesTerminology">Terminology</a>
-			<li> <a href="#ResourcesQuickStart">Examples</a>
-				<ol>
-					<li> <a href="#UsingSystemResources">Using System Resources</a>
-					<li> <a href="#StringResources">String Resources</a>
-					<li> <a href="#ColorResources">Color Resources</a>
-					<li> <a href="#DrawableResources">Drawable Resources</a>
-					<li> <a href="#LayoutResources">Layout Resources</a>
-					<li> <a href="#ReferencesToResources">References to Resources</a>
-					<li> <a href="#ReferencesToThemeAttributes">References to Theme Attributes</a>
-					<li> <a href="#StyleResources">Style Resources</a>
-					<li> <a href="#StylesInLayoutResources">Styles in Layout Resources</a>                    
-				</ol>
-		</ol>
-</ol>
-
-<a name="Resources"></a>
-<h2>Resources</h2>
-
-<p>This topic includes a terminology list associated with resources, and a series
-    of examples of using resources in code. For a complete guide on creating and
-    using resources, see the document on <a href="{@docRoot}guide/topics/resources/resources-i18n.html">Resources
-    and Internationalization</a>.  For a reference on the supported Android resource types,
-    see <a href="{@docRoot}guide/topics/resources/available-resources.html">Available Resource Types</a>.</p>
-<p>The Android resource system keeps track of all non-code
-    assets associated with an application.  You use the
-    {@link android.content.res.Resources Resources} class to access your
-    application's resources; the Resources instance associated with your
-    application can generally be found through
-    {@link android.content.Context#getResources Context.getResources()}.</p>
-<p>An application's resources are compiled into the application
-binary at build time for you by the build system.  To use a resource,
-you must install it correctly in the source tree and build your
-application.  As part of the build process, Java symbols for each
-of the resources are generated that you can use in your source
-code -- this allows the compiler to verify that your application code matches
-up with the resources you defined.</p>
-
-<p>The rest of this section is organized as a tutorial on how to
-use resources in an application.</p>
-
-<a name="ResourcesTerminology"></a>
-<h3>Terminology</h3>
-
-<p>The resource system brings a number of different pieces together to
-form the final complete resource functionality.  To help understand the
-overall system, here are some brief definitions of the core concepts and
-components you will encounter in using it:</p>
-
-<p><b>Asset</b>: A single blob of data associated with an application.  This
-includes Java object files, graphics (such as PNG images), XML files, etc.
-These files are organized in a directory hierarchy that, during final packaging
-of the application, is bundled together into a single ZIP file.</p>
-
-<p><b>aapt</b>: The tool that generates the final ZIP file of application
-assets.  In addition to collecting raw assets together, it also parses
-resource definitions into binary asset data.</p>
-
-<p><b>Resource Table</b>: A special asset that aapt generates for you,
-describing all of the resources contained in an application/package.
-This file is accessed for you by the Resources class; it is not touched
-directly by applications.</p>
-
-<p><b>Resource</b>: An entry in the Resource Table describing a single
-named value.  Broadly, there are two types of resources: primitives and
-bags.</p>
-
-<p><b>Resource Identifier</b>: In the Resource Table all resources are
-identified by a unique integer number.  In source code (resource descriptions,
-XML files, Java code) you can use symbolic names that stand as constants for
-the actual resource identifier integer.</p>
-
-<p><b>Primitive Resource</b>: All primitive resources can be written as a
-simple string, using formatting to describe a variety of primitive types
-included in the resource system: integers, colors, strings, references to
-other resources, etc.  Complex resources, such as bitmaps and XML
-describes, are stored as a primitive string resource whose value is the path
-of the underlying Asset holding its actual data.</p>
-
-<p><b>Bag Resource</b>: A special kind of resource entry that, instead of a
-simple string, holds an arbitrary list of name/value pairs.  Each name is
-itself a resource identifier, and each value can hold
-the same kinds of string formatted data as a normal resource.  Bags also
-support inheritance: a bag can inherit the values from another bag, selectively
-replacing or extending them to generate its own contents.</p>
-
-<p><b>Kind</b>: The resource kind is a way to organize resource identifiers
-for various purposes.  For example, drawable resources are used to
-instantiate Drawable objects, so their data is a primitive resource containing
-either a color constant or string path to a bitmap or XML asset.  Other
-common resource kinds are string (localized string primitives), color
-(color primitives), layout (a string path to an XML asset describing a view
-layout), and style (a bag resource describing user interface attributes).
-There is also a standard "attr" resource kind, which defines the resource
-identifiers to be used for naming bag items and XML attributes</p>
-
-<p><b>Style</b>: The name of the resource kind containing bags that are used
-to supply a set of user interface attributes.  For example, a TextView class may
-be given a style resource that defines its text size, color, and alignment.
-In a layout XML file, you associate a style with a bag using the "style"
-attribute, whose value is the name of the style resource.</p>
-
-<p><b>Style Class</b>: Specifies a related set of attribute resources.
-This data is not placed in the resource table itself, but used to generate
-Java constants that make it easier for you to retrieve values out of
-a style resource and/or XML tag's attributes.  For example, the
-Android platform defines a "View" style class that
-contains all of the standard view attributes: padding, visibility,
-background, etc.; when View is inflated it uses this style class to
-retrieve those values from the XML file (at which point style and theme
-information is applied as approriate) and load them into its instance.</p>
-
-<p><b>Configuration</b>: For any particular resource identifier, there may be
-multiple different available values depending on the current configuration.
-The configuration includes the locale (language and country), screen
-orientation, screen density, etc.  The current configuration is used to
-select which resource values are in effect when the resource table is
-loaded.</p>
-
-<p><b>Theme</b>: A standard style resource that supplies global
-attribute values for a particular context.  For example, when writing a
-Activity the application developer can select a standard theme to use, such
-as the Theme.White or Theme.Black styles; this style supplies information
-such as the screen background image/color, default text color, button style,
-text editor style, text size, etc.  When inflating a layout resource, most
-values for widgets (the text color, selector, background) if not explicitly
-set will come from the current theme; style and attribute
-values supplied in the layout can also assign their value from explicitly
-named values in the theme attributes if desired.</p>
-
-<p><b>Overlay</b>: A resource table that does not define a new set of resources,
-but instead replaces the values of resources that are in another resource table.
-Like a configuration, this is applied at load time
-to the resource data; it can add new configuration values (for example
-strings in a new locale), replace existing values (for example change
-the standard white background image to a "Hello Kitty" background image),
-and modify resource bags (for example change the font size of the Theme.White
-style to have an 18 pt font size).  This is the facility that allows the
-user to select between different global appearances of their device, or
-download files with new appearances.</p>
-
-<a name="ResourcesQuickStart"></a>
-<h3>Examples</h3>
-
-<p>This section gives a few quick examples you can use to make your own resources.
-    For more details on how to define and use resources, see <a
-    href="{@docRoot}guide/topics/resources/resources-i18n.html">Resources and 
-    Internationalization</a>. </p>
-
-<a name="UsingSystemResources"></a>
-<h4>Using System Resources</h4>
-
-<p>Many resources included with the system are available to applications.
-All such resources are defined under the class "android.R".  For example,
-you can display the standard application icon in a screen with the following
-code:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        requestScreenFeatures(FEATURE_BADGE_IMAGE);
-
-        super.onStart();
-
-        setBadgeResource(android.R.drawable.sym_def_app_icon);
-    }
-}
-</pre>
-
-<p>In a similar way, this code will apply to your screen the standard
-"green background" visual treatment defined by the system:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        super.onStart();
-
-        setTheme(android.R.style.Theme_Black);
-    }
-}
-</pre>
-
-<a name="StringResources"></a>
-<h4>String Resources</h4>
-
-<p>String resources are defined using an XML resource description syntax.
-The file or multiple files containing these resources can be given any name
-(as long as it has a .xml suffix) and placed at an appropriate location in
-the source tree for the desired configuration (locale/orientation/density).
-
-<p>Here is a simple resource file describing a few strings:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;string id="mainLabel"&gt;Hello &lt;u&gt;th&lt;ignore&gt;e&lt;/ignore&gt;re&lt;/u&gt;, &lt;i&gt;you&lt;/i&gt; &lt;b&gt;Activity&lt;/b&gt;!&lt;/string&gt;
-    &lt;string id="back"&gt;Back&lt;/string&gt;
-    &lt;string id="clear"&gt;Clear&lt;/string&gt;
-&lt;/resources&gt;
-</pre>
-
-<p>Typically this file will be called "strings.xml", and must be placed
-in the <code>values</code> directory:</p>
-
-<pre>
-MyApp/res/values/strings.xml
-</pre>
-
-<p>The strings can now be retrieved by your application through the
-symbol specified in the "id" attribute:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        super.onStart();
-
-        String back = getResources().getString(R.string.back).toString();
-        back = getString(R.string.back).toString();  // synonym
-    }
-}
-</pre>
-
-<p>Unlike system resources, the resource symbol (the R class) we are using 
-here comes from our own application's package, not android.R.</p>
-
-<p>Note that the "mainLabel" string is complex, including style information.
-To support this, the <code>getString()</code> method returns a
-<code>CharSequence</code> object that you can pass to a
-<code>TextView</code> to retain those style.  This is why code
-must call <code>toString()</code> on the returned resource if it wants
-a raw string.</p>
-
-<a name="ColorResources"></a>
-<h4>Color Resources</h4>
-
-<p>Color resources are created in a way very similar to string resources,
-but with the &lt;color&gt; resource tag.  The data for these resources
-must be a hex color constant of the form "#rgb", "#argb", "#rrggbb", or
-"#aarrggbb".  The alpha channel is 0xff (or 0xf) for opaque and 0
-for transparent.</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;color id="opaque_red"&gt;#ffff0000&lt;/color&gt;
-    &lt;color id="transparent_red"&gt;#80ff0000&lt;/color&gt;
-    &lt;color id="opaque_blue"&gt;#0000ff&lt;/color&gt;
-    &lt;color id="opaque_green"&gt;#0f0&lt;/color&gt;
-&lt;/resources&gt;
-</pre>
-
-<p>While color definitions could be placed in the same resource file
-as the previously shown string data, usually you will place the colors in
-their own file:</p>
-
-<pre>
-MyApp/res/values/colors.xml
-</pre>
-
-<p>The colors can now be retrieved by your application through the
-symbol specified in the "id" attribute:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        super.onStart();
-
-        int red = getResources().getColor(R.color.opaque_red);
-    }
-}
-</pre>
-
-<a name="DrawableResources"></a>
-<h4>Drawable Resources</h4>
-
-<p>For simple drawable resources, all you need to do is place your
-image in a special resource sub-directory called "drawable".  Files here
-are things that can be handled by an implementation of the
-{@link android.graphics.drawable.Drawable Drawable} class, often bitmaps
-(such as PNG images) but also various kinds of XML descriptions
-for selectors, gradients, etc.</p>
-
-<p>The drawable files will be scanned by the
-resource tool, automatically generating a resource entry for each found.
-For example the file <code>res/drawable/&lt;myimage&gt;.&lt;ext&gt;</code>
-will result in a resource symbol named "myimage" (without the extension).  Note
-that these file names <em>must</em> be valid Java identifiers, and should
-have only lower-case letters.</p>
-
-<p>For example, to use your own custom image as a badge in a screen,
-you can place the image here:</p>
-
-<pre>
-MyApp/res/drawable/my_badge.png
-</pre>
-
-<p>The image can then be used in your code like this:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        requestScreenFeatures(FEATURE_BADGE_IMAGE);
-
-        super.onStart();
-
-        setBadgeResource(R.drawable.my_badge);
-    }
-}
-</pre>
-
-<p>For drawables that are a single solid color, you can also define them
-in a resource file very much like colors shown previously.  The only
-difference is that here we use the &lt;drawable&gt; tag to create a
-drawable resource.</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;drawable id="opaque_red"&gt;#ffff0000&lt;/drawable&gt;
-    &lt;drawable id="transparent_red"&gt;#80ff0000&lt;/drawable&gt;
-    &lt;drawable id="opaque_blue"&gt;#0000ff&lt;/drawable&gt;
-    &lt;drawable id="opaque_green"&gt;#0f0&lt;/drawable&gt;
-&lt;/resources&gt;
-</pre>
-
-<p>These resource entries are often placed in the same resource file
-as color definitions:</p>
-
-<pre>
-MyApp/res/values/colors.xml
-</pre>
-
-<a name="LayoutResources"></a>
-<h4>Layout Resources</h4>
-
-<p>Layout resources describe a view hierarchy configuration that is
-generated at runtime.  These resources are XML files placed in the
-resource directory "layout", and are how you should create the content
-views inside of your screen (instead of creating them by hand) so that
-they can be themed, styled, configured, and overlayed.</p>
-
-<p>Here is a simple layout resource consisting of a single view, a text
-editor:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text"
-        android:layout_width="fill-parent" android:layout_height="fill-parent"
-        android:text="Hello, World!" /&gt;
-&lt;/root&gt;
-</pre>
-
-<p>To use this layout, it can be placed in a file like this:</p>
-
-<pre>
-MyApp/res/layout/my_layout.xml
-</pre>
-
-<p>The layout can then be instantiated in your screen like this:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        super.onStart();
-        setContentView(R.layout.my_layout);
-    }
-}
-</pre>
-
-<p>Note that there are a number of visual attributes that can be supplied
-to TextView (including textSize, textColor, and textStyle) that we did
-not define in the previous example; in such a sitation, the default values for
-those attributes come from the theme.  If we want to customize them, we
-can supply them explicitly in the XML file:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text"
-        android:layout_width="match_parent" android:layout_height="match_parent"
-        <b>android:textSize="18" android:textColor="#008"</b>
-        android:text="Hello, World!" /&gt;
-&lt;/root&gt;
-</pre>
-
-<p>However, usually these kinds of attributes (those being attributes that
-usually make sense to vary with theme or overlay) should be defined through
-the theme or separate style resource.  Later we will see how this is done.</p>
-
-<a name="ReferencesToResources"></a>
-<h4>References to Resources</h4>
-
-<p>A value supplied in an attribute (or resource) can also be a reference to
-a resource.  This is often used in layout files to supply strings (so they
-can be localized) and images (which exist in another file), though a reference
-can be do any resource type including colors and integers.</p>
-
-<p>For example, if we have the previously defined color resources, we can
-write a layout file that sets the text color size to be the value contained in
-one of those resources:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text"
-        android:layout_width="match_parent" android:layout_height="match_parent"
-        <b>android:textColor="@color/opaque_red"</b>
-        android:text="Hello, World!" /&gt;
-&lt;/root&gt;
-</pre>
-
-<p>Note here the use of the '@' prefix to introduce a resource reference -- the
-text following that is the name of a resource in the form
-of <code>@[package:]type/name</code>.  In this case we didn't need to specify
-the package because we are referencing a resource in our own package.  To
-reference a system resource, you would need to write:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text"
-        android:layout_width="match_parent" android:layout_height="match_parent"
-        android:textColor="@<b>android:</b>color/opaque_red"
-        android:text="Hello, World!" /&gt;
-&lt;/root&gt;
-</pre>
-
-<p>As another example, you should always use resource references when supplying
-strings in a layout file so that they can be localized:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text"
-        android:layout_width="match_parent" android:layout_height="match_parent"
-        android:textColor="@android:color/opaque_red"
-        android:text="@string/hello_world" /&gt;
-&lt;/root&gt;
-</pre>
-
-<p>This facility can also be used to create references between resources.
-For example, we can create new drawable resources that are aliases for
-existing images:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;drawable id="my_background"&gt;@android:drawable/theme2_background&lt;/drawable&gt;
-&lt;/resources&gt;
-</pre>
-
-<a name="ReferencesToThemeAttributes"></a>
-<h4>References to Theme Attributes</h4>
-
-<p>Another kind of resource value allows you to reference the value of an
-attribute in the current theme.  This attribute reference can <em>only</em>
-be used in style resources and XML attributes; it allows you to customize the
-look of UI elements by changing them to standard variations supplied by the
-current theme, instead of supplying more concrete values.</p>
-
-<p>As an example, we can use this in our layout to set the text color to
-one of the standard colors defined in the base system theme:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text"
-        android:layout_width="match_parent" android:layout_height="match_parent"
-        <b>android:textColor="?android:textDisabledColor"</b>
-        android:text="@string/hello_world" /&gt;
-&lt;/root&gt;
-</pre>
-
-<p>Note that this is very similar to a resource reference, except we are using
-an '?' prefix instead of '@'.  When you use this markup, you are supplying
-the name of an attribute resource that will be looked up in the theme --
-because the resource tool knows that an attribute resource is expected,
-you do not need to explicitly state the type (which would be
-<code>?android:attr/android:textDisabledColor</code>).</p>
-
-<p>Other than using this resource identifier to find the value in the
-theme instead of raw resources, the name syntax is identical to the '@' format:
-<code>?[package:]type/name</code> with the type here being optional.</p>
-
-<a name="StyleResources"></a>
-<h4>Style Resources</h4>
-
-<p>A style resource is a set of name/value pairs describing a group
-of related attributes.  There are two main uses for these resources:
-defining overall visual themes, and describing a set of visual attributes
-to apply to a class in a layout resource.  In this section we will look
-at their use to describe themes; later we will look at using them in
-conjunction with layouts.</p>
-
-<p>Like strings, styles are defined through a resource XML file.  In the
-situation where we want to define a new theme, we can create a custom theme
-style that inherits from one of the standard system themes:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;style id="Theme" parent="android:Theme.White"&gt;
-        &lt;item id="android:foregroundColor"&gt;#FFF8D96F&lt;/item&gt;
-        &lt;item id="android:textColor"&gt;@color/opaque_blue&lt;/item&gt;
-        &lt;item id="android:textSelectedColor"&gt;?android:textColor&lt;/item&gt;
-    &lt;/style&gt;
-&lt;/resources&gt;
-</pre>
-
-<p>Typically these resource definitions will be placed in a file
-called "styles.xml" , and must be placed in the <code>values</code>
-directory:</p>
-
-<pre>
-MyApp/res/values/styles.xml
-</pre>
-
-<p>Similar to how we previously used a system style for an Activity theme,
-you can apply this style to your Activity:</p>
-
-<pre class="prettyprint">
-public class MyActivity extends Activity
-{
-    public void onStart() 
-    {
-        super.onStart();
-
-        setTheme(R.style.Theme);
-    }
-}
-</pre>
-
-<p>In the style resource shown here, we used the <code>parent</code>
-attribute to specify another style resource from which it inherits
-its values -- in this case the <code>Theme.White</code> system resource:</p>
-
-<pre>
-    &lt;style id="Home" parent="android:Theme.White"&gt;
-        ...
-    &lt;/style&gt;
-</pre>
-
-<p>Note, when doing this, that you must use the "android" prefix in front
-to tell the compiler the namespace to look in for the resource --
-the resources you are specifying here are in your application's namespace,
-not the system.  This explicit namespace specification ensures that names
-the application uses will not accidentally conflict with those defined by
-the system.</p>
-
-<p>If you don't specify an explicit parent style, it will be inferred
-from the style name -- everything before the final '.' in the name of the
-style being defined is taken as the parent style name.  Thus, to make
-another style in your application that inherits from this base Theme style,
-you can write:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;style id="Theme.WhiteText"&gt;
-        &lt;item id="android:foregroundColor"&gt;#FFFFFFFF&lt;/item&gt;
-        &lt;item id="android:textColor"&gt;?android:foregroundColor&lt;/item&gt;
-    &lt;/style&gt;
-&lt;/resources&gt;
-</pre>
-
-<p>This results in the symbol <code>R.style.Theme_WhiteText</code> that
-can be used in Java just like we did with <code>R.style.Theme</code>
-above.</p>
-
-<a name="StylesInLayoutResources"></a>
-<h4>Styles in Layout Resources</h4>
-
-<p>Often you will have a number fo views in a layout that all use the same
-set of attributes, or want to allow resource overlays to modify the values of
-attributes.  Style resources can be used for both of these purposes, to put
-attribute definitions in a single place that can be references by multiple
-XML tags and modified by overlays.  To do this, you simply define a
-new style resource with the desired values:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;resources&gt;
-    &lt;style id="SpecialText"&gt;
-        &lt;item id="android:textSize"&gt;18&lt;/item&gt;
-        &lt;item id="android:textColor"&gt;#008&lt;/item&gt;
-    &lt;/style&gt;
-&lt;/resources&gt;
-</pre>
-
-<p>You can now apply this style to your TextView in the XML file:</p>
-
-<pre>
-&lt;?xml version="1.0" encoding="utf-8"?&gt;
-&lt;root&gt;
-    &lt;EditText id="text1" <b>style="@style/SpecialText"</b>
-        android:layout_width="match_parent" android:layout_height="wrap_content"
-        android:text="Hello, World!" /&gt;
-    &lt;EditText id="text2" <b>style="@style/SpecialText"</b>
-        android:layout_width="match_parent" android:layout_height="wrap_content"
-        android:text="I love you all." /&gt;
-&lt;/root&gt;</pre>
-<h4>&nbsp;</h4>
+  <dt>Resource management ({@link android.content.res})</dt>
+  <dd>For retrieving resource data associated with an application, such as strings, drawables,
+media, and device configuration details. The most important class for accessing this data is {@link
+android.content.res.Resources}.</dd>
+</ul>
 
 </body>
 </html>
diff --git a/core/java/android/content/pm/package.html b/core/java/android/content/pm/package.html
index 766b7dd..b18adb2 100644
--- a/core/java/android/content/pm/package.html
+++ b/core/java/android/content/pm/package.html
@@ -1,7 +1,11 @@
 <HTML>
 <BODY>
-Contains classes for accessing information about an 
-application package, including information about its activities, 
-permissions, services, signatures, and providers.
+<p>Contains classes for accessing information about an
+application package, including information about its activities,
+permissions, services, signatures, and providers.</p>
+<p>Most of the information about an application package is defined by its manifest file. For
+more information, see the <a
+href="{@docRoot}guide/topics/manifest/guide/topics/manifest/manifest-intro.html">AndroidManifest.xml
+File</a> documentation.</p>
 </BODY>
 </HTML>
\ No newline at end of file
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 29bb004c..85f64d0 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -45,8 +45,28 @@
 
 /**
  * Class for accessing an application's resources.  This sits on top of the
- * asset manager of the application (accessible through getAssets()) and
- * provides a higher-level API for getting typed data from the assets.
+ * asset manager of the application (accessible through {@link #getAssets}) and
+ * provides a high-level API for getting typed data from the assets.
+ *
+ * <p>The Android resource system keeps track of all non-code assets associated with an
+ * application. You can use this class to access your application's resources. You can generally
+ * acquire the {@link android.content.res.Resources} instance associated with your application
+ * with {@link android.content.Context#getResources getResources()}.</p>
+ *
+ * <p>The Android SDK tools compile your application's resources into the application binary
+ * at build time.  To use a resource, you must install it correctly in the source tree (inside
+ * your project's {@code res/} directory) and build your application.  As part of the build
+ * process, the SDK tools generate symbols for each resource, which you can use in your application
+ * code to access the resources.</p>
+ *
+ * <p>Using application resources makes it easy to update various characteristics of your
+ * application without modifying code, and&mdash;by providing sets of alternative
+ * resources&mdash;enables you to optimize your application for a variety of device configurations
+ * (such as for different languages and screen sizes). This is an important aspect of developing
+ * Android applications that are compatible on different types of devices.</p>
+ *
+ * <p>For more information about using resources, see the documentation about <a
+ * href="{@docRoot}guide/topics/resources/index.html">Application Resources</a>.</p>
  */
 public class Resources {
     static final String TAG = "Resources";
diff --git a/core/java/android/content/res/package.html b/core/java/android/content/res/package.html
index bb09dc7..0af94a4 100644
--- a/core/java/android/content/res/package.html
+++ b/core/java/android/content/res/package.html
@@ -1,8 +1,12 @@
 <HTML>
 <BODY>
-Contains classes for accessing application resources, 
-such as raw asset files, colors, drawables, media or other other files 
-in the package, plus important device configuration details 
-(orientation, input types, etc.) that affect how the application may behave.
+<p>Contains classes for accessing application resources,
+such as raw asset files, colors, drawables, media or other other files
+in the package, plus important device configuration details
+(orientation, input types, etc.) that affect how the application may behave.</p>
+
+<p>For more information, see the <a
+href="{@docRoot}guide/topics/resources/index.html">Application Resources</a> developer guide.</p>
+{@more}
 </BODY>
 </HTML>
\ No newline at end of file
diff --git a/core/java/android/hardware/package.html b/core/java/android/hardware/package.html
index 06788a6..5b04da1 100644
--- a/core/java/android/hardware/package.html
+++ b/core/java/android/hardware/package.html
@@ -1,5 +1,9 @@
 <HTML>
 <BODY>
-Provides support for hardware devices that may not be present on every Android device.
+<p>Provides support for hardware features, such as the camera and other sensors. Be aware that
+not all Android-powered devices support all hardware features, so you should declare hardware
+that your application requires using the <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code
+&lt;uses-feature&gt;}</a> manifest element.</p>
 </BODY>
 </HTML>
diff --git a/core/java/android/inputmethodservice/package.html b/core/java/android/inputmethodservice/package.html
index 164349b..cf8e0d9 100644
--- a/core/java/android/inputmethodservice/package.html
+++ b/core/java/android/inputmethodservice/package.html
@@ -1,6 +1,6 @@
 <html>
 <body>
-Base classes for writing input methods.  These APIs are not for use by
+Base classes for writing input methods (such as software keyboards).  These APIs are not for use by
 normal applications, they are a framework specifically for writing input
 method components.  Implementations will typically derive from
 {@link android.inputmethodservice.InputMethodService}.
diff --git a/core/java/android/package.html b/core/java/android/package.html
index 1f1be2d..a7287c5 100644
--- a/core/java/android/package.html
+++ b/core/java/android/package.html
@@ -1,10 +1,17 @@
 <HTML>
 <BODY>
-Contains the resource classes used by standard Android applications.
-<p>
-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}guide/topics/resources/index.html">Resources and Assets</a>. 
+<p>Contains resource classes used by applications included in the platform and defines application
+permissions for system features.</p>
+
+<p>You can use some resources directly from these {@link android.R} classes in your own
+applications, but you should generally use only resources that you've provided directly in your
+application, in order to provide a cohesive application package that has no external dependencies.
+In particular, you should not use drawable resources from the {@code android} package, because they
+may change between platform versions, causing unforeseen conflicts with your design. Typically,
+{@link android.R.style styles} are the only resources you should use directly from these
+resources.</p>
+
+<p>For information about using resources, see the <a
+href="{@docRoot}guide/topics/resources/index.html">Application Resources</a> developer guide.</p>
 </BODY>
-</HTML>
+</HTML>
\ No newline at end of file
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index 82fe7de..4c1fb5b 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -375,12 +375,29 @@
             public static final String MEDIA_TYPE = "media_type";
 
             /**
-             * Constants for MEDIA_TYPE
+             * Constant for the {@link #MEDIA_TYPE} column indicating that file
+             * is not an audio, image, video or playlist file.
              */
             public static final int MEDIA_TYPE_NONE = 0;
+
+            /**
+             * Constant for the {@link #MEDIA_TYPE} column indicating that file is an image file.
+             */
             public static final int MEDIA_TYPE_IMAGE = 1;
+
+            /**
+             * Constant for the {@link #MEDIA_TYPE} column indicating that file is an audio file.
+             */
             public static final int MEDIA_TYPE_AUDIO = 2;
+
+            /**
+             * Constant for the {@link #MEDIA_TYPE} column indicating that file is an video file.
+             */
             public static final int MEDIA_TYPE_VIDEO = 3;
+
+            /**
+             * Constant for the {@link #MEDIA_TYPE} column indicating that file is an playlist file.
+             */
             public static final int MEDIA_TYPE_PLAYLIST = 4;
         }
     }
diff --git a/core/java/android/provider/package.html b/core/java/android/provider/package.html
index 055b037..f34aa2b 100644
--- a/core/java/android/provider/package.html
+++ b/core/java/android/provider/package.html
@@ -1,11 +1,13 @@
 <HTML>
 <BODY>
-Provides convenience classes to access the content providers supplied by
-Android.
+<p>Provides convenience classes to access the content providers supplied by
+Android.</p>
 <p>Android ships with a number of content providers that store common data such
 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}guide/topics/providers/content-providers.html">Content Providers</a>.
+providers.</p>
+<p>For information about how to use a content provider, see the <a
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
+guide.</p>
 </BODY>
 </HTML>
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index dac3135..9a6a274 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -56,8 +56,6 @@
 
     private DrawFilter mFilter;
 
-    private boolean mContextLocked;
-
     ///////////////////////////////////////////////////////////////////////////
     // JNI
     ///////////////////////////////////////////////////////////////////////////
@@ -224,33 +222,12 @@
     private static native void nFinish(int renderer);
 
     @Override
-    public boolean acquireContext() {
-        if (!mContextLocked) {
-            nAcquireContext(mRenderer);
-            mContextLocked = true;
-        }
-        return mContextLocked;
-    }
-
-    private static native void nAcquireContext(int renderer);
-
-    @Override
     public boolean callDrawGLFunction(int drawGLFunction) {
         return nCallDrawGLFunction(mRenderer, drawGLFunction);
     }
 
     private static native boolean nCallDrawGLFunction(int renderer, int drawGLFunction);
 
-    @Override
-    public void releaseContext() {
-        if (mContextLocked) {
-            nReleaseContext(mRenderer);
-            mContextLocked = false;
-        }
-    }
-
-    private static native void nReleaseContext(int renderer);
-    
     ///////////////////////////////////////////////////////////////////////////
     // Display list
     ///////////////////////////////////////////////////////////////////////////
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 3ed7549..4c40653 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -48,7 +48,6 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.os.RemoteException;
-import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.util.AttributeSet;
@@ -1721,14 +1720,14 @@
     /**
      * View has requested the status bar to be visible (the default).
      *
-     * @see setSystemUiVisibility
+     * @see #setSystemUiVisibility(int) 
      */
     public static final int STATUS_BAR_VISIBLE = 0;
 
     /**
      * View has requested the status bar to be visible (the default).
      *
-     * @see setSystemUiVisibility
+     * @see #setSystemUiVisibility(int) 
      */
     public static final int STATUS_BAR_HIDDEN = 0x00000001;
 
@@ -3283,7 +3282,7 @@
             imm.focusIn(this);
         }
 
-        invalidate();
+        invalidate(true);
         if (mOnFocusChangeListener != null) {
             mOnFocusChangeListener.onFocusChange(this, gainFocus);
         }
@@ -3722,7 +3721,7 @@
 
         // Invalidate too, since the default behavior for views is to be
         // be drawn at 50% alpha rather than to change the drawable.
-        invalidate();
+        invalidate(true);
     }
 
     /**
@@ -5286,7 +5285,7 @@
         if ((changed & GONE) != 0) {
             needGlobalAttributesUpdate(false);
             requestLayout();
-            invalidate();
+            invalidate(true);
 
             if (((mViewFlags & VISIBILITY_MASK) == GONE)) {
                 if (hasFocus()) clearFocus();
@@ -5300,7 +5299,7 @@
         /* Check if the VISIBLE bit has changed */
         if ((changed & INVISIBLE) != 0) {
             needGlobalAttributesUpdate(false);
-            invalidate();
+            invalidate(true);
 
             if (((mViewFlags & VISIBILITY_MASK) == INVISIBLE) && hasFocus()) {
                 // root view becoming invisible shouldn't clear focus
@@ -5315,8 +5314,8 @@
 
         if ((changed & VISIBILITY_MASK) != 0) {
             if (mParent instanceof ViewGroup) {
-                ((ViewGroup)mParent).onChildVisibilityChanged(this, (flags & VISIBILITY_MASK));
-                ((View) mParent).invalidate();
+                ((ViewGroup) mParent).onChildVisibilityChanged(this, (flags & VISIBILITY_MASK));
+                ((View) mParent).invalidate(true);
             }
             dispatchVisibilityChanged(this, (flags & VISIBILITY_MASK));
         }
@@ -5328,7 +5327,7 @@
         if ((changed & DRAWING_CACHE_ENABLED) != 0) {
             destroyDrawingCache();
             mPrivateFlags &= ~DRAWING_CACHE_VALID;
-            invalidateParentIfAccelerated();
+            invalidateParentCaches();
         }
 
         if ((changed & DRAWING_CACHE_QUALITY_MASK) != 0) {
@@ -5348,7 +5347,7 @@
                 mPrivateFlags &= ~SKIP_DRAW;
             }
             requestLayout();
-            invalidate();
+            invalidate(true);
         }
 
         if ((changed & KEEP_SCREEN_ON) != 0) {
@@ -5683,13 +5682,13 @@
      */
     public void setRotation(float rotation) {
         if (mRotation != rotation) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mRotation = rotation;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5717,13 +5716,13 @@
      */
     public void setRotationY(float rotationY) {
         if (mRotationY != rotationY) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mRotationY = rotationY;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5751,13 +5750,13 @@
      */
     public void setRotationX(float rotationX) {
         if (mRotationX != rotationX) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mRotationX = rotationX;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5787,13 +5786,13 @@
      */
     public void setScaleX(float scaleX) {
         if (mScaleX != scaleX) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mScaleX = scaleX;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5823,13 +5822,13 @@
      */
     public void setScaleY(float scaleY) {
         if (mScaleY != scaleY) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mScaleY = scaleY;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5865,13 +5864,13 @@
     public void setPivotX(float pivotX) {
         mPrivateFlags |= PIVOT_EXPLICITLY_SET;
         if (mPivotX != pivotX) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mPivotX = pivotX;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5906,13 +5905,13 @@
     public void setPivotY(float pivotY) {
         mPrivateFlags |= PIVOT_EXPLICITLY_SET;
         if (mPivotY != pivotY) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mPivotY = pivotY;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -5944,15 +5943,15 @@
      */
     public void setAlpha(float alpha) {
         mAlpha = alpha;
+        invalidateParentCaches();
         if (onSetAlpha((int) (alpha * 255))) {
             mPrivateFlags |= ALPHA_SET;
             // subclass is handling alpha - don't optimize rendering cache invalidation
-            invalidate();
+            invalidate(true);
         } else {
             mPrivateFlags &= ~ALPHA_SET;
             invalidate(false);
         }
-        invalidateParentIfAccelerated();
     }
 
     /**
@@ -5993,7 +5992,7 @@
                 }
             } else {
                 // Double-invalidation is necessary to capture view's old and new areas
-                invalidate();
+                invalidate(true);
             }
 
             int width = mRight - mLeft;
@@ -6009,7 +6008,7 @@
                     mMatrixDirty = true;
                 }
                 mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
-                invalidate();
+                invalidate(true);
             }
             mBackgroundSizeChanged = true;
         }
@@ -6059,7 +6058,7 @@
                 }
             } else {
                 // Double-invalidation is necessary to capture view's old and new areas
-                invalidate();
+                invalidate(true);
             }
 
             int width = mRight - mLeft;
@@ -6075,7 +6074,7 @@
                     mMatrixDirty = true;
                 }
                 mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
-                invalidate();
+                invalidate(true);
             }
             mBackgroundSizeChanged = true;
         }
@@ -6119,7 +6118,7 @@
                 }
             } else {
                 // Double-invalidation is necessary to capture view's old and new areas
-                invalidate();
+                invalidate(true);
             }
 
             int oldWidth = mRight - mLeft;
@@ -6135,7 +6134,7 @@
                     mMatrixDirty = true;
                 }
                 mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
-                invalidate();
+                invalidate(true);
             }
             mBackgroundSizeChanged = true;
         }
@@ -6176,7 +6175,7 @@
                 }
             } else {
                 // Double-invalidation is necessary to capture view's old and new areas
-                invalidate();
+                invalidate(true);
             }
 
             int oldWidth = mRight - mLeft;
@@ -6192,7 +6191,7 @@
                     mMatrixDirty = true;
                 }
                 mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
-                invalidate();
+                invalidate(true);
             }
             mBackgroundSizeChanged = true;
         }
@@ -6266,13 +6265,13 @@
      */
     public void setTranslationX(float translationX) {
         if (mTranslationX != translationX) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mTranslationX = translationX;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -6300,13 +6299,13 @@
      */
     public void setTranslationY(float translationY) {
         if (mTranslationY != translationY) {
+            invalidateParentCaches();
             // Double-invalidation is necessary to capture view's old and new areas
             invalidate(false);
             mTranslationY = translationY;
             mMatrixDirty = true;
             mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
             invalidate(false);
-            invalidateParentIfAccelerated();
         }
     }
 
@@ -6523,10 +6522,10 @@
             int oldY = mScrollY;
             mScrollX = x;
             mScrollY = y;
-            invalidateParentIfAccelerated();
+            invalidateParentCaches();
             onScrollChanged(mScrollX, mScrollY, oldX, oldY);
             if (!awakenScrollBars()) {
-                invalidate();
+                invalidate(true);
             }
         }
     }
@@ -6680,7 +6679,7 @@
 
             if (invalidate) {
                 // Invalidate to show the scrollbars
-                invalidate();
+                invalidate(true);
             }
 
             if (scrollCache.state == ScrollabilityCache.OFF) {
@@ -6817,11 +6816,10 @@
             ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE);
         }
 
-        boolean opaque = isOpaque();
         if ((mPrivateFlags & (DRAWN | HAS_BOUNDS)) == (DRAWN | HAS_BOUNDS) ||
                 (invalidateCache && (mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) ||
-                opaque != mLastIsOpaque || (mPrivateFlags & INVALIDATED) != INVALIDATED) {
-            mLastIsOpaque = opaque;
+                (mPrivateFlags & INVALIDATED) != INVALIDATED || isOpaque() != mLastIsOpaque) {
+            mLastIsOpaque = isOpaque();
             mPrivateFlags &= ~DRAWN;
             if (invalidateCache) {
                 mPrivateFlags |= INVALIDATED;
@@ -6850,16 +6848,32 @@
     }
 
     /**
-     * Used to indicate that the parent of this view should be invalidated. This functionality
+     * Used to indicate that the parent of this view should clear its caches. This functionality
      * is used to force the parent to rebuild its display list (when hardware-accelerated),
      * which is necessary when various parent-managed properties of the view change, such as
-     * alpha, translationX/Y, scrollX/Y, scaleX/Y, and rotation/X/Y.
+     * alpha, translationX/Y, scrollX/Y, scaleX/Y, and rotation/X/Y. This method only
+     * clears the parent caches and does not causes an invalidate event.
      *
      * @hide
      */
-    protected void invalidateParentIfAccelerated() {
+    protected void invalidateParentCaches() {
+        if (mParent instanceof View) {
+            ((View) mParent).mPrivateFlags |= INVALIDATED;
+        }
+    }
+    
+    /**
+     * Used to indicate that the parent of this view should be invalidated. This functionality
+     * is used to force the parent to rebuild its display list (when hardware-accelerated),
+     * which is necessary when various parent-managed properties of the view change, such as
+     * alpha, translationX/Y, scrollX/Y, scaleX/Y, and rotation/X/Y. This method will propagate
+     * an invalidation event to the parent.
+     *
+     * @hide
+     */
+    protected void invalidateParentIfNeeded() {
         if (isHardwareAccelerated() && mParent instanceof View) {
-            ((View) mParent).invalidate();
+            ((View) mParent).invalidate(true);
         }
     }
 
@@ -8023,10 +8037,8 @@
         if (layerType == mLayerType) {
             if (layerType != LAYER_TYPE_NONE && paint != mLayerPaint) {
                 mLayerPaint = paint == null ? new Paint() : paint;
-                if (mParent instanceof ViewGroup) {
-                    ((ViewGroup) mParent).invalidate();
-                }
-                invalidate();
+                invalidateParentCaches();
+                invalidate(true);
             }
             return;
         }
@@ -8057,10 +8069,8 @@
         mLayerType = layerType;
         mLayerPaint = mLayerType == LAYER_TYPE_NONE ? null : (paint == null ? new Paint() : paint);
 
-        if (mParent instanceof ViewGroup) {
-            ((ViewGroup) mParent).invalidate();
-        }
-        invalidate();
+        invalidateParentCaches();
+        invalidate(true);
     }
 
     /**
@@ -8254,7 +8264,7 @@
                 // If we're creating a new display list, make sure our parent gets invalidated
                 // since they will need to recreate their display list to account for this
                 // new child display list.
-                invalidateParentIfAccelerated();
+                invalidateParentCaches();
             }
 
             final HardwareCanvas canvas = mDisplayList.start();
@@ -9169,7 +9179,7 @@
             int drawn = mPrivateFlags & DRAWN;
 
             // Invalidate our old position
-            invalidate();
+            invalidate(true);
 
 
             int oldWidth = mRight - mLeft;
@@ -9200,7 +9210,7 @@
                 // before this call to setFrame came in, thereby clearing
                 // the DRAWN bit.
                 mPrivateFlags |= DRAWN;
-                invalidate();
+                invalidate(true);
             }
 
             // Reset drawn bit to original value (invalidate turns it off)
@@ -9589,7 +9599,7 @@
         }
 
         mBackgroundSizeChanged = true;
-        invalidate();
+        invalidate(true);
     }
 
     /**
@@ -9724,7 +9734,7 @@
         if (((mPrivateFlags & SELECTED) != 0) != selected) {
             mPrivateFlags = (mPrivateFlags & ~SELECTED) | (selected ? SELECTED : 0);
             if (!selected) resetPressedState();
-            invalidate();
+            invalidate(true);
             refreshDrawableState();
             dispatchSetSelected(selected);
         }
@@ -9766,7 +9776,7 @@
     public void setActivated(boolean activated) {
         if (((mPrivateFlags & ACTIVATED) != 0) != activated) {
             mPrivateFlags = (mPrivateFlags & ~ACTIVATED) | (activated ? ACTIVATED : 0);
-            invalidate();
+            invalidate(true);
             refreshDrawableState();
             dispatchSetActivated(activated);
         }
@@ -10610,8 +10620,8 @@
     public void startAnimation(Animation animation) {
         animation.setStartTime(Animation.START_ON_FIRST_FRAME);
         setAnimation(animation);
-        invalidate();
-        invalidateParentIfAccelerated();
+        invalidateParentCaches();
+        invalidate(true);
     }
 
     /**
@@ -10622,7 +10632,7 @@
             mCurrentAnimation.detach();
         }
         mCurrentAnimation = null;
-        invalidateParentIfAccelerated();
+        invalidateParentIfNeeded();
     }
 
     /**
@@ -11948,7 +11958,7 @@
                 state = FADING;
 
                 // Kick off the fade animation
-                host.invalidate();
+                host.invalidate(true);
             }
         }
 
diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java
index 6bb4320..db66305 100644
--- a/core/java/android/webkit/AccessibilityInjector.java
+++ b/core/java/android/webkit/AccessibilityInjector.java
@@ -113,6 +113,11 @@
      * @return True if the event was processed.
      */
     public boolean onKeyEvent(KeyEvent event) {
+        // We do not handle ENTER in any circumstances.
+        if (isEnterActionKey(event.getKeyCode())) {
+            return false;
+        }
+
         if (event.getAction() == KeyEvent.ACTION_UP) {
             return mLastDownEventHandled;
         }
@@ -367,6 +372,12 @@
         }
     }
 
+    private boolean isEnterActionKey(int keyCode) {
+        return keyCode == KeyEvent.KEYCODE_DPAD_CENTER
+                || keyCode == KeyEvent.KEYCODE_ENTER
+                || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER;
+    }
+
     /**
      * Represents a web content key-binding.
      */
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 1d5d08f..64039e8 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -16,9 +16,6 @@
 
 package android.webkit;
 
-import android.view.HardwareCanvas;
-import com.android.internal.R;
-
 import android.annotation.Widget;
 import android.app.AlertDialog;
 import android.content.BroadcastReceiver;
@@ -31,7 +28,6 @@
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.res.Configuration;
-import android.content.res.Resources;
 import android.database.DataSetObserver;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -57,7 +53,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.os.SystemClock;
 import android.provider.Settings;
 import android.speech.tts.TextToSpeech;
 import android.text.Selection;
@@ -66,6 +61,7 @@
 import android.util.EventLog;
 import android.util.Log;
 import android.view.Gravity;
+import android.view.HardwareCanvas;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -92,7 +88,6 @@
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ArrayAdapter;
 import android.widget.CheckedTextView;
-import android.widget.EdgeGlow;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.OverScroller;
@@ -677,6 +672,8 @@
     static final int SET_AUTOFILLABLE                   = 133;
     static final int AUTOFILL_COMPLETE                  = 134;
 
+    static final int SELECT_AT                          = 135;
+
     private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
     private static final int LAST_PACKAGE_MSG_ID = SET_TOUCH_HIGHLIGHT_RECTS;
 
@@ -728,7 +725,8 @@
         "SET_TOUCH_HIGHLIGHT_RECTS", //      = 131;
         "SAVE_WEBARCHIVE_FINISHED", //       = 132;
         "SET_AUTOFILLABLE", //               = 133;
-        "AUTOFILL_COMPLETE" //               = 134;
+        "AUTOFILL_COMPLETE", //              = 134;
+        "SELECT_AT" //                       = 135;
     };
 
     // If the site doesn't use the viewport meta tag to specify the viewport,
@@ -7600,6 +7598,10 @@
                     }
                     break;
 
+                case SELECT_AT:
+                    nativeSelectAt(msg.arg1, msg.arg2);
+                    break;
+
                 default:
                     super.handleMessage(msg);
                     break;
@@ -7957,24 +7959,6 @@
                 cursorData());
     }
 
-    /*
-     * Called from JNI when the cursor has moved. This method
-     * sends a message to the WebCore requesting the given
-     * nodePtr in the given framePrt to be selected which will
-     * result in firing an accessibility event announing its
-     * content.
-     *
-     * Note: Accessibility support.
-     */
-    @SuppressWarnings("unused")
-    // called from JNI
-    private void sendMoveSelection(int framePtr, int nodePtr) {
-        if (AccessibilityManager.getInstance(mContext).isEnabled()
-                && mAccessibilityInjector != null) {
-            mWebViewCore.sendMessage(EventHub.MOVE_SELECTION, framePtr, nodePtr);
-        }
-    }
-
     /**
      * Called by JNI to send a message to the webcore thread that the user
      * touched the webpage.
@@ -8286,6 +8270,7 @@
     private native Point    nativeSelectableText();
     private native void     nativeSelectAll();
     private native void     nativeSelectBestAt(Rect rect);
+    private native void     nativeSelectAt(int x, int y);
     private native int      nativeSelectionX();
     private native int      nativeSelectionY();
     private native int      nativeFindIndex();
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 0992079..27bf51c 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -188,14 +188,9 @@
         // Allow us to use up to our memory class value before V8's GC kicks in.
         // These values have been determined by experimentation.
         mLowMemoryUsageThresholdMb = manager.getLargeMemoryClass();
-        // If things get crazy, allow V8 to use up to 3 times our memory class, or a third of the
-        // device's total available memory, whichever is smaller.  This value must be no less
-        // than the low memory threshold.
-        // At that point V8 will start attempting more aggressive garbage collection.
-        mHighMemoryUsageThresholdMb = Math.max(Math.min(mLowMemoryUsageThresholdMb * 3,
-                (int) (memInfo.availMem / 3) >> 20), mLowMemoryUsageThresholdMb);
+        mHighMemoryUsageThresholdMb = (int) (mLowMemoryUsageThresholdMb * 1.5);
         // Avoid constant V8 GC when memory usage equals to working set estimate.
-        mHighUsageDeltaMb = 1;
+        mHighUsageDeltaMb = mLowMemoryUsageThresholdMb / 32;
 
         // Send a message to initialize the WebViewCore.
         Message init = sWebCoreHandler.obtainMessage(
@@ -641,18 +636,6 @@
      */
     private native String nativeModifySelection(int direction, int granularity);
 
-    /**
-     * Moves the selection to given node i.e. selects that node.
-     *
-     * Note: Accessibility support.
-     *
-     * @param framePtr Pointer to the frame containing the node to be selected.
-     * @param nodePtr Pointer to the node to be selected.
-     *
-     * @return The selection string.
-     */
-    private native String nativeMoveSelection(int framePtr, int nodePtr);
-
     // EventHub for processing messages
     private final EventHub mEventHub;
     // WebCore thread handler
@@ -1018,9 +1001,6 @@
 
         static final int PROXY_CHANGED = 193;
 
-        // accessibility support
-        static final int MOVE_SELECTION = 194;
-
         // private message ids
         private static final int DESTROY =     200;
 
@@ -1439,12 +1419,6 @@
                                     modifiedSelectionString).sendToTarget();
                             break;
 
-                        case MOVE_SELECTION:
-                            String movedSelectionString = nativeMoveSelection(msg.arg1, msg.arg2);
-                            mWebView.mPrivateHandler.obtainMessage(WebView.SELECTION_STRING_CHANGED,
-                                    movedSelectionString).sendToTarget();
-                            break;
-
                         case LISTBOX_CHOICES:
                             SparseBooleanArray choices = (SparseBooleanArray)
                                     msg.obj;
@@ -2714,6 +2688,14 @@
                 hMode, vMode).sendToTarget();
     }
 
+    // called by JNI
+    @SuppressWarnings("unused")
+    private void selectAt(int x, int y) {
+        if (mWebView != null) {
+            mWebView.mPrivateHandler.obtainMessage(WebView.SELECT_AT, x, y).sendToTarget();
+        }
+    }
+
     private void useMockDeviceOrientation() {
         mDeviceMotionAndOrientationManager.useMock();
     }
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 6d66bbc..48e91ad 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -2358,7 +2358,7 @@
                 }
                 if (mScrollY != 0) {
                     mScrollY = 0;
-                    invalidateParentIfAccelerated();
+                    invalidateParentCaches();
                     finishGlows();
                     invalidate();
                 }
@@ -2735,7 +2735,7 @@
 
                 if (mScrollY != 0) {
                     mScrollY = 0;
-                    invalidateParentIfAccelerated();
+                    invalidateParentCaches();
                     finishGlows();
                     invalidate();
                 }
@@ -2954,7 +2954,7 @@
                         // Coming back to 'real' list scrolling
                         incrementalDeltaY = -newScroll;
                         mScrollY = 0;
-                        invalidateParentIfAccelerated();
+                        invalidateParentIfNeeded();
 
                         // No need to do all this work if we're not going to move anyway
                         if (incrementalDeltaY != 0) {
@@ -3248,7 +3248,7 @@
     protected void onOverScrolled(int scrollX, int scrollY,
             boolean clampedX, boolean clampedY) {
         mScrollY = scrollY;
-        invalidateParentIfAccelerated();
+        invalidateParentIfNeeded();
 
         if (clampedY) {
             // Velocity is broken by hitting the limit; don't start a fling off of this.
@@ -5289,12 +5289,15 @@
     /**
      * Called back when the adapter connects to the RemoteViewsService.
      */
-    public void onRemoteAdapterConnected() {
+    public boolean onRemoteAdapterConnected() {
         if (mRemoteAdapter != mAdapter) {
             setAdapter(mRemoteAdapter);
+            return false;
         } else if (mRemoteAdapter != null) {
             mRemoteAdapter.superNotifyDataSetChanged();
+            return true;
         }
+        return false;
     }
 
     /**
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index b505c85..e3a62db 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -54,6 +54,12 @@
     int mWhichChild = 0;
 
     /**
+     * The index of the child to restore after the asynchronous connection from the
+     * RemoteViewsAdapter has been.
+     */
+    private int mRestoreWhichChild = -1;
+
+    /**
      * Whether or not the first view(s) should be animated in
      */
     boolean mAnimateFirstTime = true;
@@ -780,7 +786,15 @@
         // set mWhichChild
         mWhichChild = ss.whichChild;
 
-        setDisplayedChild(mWhichChild);
+        // When using RemoteAdapters, the async connection process can lead to
+        // onRestoreInstanceState to be called before setAdapter(), so we need to save the previous
+        // values to restore the list position after we connect, and can skip setting the displayed
+        // child until then.
+        if (mRemoteViewsAdapter != null && mAdapter == null) {
+            mRestoreWhichChild = mWhichChild;
+        } else {
+            setDisplayedChild(mWhichChild);
+        }
     }
 
     /**
@@ -957,12 +971,21 @@
     /**
      * Called back when the adapter connects to the RemoteViewsService.
      */
-    public void onRemoteAdapterConnected() {
+    public boolean onRemoteAdapterConnected() {
         if (mRemoteViewsAdapter != mAdapter) {
             setAdapter(mRemoteViewsAdapter);
+
+            // Restore the previous position (see onRestoreInstanceState)
+            if (mRestoreWhichChild > -1) {
+                setDisplayedChild(mRestoreWhichChild);
+                mRestoreWhichChild = -1;
+            }
+            return false;
         } else if (mRemoteViewsAdapter != null) {
             mRemoteViewsAdapter.superNotifyDataSetChanged();
+            return true;
         }
+        return false;
     }
 
     /**
@@ -992,10 +1015,4 @@
      */
     public void fyiWillBeAdvancedByHostKThx() {
     }
-
-    @Override
-    protected void onDetachedFromWindow() {
-        mAdapter = null;
-        super.onDetachedFromWindow();
-    }
 }
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index ff6677f..13f0890 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -647,7 +647,7 @@
         if (!mScroller.isFinished()) {
             mScrollX = scrollX;
             mScrollY = scrollY;
-            invalidateParentIfAccelerated();
+            invalidateParentIfNeeded();
             if (clampedX) {
                 mScroller.springBack(mScrollX, mScrollY, 0, getScrollRange(), 0, 0);
             }
diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java
index f329a3e..0a48feb 100644
--- a/core/java/android/widget/RemoteViewsAdapter.java
+++ b/core/java/android/widget/RemoteViewsAdapter.java
@@ -48,7 +48,7 @@
     private static final String TAG = "RemoteViewsAdapter";
 
     // The max number of items in the cache
-    private static final int sDefaultCacheSize = 36;
+    private static final int sDefaultCacheSize = 40;
     // The delay (in millis) to wait until attempting to unbind from a service after a request.
     // This ensures that we don't stay continually bound to the service and that it can be destroyed
     // if we need the memory elsewhere in the system.
@@ -65,6 +65,9 @@
     private WeakReference<RemoteAdapterConnectionCallback> mCallback;
     private FixedSizeRemoteViewsCache mCache;
 
+    // A flag to determine whether we should notify data set changed after we connect
+    private boolean mNotifyDataSetChangedAfterOnServiceConnected = false;
+
     // The set of requested views that are to be notified when the associated RemoteViews are
     // loaded.
     private RemoteViewsFrameLayoutRefSet mRequestedViews;
@@ -79,7 +82,10 @@
      * are actually connected to/disconnected from their actual services.
      */
     public interface RemoteAdapterConnectionCallback {
-        public void onRemoteAdapterConnected();
+        /**
+         * @return whether the adapter was set or not.
+         */
+        public boolean onRemoteAdapterConnected();
 
         public void onRemoteAdapterDisconnected();
     }
@@ -93,7 +99,8 @@
      */
     private static class RemoteViewsAdapterServiceConnection extends
             IRemoteViewsAdapterConnection.Stub {
-        private boolean mConnected;
+        private boolean mIsConnected;
+        private boolean mIsConnecting;
         private WeakReference<RemoteViewsAdapter> mAdapter;
         private IRemoteViewsFactory mRemoteViewsFactory;
 
@@ -101,27 +108,58 @@
             mAdapter = new WeakReference<RemoteViewsAdapter>(adapter);
         }
 
-        public void onServiceConnected(IBinder service) {
-            mRemoteViewsFactory = IRemoteViewsFactory.Stub.asInterface(service);
-            mConnected = true;
+        public synchronized void bind(Context context, int appWidgetId, Intent intent) {
+            if (!mIsConnecting) {
+                try {
+                    final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
+                    mgr.bindRemoteViewsService(appWidgetId, intent, asBinder());
+                    mIsConnecting = true;
+                } catch (Exception e) {
+                    Log.e("RemoteViewsAdapterServiceConnection", "bind(): " + e.getMessage());
+                    mIsConnecting = false;
+                    mIsConnected = false;
+                }
+            }
+        }
 
-            // Queue up work that we need to do for the callback to run
+        public synchronized void unbind(Context context, int appWidgetId, Intent intent) {
+            try {
+                final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
+                mgr.unbindRemoteViewsService(appWidgetId, intent);
+                mIsConnecting = false;
+            } catch (Exception e) {
+                Log.e("RemoteViewsAdapterServiceConnection", "unbind(): " + e.getMessage());
+                mIsConnecting = false;
+                mIsConnected = false;
+            }
+        }
+
+        public synchronized void onServiceConnected(IBinder service) {
+            mRemoteViewsFactory = IRemoteViewsFactory.Stub.asInterface(service);
+
+            // Remove any deferred unbind messages
             final RemoteViewsAdapter adapter = mAdapter.get();
             if (adapter == null) return;
+
+            // Queue up work that we need to do for the callback to run
             adapter.mWorkerQueue.post(new Runnable() {
                 @Override
                 public void run() {
-                    // Call back to the service to notify that the data set changed
-                    if (adapter.mServiceConnection.isConnected()) {
+                    if (adapter.mNotifyDataSetChangedAfterOnServiceConnected) {
+                        // Handle queued notifyDataSetChanged() if necessary
+                        adapter.onNotifyDataSetChanged();
+                    } else {
                         IRemoteViewsFactory factory =
                             adapter.mServiceConnection.getRemoteViewsFactory();
                         try {
-                            // call back to the factory
-                            factory.onDataSetChanged();
+                            if (!factory.isCreated()) {
+                                // We only call onDataSetChanged() if this is the factory was just
+                                // create in response to this bind
+                                factory.onDataSetChanged();
+                            }
                         } catch (Exception e) {
                             Log.e(TAG, "Error notifying factory of data set changed in " +
                                         "onServiceConnected(): " + e.getMessage());
-                            e.printStackTrace();
 
                             // Return early to prevent anything further from being notified
                             // (effectively nothing has changed)
@@ -130,13 +168,16 @@
 
                         // Request meta data so that we have up to date data when calling back to
                         // the remote adapter callback
-                        adapter.updateMetaData();
+                        adapter.updateTemporaryMetaData();
 
-                        // Post a runnable to call back to the view to notify it that we have
-                        // connected
+                        // Notify the host that we've connected
                         adapter.mMainQueue.post(new Runnable() {
                             @Override
                             public void run() {
+                                synchronized (adapter.mCache) {
+                                    adapter.mCache.commitTemporaryMetaData();
+                                }
+
                                 final RemoteAdapterConnectionCallback callback =
                                     adapter.mCallback.get();
                                 if (callback != null) {
@@ -145,35 +186,44 @@
                             }
                         });
                     }
+
+                    // Enqueue unbind message
+                    adapter.enqueueDeferredUnbindServiceMessage();
+                    mIsConnected = true;
+                    mIsConnecting = false;
                 }
             });
         }
 
-        public void onServiceDisconnected() {
-            mConnected = false;
+        public synchronized void onServiceDisconnected() {
+            mIsConnected = false;
+            mIsConnecting = false;
             mRemoteViewsFactory = null;
 
+            // Clear the main/worker queues
             final RemoteViewsAdapter adapter = mAdapter.get();
             if (adapter == null) return;
             
-            // Clear the main/worker queues
-            adapter.mMainQueue.removeMessages(sUnbindServiceMessageType);
-            adapter.mMainQueue.removeMessages(sDefaultMessageType);
-            adapter.mWorkerQueue.removeMessages(sDefaultMessageType);
+            adapter.mMainQueue.post(new Runnable() {
+                @Override
+                public void run() {
+                    // Dequeue any unbind messages
+                    adapter.mMainQueue.removeMessages(sUnbindServiceMessageType);
 
-            final RemoteAdapterConnectionCallback callback = adapter.mCallback.get();
-            if (callback != null) {
-                callback.onRemoteAdapterDisconnected();
-            }
-            adapter.mCache.reset();
+                    final RemoteAdapterConnectionCallback callback = adapter.mCallback.get();
+                    if (callback != null) {
+                        callback.onRemoteAdapterDisconnected();
+                    }
+                }
+            });
         }
 
-        public IRemoteViewsFactory getRemoteViewsFactory() {
+        public synchronized IRemoteViewsFactory getRemoteViewsFactory() {
             return mRemoteViewsFactory;
         }
 
-        public boolean isConnected() {
-            return mConnected;
+        public synchronized boolean isConnected() {
+            return mIsConnected;
         }
     }
 
@@ -270,7 +320,6 @@
         int count;
         int viewTypeCount;
         boolean hasStableIds;
-        boolean isDataDirty;
 
         // Used to determine how to construct loading views.  If a loading view is not specified
         // by the user, then we try and load the first view, and use its height as the height for
@@ -280,22 +329,31 @@
         int mFirstViewHeight;
 
         // A mapping from type id to a set of unique type ids
-        private Map<Integer, Integer> mTypeIdIndexMap;
+        private final HashMap<Integer, Integer> mTypeIdIndexMap = new HashMap<Integer, Integer>();
 
         public RemoteViewsMetaData() {
             reset();
         }
 
+        public void set(RemoteViewsMetaData d) {
+            synchronized (d) {
+                count = d.count;
+                viewTypeCount = d.viewTypeCount;
+                hasStableIds = d.hasStableIds;
+                setLoadingViewTemplates(d.mUserLoadingView, d.mFirstView);
+            }
+        }
+
         public void reset() {
             count = 0;
+
             // by default there is at least one dummy view type
             viewTypeCount = 1;
             hasStableIds = true;
-            isDataDirty = false;
             mUserLoadingView = null;
             mFirstView = null;
             mFirstViewHeight = 0;
-            mTypeIdIndexMap = new HashMap<Integer, Integer>();
+            mTypeIdIndexMap.clear();
         }
 
         public void setLoadingViewTemplates(RemoteViews loadingView, RemoteViews firstView) {
@@ -363,17 +421,19 @@
     private class RemoteViewsIndexMetaData {
         int typeId;
         long itemId;
+        boolean isRequested;
 
-        public RemoteViewsIndexMetaData(RemoteViews v, long itemId) {
-            set(v, itemId);
+        public RemoteViewsIndexMetaData(RemoteViews v, long itemId, boolean requested) {
+            set(v, itemId, requested);
         }
 
-        public void set(RemoteViews v, long id) {
+        public void set(RemoteViews v, long id, boolean requested) {
             itemId = id;
             if (v != null)
                 typeId = v.getLayoutId();
             else
                 typeId = 0;
+            isRequested = requested;
         }
     }
 
@@ -385,6 +445,7 @@
 
         // The meta data related to all the RemoteViews, ie. count, is stable, etc.
         private RemoteViewsMetaData mMetaData;
+        private RemoteViewsMetaData mTemporaryMetaData;
 
         // The cache/mapping of position to RemoteViewsMetaData.  This set is guaranteed to be
         // greater than or equal to the set of RemoteViews.
@@ -402,6 +463,10 @@
         // The set of indices that have been explicitly requested by the collection view
         private HashSet<Integer> mRequestedIndices;
 
+        // We keep a reference of the last requested index to determine which item to prune the
+        // farthest items from when we hit the memory limit
+        private int mLastRequestedIndex;
+
         // The set of indices to load, including those explicitly requested, as well as those
         // determined by the preloading algorithm to be prefetched
         private HashSet<Integer> mLoadIndices;
@@ -418,7 +483,7 @@
         private int mMaxCount;
         private int mMaxCountSlack;
         private static final float sMaxCountSlackPercent = 0.75f;
-        private static final int sMaxMemoryUsage = 1024 * 1024;
+        private static final int sMaxMemoryLimitInBytes = 2 * 1024 * 1024;
 
         public FixedSizeRemoteViewsCache(int maxCacheSize) {
             mMaxCount = maxCacheSize;
@@ -426,34 +491,37 @@
             mPreloadLowerBound = 0;
             mPreloadUpperBound = -1;
             mMetaData = new RemoteViewsMetaData();
+            mTemporaryMetaData = new RemoteViewsMetaData();
             mIndexMetaData = new HashMap<Integer, RemoteViewsIndexMetaData>();
             mIndexRemoteViews = new HashMap<Integer, RemoteViews>();
             mRequestedIndices = new HashSet<Integer>();
+            mLastRequestedIndex = -1;
             mLoadIndices = new HashSet<Integer>();
         }
 
-        public void insert(int position, RemoteViews v, long itemId) {
+        public void insert(int position, RemoteViews v, long itemId, boolean isRequested) {
             // Trim the cache if we go beyond the count
             if (mIndexRemoteViews.size() >= mMaxCount) {
                 mIndexRemoteViews.remove(getFarthestPositionFrom(position));
             }
 
             // Trim the cache if we go beyond the available memory size constraints
-            while (getRemoteViewsBitmapMemoryUsage() >= sMaxMemoryUsage) {
+            int pruneFromPosition = (mLastRequestedIndex > -1) ? mLastRequestedIndex : position;
+            while (getRemoteViewsBitmapMemoryUsage() >= sMaxMemoryLimitInBytes) {
                 // Note: This is currently the most naive mechanism for deciding what to prune when
                 // we hit the memory limit.  In the future, we may want to calculate which index to
                 // remove based on both its position as well as it's current memory usage, as well
                 // as whether it was directly requested vs. whether it was preloaded by our caching
                 // mechanism.
-                mIndexRemoteViews.remove(getFarthestPositionFrom(position));
+                mIndexRemoteViews.remove(getFarthestPositionFrom(pruneFromPosition));
             }
 
             // Update the metadata cache
             if (mIndexMetaData.containsKey(position)) {
                 final RemoteViewsIndexMetaData metaData = mIndexMetaData.get(position);
-                metaData.set(v, itemId);
+                metaData.set(v, itemId, isRequested);
             } else {
-                mIndexMetaData.put(position, new RemoteViewsIndexMetaData(v, itemId));
+                mIndexMetaData.put(position, new RemoteViewsIndexMetaData(v, itemId, isRequested));
             }
             mIndexRemoteViews.put(position, v);
         }
@@ -461,6 +529,9 @@
         public RemoteViewsMetaData getMetaData() {
             return mMetaData;
         }
+        public RemoteViewsMetaData getTemporaryMetaData() {
+            return mTemporaryMetaData;
+        }
         public RemoteViews getRemoteViewsAt(int position) {
             if (mIndexRemoteViews.containsKey(position)) {
                 return mIndexRemoteViews.get(position);
@@ -474,6 +545,14 @@
             return null;
         }
 
+        public void commitTemporaryMetaData() {
+            synchronized (mTemporaryMetaData) {
+                synchronized (mMetaData) {
+                    mMetaData.set(mTemporaryMetaData);
+                }
+            }
+        }
+
         private int getRemoteViewsBitmapMemoryUsage() {
             // Calculate the memory usage of all the RemoteViews bitmaps being cached
             int mem = 0;
@@ -489,28 +568,42 @@
             // Find the index farthest away and remove that
             int maxDist = 0;
             int maxDistIndex = -1;
+            int maxDistNonRequested = 0;
+            int maxDistIndexNonRequested = -1;
             for (int i : mIndexRemoteViews.keySet()) {
                 int dist = Math.abs(i-pos);
+                if (dist > maxDistNonRequested && !mIndexMetaData.get(i).isRequested) {
+                    // maxDistNonRequested/maxDistIndexNonRequested will store the index of the
+                    // farthest non-requested position
+                    maxDistIndexNonRequested = i;
+                    maxDistNonRequested = dist;
+                }
                 if (dist > maxDist) {
+                    // maxDist/maxDistIndex will store the index of the farthest position
+                    // regardless of whether it was directly requested or not
                     maxDistIndex = i;
                     maxDist = dist;
                 }
             }
+            if (maxDistIndexNonRequested > -1) {
+                return maxDistIndexNonRequested;
+            }
             return maxDistIndex;
         }
 
         public void queueRequestedPositionToLoad(int position) {
+            mLastRequestedIndex = position;
             synchronized (mLoadIndices) {
                 mRequestedIndices.add(position);
                 mLoadIndices.add(position);
             }
         }
-        public void queuePositionsToBePreloadedFromRequestedPosition(int position) {
+        public boolean queuePositionsToBePreloadedFromRequestedPosition(int position) {
             // Check if we need to preload any items
             if (mPreloadLowerBound <= position && position <= mPreloadUpperBound) {
                 int center = (mPreloadUpperBound + mPreloadLowerBound) / 2;
                 if (Math.abs(position - center) < mMaxCountSlack) {
-                    return;
+                    return false;
                 }
             }
 
@@ -537,8 +630,10 @@
                 // But remove all the indices that have already been loaded and are cached
                 mLoadIndices.removeAll(mIndexRemoteViews.keySet());
             }
+            return true;
         }
-        public int getNextIndexToLoad() {
+        /** Returns the next index to load, and whether that index was directly requested or not */
+        public int[] getNextIndexToLoad() {
             // We try and prioritize items that have been requested directly, instead
             // of items that are loaded as a result of the caching mechanism
             synchronized (mLoadIndices) {
@@ -547,17 +642,17 @@
                     Integer i = mRequestedIndices.iterator().next();
                     mRequestedIndices.remove(i);
                     mLoadIndices.remove(i);
-                    return i.intValue();
+                    return new int[]{i.intValue(), 1};
                 }
 
                 // Otherwise, preload other indices as necessary
                 if (!mLoadIndices.isEmpty()) {
                     Integer i = mLoadIndices.iterator().next();
                     mLoadIndices.remove(i);
-                    return i.intValue();
+                    return new int[]{i.intValue(), 0};
                 }
 
-                return -1;
+                return new int[]{-1, 0};
             }
         }
 
@@ -575,6 +670,7 @@
 
             mPreloadLowerBound = 0;
             mPreloadUpperBound = -1;
+            mLastRequestedIndex = -1;
             mIndexRemoteViews.clear();
             mIndexMetaData.clear();
             synchronized (mLoadIndices) {
@@ -616,100 +712,117 @@
         mWorkerQueue.post(new Runnable() {
             @Override
             public void run() {
-                // Get the next index to load
-                int position = -1;
-                synchronized (mCache) {
-                    position = mCache.getNextIndexToLoad();
-                }
-                if (position > -1) {
-                    // Load the item, and notify any existing RemoteViewsFrameLayouts
-                    updateRemoteViews(position);
+                if (mServiceConnection.isConnected()) {
+                    // Get the next index to load
+                    int position = -1;
+                    boolean isRequested = false;
+                    synchronized (mCache) {
+                        int[] res = mCache.getNextIndexToLoad();
+                        position = res[0];
+                        isRequested = res[1] > 0;
+                    }
+                    if (position > -1) {
+                        // Load the item, and notify any existing RemoteViewsFrameLayouts
+                        updateRemoteViews(position, isRequested);
 
-                    // Queue up for the next one to load
-                    loadNextIndexInBackground();
+                        // Queue up for the next one to load
+                        loadNextIndexInBackground();
+                    } else {
+                        // No more items to load, so queue unbind
+                        enqueueDeferredUnbindServiceMessage();
+                    }
                 }
             }
         });
     }
 
-    private void updateMetaData() {
-        if (mServiceConnection.isConnected()) {
-            try {
-                IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+    private void processException(String method, Exception e) {
+        Log.e("RemoteViewsAdapter", "Error in " + method + ": " + e.getMessage());
 
-                // get the properties/first view (so that we can use it to
-                // measure our dummy views)
-                boolean hasStableIds = factory.hasStableIds();
-                int viewTypeCount = factory.getViewTypeCount();
-                int count = factory.getCount();
-                RemoteViews loadingView = factory.getLoadingView();
-                RemoteViews firstView = null;
-                if ((count > 0) && (loadingView == null)) {
-                    firstView = factory.getViewAt(0);
-                }
-                final RemoteViewsMetaData metaData = mCache.getMetaData();
-                synchronized (metaData) {
-                    metaData.hasStableIds = hasStableIds;
-                    metaData.viewTypeCount = viewTypeCount + 1;
-                    metaData.count = count;
-                    metaData.setLoadingViewTemplates(loadingView, firstView);
-                }
-            } catch (Exception e) {
-                // print the error
-                Log.e(TAG, "Error in requestMetaData(): " + e.getMessage());
-
-                // reset any members after the failed call
-                final RemoteViewsMetaData metaData = mCache.getMetaData();
-                synchronized (metaData) {
-                    metaData.reset();
-                }
+        // If we encounter a crash when updating, we should reset the metadata & cache and trigger
+        // a notifyDataSetChanged to update the widget accordingly
+        final RemoteViewsMetaData metaData = mCache.getMetaData();
+        synchronized (metaData) {
+            metaData.reset();
+        }
+        synchronized (mCache) {
+            mCache.reset();
+        }
+        mMainQueue.post(new Runnable() {
+            @Override
+            public void run() {
+                superNotifyDataSetChanged();
             }
+        });
+    }
+
+    private void updateTemporaryMetaData() {
+        IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+
+        try {
+            // get the properties/first view (so that we can use it to
+            // measure our dummy views)
+            boolean hasStableIds = factory.hasStableIds();
+            int viewTypeCount = factory.getViewTypeCount();
+            int count = factory.getCount();
+            RemoteViews loadingView = factory.getLoadingView();
+            RemoteViews firstView = null;
+            if ((count > 0) && (loadingView == null)) {
+                firstView = factory.getViewAt(0);
+            }
+            final RemoteViewsMetaData tmpMetaData = mCache.getTemporaryMetaData();
+            synchronized (tmpMetaData) {
+                tmpMetaData.hasStableIds = hasStableIds;
+                // We +1 because the base view type is the loading view
+                tmpMetaData.viewTypeCount = viewTypeCount + 1;
+                tmpMetaData.count = count;
+                tmpMetaData.setLoadingViewTemplates(loadingView, firstView);
+            }
+        } catch (Exception e) {
+            processException("updateMetaData", e);
         }
     }
 
-    private void updateRemoteViews(final int position) {
-        if (mServiceConnection.isConnected()) {
-            IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+    private void updateRemoteViews(final int position, boolean isRequested) {
+        if (!mServiceConnection.isConnected()) return;
+        IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
 
-            // Load the item information from the remote service
-            RemoteViews remoteViews = null;
-            long itemId = 0;
-            try {
-                remoteViews = factory.getViewAt(position);
-                itemId = factory.getItemId(position);
-            } catch (Throwable t) {
-                Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + t.getMessage());
-                t.printStackTrace();
+        // Load the item information from the remote service
+        RemoteViews remoteViews = null;
+        long itemId = 0;
+        try {
+            remoteViews = factory.getViewAt(position);
+            itemId = factory.getItemId(position);
+        } catch (Exception e) {
+            Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + e.getMessage());
 
-                // Return early to prevent additional work in re-centering the view cache, and
-                // swapping from the loading view
-                return;
-            }
+            // Return early to prevent additional work in re-centering the view cache, and
+            // swapping from the loading view
+            return;
+        }
 
-            if (remoteViews == null) {
-                // If a null view was returned, we break early to prevent it from getting
-                // into our cache and causing problems later. The effect is that the child  at this
-                // position will remain as a loading view until it is updated.
-                Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + " null RemoteViews " +
-                        "returned from RemoteViewsFactory.");
-                return;
-            }
-            synchronized (mCache) {
-                // Cache the RemoteViews we loaded
-                mCache.insert(position, remoteViews, itemId);
+        if (remoteViews == null) {
+            // If a null view was returned, we break early to prevent it from getting
+            // into our cache and causing problems later. The effect is that the child  at this
+            // position will remain as a loading view until it is updated.
+            Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + " null RemoteViews " +
+                    "returned from RemoteViewsFactory.");
+            return;
+        }
+        synchronized (mCache) {
+            // Cache the RemoteViews we loaded
+            mCache.insert(position, remoteViews, itemId, isRequested);
 
-                // Notify all the views that we have previously returned for this index that
-                // there is new data for it.
-                final RemoteViews rv = remoteViews;
-                final int typeId = mCache.getMetaDataAt(position).typeId;
-                mMainQueue.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        mRequestedViews.notifyOnRemoteViewsLoaded(position, rv, typeId);
-                        enqueueDeferredUnbindServiceMessage();
-                    }
-                });
-            }
+            // Notify all the views that we have previously returned for this index that
+            // there is new data for it.
+            final RemoteViews rv = remoteViews;
+            final int typeId = mCache.getMetaDataAt(position).typeId;
+            mMainQueue.post(new Runnable() {
+                @Override
+                public void run() {
+                    mRequestedViews.notifyOnRemoteViewsLoaded(position, rv, typeId);
+                }
+            });
         }
     }
 
@@ -718,7 +831,6 @@
     }
 
     public int getCount() {
-        requestBindService();
         final RemoteViewsMetaData metaData = mCache.getMetaData();
         synchronized (metaData) {
             return metaData.count;
@@ -731,7 +843,6 @@
     }
 
     public long getItemId(int position) {
-        requestBindService();
         synchronized (mCache) {
             if (mCache.containsMetaDataAt(position)) {
                 return mCache.getMetaDataAt(position).itemId;
@@ -741,7 +852,6 @@
     }
 
     public int getItemViewType(int position) {
-        requestBindService();
         int typeId = 0;
         synchronized (mCache) {
             if (mCache.containsMetaDataAt(position)) {
@@ -773,13 +883,23 @@
     }
 
     public View getView(int position, View convertView, ViewGroup parent) {
-        requestBindService();
-        if (mServiceConnection.isConnected()) {
-            // "Request" an index so that we can queue it for loading, initiate subsequent
-            // preloading, etc.
-            synchronized (mCache) {
+        // "Request" an index so that we can queue it for loading, initiate subsequent
+        // preloading, etc.
+        synchronized (mCache) {
+            boolean isInCache = mCache.containsRemoteViewAt(position);
+            boolean isConnected = mServiceConnection.isConnected();
+            boolean hasNewItems = false;
+
+            if (!isConnected) {
+                // Requesting bind service will trigger a super.notifyDataSetChanged(), which will
+                // in turn trigger another request to getView()
+                requestBindService();
+            } else {
                 // Queue up other indices to be preloaded based on this position
-                mCache.queuePositionsToBePreloadedFromRequestedPosition(position);
+                hasNewItems = mCache.queuePositionsToBePreloadedFromRequestedPosition(position);
+            }
+
+            if (isInCache) {
                 View convertViewChild = null;
                 int convertViewTypeId = 0;
                 RemoteViewsFrameLayout layout = null;
@@ -792,51 +912,47 @@
 
                 // Second, we try and retrieve the RemoteViews from the cache, returning a loading
                 // view and queueing it to be loaded if it has not already been loaded.
-                if (mCache.containsRemoteViewAt(position)) {
-                    Context context = parent.getContext();
-                    RemoteViews rv = mCache.getRemoteViewsAt(position);
-                    int typeId = mCache.getMetaDataAt(position).typeId;
+                Context context = parent.getContext();
+                RemoteViews rv = mCache.getRemoteViewsAt(position);
+                int typeId = mCache.getMetaDataAt(position).typeId;
 
-                    // Reuse the convert view where possible
-                    if (layout != null) {
-                        if (convertViewTypeId == typeId) {
-                            rv.reapply(context, convertViewChild);
-                            return layout;
-                        }
+                // Reuse the convert view where possible
+                if (layout != null) {
+                    if (convertViewTypeId == typeId) {
+                        rv.reapply(context, convertViewChild);
+                        return layout;
                     }
-
-                    // Otherwise, create a new view to be returned
-                    View newView = rv.apply(context, parent);
-                    newView.setTagInternal(com.android.internal.R.id.rowTypeId, new Integer(typeId));
-                    if (layout != null) {
-                        layout.removeAllViews();
-                    } else {
-                        layout = new RemoteViewsFrameLayout(context);
-                    }
-                    layout.addView(newView);
-                    return layout;
+                    layout.removeAllViews();
                 } else {
-                    // If the cache does not have the RemoteViews at this position, then create a
-                    // loading view and queue the actual position to be loaded in the background
-                    RemoteViewsFrameLayout loadingView = null;
-                    final RemoteViewsMetaData metaData = mCache.getMetaData();
-                    synchronized (metaData) {
-                        loadingView = metaData.createLoadingView(position, convertView, parent);
-                    }
-
-                    mRequestedViews.add(position, loadingView);
-                    mCache.queueRequestedPositionToLoad(position);
-                    loadNextIndexInBackground();
-
-                    return loadingView;
+                    layout = new RemoteViewsFrameLayout(context);
                 }
+
+                // Otherwise, create a new view to be returned
+                View newView = rv.apply(context, parent);
+                newView.setTagInternal(com.android.internal.R.id.rowTypeId, new Integer(typeId));
+                layout.addView(newView);
+                if (hasNewItems) loadNextIndexInBackground();
+
+                return layout;
+            } else {
+                // If the cache does not have the RemoteViews at this position, then create a
+                // loading view and queue the actual position to be loaded in the background
+                RemoteViewsFrameLayout loadingView = null;
+                final RemoteViewsMetaData metaData = mCache.getMetaData();
+                synchronized (metaData) {
+                    loadingView = metaData.createLoadingView(position, convertView, parent);
+                }
+
+                mRequestedViews.add(position, loadingView);
+                mCache.queueRequestedPositionToLoad(position);
+                loadNextIndexInBackground();
+
+                return loadingView;
             }
         }
-        return new View(parent.getContext());
     }
 
     public int getViewTypeCount() {
-        requestBindService();
         final RemoteViewsMetaData metaData = mCache.getMetaData();
         synchronized (metaData) {
             return metaData.viewTypeCount;
@@ -844,7 +960,6 @@
     }
 
     public boolean hasStableIds() {
-        requestBindService();
         final RemoteViewsMetaData metaData = mCache.getMetaData();
         synchronized (metaData) {
             return metaData.hasStableIds;
@@ -855,44 +970,67 @@
         return getCount() <= 0;
     }
 
-    public void notifyDataSetChanged() {
-        mWorkerQueue.post(new Runnable() {
+
+    private void onNotifyDataSetChanged() {
+        // Complete the actual notifyDataSetChanged() call initiated earlier
+        IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+        try {
+            factory.onDataSetChanged();
+        } catch (Exception e) {
+            Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());
+
+            // Return early to prevent from further being notified (since nothing has
+            // changed)
+            return;
+        }
+
+        // Flush the cache so that we can reload new items from the service
+        synchronized (mCache) {
+            mCache.reset();
+        }
+
+        // Re-request the new metadata (only after the notification to the factory)
+        updateTemporaryMetaData();
+
+        // Propagate the notification back to the base adapter
+        mMainQueue.post(new Runnable() {
             @Override
             public void run() {
-                // Complete the actual notifyDataSetChanged() call initiated earlier
-                if (mServiceConnection.isConnected()) {
-                    IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
-                    try {
-                        factory.onDataSetChanged();
-                    } catch (Exception e) {
-                        Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());
-
-                        // Return early to prevent from further being notified (since nothing has
-                        // changed)
-                        return;
-                    }
-                }
-
-                // Flush the cache so that we can reload new items from the service
                 synchronized (mCache) {
-                    mCache.reset();
+                    mCache.commitTemporaryMetaData();
                 }
 
-                // Re-request the new metadata (only after the notification to the factory)
-                updateMetaData();
-
-                // Propagate the notification back to the base adapter
-                mMainQueue.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        superNotifyDataSetChanged();
-                    }
-                });
+                superNotifyDataSetChanged();
+                enqueueDeferredUnbindServiceMessage();
             }
         });
 
-        // Note: we do not call super.notifyDataSetChanged() until the RemoteViewsFactory has had
-        // a chance to update itself and return new meta data associated with the new data.
+        // Reset the notify flagflag
+        mNotifyDataSetChangedAfterOnServiceConnected = false;
+    }
+
+    public void notifyDataSetChanged() {
+        // Dequeue any unbind messages
+        mMainQueue.removeMessages(sUnbindServiceMessageType);
+
+        // If we are not connected, queue up the notifyDataSetChanged to be handled when we do
+        // connect
+        if (!mServiceConnection.isConnected()) {
+            if (mNotifyDataSetChangedAfterOnServiceConnected) {
+                return;
+            }
+
+            mNotifyDataSetChangedAfterOnServiceConnected = true;
+            requestBindService();
+            return;
+        }
+
+        mWorkerQueue.post(new Runnable() {
+            @Override
+            public void run() {
+                onNotifyDataSetChanged();
+            }
+        });
     }
 
     void superNotifyDataSetChanged() {
@@ -904,9 +1042,8 @@
         boolean result = false;
         switch (msg.what) {
         case sUnbindServiceMessageType:
-            final AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
             if (mServiceConnection.isConnected()) {
-                mgr.unbindRemoteViewsService(mAppWidgetId, mIntent);
+                mServiceConnection.unbind(mContext, mAppWidgetId, mIntent);
             }
             result = true;
             break;
@@ -917,20 +1054,19 @@
     }
 
     private void enqueueDeferredUnbindServiceMessage() {
-        /* Temporarily disable delayed service unbinding
         // Remove any existing deferred-unbind messages
         mMainQueue.removeMessages(sUnbindServiceMessageType);
         mMainQueue.sendEmptyMessageDelayed(sUnbindServiceMessageType, sUnbindServiceDelay);
-        */
     }
 
     private boolean requestBindService() {
         // Try binding the service (which will start it if it's not already running)
         if (!mServiceConnection.isConnected()) {
-            final AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
-            mgr.bindRemoteViewsService(mAppWidgetId, mIntent, mServiceConnection.asBinder());
+            mServiceConnection.bind(mContext, mAppWidgetId, mIntent);
         }
 
+        // Remove any existing deferred-unbind messages
+        mMainQueue.removeMessages(sUnbindServiceMessageType);
         return mServiceConnection.isConnected();
     }
 }
diff --git a/core/java/android/widget/RemoteViewsService.java b/core/java/android/widget/RemoteViewsService.java
index e5a3de2..fb2c416 100644
--- a/core/java/android/widget/RemoteViewsService.java
+++ b/core/java/android/widget/RemoteViewsService.java
@@ -17,11 +17,11 @@
 package android.widget;
 
 import java.util.HashMap;
-import java.util.Map;
 
 import android.app.Service;
 import android.content.Intent;
 import android.os.IBinder;
+import android.util.Log;
 import android.util.Pair;
 
 import com.android.internal.widget.IRemoteViewsFactory;
@@ -35,8 +35,13 @@
 
     private static final String LOG_TAG = "RemoteViewsService";
 
-    // multimap implementation for reference counting
-    private HashMap<Intent.FilterComparison, Pair<RemoteViewsFactory, Integer>> mRemoteViewFactories;
+    // Used for reference counting of RemoteViewsFactories
+    // Because we are now unbinding when we are not using the Service (to allow them to be
+    // reclaimed), the references to the factories that are created need to be stored and used when
+    // the service is restarted (in response to user input for example).  When the process is
+    // destroyed, so is this static cache of RemoteViewsFactories.
+    private static final HashMap<Intent.FilterComparison, RemoteViewsFactory> mRemoteViewFactories =
+            new HashMap<Intent.FilterComparison, RemoteViewsFactory>();
     private final Object mLock = new Object();
 
     /**
@@ -126,9 +131,13 @@
      * A private proxy class for the private IRemoteViewsFactory interface through the
      * public RemoteViewsFactory interface.
      */
-    private class RemoteViewsFactoryAdapter extends IRemoteViewsFactory.Stub {
-        public RemoteViewsFactoryAdapter(RemoteViewsFactory factory) {
+    private static class RemoteViewsFactoryAdapter extends IRemoteViewsFactory.Stub {
+        public RemoteViewsFactoryAdapter(RemoteViewsFactory factory, boolean isCreated) {
             mFactory = factory;
+            mIsCreated = isCreated;
+        }
+        public synchronized boolean isCreated() {
+            return mIsCreated;
         }
         public synchronized void onDataSetChanged() {
             mFactory.onDataSetChanged();
@@ -155,58 +164,28 @@
         }
 
         private RemoteViewsFactory mFactory;
-    }
-
-    public RemoteViewsService() {
-        mRemoteViewFactories =
-                new HashMap<Intent.FilterComparison, Pair<RemoteViewsFactory, Integer>>();
+        private boolean mIsCreated;
     }
 
     @Override
     public IBinder onBind(Intent intent) {
         synchronized (mLock) {
-            // increment the reference count to the particular factory associated with this intent
             Intent.FilterComparison fc = new Intent.FilterComparison(intent);
-            Pair<RemoteViewsFactory, Integer> factoryRef = null;
             RemoteViewsFactory factory = null;
+            boolean isCreated = false;
             if (!mRemoteViewFactories.containsKey(fc)) {
                 factory = onGetViewFactory(intent);
-                factoryRef = new Pair<RemoteViewsFactory, Integer>(factory, 1);
-                mRemoteViewFactories.put(fc, factoryRef);
+                mRemoteViewFactories.put(fc, factory);
                 factory.onCreate();
+                isCreated = false;
             } else {
-                Pair<RemoteViewsFactory, Integer> oldFactoryRef = mRemoteViewFactories.get(fc);
-                factory = oldFactoryRef.first;
-                int newRefCount = oldFactoryRef.second.intValue() + 1;
-                factoryRef = new Pair<RemoteViewsFactory, Integer>(oldFactoryRef.first, newRefCount);
-                mRemoteViewFactories.put(fc, factoryRef);
+                factory = mRemoteViewFactories.get(fc);
+                isCreated = true;
             }
-            return new RemoteViewsFactoryAdapter(factory);
+            return new RemoteViewsFactoryAdapter(factory, isCreated);
         }
     }
 
-    @Override
-    public boolean onUnbind(Intent intent) {
-        synchronized (mLock) {
-            Intent.FilterComparison fc = new Intent.FilterComparison(intent);
-            if (mRemoteViewFactories.containsKey(fc)) {
-                // this alleviates the user's responsibility of having to clear all factories
-                Pair<RemoteViewsFactory, Integer> oldFactoryRef =
-                        mRemoteViewFactories.get(fc);
-                int newRefCount = oldFactoryRef.second.intValue() - 1;
-                if (newRefCount <= 0) {
-                    oldFactoryRef.first.onDestroy();
-                    mRemoteViewFactories.remove(fc);
-                } else {
-                    Pair<RemoteViewsFactory, Integer> factoryRef =
-                            new Pair<RemoteViewsFactory, Integer>(oldFactoryRef.first, newRefCount);
-                    mRemoteViewFactories.put(fc, factoryRef);
-                }
-            }
-        }
-        return super.onUnbind(intent);
-    }
-
     /**
      * To be implemented by the derived service to generate appropriate factories for
      * the data.
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index fc049cc..d1cfcec 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -644,7 +644,7 @@
         if (!mScroller.isFinished()) {
             mScrollX = scrollX;
             mScrollY = scrollY;
-            invalidateParentIfAccelerated();
+            invalidateParentIfNeeded();
             if (clampedY) {
                 mScroller.springBack(mScrollX, mScrollY, 0, 0, 0, getScrollRange());
             }
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index fedda68..213117d 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3508,6 +3508,8 @@
     private static class ErrorPopup extends PopupWindow {
         private boolean mAbove = false;
         private final TextView mView;
+        private int mPopupInlineErrorBackgroundId = 0;
+        private int mPopupInlineErrorAboveBackgroundId = 0;
 
         ErrorPopup(TextView v, int width, int height) {
             super(v, width, height);
@@ -3518,10 +3520,23 @@
             mAbove = above;
 
             if (above) {
-                mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error_above);
+                mPopupInlineErrorAboveBackgroundId =
+                    getResourceId(mPopupInlineErrorAboveBackgroundId, com.android.internal.R.styleable.Theme_errorMessageAboveBackground);
             } else {
-                mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error);
+                mPopupInlineErrorBackgroundId =
+                    getResourceId(mPopupInlineErrorBackgroundId, com.android.internal.R.styleable.Theme_errorMessageBackground);
             }
+
+            mView.setBackgroundResource(above ? mPopupInlineErrorAboveBackgroundId : mPopupInlineErrorBackgroundId);
+        }
+
+        private int getResourceId(int currentId, int index) {
+            if (currentId == 0) {
+                TypedArray styledAttributes = mView.getContext().obtainStyledAttributes(R.styleable.Theme);
+                currentId = styledAttributes.getResourceId(index, 0);
+                styledAttributes.recycle();
+            }
+            return currentId;
         }
 
         @Override
@@ -6272,7 +6287,7 @@
             if (mScroller.computeScrollOffset()) {
                 mScrollX = mScroller.getCurrX();
                 mScrollY = mScroller.getCurrY();
-                invalidateParentIfAccelerated();
+                invalidateParentCaches();
                 postInvalidate();  // So we draw again
             }
         }
diff --git a/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl b/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl
index ae9900c..60eca00 100644
--- a/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl
+++ b/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl
@@ -27,5 +27,6 @@
     int getViewTypeCount();
     long getItemId(int position);
     boolean hasStableIds();
+    boolean isCreated();
 }
 
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 9de270d..7a609a5 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -137,21 +137,11 @@
     renderer->finish();
 }
 
-static void android_view_GLES20Canvas_acquireContext(JNIEnv* env, jobject clazz,
-        OpenGLRenderer* renderer) {
-    renderer->acquireContext();
-}
-
 static bool android_view_GLES20Canvas_callDrawGLFunction(JNIEnv* env, jobject clazz,
         OpenGLRenderer* renderer, Functor *functor) {
     return renderer->callDrawGLFunction(functor);
 }
 
-static void android_view_GLES20Canvas_releaseContext(JNIEnv* env, jobject clazz,
-        OpenGLRenderer* renderer) {
-    renderer->releaseContext();
-}
-
 // ----------------------------------------------------------------------------
 // State
 // ----------------------------------------------------------------------------
@@ -609,8 +599,6 @@
     { "nPrepare",           "(IZ)V",           (void*) android_view_GLES20Canvas_prepare },
     { "nPrepareDirty",      "(IIIIIZ)V",       (void*) android_view_GLES20Canvas_prepareDirty },
     { "nFinish",            "(I)V",            (void*) android_view_GLES20Canvas_finish },
-    { "nAcquireContext",    "(I)V",            (void*) android_view_GLES20Canvas_acquireContext },
-    { "nReleaseContext",    "(I)V",            (void*) android_view_GLES20Canvas_releaseContext },
 
     { "nCallDrawGLFunction", "(II)Z",
             (void*) android_view_GLES20Canvas_callDrawGLFunction },
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index bd0cd35..a91829c 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1095,7 +1095,7 @@
     <permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"
         android:label="@string/permlab_changeComponentState"
         android:description="@string/permdesc_changeComponentState"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signatureOrSystem" />
 
     <!-- Allows an application to use SurfaceFlinger's low level features -->
     <permission android:name="android.permission.ACCESS_SURFACE_FLINGER"
diff --git a/core/res/res/anim/wallpaper_open_exit.xml b/core/res/res/anim/wallpaper_open_exit.xml
index 47ea0b4..0aeb550 100644
--- a/core/res/res/anim/wallpaper_open_exit.xml
+++ b/core/res/res/anim/wallpaper_open_exit.xml
@@ -18,7 +18,8 @@
 -->
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
-        android:detachWallpaper="true" android:shareInterpolator="false">
+        android:detachWallpaper="true" android:shareInterpolator="false"
+        android:zAdjustment="top">
     <scale android:fromXScale="1.0" android:toXScale="1.0"
             android:fromYScale="1.0" android:toYScale="0.0"
             android:pivotX="50%p" android:pivotY="50%p"
diff --git a/core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png
new file mode 100644
index 0000000..dd4af6d
--- /dev/null
+++ b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png
new file mode 100644
index 0000000..8925112
--- /dev/null
+++ b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png b/core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png
new file mode 100755
index 0000000..66c2c09
--- /dev/null
+++ b/core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png b/core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png
new file mode 100755
index 0000000..c5113f2
--- /dev/null
+++ b/core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png
Binary files differ
diff --git a/core/res/res/layout/textview_hint.xml b/core/res/res/layout/textview_hint.xml
index 20b08bf..f9c4406 100644
--- a/core/res/res/layout/textview_hint.xml
+++ b/core/res/res/layout/textview_hint.xml
@@ -17,7 +17,6 @@
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@drawable/popup_inline_error"
     android:textAppearance="?android:attr/textAppearanceSmall"
     android:textColor="@color/primary_text_light"
 />
diff --git a/core/res/res/values-xlarge/dimens.xml b/core/res/res/values-xlarge/dimens.xml
index 63d3619..e058442 100644
--- a/core/res/res/values-xlarge/dimens.xml
+++ b/core/res/res/values-xlarge/dimens.xml
@@ -40,9 +40,6 @@
     <dimen name="thumbnail_width">230dp</dimen>
     <!-- The height that is used when creating thumbnails of applications. -->
     <dimen name="thumbnail_height">135dp</dimen>
-    <!-- The standard size (both width and height) of an application icon that
-         will be displayed in the app launcher and elsewhere. -->
-    <dimen name="app_icon_size">64dip</dimen>
     <!-- Minimum width of the search view text entry area. -->
     <dimen name="search_view_text_min_width">192dip</dimen>
 
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 260c7c6..4a56532 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -142,6 +142,11 @@
         <!-- EditText background drawable. -->
         <attr name="editTextBackground" format="reference" />
 
+        <!-- Popup text displayed in TextView when setError is used. -->
+        <attr name="errorMessageBackground" format="reference" />
+        <!-- Background used instead of errorMessageBackground when the popup has to be above. -->
+        <attr name="errorMessageAboveBackground" format="reference" />
+
         <!-- A styled string, specifying the style to be used for showing
              inline candidate text when composing with an input method.  The
              text itself will be ignored, but the style spans will be applied
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index ddaeb82..c5ae77f 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -217,6 +217,8 @@
         <item name="starStyle">@android:style/Widget.CompoundButton.Star</item>
         <item name="tabWidgetStyle">@android:style/Widget.TabWidget</item>
         <item name="textViewStyle">@android:style/Widget.TextView</item>
+        <item name="errorMessageBackground">@android:drawable/popup_inline_error</item>
+        <item name="errorMessageAboveBackground">@android:drawable/popup_inline_error_above</item>
         <item name="webTextViewStyle">@android:style/Widget.WebTextView</item>
         <item name="webViewStyle">@android:style/Widget.WebView</item>
         <item name="dropDownItemStyle">@android:style/Widget.DropDownItem</item>
@@ -934,6 +936,8 @@
         <item name="starStyle">@android:style/Widget.Holo.CompoundButton.Star</item>
         <item name="tabWidgetStyle">@android:style/Widget.Holo.TabWidget</item>
         <item name="textViewStyle">@android:style/Widget.Holo.TextView</item>
+        <item name="errorMessageBackground">@android:drawable/popup_inline_error_holo_dark</item>
+        <item name="errorMessageAboveBackground">@android:drawable/popup_inline_error_above_holo_dark</item>
         <item name="webTextViewStyle">@android:style/Widget.Holo.WebTextView</item>
         <item name="webViewStyle">@android:style/Widget.Holo.WebView</item>
         <item name="dropDownItemStyle">@android:style/Widget.Holo.DropDownItem</item>
@@ -1207,6 +1211,8 @@
         <item name="starStyle">@android:style/Widget.Holo.Light.CompoundButton.Star</item>
         <item name="tabWidgetStyle">@android:style/Widget.Holo.Light.TabWidget</item>
         <item name="textViewStyle">@android:style/Widget.Holo.Light.TextView</item>
+        <item name="errorMessageBackground">@android:drawable/popup_inline_error_holo_light</item>
+        <item name="errorMessageAboveBackground">@android:drawable/popup_inline_error_above_holo_light</item>
         <item name="webTextViewStyle">@android:style/Widget.Holo.Light.WebTextView</item>
         <item name="webViewStyle">@android:style/Widget.Holo.Light.WebView</item>
         <item name="dropDownItemStyle">@android:style/Widget.Holo.Light.DropDownItem</item>
diff --git a/core/tests/coretests/src/android/webkit/AccessibilityInjectorTest.java b/core/tests/coretests/src/android/webkit/AccessibilityInjectorTest.java
index 4edd127..16108e6 100644
--- a/core/tests/coretests/src/android/webkit/AccessibilityInjectorTest.java
+++ b/core/tests/coretests/src/android/webkit/AccessibilityInjectorTest.java
@@ -51,7 +51,7 @@
     private static final long TIMEOUT_ENABLE_ACCESSIBILITY_AND_MOCK_SERVICE = 1000;
 
     /** The count of tests to detect when to shut down the service. */
-    private static final int TEST_CASE_COUNT = 8;
+    private static final int TEST_CASE_COUNT = 16;
 
     /** The meta state for pressed left ALT. */
     private static final int META_STATE_ALT_LEFT_ON = KeyEvent.META_ALT_ON
@@ -140,7 +140,8 @@
                    "</p>" +
                    "<p>" +
                      "d" +
-                     "<input>e</input>" +
+                     "<p/>" +
+                     "e" +
                    "</p>" +
                "</body>" +
              "</html>";
@@ -179,6 +180,10 @@
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
         assertSelectionString(null);
 
+        // go to the fifth character (reverse)
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("e");
+
         // go to the fourth character (reverse)
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
         assertSelectionString("d");
@@ -199,6 +204,10 @@
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
         assertSelectionString(null);
 
+        // go to the first character
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("a");
+
         // go to the second character (reverse again)
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
         assertSelectionString("<b>b</b>");
@@ -223,11 +232,11 @@
                    "</p>" +
                    "<p>" +
                      " scattered " +
-                     "<input>all</input>" +
-                     " over " +
+                     "<p/>" +
+                     " all over " +
                    "</p>" +
                    "<div>" +
-                     "<button>the place.</button>" +
+                     "<p>the place.</p>" +
                    "</div>" +
                "</body>" +
              "</html>";
@@ -284,7 +293,7 @@
 
         // go to the last word (reverse)
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
-        assertSelectionString("place");
+        assertSelectionString("place.");
 
         // go to the eight word
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
@@ -322,6 +331,10 @@
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
         assertSelectionString(null);
 
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("This");
+
         // go to the second word (reverse again)
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
         assertSelectionString("is");
@@ -384,6 +397,10 @@
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
         assertSelectionString(null);
 
+        // go to the fifth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("This is the second sentence of the second paragraph.");
+
         // go to the fourth sentence (reverse)
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
         assertSelectionString("This is the first sentence of the second paragraph.");
@@ -405,6 +422,11 @@
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
         assertSelectionString(null);
 
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("This is the first sentence of the first paragraph and has an "
+                + "<b>inline bold tag</b>.");
+
         // go to the second sentence (reverse again)
         sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
         assertSelectionString("This is the second sentence of the first paragraph.");
@@ -747,6 +769,539 @@
     }
 
     /**
+     * Tests that the selection does not cross anchor boundaries. This is a
+     * workaround for the asymmetric and inconsistent handling of text with
+     * links by WebKit while traversing by sentence.
+     */
+    @LargeTest
+    public void testEnforceSelectionDoesNotCrossAnchorBoundary1() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<div>First</div>" +
+                "<p>" +
+                  "<a href=\"\">Second</a> Third" +
+                "</p>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"\">Second</a>");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("Third");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("Third");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"\">Second</a>");
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+
+        // go to before the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+    }
+
+    /**
+     * Tests that the selection does not cross anchor boundaries. This is a
+     * workaround for the asymmetric and inconsistent handling of text with
+     * links by WebKit while traversing by sentence.
+     */
+    @LargeTest
+    public void testEnforceSelectionDoesNotCrossAnchorBoundary2() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<div>First</div>" +
+                "<a href=\"#\">Second</a>" +
+                "&nbsp;" +
+                "<a href=\"#\">Third</a>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\">Second</a>");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("&nbsp;");
+
+        // go to the fourth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\">Third</a>");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the fourth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"#\">Third</a>");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("&nbsp;");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"#\">Second</a>");
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+
+        // go to before the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+    }
+
+    /**
+     * Tests that the selection does not cross anchor boundaries. This is a
+     * workaround for the asymmetric and inconsistent handling of text with
+     * links by WebKit while traversing by sentence.
+     */
+    @LargeTest
+    public void testEnforceSelectionDoesNotCrossAnchorBoundary3() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<div>" +
+                  "First" +
+                "<div>" +
+                "<div>" +
+                  "<a href=\"#\">Second</a>" +
+                "</div>" +
+                "<div>" +
+                  "Third" +
+                "</div>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\">Second</a>");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("Third");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("Third");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"#\">Second</a>");
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+
+        // go to before the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+    }
+
+    /**
+     * Tests skipping of content with hidden visibility.
+     */
+    @LargeTest
+    public void testSkipVisibilityHidden() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<div>First </div>" +
+                "<div style=\"visibility:hidden;\">Second</div>" +
+                "<div> Third</div>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // change navigation axis to word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, META_STATE_ALT_LEFT_ON);
+        assertSelectionString("1"); // expect the word navigation axis
+
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the third word (the second is invisible)
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("Third");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the third word (the second is invisible)
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("Third");
+
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+
+        // go to before the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+    }
+
+    /**
+     * Tests skipping of content with display none.
+     */
+    @LargeTest
+    public void testSkipDisplayNone() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<div>First</div>" +
+                "<div style=\"display: none;\">Second</div>" +
+                "<div>Third</div>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // change navigation axis to word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, META_STATE_ALT_LEFT_ON);
+        assertSelectionString("1"); // expect the word navigation axis
+
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the third word (the second is invisible)
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("Third");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the third word (the second is invisible)
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("Third");
+
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+
+        // go to before the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first word
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+    }
+
+    /**
+     * Tests for the selection not getting stuck.
+     *
+     * Note: The selection always proceeds but if it can
+     * be selecting the same content i.e. between the start
+     * and end are contained the same text nodes.
+     */
+    @LargeTest
+    public void testSelectionTextProceed() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<a href=\"#\">First</a>" +
+                "<span><a href=\"#\"><span>Second</span>&nbsp;<small>a</small></a>" +
+                "</span>&nbsp;<a href=\"#\">Third</a>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\">First</a>");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\"><span>Second&nbsp;<small>a</small></a>");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("&nbsp;");
+
+        // go to the fourth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\">Third</a>");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"#\">Third</a>");
+
+        // NOTE: Here we are a bit asymmetric around whitespace but we can live with it
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("&nbsp;");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"#\"><span>Second&nbsp;<small>a</small></a>");
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<a href=\"#\">First</a>");
+
+        // go to before the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<a href=\"#\">First</a>");
+    }
+
+    /**
+     * Tests if input elements are selected rather skipped.
+     */
+    @LargeTest
+    public void testSelectionOfInputElements() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<p>" +
+                  "First" +
+                "</p>" +
+                "<input type=\"text\"/>" +
+                "<p>" +
+                  "Second" +
+                "</p>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<input type=\"text\">");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("Second");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("Second");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<input type=\"text\">");
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+
+        // go to before the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString(null);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+    }
+
+    /**
+     * Tests traversing of input controls.
+     */
+    @LargeTest
+    public void testSelectionOfInputElements2() throws Exception {
+        // a bit ugly but helps detect beginning and end of all tests so accessibility
+        // and the mock service are not toggled on every test (expensive)
+        sExecutedTestCount++;
+
+        String html =
+            "<!DOCTYPE html>" +
+            "<html>" +
+              "<head>" +
+              "</head>" +
+              "<body>" +
+                "<div>" +
+                  "First" +
+                  "<input type=\"text\"/>" +
+                  "<span>" +
+                    "<input type=\"text\"/>" +
+                  "</span>" +
+                  "<button type=\"button\">Click Me!</button>" +
+                  "<div>" +
+                    "<input type=\"submit\"/>" +
+                  "</div>" +
+                  "<p>" +
+                    "Second" +
+                  "</p>" +
+                "</div>" +
+              "</body>" +
+            "</html>";
+
+        WebView webView = createWebVewWithHtml(html);
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("First");
+
+        // go to the second sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<input type=\"text\">");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<input type=\"text\">");
+
+        // go to the fourth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<button type=\"button\">Click Me!</button>");
+
+        // go to the fifth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("<input type=\"submit\">");
+
+        // go to the sixth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString("Second");
+
+        // go to past the last sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_DOWN, 0);
+        assertSelectionString(null);
+
+        // go to the sixth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("Second");
+
+        // go to the fifth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<input type=\"submit\">");
+
+        // go to the fourth sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<button type=\"button\">Click Me!</button>");
+
+        // go to the third sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("<input type=\"text\">");
+
+        // go to the first sentence
+        sendKeyEvent(webView, KeyEvent.KEYCODE_DPAD_UP, 0);
+        assertSelectionString("First");
+    }
+
+    /**
      * Enable accessibility and the mock accessibility service.
      */
     private void enableAccessibilityAndMockAccessibilityService() {
@@ -887,7 +1442,8 @@
      */
     private void restoreDefaultWebContentKeyBindings() {
         Settings.Secure.putString(getContext().getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS, mDefaultKeyBindings);
+                Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS,
+                mDefaultKeyBindings);
     }
 
     /**
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 00b06e0..c1deed3 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1596,51 +1596,6 @@
     }
 
     /**
-     * <p>Acquires the Canvas context. After invoking this method, the Canvas
-     * context  can be modified by the caller. For instance, if you acquire
-     * the context of an OpenGL Canvas you can reset the GL viewport, scissor,
-     * etc.</p>
-     * 
-     * <p>A call to {@link #acquireContext()} should aways be followed by
-     * a call to {@link #releaseContext()}, preferrably using a try block:</p>
-     * 
-     * <pre>
-     * try {
-     *     if (canvas.acquireContext()) {
-     *         // Use the canvas and/or its context
-     *     }
-     * } finally {
-     *     canvas.releaseContext();
-     * }
-     * </pre>
-     * 
-     * <p>Acquiring the context can be an expensive operation and should not
-     * be done unless absolutely necessary.</p>
-     * 
-     * <p>Applications should never invoke this method directly.</p>
-     * 
-     * @return True if the context could be acquired successfully, false
-     *         otherwise (if the context is already acquired for instance.)
-     * 
-     * @see #releaseContext() 
-     * 
-     * @hide
-     */
-    public boolean acquireContext() {
-        return false;
-    }
-
-    /**
-     * <p>Release the context acquired with {@link #acquireContext()}.</p>
-     * 
-     * @see #acquireContext() 
-     * 
-     * @hide
-     */
-    public void releaseContext() {
-    }
-
-    /**
      * Free up as much memory as possible from private caches (e.g. fonts, images)
      *
      * @hide
diff --git a/graphics/java/android/graphics/drawable/package.html b/graphics/java/android/graphics/drawable/package.html
index da49df7..60b7a2c 100644
--- a/graphics/java/android/graphics/drawable/package.html
+++ b/graphics/java/android/graphics/drawable/package.html
@@ -1,9 +1,10 @@
 <HTML>
 <BODY>
-Provides classes to manage a variety of visual elements that are intended for
+<p>Provides classes to manage a variety of visual elements that are intended for
 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}guide/topics/resources/available-resources.html">Availeble Resource Types</a>.
+level indicator).</p>
+<p>You can create most of these drawables using XML, as described in <a
+href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>.</p>
 </BODY>
 </HTML>
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 794355b..4a39fbf2 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -158,6 +158,7 @@
     int32_t mNumFramesReceived;
     int64_t mLastFrameTimestampUs;
     bool mStarted;
+    int32_t mNumFramesEncoded;
 
     CameraSource(const sp<ICamera>& camera, int32_t cameraId,
                  Size videoSize, int32_t frameRate,
@@ -189,7 +190,6 @@
     List<int64_t> mFrameTimes;
 
     int64_t mFirstFrameTimeUs;
-    int32_t mNumFramesEncoded;
     int32_t mNumFramesDropped;
     int32_t mNumGlitches;
     int64_t mGlitchDurationThresholdUs;
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 3251c28..82948cb 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -47,6 +47,9 @@
 
         // Store meta data in video buffers
         kStoreMetaDataInVideoBuffers = 32,
+
+        // Only submit one input buffer at one time.
+        kOnlySubmitOneInputBufferAtOneTime = 64,
     };
     static sp<MediaSource> Create(
             const sp<IOMX> &omx,
@@ -192,6 +195,7 @@
     Condition mBufferFilled;
 
     bool mIsMetaDataStoredInVideoBuffers;
+    bool mOnlySubmitOneBufferAtOneTime;
 
     OMXCodec(const sp<IOMX> &omx, IOMX::node_id node, uint32_t quirks,
              bool isEncoder, const char *mime, const char *componentName,
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index c2106d4..cfc853c 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -82,8 +82,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 const char* DisplayList::OP_NAMES[] = {
-    "AcquireContext",
-    "ReleaseContext",
     "Save",
     "Restore",
     "RestoreToCount",
@@ -239,16 +237,6 @@
                 needsInvalidate |= renderer.callDrawGLFunction(functor);
             }
             break;
-            case AcquireContext: {
-                DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
-                renderer.acquireContext();
-            }
-            break;
-            case ReleaseContext: {
-                DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
-                renderer.releaseContext();
-            }
-            break;
             case Save: {
                 int rendererNum = getInt();
                 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
@@ -644,15 +632,9 @@
 }
 
 void DisplayListRenderer::interrupt() {
-
 }
+
 void DisplayListRenderer::resume() {
-
-}
-void DisplayListRenderer::acquireContext() {
-    // TODO: probably noop instead of calling super
-    addOp(DisplayList::AcquireContext);
-    OpenGLRenderer::acquireContext();
 }
 
 bool DisplayListRenderer::callDrawGLFunction(Functor *functor) {
@@ -661,12 +643,6 @@
     return false; // No invalidate needed at record-time
 }
 
-void DisplayListRenderer::releaseContext() {
-    // TODO: probably noop instead of calling super
-    addOp(DisplayList::ReleaseContext);
-    OpenGLRenderer::releaseContext();
-}
-
 int DisplayListRenderer::save(int flags) {
     addOp(DisplayList::Save);
     addInt(flags);
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index bab5149..a6d2bfe 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -89,9 +89,7 @@
     // IMPORTANT: Update the intialization of OP_NAMES in the .cpp file
     //            when modifying this file
     enum Op {
-        AcquireContext = 0,
-        ReleaseContext,
-        Save,
+        Save = 0,
         Restore,
         RestoreToCount,
         SaveLayer,
@@ -245,8 +243,6 @@
     void finish();
 
     bool callDrawGLFunction(Functor *functor);
-    void acquireContext();
-    void releaseContext();
 
     void interrupt();
     void resume();
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index c378f46..81c3407 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -191,10 +191,6 @@
     mCaches.unbindMeshBuffer();
 }
 
-void OpenGLRenderer::acquireContext() {
-    interrupt();
-}
-
 void OpenGLRenderer::resume() {
     glViewport(0, 0, mSnapshot->viewport.getWidth(), mSnapshot->viewport.getHeight());
 
@@ -212,10 +208,6 @@
     glBlendEquation(GL_FUNC_ADD);
 }
 
-void OpenGLRenderer::releaseContext() {
-    resume();
-}
-
 bool OpenGLRenderer::callDrawGLFunction(Functor *functor) {
     interrupt();
     if (mDirtyClip) {
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 77de1d2..64def03 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -71,8 +71,6 @@
     virtual void resume();
 
     virtual bool callDrawGLFunction(Functor *functor);
-    virtual void acquireContext();
-    virtual void releaseContext();
 
     int getSaveCount() const;
     virtual int save(int flags);
diff --git a/libs/rs/rsScriptC_LibCL.cpp b/libs/rs/rsScriptC_LibCL.cpp
index 02d33b7..57855db 100644
--- a/libs/rs/rsScriptC_LibCL.cpp
+++ b/libs/rs/rsScriptC_LibCL.cpp
@@ -195,7 +195,7 @@
     { "_Z4logbf", (void *)&logbf, true },
     { "_Z3madfff", (void *)&SC_mad, true },
     { "_Z4modffPf", (void *)&modff, true },
-    //{ "nan", (void *)&, true },
+    //{ "_Z3nanj", (void *)&SC_nan, true },
     { "_Z9nextafterff", (void *)&nextafterf, true },
     { "_Z3powff", (void *)&powf, true },
     { "_Z9remainderff", (void *)&remainderf, true },
@@ -210,7 +210,7 @@
     { "_Z4sqrtf", (void *)&sqrtf, true },
     { "_Z3tanf", (void *)&tanf, true },
     { "_Z4tanhf", (void *)&tanhf, true },
-    { "_Z6tgammaf", (void *)&lgammaf, true }, // FIXME!!! NEEDS TO USE tgammaf
+    { "_Z6tgammaf", (void *)&tgammaf, true },
     { "_Z5truncf", (void *)&truncf, true },
 
     // OpenCL Int
diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh
index fdaa903..e32d4351 100644
--- a/libs/rs/scriptc/rs_core.rsh
+++ b/libs/rs/scriptc/rs_core.rsh
@@ -1,11 +1,7 @@
 #ifndef __RS_CORE_RSH__
 #define __RS_CORE_RSH__
 
-#ifdef BCC_PREPARE_BC
-#define _RS_STATIC  extern
-#else
-#define _RS_STATIC  static
-#endif
+#define _RS_RUNTIME extern
 
 // Debugging, print to the LOG a description string and a value.
 extern void __attribute__((overloadable))
@@ -41,56 +37,19 @@
 #define RS_DEBUG(a) rsDebug(#a, a)
 #define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
 
-_RS_STATIC void __attribute__((overloadable)) rsDebug(const char *s, float2 v) {
-    rsDebug(s, v.x, v.y);
-}
-_RS_STATIC void __attribute__((overloadable)) rsDebug(const char *s, float3 v) {
-    rsDebug(s, v.x, v.y, v.z);
-}
-_RS_STATIC void __attribute__((overloadable)) rsDebug(const char *s, float4 v) {
-    rsDebug(s, v.x, v.y, v.z, v.w);
-}
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float2 v);
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float3 v);
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float4 v);
 
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b)
-{
-    uchar4 c;
-    c.x = (uchar)(r * 255.f);
-    c.y = (uchar)(g * 255.f);
-    c.z = (uchar)(b * 255.f);
-    c.w = 255;
-    return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
 
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a)
-{
-    uchar4 c;
-    c.x = (uchar)(r * 255.f);
-    c.y = (uchar)(g * 255.f);
-    c.z = (uchar)(b * 255.f);
-    c.w = (uchar)(a * 255.f);
-    return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
 
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color)
-{
-    color *= 255.f;
-    uchar4 c = {color.x, color.y, color.z, 255};
-    return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
 
-_RS_STATIC uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color)
-{
-    color *= 255.f;
-    uchar4 c = {color.x, color.y, color.z, color.w};
-    return c;
-}
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
 
-_RS_STATIC float4 rsUnpackColor8888(uchar4 c)
-{
-    float4 ret = (float4)0.0039156862745f;
-    ret *= convert_float4(c);
-    return ret;
-}
+_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
 
 //extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float r, float g, float b);
 //extern uchar4 __attribute__((overloadable)) rsPackColorTo565(float3);
@@ -101,35 +60,23 @@
 // Matrix ops
 /////////////////////////////////////////////////////
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v) {
-    m->m[row * 4 + col] = v;
-}
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
 
-_RS_STATIC float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col) {
-    return m->m[row * 4 + col];
-}
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v) {
-    m->m[row * 3 + col] = v;
-}
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
 
-_RS_STATIC float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col) {
-    return m->m[row * 3 + col];
-}
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v) {
-    m->m[row * 2 + col] = v;
-}
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
 
-_RS_STATIC float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col) {
-    return m->m[row * 2 + col];
-}
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
 
 extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
 extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
@@ -188,61 +135,23 @@
 extern void __attribute__((overloadable))
 rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
 
-_RS_STATIC float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float4 in) {
-    float4 ret;
-    ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + (m->m[8] * in.z) + (m->m[12] * in.w);
-    ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + (m->m[9] * in.z) + (m->m[13] * in.w);
-    ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + (m->m[10] * in.z) + (m->m[14] * in.w);
-    ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + (m->m[11] * in.z) + (m->m[15] * in.w);
-    return ret;
-}
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
 
-_RS_STATIC float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float3 in) {
-    float4 ret;
-    ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + (m->m[8] * in.z) + m->m[12];
-    ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + (m->m[9] * in.z) + m->m[13];
-    ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + (m->m[10] * in.z) + m->m[14];
-    ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + (m->m[11] * in.z) + m->m[15];
-    return ret;
-}
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
 
-_RS_STATIC float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float2 in) {
-    float4 ret;
-    ret.x = (m->m[0] * in.x) + (m->m[4] * in.y) + m->m[12];
-    ret.y = (m->m[1] * in.x) + (m->m[5] * in.y) + m->m[13];
-    ret.z = (m->m[2] * in.x) + (m->m[6] * in.y) + m->m[14];
-    ret.w = (m->m[3] * in.x) + (m->m[7] * in.y) + m->m[15];
-    return ret;
-}
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
 
-_RS_STATIC float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float3 in) {
-    float3 ret;
-    ret.x = (m->m[0] * in.x) + (m->m[3] * in.y) + (m->m[6] * in.z);
-    ret.y = (m->m[1] * in.x) + (m->m[4] * in.y) + (m->m[7] * in.z);
-    ret.z = (m->m[2] * in.x) + (m->m[5] * in.y) + (m->m[8] * in.z);
-    return ret;
-}
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
 
-_RS_STATIC float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float2 in) {
-    float3 ret;
-    ret.x = (m->m[0] * in.x) + (m->m[3] * in.y);
-    ret.y = (m->m[1] * in.x) + (m->m[4] * in.y);
-    ret.z = (m->m[2] * in.x) + (m->m[5] * in.y);
-    return ret;
-}
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
 
-_RS_STATIC float2 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, float2 in) {
-    float2 ret;
-    ret.x = (m->m[0] * in.x) + (m->m[2] * in.y);
-    ret.y = (m->m[1] * in.x) + (m->m[3] * in.y);
-    return ret;
-}
+_RS_RUNTIME float2 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
 
 // Returns true if the matrix was successfully inversed
 extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
@@ -255,26 +164,13 @@
 // int ops
 /////////////////////////////////////////////////////
 
-__inline__ _RS_STATIC uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
-__inline__ _RS_STATIC char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
+_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
+_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
+_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
+_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
+_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
+_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
 
-#undef _RS_STATIC
+#undef _RS_RUNTIME
 
 #endif
-
diff --git a/location/java/android/location/package.html b/location/java/android/location/package.html
index bbaeb42..be34774 100644
--- a/location/java/android/location/package.html
+++ b/location/java/android/location/package.html
@@ -1,12 +1,11 @@
 <html>
-<head>
-<script type="text/javascript" src="http://www.corp.google.com/style/prettify.js"></script>
-<script src="http://www.corp.google.com/eng/techpubs/include/navbar.js" type="text/javascript"></script>
-</head>
 
 <body>
 
-<p>Classes defining Android location-based and related services.</p>
+<p>Contains classes that define Android location-based and related services.</p>
+<p>For more information about location services, see the documentation for <a
+href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User Location</a>.</p>
+{@more}
 
 </body>
 </html>
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
old mode 100755
new mode 100644
index f10f5e8..1244b8e
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -24,15 +24,16 @@
 import java.util.Iterator;
 import java.util.List;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
 import android.media.videoeditor.VideoEditor.ExportProgressListener;
 import android.media.videoeditor.VideoEditor.PreviewProgressListener;
 import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener;
 import android.util.Log;
 import android.util.Pair;
 import android.view.Surface;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
 
 /**
  *This class provide Native methods to be used by MediaArtist {@hide}
@@ -70,11 +71,17 @@
     private boolean mExportDone = false;
 
     private int mProgressToApp;
+
     /**
      *  The resize paint
      */
     private static final Paint sResizePaint = new Paint(Paint.FILTER_BITMAP_FLAG);
 
+    private String mRenderPreviewOverlayFile;
+    private int   mRenderPreviewRenderingMode;
+
+    private boolean mIsFirstProgress;
+
     public static final int TASK_LOADING_SETTINGS = 1;
 
     public static final int TASK_ENCODING = 2;
@@ -1899,12 +1906,35 @@
     }
 
     @SuppressWarnings("unused")
-    private void onPreviewProgressUpdate(int progress, boolean isFinished) {
+    private void onPreviewProgressUpdate(int progress, boolean isFinished,
+                  boolean updateOverlay, String filename, int renderingMode) {
         if (mPreviewProgressListener != null) {
-            mPreviewProgressListener.onProgress(mVideoEditor, progress, isFinished);
+            if (mIsFirstProgress) {
+                mPreviewProgressListener.onStart(mVideoEditor);
+                mIsFirstProgress = false;
+            }
+
+            final VideoEditor.OverlayData overlayData;
+            if (updateOverlay) {
+                overlayData = new VideoEditor.OverlayData();
+                if (filename != null) {
+                    overlayData.set(BitmapFactory.decodeFile(filename), renderingMode);
+                } else {
+                    overlayData.setClear();
+                }
+            } else {
+                overlayData = null;
+            }
+
+            mPreviewProgressListener.onProgress(mVideoEditor, progress, overlayData);
+
             if (progress != 0) {
                 mPreviewProgress = progress;
             }
+
+            if (isFinished) {
+                mPreviewProgressListener.onStop(mVideoEditor);
+            }
         }
     }
 
@@ -2894,6 +2924,7 @@
                     maxHeight = populateMediaItemProperties(lMediaItem,
                                                             previewIndex,
                                                             maxHeight);
+                    /* Get the clip properties of the media item. */
                     if (lMediaItem instanceof MediaImageItem)
                     {
                         int tmpCnt = 0;
@@ -3014,11 +3045,11 @@
      * @param callbackAfterFrameCount INdicated after how many frames
      * the callback is needed
      * @param listener The PreviewProgressListener
-     *
      */
     public void doPreview(Surface surface, long fromMs, long toMs, boolean loop,
             int callbackAfterFrameCount, PreviewProgressListener listener) {
         mPreviewProgress = fromMs;
+        mIsFirstProgress = true;
         mPreviewProgressListener = listener;
 
         if (!mInvalidatePreviewArray) {
@@ -3042,9 +3073,6 @@
                 Log.e("MediaArtistNativeHelper", "Runtime exception in nativeStartPreview");
                 throw ex;
             }
-
-        } else {
-            return;
         }
     }
 
@@ -3064,22 +3092,37 @@
      * @param time The time in ms at which the frame has to be rendered
      * @param surfaceWidth The surface width
      * @param surfaceHeight The surface height
+     * @param overlayData The overlay data
      *
      * @return The actual time from the story board at which the  frame was extracted
      * and rendered
      */
     public long renderPreviewFrame(Surface surface, long time, int surfaceWidth,
-                                   int surfaceHeight) {
+            int surfaceHeight, VideoEditor.OverlayData overlayData) {
         long timeMs = 0;
         if (!mInvalidatePreviewArray) {
             try {
-                for (int clipCnt = 0; clipCnt < mPreviewEditSettings.clipSettingsArray.length; clipCnt++) {
+                for (int clipCnt = 0;
+                      clipCnt < mPreviewEditSettings.clipSettingsArray.length;
+                      clipCnt++) {
+
                     if (mPreviewEditSettings.clipSettingsArray[clipCnt].fileType == FileType.JPG) {
-                        mPreviewEditSettings.clipSettingsArray[clipCnt].clipPath = mPreviewEditSettings.clipSettingsArray[clipCnt].clipDecodedPath;
+                        mPreviewEditSettings.clipSettingsArray[clipCnt].clipPath =
+                            mPreviewEditSettings.clipSettingsArray[clipCnt].clipDecodedPath;
                     }
                 }
+
+                // Reset the render preview frame params that shall be set by native.
+                mRenderPreviewOverlayFile = null;
+                mRenderPreviewRenderingMode = MediaRendering.RESIZING;
                 nativePopulateSettings(mPreviewEditSettings, mClipProperties, mAudioSettings);
                 timeMs = (long)nativeRenderPreviewFrame(surface, time, surfaceWidth, surfaceHeight);
+
+                if (mRenderPreviewOverlayFile != null) {
+                    overlayData.set(BitmapFactory.decodeFile(mRenderPreviewOverlayFile), mRenderPreviewRenderingMode);
+                } else {
+                    overlayData.setClear();
+                }
             } catch (IllegalArgumentException ex) {
                 Log.e("MediaArtistNativeHelper",
                 "Illegal Argument exception in nativeRenderPreviewFrame");
@@ -3094,11 +3137,16 @@
             }
             return timeMs;
         } else {
-
             throw new RuntimeException("Call generate preview first");
         }
     }
 
+    private void previewFrameEditInfo(String filename, int renderingMode) {
+        mRenderPreviewOverlayFile = filename;
+        mRenderPreviewRenderingMode = renderingMode;
+    }
+
+
     /**
      * This function is responsible for rendering a single frame
      * from a single media item on the surface
@@ -3551,7 +3599,6 @@
         int outBitrate = 0;
         mExportFilename = filePath;
         previewStoryBoard(mediaItemsList, mediaTransitionList, mediaBGMList,null);
-
         mExportProgressListener = listener;
 
         mProgressToApp = 0;
@@ -3678,7 +3725,6 @@
         int outBitrate = 0;
         mExportFilename = filePath;
         previewStoryBoard(mediaItemsList, mediaTransitionList, mediaBGMList,null);
-
         mExportProgressListener = listener;
 
         mProgressToApp = 0;
@@ -4003,6 +4049,7 @@
     public void clearPreviewSurface(Surface surface) {
        nativeClearSurface(surface);
     }
+
     /**     Native Methods        */
     native Properties getMediaProperties(String file) throws IllegalArgumentException,
     IllegalStateException, RuntimeException, Exception;
diff --git a/media/java/android/media/videoeditor/Transition.java b/media/java/android/media/videoeditor/Transition.java
index feec284..4d1bafb 100755
--- a/media/java/android/media/videoeditor/Transition.java
+++ b/media/java/android/media/videoeditor/Transition.java
@@ -332,8 +332,6 @@
         List<EffectSettings> effectSettings_clip2;
 
         String output = null;
-        String effectClip1 = null;
-        String effectClip2 = null;
 
         if (mNativeHelper == null) {
             if (m1 != null)
diff --git a/media/java/android/media/videoeditor/VideoEditor.java b/media/java/android/media/videoeditor/VideoEditor.java
index f1ad921..9006613 100755
--- a/media/java/android/media/videoeditor/VideoEditor.java
+++ b/media/java/android/media/videoeditor/VideoEditor.java
@@ -20,7 +20,10 @@
 import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.CancellationException;
-
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Canvas;
+import android.graphics.Rect;
 import android.view.SurfaceHolder;
 
 /**
@@ -78,9 +81,26 @@
          * @param videoEditor The VideoEditor instance
          * @param timeMs The current preview position (expressed in milliseconds
          *        since the beginning of the storyboard timeline).
-         * @param end true if the end of the timeline was reached
+         * @param overlayData The overlay data (null if the overlay data
+         *      is unchanged)
          */
-        public void onProgress(VideoEditor videoEditor, long timeMs, boolean end);
+        public void onProgress(VideoEditor videoEditor, long timeMs,
+                               OverlayData overlayData);
+        /**
+         * This method notifies the listener when the preview is started
+         * previewing a project.
+         *
+         * @param videoEditor The VideoEditor instance
+         */
+        public void onStart(VideoEditor videoEditor);
+
+        /**
+         * This method notifies the listener when the preview is stopped
+         * previewing a project.
+         *
+         * @param videoEditor The VideoEditor instance
+         */
+        public void onStop(VideoEditor videoEditor);
     }
 
     /**
@@ -126,6 +146,158 @@
     }
 
     /**
+     * The overlay data
+     */
+    public static final class OverlayData {
+        // Instance variables
+        private Bitmap mOverlayBitmap;
+        private int mRenderingMode;
+        private boolean mClear;
+
+        /**
+         * Default constructor
+         */
+        public OverlayData() {
+            mOverlayBitmap = null;
+            mRenderingMode = MediaArtistNativeHelper.MediaRendering.BLACK_BORDERS;
+            mClear = false;
+        }
+
+        /**
+         * Releases the bitmap
+         */
+        public void release() {
+            if (mOverlayBitmap != null) {
+                mOverlayBitmap.recycle();
+                mOverlayBitmap = null;
+            }
+        }
+
+        /**
+         * Check if the overlay needs to be rendered
+         *
+         * @return true if rendering is needed
+         */
+        public boolean needsRendering() {
+            return (mClear || mOverlayBitmap != null);
+        }
+
+        /**
+         * Store the overlay data
+         *
+         * @param overlayBitmap The overlay bitmap
+         * @param renderingMode The rendering mode
+         */
+        void set(Bitmap overlayBitmap, int renderingMode) {
+            mOverlayBitmap = overlayBitmap;
+            mRenderingMode = renderingMode;
+            mClear = false;
+        }
+
+        /**
+         * Clear the overlay
+         */
+        void setClear() {
+            mClear = true;
+        }
+
+        /**
+        * Render the overlay by either clearing it or by
+        * rendering the overlay bitmap with the specified
+        * rendering mode
+        *
+        * @param destBitmap The destination bitmap
+        */
+        public void renderOverlay(Bitmap destBitmap) {
+            if (mClear) {
+                destBitmap.eraseColor(Color.TRANSPARENT);
+            } else if (mOverlayBitmap != null) {
+                final Canvas overlayCanvas = new Canvas(destBitmap);
+                final Rect destRect;
+                final Rect srcRect;
+                switch (mRenderingMode) {
+                    case MediaArtistNativeHelper.MediaRendering.RESIZING: {
+                        destRect = new Rect(0, 0, overlayCanvas.getWidth(),
+                                                 overlayCanvas.getHeight());
+                        srcRect = new Rect(0, 0, mOverlayBitmap.getWidth(),
+                                                 mOverlayBitmap.getHeight());
+                        break;
+                    }
+
+                    case MediaArtistNativeHelper.MediaRendering.BLACK_BORDERS: {
+                        int left, right, top, bottom;
+                        float aROverlayImage, aRCanvas;
+                        aROverlayImage = (float)(mOverlayBitmap.getWidth()) /
+                                         (float)(mOverlayBitmap.getHeight());
+
+                        aRCanvas = (float)(overlayCanvas.getWidth()) /
+                                         (float)(overlayCanvas.getHeight());
+
+                        if (aROverlayImage > aRCanvas) {
+                            int newHeight = ((overlayCanvas.getWidth() * mOverlayBitmap.getHeight())
+                                             / mOverlayBitmap.getWidth());
+                            left = 0;
+                            top  = (overlayCanvas.getHeight() - newHeight) / 2;
+                            right = overlayCanvas.getWidth();
+                            bottom = top + newHeight;
+                        } else {
+                            int newWidth = ((overlayCanvas.getHeight() * mOverlayBitmap.getWidth())
+                                                / mOverlayBitmap.getHeight());
+                            left = (overlayCanvas.getWidth() - newWidth) / 2;
+                            top  = 0;
+                            right = left + newWidth;
+                            bottom = overlayCanvas.getHeight();
+                        }
+
+                        destRect = new Rect(left, top, right, bottom);
+                        srcRect = new Rect(0, 0, mOverlayBitmap.getWidth(), mOverlayBitmap.getHeight());
+                        break;
+                    }
+
+                    case MediaArtistNativeHelper.MediaRendering.CROPPING: {
+                        // Calculate the source rect
+                        int left, right, top, bottom;
+                        float aROverlayImage, aRCanvas;
+                        aROverlayImage = (float)(mOverlayBitmap.getWidth()) /
+                                         (float)(mOverlayBitmap.getHeight());
+                        aRCanvas = (float)(overlayCanvas.getWidth()) /
+                                        (float)(overlayCanvas.getHeight());
+                        if (aROverlayImage < aRCanvas) {
+                            int newHeight = ((mOverlayBitmap.getWidth() * overlayCanvas.getHeight())
+                                       / overlayCanvas.getWidth());
+
+                            left = 0;
+                            top  = (mOverlayBitmap.getHeight() - newHeight) / 2;
+                            right = mOverlayBitmap.getWidth();
+                            bottom = top + newHeight;
+                        } else {
+                            int newWidth = ((mOverlayBitmap.getHeight() * overlayCanvas.getWidth())
+                                        / overlayCanvas.getHeight());
+                            left = (mOverlayBitmap.getWidth() - newWidth) / 2;
+                            top  = 0;
+                            right = left + newWidth;
+                            bottom = mOverlayBitmap.getHeight();
+                        }
+
+                        srcRect = new Rect(left, top, right, bottom);
+                        destRect = new Rect(0, 0, overlayCanvas.getWidth(), overlayCanvas.getHeight());
+                        break;
+                    }
+
+                    default: {
+                        throw new IllegalStateException("Rendering mode: " + mRenderingMode);
+                    }
+                }
+
+                destBitmap.eraseColor(Color.TRANSPARENT);
+                overlayCanvas.drawBitmap(mOverlayBitmap, srcRect, destRect, null);
+
+                mOverlayBitmap.recycle();
+            }
+        }
+    }
+
+    /**
      * @return The path where the VideoEditor stores all files related to the
      *         project
      */
@@ -518,6 +690,7 @@
      *
      * @param surfaceHolder SurfaceHolder used by the application
      * @param timeMs time corresponding to the frame to display
+     * @param overlayData The overlay data
      *
      * @return The accurate time stamp of the frame that is rendered.
      *
@@ -526,7 +699,8 @@
      * @throws IllegalArgumentException if time is negative or beyond the
      *        preview duration
      */
-    public long renderPreviewFrame(SurfaceHolder surfaceHolder, long timeMs);
+    public long renderPreviewFrame(SurfaceHolder surfaceHolder, long timeMs,
+            OverlayData overlayData);
 
     /**
      * This method must be called after any changes made to the storyboard
@@ -535,7 +709,6 @@
      */
     public void generatePreview(MediaProcessingProgressListener listener);
 
-
     /**
      * Start the preview of all the storyboard items applied on all MediaItems
      * This method does not block (does not wait for the preview to complete).
@@ -580,5 +753,4 @@
      * and needs to be cleared.
      */
     public void clearSurface(SurfaceHolder surfaceHolder);
-
 }
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index 672ce19..d2dfe82bf 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -899,7 +899,8 @@
     /*
      * {@inheritDoc}
      */
-    public long renderPreviewFrame(SurfaceHolder surfaceHolder, long timeMs) {
+    public long renderPreviewFrame(SurfaceHolder surfaceHolder, long timeMs,
+                                    OverlayData overlayData) {
         long result = 0;
         int surfaceWidth = 0;
         int surfaceHeight = 0;
@@ -939,7 +940,7 @@
             if (!mMANativeHelper.mInvalidatePreviewArray) {
                 if (mMediaItems.size() > 0) {
                     result = mMANativeHelper.renderPreviewFrame(surface,
-                                             timeMs,surfaceWidth,surfaceHeight);
+                                             timeMs,surfaceWidth,surfaceHeight, overlayData);
                 }
                 else {
                     result = 0;
@@ -1643,7 +1644,7 @@
                     mMANativeHelper.previewStoryBoard(mMediaItems, mTransitions,
                                                       mAudioTracks, null);
                     mMANativeHelper.doPreview(mSurface, fromMs, toMs, loop,
-                                             callbackAfterFrameCount, listener);
+                                     callbackAfterFrameCount, listener);
                     mPreviewInProgress = true;
                 } catch (IllegalArgumentException ex) {
                     mPreviewSemaphore.release();
@@ -1683,7 +1684,7 @@
         }
     }
 
-    /**
+    /*
      * Remove transitions associated with the specified media item
      *
      * @param mediaItem The media item
diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp
index 52e032a..369faa9 100755
--- a/media/jni/mediaeditor/VideoEditorClasses.cpp
+++ b/media/jni/mediaeditor/VideoEditorClasses.cpp
@@ -2481,7 +2481,7 @@
 
             pSettings->xVSS.width = pSettings->xVSS.pFramingBuffer->u_width;
             pSettings->xVSS.height = pSettings->xVSS.pFramingBuffer->u_height;
-            pSettings->xVSS.rgbType = M4VSS3GPP_kRGB888;
+            pSettings->xVSS.rgbType = M4VSS3GPP_kRGB565;
 
             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
                     "pFramingBuffer u_width %d ", pSettings->xVSS.pFramingBuffer->u_width);
diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp
index 8ce788b..4149bc9 100755
--- a/media/jni/mediaeditor/VideoEditorMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorMain.cpp
@@ -86,6 +86,7 @@
     jmethodID                      onWarningMethodId;
     jmethodID                      onProgressUpdateMethodId;
     jmethodID                      onPreviewProgressUpdateMethodId;
+    jmethodID                      previewFrameEditInfoId;
     M4xVSS_InitParams              initParams;
     void*                          pTextRendererHandle;
     M4xVSS_getTextRgbBufferFct     pTextRendererFunction;
@@ -102,6 +103,9 @@
     M4OSA_Bool                      bSkipState;
     jmethodID                       onAudioGraphProgressUpdateMethodId;
     Mutex                           mLock;
+    bool                            mIsUpdateOverlay;
+    char                            *mOverlayFileName;
+    int                             mOverlayRenderingMode;
 } ManualEditContext;
 
 extern "C" M4OSA_ERR M4MCS_open_normalMode(
@@ -224,7 +228,7 @@
                 JNIEnv*                             pEnv);
 
 static void jniPreviewProgressCallback(void* cookie, M4OSA_UInt32 msgType,
-                                        M4OSA_UInt32 argc);
+                                        void *argc);
 
 static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
                                                     jobject thiz,
@@ -374,35 +378,105 @@
 }
 
 static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,
-                                        M4OSA_UInt32 argc)
+                                        void *argc)
 {
     ManualEditContext *pContext = (ManualEditContext *)cookie;
     JNIEnv*     pEnv = NULL;
     bool        isFinished = false;
     int         currentMs = 0;
     int         error = M4NO_ERROR;
+    bool        isUpdateOverlay = false;
+    int         overlayEffectIndex;
+    char        *extPos;
+    bool        isSendProgress = true;
+    jstring     tmpFileName;
+    VideoEditorCurretEditInfo *pCurrEditInfo;
 
     // Attach the current thread.
     pContext->pVM->AttachCurrentThread(&pEnv, NULL);
     switch(msgType)
     {
         case MSG_TYPE_PROGRESS_INDICATION:
-            currentMs = argc;
+            currentMs = *(int*)argc;
             break;
         case MSG_TYPE_PLAYER_ERROR:
             currentMs = -1;
-            error = argc;
+            error = *(int*)argc;
             break;
         case MSG_TYPE_PREVIEW_END:
             isFinished = true;
             break;
+        case MSG_TYPE_OVERLAY_UPDATE:
+        {
+            int overlayFileNameLen = 0;
+            isSendProgress = false;
+            pContext->mIsUpdateOverlay = true;
+            pCurrEditInfo = (VideoEditorCurretEditInfo*)argc;
+            overlayEffectIndex = pCurrEditInfo->overlaySettingsIndex;
+            LOGV("MSG_TYPE_OVERLAY_UPDATE");
+
+            if (pContext->mOverlayFileName != NULL) {
+                M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+                pContext->mOverlayFileName = NULL;
+            }
+
+            overlayFileNameLen =
+                strlen((const char*)pContext->pEditSettings->Effects[overlayEffectIndex].xVSS.pFramingFilePath);
+
+            pContext->mOverlayFileName =
+                (char*)M4OSA_malloc(overlayFileNameLen+1,
+                                    M4VS, (M4OSA_Char*)"videoEdito JNI overlayFile");
+            if (pContext->mOverlayFileName != NULL) {
+                strncpy (pContext->mOverlayFileName,
+                    (const char*)pContext->pEditSettings->\
+                    Effects[overlayEffectIndex].xVSS.pFramingFilePath, overlayFileNameLen);
+                //Change the name to png file
+                extPos = strstr(pContext->mOverlayFileName, ".rgb");
+                if (extPos != NULL) {
+                    *extPos = '\0';
+                } else {
+                    LOGE("ERROR the overlay file is incorrect");
+                }
+
+                strcat(pContext->mOverlayFileName, ".png");
+                LOGV("Conv string is %s", pContext->mOverlayFileName);
+                LOGV("Current Clip index = %d", pCurrEditInfo->clipIndex);
+
+                pContext->mOverlayRenderingMode = pContext->pEditSettings->\
+                         pClipList[pCurrEditInfo->clipIndex]->xVSS.MediaRendering;
+                LOGI("rendering mode %d ", pContext->mOverlayRenderingMode);
+
+            }
+
+            break;
+        }
+
+        case MSG_TYPE_OVERLAY_CLEAR:
+            isSendProgress = false;
+            pContext->mOverlayFileName = NULL;
+            LOGI("MSG_TYPE_OVERLAY_CLEAR");
+            //argc is not used
+            pContext->mIsUpdateOverlay = true;
+            break;
         default:
             break;
     }
 
-    pEnv->CallVoidMethod(pContext->engine,
-                        pContext->onPreviewProgressUpdateMethodId,
-                        currentMs,isFinished);
+    if (isSendProgress) {
+        tmpFileName  = pEnv->NewStringUTF(pContext->mOverlayFileName);
+        pEnv->CallVoidMethod(pContext->engine,
+                pContext->onPreviewProgressUpdateMethodId,
+                currentMs,isFinished, pContext->mIsUpdateOverlay,
+                tmpFileName, pContext->mOverlayRenderingMode);
+
+        if (pContext->mIsUpdateOverlay) {
+            pContext->mIsUpdateOverlay = false;
+        }
+
+        if (tmpFileName) {
+            pEnv->DeleteLocalRef(tmpFileName);
+        }
+    }
 
     // Detach the current thread.
     pContext->pVM->DetachCurrentThread();
@@ -422,6 +496,11 @@
                                              (M4OSA_NULL == pContext),
                                              "not initialized");
     pContext->mPreviewController->stopPreview();
+
+    if (pContext->mOverlayFileName != NULL) {
+        M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+        pContext->mOverlayFileName = NULL;
+    }
 }
 
 static void videoEditor_clearSurface(JNIEnv* pEnv,
@@ -507,6 +586,7 @@
     M4OSA_Context tnContext = M4OSA_NULL;
     const char* pMessage = NULL;
     M4VIFI_ImagePlane *yuvPlane = NULL;
+    VideoEditorCurretEditInfo  currEditInfo;
 
     VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO,
         "VIDEO_EDITOR", "surfaceWidth = %d",surfaceWidth);
@@ -770,9 +850,36 @@
         pContext->pEditSettings->\
         pClipList[iCurrentClipIndex]->xVSS.MediaRendering,
         pContext->pEditSettings->xVSS.outputVideoSize);
-
     result = pContext->mPreviewController->renderPreviewFrame(previewSurface,
-                                                              &frameStr);
+                                                              &frameStr, &currEditInfo);
+
+    if (currEditInfo.overlaySettingsIndex != -1) {
+        char tmpOverlayFilename[100];
+        char *extPos = NULL;
+        jstring tmpOverlayString;
+        int tmpRenderingMode = 0;
+
+        strncpy (tmpOverlayFilename,
+                (const char*)pContext->pEditSettings->Effects[currEditInfo.overlaySettingsIndex].xVSS.pFramingFilePath, 99);
+
+        //Change the name to png file
+        extPos = strstr(tmpOverlayFilename, ".rgb");
+        if (extPos != NULL) {
+            *extPos = '\0';
+        } else {
+            LOGE("ERROR the overlay file is incorrect");
+        }
+
+        strcat(tmpOverlayFilename, ".png");
+
+        tmpRenderingMode = pContext->pEditSettings->pClipList[iCurrentClipIndex]->xVSS.MediaRendering;
+        tmpOverlayString = pEnv->NewStringUTF(tmpOverlayFilename);
+        pEnv->CallVoidMethod(pContext->engine,
+            pContext->previewFrameEditInfoId,
+            tmpOverlayString, tmpRenderingMode);
+
+    }
+
     videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
             (M4NO_ERROR != result), result);
 
@@ -937,7 +1044,7 @@
     /*  pContext->mPreviewController->setPreviewFrameRenderingMode(M4xVSS_kBlackBorders,
     (M4VIDEOEDITING_VideoFrameSize)(M4VIDEOEDITING_kHD960+1));*/
     result
-    = pContext->mPreviewController->renderPreviewFrame(previewSurface,&frameStr);
+    = pContext->mPreviewController->renderPreviewFrame(previewSurface,&frameStr, NULL);
     videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
                                                 (M4NO_ERROR != result), result);
 
@@ -1325,7 +1432,7 @@
                                      "not initialized");
 
     pContext->onPreviewProgressUpdateMethodId = pEnv->GetMethodID(engineClass,
-            "onPreviewProgressUpdate",     "(IZ)V");
+            "onPreviewProgressUpdate",     "(IZZLjava/lang/String;I)V");
     // Check if the context is valid (required because the context is dereferenced).
     if (needToBeLoaded) {
         // Make sure that we are in a correct state.
@@ -1342,6 +1449,9 @@
     }
     M4OSA_TRACE1_0("videoEditorC_getEditSettings done");
 
+    pContext->previewFrameEditInfoId = pEnv->GetMethodID(engineClass,
+        "previewFrameEditInfo", "(Ljava/lang/String;I)V");
+
     if ( pContext->pEditSettings != NULL )
     {
         // Check if the edit settings could be retrieved.
@@ -1440,22 +1550,22 @@
                 width = pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_width;
                 height = pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_height;
 
-                pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_stride = width*3;
+                //RGB 565
+                pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_stride = width*2;
 
-                //for RGB888
+                //for RGB565
                 pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_topleft = 0;
-
                 pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->pac_data =
-                                                    (M4VIFI_UInt8 *)M4OSA_malloc(width*height*3,
-                    0x00,(M4OSA_Char *)"pac_data buffer");
+                            (M4VIFI_UInt8 *)M4OSA_malloc(width*height*2,
+                            0x00,(M4OSA_Char *)"pac_data buffer");
 
                 M4OSA_memcpy((M4OSA_Int8 *)&pContext->pEditSettings->\
                     Effects[j].xVSS.pFramingBuffer->\
-                    pac_data[0],(M4OSA_Int8 *)&aFramingCtx->FramingRgb->pac_data[0],(width*height*3));
+                    pac_data[0],(M4OSA_Int8 *)&aFramingCtx->FramingRgb->pac_data[0],(width*height*2));
 
-                //As of now rgb type is always rgb888, can be changed in future for rgb 565
+                //As of now rgb type is 565
                 pContext->pEditSettings->Effects[j].xVSS.rgbType =
-                (M4VSS3GPP_RGBType)M4VSS3GPP_kRGB888; //M4VSS3GPP_kRGB565;
+                    (M4VSS3GPP_RGBType) M4VSS3GPP_kRGB565;
 
                 if (aFramingCtx->FramingYuv != M4OSA_NULL )
                 {
@@ -2153,6 +2263,8 @@
             M4OSA_chrNCat((M4OSA_Char*)pContext->initParams.pTempPath, tmpString, M4OSA_chrLength(tmpString));
             M4OSA_chrNCat((M4OSA_Char*)pContext->initParams.pTempPath, (M4OSA_Char*)"/", 1);
             M4OSA_free((M4OSA_MemAddr32)tmpString);
+            pContext->mIsUpdateOverlay = false;
+            pContext->mOverlayFileName = NULL;
         }
 
         // Check if the initialization succeeded
diff --git a/media/jni/mediaeditor/VideoEditorMain.h b/media/jni/mediaeditor/VideoEditorMain.h
index b73913a..ca4a945 100755
--- a/media/jni/mediaeditor/VideoEditorMain.h
+++ b/media/jni/mediaeditor/VideoEditorMain.h
@@ -21,11 +21,18 @@
 
 typedef enum
 {
-    MSG_TYPE_PROGRESS_INDICATION,             /* Playback progress indication event*/
-    MSG_TYPE_PLAYER_ERROR,                    /* Playback error*/
-    MSG_TYPE_PREVIEW_END,                     /* Preview of clips is complete */
+    MSG_TYPE_PROGRESS_INDICATION,     // Playback progress indication event
+    MSG_TYPE_PLAYER_ERROR,            // Playback error
+    MSG_TYPE_PREVIEW_END,             // Preview of clips is complete
+    MSG_TYPE_OVERLAY_UPDATE,          // update overlay during preview
+    MSG_TYPE_OVERLAY_CLEAR,           // clear the overlay
 } progress_callback_msg_type;
 
+typedef struct {
+    int overlaySettingsIndex;
+    int clipIndex;
+} VideoEditorCurretEditInfo;
+
 typedef struct
 {
     M4OSA_Void     *pFile;                   /** PCM file path */
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index 65df68c..f134cba 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -1239,6 +1239,14 @@
         encoder_flags |= OMXCodec::kHardwareCodecsOnly;
         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
     }
+
+    // Do not wait for all the input buffers to become available.
+    // This give timelapse video recording faster response in
+    // receiving output from video encoder component.
+    if (mCaptureTimeLapse) {
+        encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
+    }
+
     sp<MediaSource> encoder = OMXCodec::Create(
             client.interface(), enc_meta,
             true /* createEncoder */, cameraSource,
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index b1c6b18..66e0657 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -147,8 +147,8 @@
       mNumFramesReceived(0),
       mLastFrameTimestampUs(0),
       mStarted(false),
-      mFirstFrameTimeUs(0),
       mNumFramesEncoded(0),
+      mFirstFrameTimeUs(0),
       mNumFramesDropped(0),
       mNumGlitches(0),
       mGlitchDurationThresholdUs(200000),
diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp
index b58b9d8..e6fe618 100644
--- a/media/libstagefright/CameraSourceTimeLapse.cpp
+++ b/media/libstagefright/CameraSourceTimeLapse.cpp
@@ -491,7 +491,10 @@
             }
         }
 
-        if (*timestampUs <
+        // Workaround to bypass the first 2 input frames for skipping.
+        // The first 2 output frames from the encoder are: decoder specific info and
+        // the compressed video frame data for the first input video frame.
+        if (mNumFramesEncoded >= 1 && *timestampUs <
                 (mLastTimeLapseFrameRealTimestampUs + mTimeBetweenTimeLapseFrameCaptureUs)) {
             // Skip all frames from last encoded frame until
             // sufficient time (mTimeBetweenTimeLapseFrameCaptureUs) has passed.
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 7c6e561..2a19b25 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -522,6 +522,12 @@
     if (flags & kStoreMetaDataInVideoBuffers) {
         mIsMetaDataStoredInVideoBuffers = true;
     }
+
+    mOnlySubmitOneBufferAtOneTime = false;
+    if (flags & kOnlySubmitOneInputBufferAtOneTime) {
+        mOnlySubmitOneBufferAtOneTime = true;
+    }
+
     if (!(flags & kIgnoreCodecSpecificData)) {
         uint32_t type;
         const void *data;
@@ -2610,7 +2616,17 @@
 
     Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexInput];
     for (size_t i = 0; i < buffers->size(); ++i) {
-        if (!drainInputBuffer(&buffers->editItemAt(i))) {
+        BufferInfo *info = &buffers->editItemAt(i);
+
+        if (info->mStatus != OWNED_BY_US) {
+            continue;
+        }
+
+        if (!drainInputBuffer(info)) {
+            break;
+        }
+
+        if (mOnlySubmitOneBufferAtOneTime) {
             break;
         }
     }
diff --git a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
index bbde516..8bfe285 100644
--- a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
+++ b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
@@ -359,7 +359,10 @@
         }
     }
 
-    CHECK_EQ(offset, buffer->size());
+    if (offset < buffer->size()) {
+        LOGI("ignoring %d bytes of trailing data", buffer->size() - offset);
+    }
+    CHECK_LE(offset, buffer->size());
 
     return out;
 }
diff --git a/media/mtp/MtpUtils.cpp b/media/mtp/MtpUtils.cpp
index ab01ef5..6ec8876 100644
--- a/media/mtp/MtpUtils.cpp
+++ b/media/mtp/MtpUtils.cpp
@@ -55,7 +55,7 @@
     tm.tm_min = minute;
     tm.tm_hour = hour;
     tm.tm_mday = day;
-    tm.tm_mon = month;
+    tm.tm_mon = month - 1;  // mktime uses months in 0 - 11 range
     tm.tm_year = year - 1900;
     tm.tm_wday = 0;
     tm.tm_isdst = -1;
@@ -72,7 +72,9 @@
 
     localtime_r(&seconds, &tm);
     snprintf(buffer, bufferLength, "%04d%02d%02dT%02d%02d%02d",
-        tm.tm_year + 1900, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+        tm.tm_year + 1900, 
+        tm.tm_mon + 1, // localtime_r uses months in 0 - 11 range
+        tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
 }
 
 }  // namespace android
diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_ticker_tile.png b/packages/SystemUI/res/drawable-mdpi/status_bar_ticker_tile.png
new file mode 100644
index 0000000..85394fa
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/status_bar_ticker_tile.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_1x.png
new file mode 100644
index 0000000..8e039ce
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_3g.png
new file mode 100644
index 0000000..0cb0a08
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_4g.png
new file mode 100644
index 0000000..c3cd10b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_e.png
new file mode 100644
index 0000000..650f67b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_g.png
new file mode 100644
index 0000000..f5b1618
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_h.png
new file mode 100644
index 0000000..eddc487
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_1x.png
new file mode 100644
index 0000000..39dfcd3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_3g.png
new file mode 100644
index 0000000..e78d872
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_4g.png
new file mode 100644
index 0000000..5f88279
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_e.png
new file mode 100644
index 0000000..ad73252
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_g.png
new file mode 100644
index 0000000..d02de5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_h.png
new file mode 100644
index 0000000..cb13b91
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_in_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_1x.png
new file mode 100644
index 0000000..39dfcd3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_3g.png
new file mode 100644
index 0000000..e78d872
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_4g.png
new file mode 100644
index 0000000..8c04bd61
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_e.png
new file mode 100644
index 0000000..ad73252
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_g.png
new file mode 100644
index 0000000..d02de5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_h.png
new file mode 100644
index 0000000..cb13b91
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_inandout_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_1x.png
new file mode 100644
index 0000000..39dfcd3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_3g.png
new file mode 100644
index 0000000..e78d872
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_4g.png
new file mode 100644
index 0000000..456d0b6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_e.png
new file mode 100644
index 0000000..ad73252
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_g.png
new file mode 100644
index 0000000..d02de5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_h.png
new file mode 100644
index 0000000..cb13b91
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_out_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_roam.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_roam.png
new file mode 100644
index 0000000..1eb0142
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_connected_roam.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_1x.png
new file mode 100644
index 0000000..4c8e7c3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_3g.png
new file mode 100644
index 0000000..657dc04
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_4g.png
new file mode 100644
index 0000000..359e8f8
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_e.png
new file mode 100644
index 0000000..e5b0841
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_g.png
new file mode 100644
index 0000000..4fe8df3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_h.png
new file mode 100644
index 0000000..a7a7beac
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_1x.png
new file mode 100644
index 0000000..39dfcd3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_3g.png
new file mode 100644
index 0000000..e78d872
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_4g.png
new file mode 100644
index 0000000..456d0b6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_e.png
new file mode 100644
index 0000000..ad73252
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_g.png
new file mode 100644
index 0000000..d02de5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_h.png
new file mode 100644
index 0000000..cb13b91
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_in_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_1x.png
new file mode 100644
index 0000000..39dfcd3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_3g.png
new file mode 100644
index 0000000..e78d872
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_4g.png
new file mode 100644
index 0000000..456d0b6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_e.png
new file mode 100644
index 0000000..ad73252
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_g.png
new file mode 100644
index 0000000..d02de5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_h.png
new file mode 100644
index 0000000..cb13b91
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_inandout_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_1x.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_1x.png
new file mode 100644
index 0000000..39dfcd3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_3g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_3g.png
new file mode 100644
index 0000000..e78d872
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_4g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_4g.png
new file mode 100644
index 0000000..456d0b6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_e.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_e.png
new file mode 100644
index 0000000..ad73252
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_g.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_g.png
new file mode 100644
index 0000000..d02de5b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_h.png b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_h.png
new file mode 100644
index 0000000..cb13b91
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-hdpi/stat_sys_data_fully_out_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_1x.png
new file mode 100644
index 0000000..2cbec7b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_3g.png
new file mode 100644
index 0000000..0efb9c9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_4g.png
new file mode 100644
index 0000000..2eae1e1
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_e.png
new file mode 100644
index 0000000..7e82c4c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_g.png
new file mode 100644
index 0000000..d37f1e5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_h.png
new file mode 100644
index 0000000..5f7349e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_1x.png
new file mode 100644
index 0000000..f50c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_3g.png
new file mode 100644
index 0000000..1fff17e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_4g.png
new file mode 100644
index 0000000..821d00e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_e.png
new file mode 100644
index 0000000..e27439e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_g.png
new file mode 100644
index 0000000..8b53f0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_h.png
new file mode 100644
index 0000000..a23ec6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_in_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_1x.png
new file mode 100644
index 0000000..f50c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_3g.png
new file mode 100644
index 0000000..1fff17e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_4g.png
new file mode 100644
index 0000000..4cdce84
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_e.png
new file mode 100644
index 0000000..e27439e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_g.png
new file mode 100644
index 0000000..8b53f0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_h.png
new file mode 100644
index 0000000..a23ec6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_inandout_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_1x.png
new file mode 100644
index 0000000..f50c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_3g.png
new file mode 100644
index 0000000..1fff17e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_4g.png
new file mode 100644
index 0000000..5a2662a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_e.png
new file mode 100644
index 0000000..e27439e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_g.png
new file mode 100644
index 0000000..8b53f0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_h.png
new file mode 100644
index 0000000..a23ec6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_out_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_roam.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_roam.png
new file mode 100644
index 0000000..31358ec
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_connected_roam.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_1x.png
new file mode 100644
index 0000000..e5a3484
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_3g.png
new file mode 100644
index 0000000..2a3a5dc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_4g.png
new file mode 100644
index 0000000..5dbd1ab
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_e.png
new file mode 100644
index 0000000..51d1f76
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_g.png
new file mode 100644
index 0000000..10d81ca
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_h.png
new file mode 100644
index 0000000..1d9bda0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_1x.png
new file mode 100644
index 0000000..f50c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_3g.png
new file mode 100644
index 0000000..1fff17e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_4g.png
new file mode 100644
index 0000000..5a2662a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_e.png
new file mode 100644
index 0000000..e27439e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_g.png
new file mode 100644
index 0000000..8b53f0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_h.png
new file mode 100644
index 0000000..a23ec6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_in_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_1x.png
new file mode 100644
index 0000000..f50c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_3g.png
new file mode 100644
index 0000000..1fff17e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_4g.png
new file mode 100644
index 0000000..5a2662a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_e.png
new file mode 100644
index 0000000..e27439e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_g.png
new file mode 100644
index 0000000..8b53f0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_h.png
new file mode 100644
index 0000000..a23ec6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_inandout_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_1x.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_1x.png
new file mode 100644
index 0000000..f50c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_3g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_3g.png
new file mode 100644
index 0000000..1fff17e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_4g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_4g.png
new file mode 100644
index 0000000..5a2662a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_e.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_e.png
new file mode 100644
index 0000000..e27439e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_g.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_g.png
new file mode 100644
index 0000000..8b53f0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_h.png b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_h.png
new file mode 100644
index 0000000..a23ec6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/stat_sys_data_fully_out_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/status_bar_ticker_background.xml b/packages/SystemUI/res/drawable/status_bar_ticker_background.xml
index c230358..83524a6 100644
--- a/packages/SystemUI/res/drawable/status_bar_ticker_background.xml
+++ b/packages/SystemUI/res/drawable/status_bar_ticker_background.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2011 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,14 +14,8 @@
      limitations under the License.
 -->
 
-<layer-list
+<bitmap
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:opacity="translucent"
-    >
-    <item
-        android:drawable="@drawable/ticker_background_color"
-        android:top="12dp"
-        />
-</layer-list>
-
-
+    android:tileMode="repeat"
+    android:src="@drawable/status_bar_ticker_tile"
+    />
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml
index a1216aa..ecd2b6f 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml
@@ -30,7 +30,7 @@
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_alignParentBottom="true"
-        android:paddingBottom="48dip"
+        android:paddingBottom="@*android:dimen/status_bar_height"
         android:clipToPadding="false">
 
         <LinearLayout android:id="@+id/recents_glow"
@@ -52,4 +52,20 @@
 
     </FrameLayout>
 
+    <!-- The outer FrameLayout is just used as an opaque background for the dismiss icon -->
+    <FrameLayout
+        android:layout_width="80px"
+        android:layout_height="@*android:dimen/status_bar_height"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentLeft="true"
+        android:background="#ff000000">
+
+        <View android:id="@+id/recents_dismiss_button"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@drawable/ic_sysbar_back_ime"
+        />
+
+    </FrameLayout>
+
 </com.android.systemui.statusbar.tablet.RecentAppsPanel>
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_ticker_compat.xml b/packages/SystemUI/res/layout-xlarge/status_bar_ticker_compat.xml
index 6de7697..d963de1 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_ticker_compat.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_ticker_compat.xml
@@ -18,9 +18,9 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="@*android:dimen/status_bar_height"
+    android:layout_height="match_parent"
     android:orientation="horizontal"
-    android:background="@drawable/status_bar_ticker_background"
+    android:gravity="bottom"
     >
 
     <ImageView
@@ -30,29 +30,38 @@
         android:scaleType="center"
         android:visibility="gone"
         />
-    
-    <ImageView android:id="@+id/left_icon"
-        android:layout_width="64dp"
-        android:layout_height="match_parent"
-        android:scaleType="center"
-        android:visibility="gone"
-        />
 
-    <TextView android:id="@+id/text"
-        android:textAppearance="@*android:style/TextAppearance.StatusBar.Ticker"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center_vertical"
-        android:layout_marginLeft="12dp"
-        android:gravity="center_vertical"
-        android:maxLines="2"
-        />
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="@*android:dimen/status_bar_height"
+        android:layout_weight="1"
+        android:background="@drawable/status_bar_ticker_background"
+        >
+        
+        <ImageView android:id="@+id/left_icon"
+            android:layout_width="64dp"
+            android:layout_height="match_parent"
+            android:scaleType="center"
+            android:visibility="gone"
+            />
 
-    <ImageView android:id="@+id/right_icon"
-        android:layout_width="64dp"
-        android:layout_height="match_parent"
-        android:scaleType="center"
-        android:visibility="gone"
-        />
+        <TextView android:id="@+id/text"
+            android:textAppearance="@*android:style/TextAppearance.StatusBar.Ticker"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center_vertical"
+            android:layout_marginLeft="12dp"
+            android:gravity="center_vertical"
+            android:maxLines="2"
+            />
+
+        <ImageView android:id="@+id/right_icon"
+            android:layout_width="64dp"
+            android:layout_height="match_parent"
+            android:scaleType="center"
+            android:visibility="gone"
+            />
+
+    </LinearLayout>
 
 </LinearLayout>
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_ticker_panel.xml b/packages/SystemUI/res/layout-xlarge/status_bar_ticker_panel.xml
index d570ace..6cd8899 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_ticker_panel.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_ticker_panel.xml
@@ -18,14 +18,10 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     android:orientation="horizontal"
-    android:background="@drawable/status_bar_ticker_background"
     android:gravity="bottom"
     >
-    <!--
-    android:background="@drawable/ticker_background"
-    -->
 
     <ImageView
         android:id="@+id/large_icon"
@@ -34,6 +30,12 @@
         android:scaleType="center"
         android:visibility="gone"
         />
-        <!-- TODO: scaleType should be top-left but ImageView doesn't support that. -->
 
+    <FrameLayout
+        android:id="@+id/ticker_expanded"
+        android:layout_weight="1"
+        android:layout_height="@*android:dimen/status_bar_height"
+        android:layout_width="match_parent"
+        android:background="@drawable/status_bar_ticker_background"
+        />
 </LinearLayout>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
index a5e2fda..86c3e75 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
@@ -70,6 +70,7 @@
     private Bitmap mGlowBitmap;
     private boolean mShowing;
     private Choreographer mChoreo;
+    private View mRecentsDismissButton;
 
     static class ActivityDescription {
         int id;
@@ -272,6 +273,12 @@
         mRecentsGlowView = findViewById(R.id.recents_glow);
         mRecentsScrim = (View) findViewById(R.id.recents_bg_protect);
         mChoreo = new Choreographer(this, mRecentsScrim, mRecentsGlowView);
+        mRecentsDismissButton = findViewById(R.id.recents_dismiss_button);
+        mRecentsDismissButton.setOnClickListener(new OnClickListener() {
+            public void onClick(View v) {
+                hide(true);
+            }
+        });
 
         // In order to save space, we make the background texture repeat in the Y direction
         if (mRecentsScrim != null && mRecentsScrim.getBackground() instanceof BitmapDrawable) {
@@ -399,8 +406,7 @@
         } else {
             // Immediately hide this panel
             mShowing = false;
-            setVisibility(View.GONE);
-            // mBar.animateCollapse();
+            hide(false);
         }
     }
 
@@ -445,8 +451,8 @@
             appIcon.setImageDrawable(activityDescription.icon);
             appLabel.setText(activityDescription.label);
             appDesc.setText(activityDescription.description);
-            view.setOnClickListener(this);
-            view.setTag(activityDescription);
+            appThumbnail.setOnClickListener(this);
+            appThumbnail.setTag(activityDescription);
             mRecentsContainer.addView(view);
         }
 
@@ -469,7 +475,13 @@
             if (DEBUG) Log.v(TAG, "Starting activity " + intent);
             getContext().startActivity(intent);
         }
+        hide(true);
+    }
+
+    private void hide(boolean animate) {
         setVisibility(View.GONE);
-        mBar.animateCollapse();
+        if (animate) {
+            mBar.animateCollapse();
+        }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
index 440d680..5184462 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
@@ -38,7 +38,7 @@
 import android.view.WindowManagerImpl;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
-import android.widget.LinearLayout;
+import android.widget.FrameLayout;
 import android.widget.TextView;
 
 import com.android.internal.statusbar.StatusBarIcon;
@@ -173,6 +173,7 @@
                     mWindow = makeWindow();
                     WindowManagerImpl.getDefault().addView(mWindow, mWindow.getLayoutParams());
                 }
+
                 mWindow.addView(mCurrentView);
                 sendEmptyMessageDelayed(MSG_ADVANCE, ADVANCE_DELAY);
                 break;
@@ -259,10 +260,11 @@
         }
         if (n.tickerView != null) {
             group = (ViewGroup)inflater.inflate(R.layout.status_bar_ticker_panel, null, false);
+            ViewGroup content = (FrameLayout) group.findViewById(R.id.ticker_expanded);
             View expanded = null;
             Exception exception = null;
             try {
-                expanded = n.tickerView.apply(mContext, group);
+                expanded = n.tickerView.apply(mContext, content);
             }
             catch (RuntimeException e) {
                 exception = e;
@@ -273,12 +275,10 @@
                 Slog.e(TAG, "couldn't inflate view for notification " + ident, exception);
                 return null;
             }
-            final int statusBarHeight = mContext.getResources().getDimensionPixelSize(
-                    com.android.internal.R.dimen.status_bar_height);
-            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
-                    ViewGroup.LayoutParams.WRAP_CONTENT, statusBarHeight, 1.0f);
-            lp.gravity = Gravity.BOTTOM;
-            group.addView(expanded, lp);
+            FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
+                    ViewGroup.LayoutParams.MATCH_PARENT, 
+                    ViewGroup.LayoutParams.MATCH_PARENT);
+            content.addView(expanded, lp);
         } else if (n.tickerText != null) {
             group = (ViewGroup)inflater.inflate(R.layout.status_bar_ticker_compat, mWindow, false);
             final Drawable icon = StatusBarIconView.getIcon(mContext,
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index 59a540b..ad25657 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -22,6 +22,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -62,6 +63,7 @@
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.util.Pair;
 import android.util.Slog;
 import android.util.TypedValue;
@@ -121,18 +123,15 @@
      * globally and may lead us to leak AppWidgetService instances (if there were more than one).
      */
     static class ServiceConnectionProxy implements ServiceConnection {
-        private final AppWidgetService mAppWidgetService;
         private final Pair<Integer, Intent.FilterComparison> mKey;
         private final IBinder mConnectionCb;
 
-        ServiceConnectionProxy(AppWidgetService appWidgetService,
-                Pair<Integer, Intent.FilterComparison> key, IBinder connectionCb) {
-            mAppWidgetService = appWidgetService;
+        ServiceConnectionProxy(Pair<Integer, Intent.FilterComparison> key, IBinder connectionCb) {
             mKey = key;
             mConnectionCb = connectionCb;
         }
         public void onServiceConnected(ComponentName name, IBinder service) {
-            IRemoteViewsAdapterConnection cb =
+            final IRemoteViewsAdapterConnection cb =
                 IRemoteViewsAdapterConnection.Stub.asInterface(mConnectionCb);
             try {
                 cb.onServiceConnected(service);
@@ -141,19 +140,13 @@
             }
         }
         public void onServiceDisconnected(ComponentName name) {
-            IRemoteViewsAdapterConnection cb =
+            disconnect();
+        }
+        public void disconnect() {
+            final IRemoteViewsAdapterConnection cb =
                 IRemoteViewsAdapterConnection.Stub.asInterface(mConnectionCb);
             try {
                 cb.onServiceDisconnected();
-                mAppWidgetService.mServiceConnectionUpdateHandler.post(new Runnable() {
-                    public void run() {
-                        // We don't want to touch mBoundRemoteViewsServices from any other thread
-                        // so queue this to run on the main thread.
-                        if (mAppWidgetService.mBoundRemoteViewsServices.containsKey(mKey)) {
-                            mAppWidgetService.mBoundRemoteViewsServices.remove(mKey);
-                        }
-                    }
-                });
             } catch (RemoteException e) {
                 e.printStackTrace();
             }
@@ -163,7 +156,6 @@
     // Manages connections to RemoteViewsServices
     private final HashMap<Pair<Integer, FilterComparison>, ServiceConnection>
         mBoundRemoteViewsServices = new HashMap<Pair<Integer,FilterComparison>,ServiceConnection>();
-    private final Handler mServiceConnectionUpdateHandler = new Handler();
 
     Context mContext;
     Locale mLocale;
@@ -456,13 +448,24 @@
                 throw new IllegalArgumentException("Unknown component " + componentName);
             }
 
-            // Bind to the RemoteViewsService (which will trigger a callback to the
-            // RemoteViewsAdapter)
+            // If there is already a connection made for this service intent, then disconnect from
+            // that first.  (This does not allow multiple connections to the same service under
+            // the same key)
+            ServiceConnectionProxy conn = null;
             Pair<Integer, FilterComparison> key = Pair.create(appWidgetId,
                     new FilterComparison(intent));
-            final ServiceConnection conn = new ServiceConnectionProxy(this, key, connection);
+            if (mBoundRemoteViewsServices.containsKey(key)) {
+                conn = (ServiceConnectionProxy) mBoundRemoteViewsServices.get(key);
+                conn.disconnect();
+                mContext.unbindService(conn);
+                mBoundRemoteViewsServices.remove(key);
+            }
+
+            // Bind to the RemoteViewsService (which will trigger a callback to the
+            // RemoteViewsAdapter.onServiceConnected())
             final long token = Binder.clearCallingIdentity();
             try {
+                conn = new ServiceConnectionProxy(key, connection);
                 mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE);
                 mBoundRemoteViewsServices.put(key, conn);
             } finally {
@@ -473,37 +476,43 @@
 
     public void unbindRemoteViewsService(int appWidgetId, Intent intent) {
         synchronized (mAppWidgetIds) {
-            AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
-            if (id == null) {
-                throw new IllegalArgumentException("bad appWidgetId");
-            }
-
             // Unbind from the RemoteViewsService (which will trigger a callback to the bound
             // RemoteViewsAdapter)
             Pair<Integer, FilterComparison> key = Pair.create(appWidgetId,
                     new FilterComparison(intent));
             if (mBoundRemoteViewsServices.containsKey(key)) {
-                final ServiceConnection conn = mBoundRemoteViewsServices.get(key);
-                mBoundRemoteViewsServices.remove(key);
-                conn.onServiceDisconnected(null);
+                // We don't need to use the appWidgetId until after we are sure there is something
+                // to unbind.  Note that this may mask certain issues with apps calling unbind()
+                // more than necessary.
+                AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
+                if (id == null) {
+                    throw new IllegalArgumentException("bad appWidgetId");
+                }
+
+                ServiceConnectionProxy conn =
+                    (ServiceConnectionProxy) mBoundRemoteViewsServices.get(key);
+                conn.disconnect();
                 mContext.unbindService(conn);
+                mBoundRemoteViewsServices.remove(key);
+            } else {
+                Log.e("AppWidgetService", "Error (unbindRemoteViewsService): Connection not bound");
             }
         }
     }
 
     private void unbindAppWidgetRemoteViewsServicesLocked(AppWidgetId id) {
+        int appWidgetId = id.appWidgetId;
+        // Unbind all connections to Services bound to this AppWidgetId
         Iterator<Pair<Integer, Intent.FilterComparison>> it =
             mBoundRemoteViewsServices.keySet().iterator();
-        int appWidgetId = id.appWidgetId;
-
-        // Unbind all connections to AppWidgets bound to this id
         while (it.hasNext()) {
             final Pair<Integer, Intent.FilterComparison> key = it.next();
             if (key.first.intValue() == appWidgetId) {
-                final ServiceConnection conn = mBoundRemoteViewsServices.get(key);
-                it.remove();
-                conn.onServiceDisconnected(null);
+                final ServiceConnectionProxy conn = (ServiceConnectionProxy)
+                        mBoundRemoteViewsServices.get(key);
+                conn.disconnect();
                 mContext.unbindService(conn);
+                it.remove();
             }
         }
     }
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index bd3c554..e689654 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1152,7 +1152,17 @@
                 if (checkType == prevNetType) continue;
                 if (mNetAttributes[checkType] == null) continue;
                 if (!mNetAttributes[checkType].isDefault()) continue;
-                if (!mNetTrackers[checkType].isAvailable()) continue;
+
+// Enabling the isAvailable() optimization caused mobile to not get
+// selected if it was in the middle of error handling. Specifically
+// a moble connection that took 30 seconds to complete the DEACTIVATE_DATA_CALL
+// would not be available and we wouldn't get connected to anything.
+// So removing the isAvailable() optimization below for now. TODO: This
+// optimization should work and we need to investigate why it doesn't work.
+// This could be related to how DEACTIVATE_DATA_CALL is reporting its
+// complete before it is really complete.
+//                if (!mNetTrackers[checkType].isAvailable()) continue;
+
 //                if (currentPriority >= mNetAttributes[checkType].mPriority) continue;
 
                 NetworkStateTracker checkTracker = mNetTrackers[checkType];
diff --git a/services/java/com/android/server/ScreenRotationAnimation.java b/services/java/com/android/server/ScreenRotationAnimation.java
index bef64b3..90318f1 100644
--- a/services/java/com/android/server/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/ScreenRotationAnimation.java
@@ -102,7 +102,7 @@
                 Slog.w(TAG, "Unable to allocate freeze surface", e);
             }
 
-            if (false) {
+            if (true) {
                 try {
                     int size = mOriginalWidth > mOriginalHeight ? mOriginalWidth : mOriginalHeight;
                     mBlackSurface = new Surface(session, 0, "BlackSurface",
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 2c8403c..30a9432 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1918,9 +1918,10 @@
                 WindowState wb = localmWindows.get(foundI-1);
                 if (wb.mBaseLayer < maxLayer &&
                         wb.mAttachedWindow != foundW &&
-                        wb.mAttachedWindow != foundW.mAttachedWindow &&
+                        (foundW.mAttachedWindow == null ||
+                                wb.mAttachedWindow != foundW.mAttachedWindow) &&
                         (wb.mAttrs.type != TYPE_APPLICATION_STARTING ||
-                                wb.mToken != foundW.mToken)) {
+                                foundW.mToken == null || wb.mToken != foundW.mToken)) {
                     // This window is not related to the previous one in any
                     // interesting way, so stop here.
                     break;
@@ -5003,7 +5004,6 @@
         Bitmap rawss;
 
         int maxLayer = 0;
-        boolean foundApp;
         final Rect frame = new Rect();
 
         float scale;
@@ -5013,24 +5013,49 @@
         synchronized(mWindowMap) {
             long ident = Binder.clearCallingIdentity();
 
+            dw = mDisplay.getWidth();
+            dh = mDisplay.getHeight();
+
             int aboveAppLayer = mPolicy.windowTypeToLayerLw(
                     WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
                     + TYPE_LAYER_OFFSET;
             aboveAppLayer += TYPE_LAYER_MULTIPLIER;
 
+            boolean isImeTarget = mInputMethodTarget != null
+                    && mInputMethodTarget.mAppToken != null
+                    && mInputMethodTarget.mAppToken.appToken != null
+                    && mInputMethodTarget.mAppToken.appToken.asBinder() == appToken;
+
             // Figure out the part of the screen that is actually the app.
-            for (int i=0; i<mWindows.size(); i++) {
+            boolean including = false;
+            for (int i=mWindows.size()-1; i>=0; i--) {
                 WindowState ws = mWindows.get(i);
                 if (ws.mSurface == null) {
                     continue;
                 }
                 if (ws.mLayer >= aboveAppLayer) {
-                    break;
-                }
-                if (appToken != null && (ws.mAppToken == null
-                        || ws.mAppToken.token != appToken)) {
                     continue;
                 }
+                // When we will skip windows: when we are not including
+                // ones behind a window we didn't skip, and we are actually
+                // taking a screenshot of a specific app.
+                if (!including && appToken != null) {
+                    // Also, we can possibly skip this window if it is not
+                    // an IME target or the application for the screenshot
+                    // is not the current IME target.
+                    if (!ws.mIsImWindow || !isImeTarget) {
+                        // And finally, this window is of no interest if it
+                        // is not associated with the screenshot app.
+                        if (ws.mAppToken == null || ws.mAppToken.token != appToken) {
+                            continue;
+                        }
+                    }
+                }
+
+                // We keep on including windows until we go past a full-screen
+                // window.
+                including = !ws.mIsImWindow && !ws.isFullscreen(dw, dh);
+
                 if (maxLayer < ws.mAnimLayer) {
                     maxLayer = ws.mAnimLayer;
                 }
@@ -5065,8 +5090,8 @@
             }
 
             // The screen shot will contain the entire screen.
-            dw = (int)(mDisplay.getWidth()*scale);
-            dh = (int)(mDisplay.getHeight()*scale);
+            dw = (int)(dw*scale);
+            dh = (int)(dh*scale);
             if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) {
                 int tmp = dw;
                 dw = dh;
@@ -10856,17 +10881,19 @@
         mInputMonitor.updateInputWindowsLw(true /*force*/);
 
         setHoldScreenLocked(holdScreen != null);
-        if (screenBrightness < 0 || screenBrightness > 1.0f) {
-            mPowerManager.setScreenBrightnessOverride(-1);
-        } else {
-            mPowerManager.setScreenBrightnessOverride((int)
-                    (screenBrightness * Power.BRIGHTNESS_ON));
-        }
-        if (buttonBrightness < 0 || buttonBrightness > 1.0f) {
-            mPowerManager.setButtonBrightnessOverride(-1);
-        } else {
-            mPowerManager.setButtonBrightnessOverride((int)
-                    (buttonBrightness * Power.BRIGHTNESS_ON));
+        if (!mDisplayFrozen) {
+            if (screenBrightness < 0 || screenBrightness > 1.0f) {
+                mPowerManager.setScreenBrightnessOverride(-1);
+            } else {
+                mPowerManager.setScreenBrightnessOverride((int)
+                        (screenBrightness * Power.BRIGHTNESS_ON));
+            }
+            if (buttonBrightness < 0 || buttonBrightness > 1.0f) {
+                mPowerManager.setButtonBrightnessOverride(-1);
+            } else {
+                mPowerManager.setButtonBrightnessOverride((int)
+                        (buttonBrightness * Power.BRIGHTNESS_ON));
+            }
         }
         if (holdScreen != mHoldingScreenOn) {
             mHoldingScreenOn = holdScreen;
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 2040cbd..5b44d390 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -3187,7 +3187,6 @@
         EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY,
                 System.identityHashCode(r),
                 r.task.taskId, r.shortComponentName, reason);
-        r.task.numActivities--;
         if (index < (mHistory.size()-1)) {
             ActivityRecord next = (ActivityRecord)mHistory.get(index+1);
             if (next.task == r.task) {
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 464841b..8d83f0b 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -563,10 +563,15 @@
     if (s == 0) {
         s = createSurface();
         mClientSurface = s;
+        mClientSurfaceBinder = s->asBinder();
     }
     return s;
 }
 
+wp<IBinder> LayerBaseClient::getSurfaceBinder() const {
+    return mClientSurfaceBinder;
+}
+
 sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const
 {
     return new Surface(mFlinger, mIdentity,
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 1a34f52..8ed4749 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -285,6 +285,7 @@
     virtual ~LayerBaseClient();
 
             sp<Surface> getSurface();
+            wp<IBinder> getSurfaceBinder() const;
     virtual sp<Surface> createSurface() const;
     virtual sp<LayerBaseClient> getLayerBaseClient() const {
         return const_cast<LayerBaseClient*>(this); }
@@ -325,6 +326,7 @@
 private:
     mutable Mutex mLock;
     mutable wp<Surface> mClientSurface;
+    wp<IBinder> mClientSurfaceBinder;
     const wp<Client> mClientRef;
     // only read
     const uint32_t mIdentity;
diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp
index 80cc52c..11f8feb 100644
--- a/services/surfaceflinger/LayerDim.cpp
+++ b/services/surfaceflinger/LayerDim.cpp
@@ -67,8 +67,14 @@
         const GLfloat alpha = s.alpha/255.0f;
         const uint32_t fbHeight = hw.getHeight();
         glDisable(GL_DITHER);
-        glEnable(GL_BLEND);
-        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+        if (s.alpha == 0xFF) {
+            glDisable(GL_BLEND);
+        } else {
+            glEnable(GL_BLEND);
+            glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+        }
+
         glColor4f(0, 0, 0, alpha);
 
 #if defined(GL_OES_EGL_image_external)
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 291ebc5..87b66ea 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1088,7 +1088,7 @@
 {
     sp<LayerBaseClient> lbc(layerBase->getLayerBaseClient());
     if (lbc != 0) {
-        mLayerMap.removeItem( lbc->getSurface()->asBinder() );
+        mLayerMap.removeItem( lbc->getSurfaceBinder() );
     }
     ssize_t index = mCurrentState.layersSortedByZ.remove(layerBase);
     if (index >= 0) {
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index 39bbd63..9479a2d 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -226,7 +226,15 @@
     private Context mContext;
     WakeLock mWakeLock;
     int mWakeLockTimeout;
+    // The number of requests pending to be sent out, it increases before calling
+    // EVENT_SEND and decreases while handling EVENT_SEND. It gets cleared while
+    // WAKE_LOCK_TIMEOUT occurs.
     int mRequestMessagesPending;
+    // The number of requests sent out but waiting for response. It increases while
+    // sending request and decreases while handling response. It should match
+    // mRequestList.size() unless there are requests no replied while
+    // WAKE_LOCK_TIMEOUT occurs.
+    int mRequestMessagesWaiting;
 
     // Is this the first radio state change?
     private boolean mInitialRadioStateChange = true;
@@ -308,16 +316,19 @@
                         if (s == null) {
                             rr.onError(RADIO_NOT_AVAILABLE, null);
                             rr.release();
-                            mRequestMessagesPending--;
+                            if (mRequestMessagesPending > 0)
+                                mRequestMessagesPending--;
                             alreadySubtracted = true;
                             return;
                         }
 
                         synchronized (mRequestsList) {
                             mRequestsList.add(rr);
+                            mRequestMessagesWaiting++;
                         }
 
-                        mRequestMessagesPending--;
+                        if (mRequestMessagesPending > 0)
+                            mRequestMessagesPending--;
                         alreadySubtracted = true;
 
                         byte[] data;
@@ -366,7 +377,7 @@
                         releaseWakeLockIfDone();
                     }
 
-                    if (!alreadySubtracted) {
+                    if (!alreadySubtracted && mRequestMessagesPending > 0) {
                         mRequestMessagesPending--;
                     }
 
@@ -381,20 +392,44 @@
                             // new send request. So when WAKE_LOCK_TIMEOUT occurs
                             // all requests in mRequestList already waited at
                             // least DEFAULT_WAKE_LOCK_TIMEOUT but no response.
-                            // Therefore all should be treated as lost requests.
-                            // Those lost requests return GENERIC_FAILURE and
-                            // request list is cleared.
+                            // Reset mRequestMessagesWaiting to enable
+                            // releaseWakeLockIfDone().
                             //
-                            // Note: mRequestMessagesPending shows how many
-                            //       requests are waiting to be sent (and before
-                            //       to be added in request list) since star the
-                            //       timer. It should be
-                            //       zero here since all request should already
-                            //       be put in request list while TIMEOUT occurs.
-                            clearRequestsList(GENERIC_FAILURE, true);
+                            // Note: Keep mRequestList so that delayed response
+                            // can still be handled when response finally comes.
+                            if (mRequestMessagesWaiting != 0) {
+                                Log.d(LOG_TAG, "NOTE: mReqWaiting is NOT 0 but"
+                                        + mRequestMessagesWaiting + " at TIMEOUT, reset!"
+                                        + " There still msg waitng for response");
+
+                                mRequestMessagesWaiting = 0;
+
+                                if (RILJ_LOGD) {
+                                    synchronized (mRequestsList) {
+                                        int count = mRequestsList.size();
+                                        Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " +
+                                                " mRequestList=" + count);
+
+                                        for (int i = 0; i < count; i++) {
+                                            rr = mRequestsList.get(i);
+                                            Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] "
+                                                    + requestToString(rr.mRequest));
+                                        }
+                                    }
+                                }
+                            }
+                            // mRequestMessagesPending shows how many
+                            // requests are waiting to be sent (and before
+                            // to be added in request list) since star the
+                            // WAKE_LOCK_TIMEOUT timer. Since WAKE_LOCK_TIMEOUT
+                            // is the expected time to get response, all requests
+                            // should already sent out (i.e.
+                            // mRequestMessagesPending is 0 )while TIMEOUT occurs.
                             if (mRequestMessagesPending != 0) {
-                                Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 at TIMEOUT, "
-                                    + "mReqPending = " + mRequestMessagesPending);
+                                Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 but"
+                                        + mRequestMessagesPending + " at TIMEOUT, reset!");
+                                mRequestMessagesPending = 0;
+
                             }
                             mWakeLock.release();
                         }
@@ -612,6 +647,7 @@
         mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT,
                 DEFAULT_WAKE_LOCK_TIMEOUT);
         mRequestMessagesPending = 0;
+        mRequestMessagesWaiting = 0;
 
         mContext = context;
 
@@ -1980,7 +2016,7 @@
     /**
      * Holds a PARTIAL_WAKE_LOCK whenever
      * a) There is outstanding RIL request sent to RIL deamon and no replied
-     * b) There is a request waiting to be sent out.
+     * b) There is a request pending to be sent out.
      *
      * There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't
      * happen often.
@@ -2003,7 +2039,7 @@
         synchronized (mWakeLock) {
             if (mWakeLock.isHeld() &&
                 (mRequestMessagesPending == 0) &&
-                (mRequestsList.size() == 0)) {
+                (mRequestMessagesWaiting == 0)) {
                 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
                 mWakeLock.release();
             }
@@ -2067,6 +2103,7 @@
                 rr.release();
             }
             mRequestsList.clear();
+            mRequestMessagesWaiting = 0;
         }
     }
 
@@ -2077,6 +2114,8 @@
 
                 if (rr.mSerial == serial) {
                     mRequestsList.remove(i);
+                    if (mRequestMessagesWaiting > 0)
+                        mRequestMessagesWaiting--;
                     return rr;
                 }
             }
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 0c3aef4..bd52dc2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -304,7 +304,7 @@
                 if (lastResult.isSuccess()) {
                     lastResult = scene.inflate();
                     if (lastResult.isSuccess()) {
-                        lastResult = scene.render();
+                        lastResult = scene.render(true /*freshRender*/);
                     }
                 }
             } finally {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
index 3bc0202..963dc4d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -108,7 +108,7 @@
             Bridge.prepareThread();
             mLastResult = mSession.acquire(timeout);
             if (mLastResult.isSuccess()) {
-                mLastResult = mSession.render();
+                mLastResult = mSession.render(false /*freshRender*/);
             }
         } finally {
             mSession.release();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
index 2bd7cc7..4c18656 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
@@ -146,7 +146,7 @@
                     }
 
                     bundle.mTarget.handleMessage(bundle.mMessage);
-                    if (mSession.render().isSuccess()) {
+                    if (mSession.render(false /*freshRender*/).isSuccess()) {
                         mListener.onNewFrame(session);
                     }
                 } finally {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index d7b7009..6224047 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -72,6 +72,7 @@
 import android.widget.TabWidget;
 import android.widget.TabHost.TabSpec;
 
+import java.awt.AlphaComposite;
 import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
@@ -385,13 +386,17 @@
      * <p>
      * {@link #acquire(long)} must have been called before this.
      *
+     * @param freshRender whether the render is a new one and should erase the existing bitmap (in
+     *      the case where bitmaps are reused). This is typically needed when not playing
+     *      animations.)
+     *
      * @throws IllegalStateException if the current context is different than the one owned by
      *      the scene, or if {@link #acquire(long)} was not called.
      *
      * @see SceneParams#getRenderingMode()
      * @see LayoutScene#render(long)
      */
-    public Result render() {
+    public Result render(boolean freshRender) {
         checkLock();
 
         try {
@@ -450,6 +455,7 @@
 
             // draw the views
             // create the BufferedImage into which the layout will be rendered.
+            boolean newImage = false;
             if (newRenderSize || mCanvas == null) {
                 if (mParams.getImageFactory() != null) {
                     mImage = mParams.getImageFactory().getImage(mMeasuredScreenWidth,
@@ -457,11 +463,15 @@
                 } else {
                     mImage = new BufferedImage(mMeasuredScreenWidth,
                             mMeasuredScreenHeight - mScreenOffset, BufferedImage.TYPE_INT_ARGB);
+                    newImage = true;
                 }
 
                 if (mParams.isBgColorOverridden()) {
+                    // since we override the content, it's the same as if it was a new image.
+                    newImage = true;
                     Graphics2D gc = mImage.createGraphics();
                     gc.setColor(new Color(mParams.getOverrideBgColor(), true));
+                    gc.setComposite(AlphaComposite.Src);
                     gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight - mScreenOffset);
                     gc.dispose();
                 }
@@ -476,6 +486,14 @@
                 mCanvas.setDensity(mParams.getDensity());
             }
 
+            if (freshRender && newImage == false) {
+                Graphics2D gc = mImage.createGraphics();
+                gc.setColor(new Color(0x00000000, true));
+                gc.setComposite(AlphaComposite.Src);
+                gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight - mScreenOffset);
+                gc.dispose();
+            }
+
             mViewRoot.draw(mCanvas);
 
             mViewInfoList = visitAllChildren((ViewGroup)mViewRoot, mContext);
@@ -600,7 +618,7 @@
             return result;
         }
 
-        result = render();
+        result = render(false /*freshRender*/);
         if (result.isSuccess()) {
             result = result.getCopyWithData(child);
         }
@@ -678,7 +696,7 @@
                         }
 
                         try {
-                            result = render();
+                            result = render(false /*freshRender*/);
                             if (result.isSuccess()) {
                                 listener.onNewFrame(RenderSessionImpl.this.getSession());
                             }
@@ -734,7 +752,7 @@
             return result;
         }
 
-        result = render();
+        result = render(false /*freshRender*/);
         if (layoutParams != null && result.isSuccess()) {
             result = result.getCopyWithData(layoutParams);
         }
@@ -866,7 +884,7 @@
             return result;
         }
 
-        return render();
+        return render(false /*freshRender*/);
     }
 
     /**