Merge "Fix issue #3424823: 4-corner trick causes runtime restart" into honeycomb
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 4d5238c..2420b84 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -33,6 +33,7 @@
     void enqueueToast(String pkg, ITransientNotification callback, int duration);
     void cancelToast(String pkg, ITransientNotification callback);
     void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived);
+    void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, in Notification notification, inout int[] idReceived);
     void cancelNotificationWithTag(String pkg, String tag, int id);
 }
 
diff --git a/core/java/android/preference/SeekBarPreference.java b/core/java/android/preference/SeekBarPreference.java
index 658c2a7..037fb41 100644
--- a/core/java/android/preference/SeekBarPreference.java
+++ b/core/java/android/preference/SeekBarPreference.java
@@ -29,25 +29,30 @@
  */
 public class SeekBarPreference extends DialogPreference {
     private static final String TAG = "SeekBarPreference";
-    
+
     private Drawable mMyIcon;
 
     public SeekBarPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         setDialogLayoutResource(com.android.internal.R.layout.seekbar_dialog);
-        setPositiveButtonText(android.R.string.ok);
-        setNegativeButtonText(android.R.string.cancel);
-        
+        createActionButtons();
+
         // Steal the XML dialogIcon attribute's value
         mMyIcon = getDialogIcon();
         setDialogIcon(null);
     }
 
+    // Allow subclasses to override the action buttons
+    public void createActionButtons() {
+        setPositiveButtonText(android.R.string.ok);
+        setNegativeButtonText(android.R.string.cancel);
+    }
+
     @Override
     protected void onBindDialogView(View view) {
         super.onBindDialogView(view);
-        
+
         final ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
         if (mMyIcon != null) {
             iconView.setImageDrawable(mMyIcon);
diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java
index 50ca71e..3b12780 100644
--- a/core/java/android/preference/VolumePreference.java
+++ b/core/java/android/preference/VolumePreference.java
@@ -236,14 +236,11 @@
             @Override
             public void onChange(boolean selfChange) {
                 super.onChange(selfChange);
-                if (mSeekBar != null) {
-                    int volume = System.getInt(mContext.getContentResolver(),
-                            System.VOLUME_SETTINGS[mStreamType], -1);
-                    // Works around an atomicity problem with volume updates
-                    // TODO: Fix the actual issue, probably in AudioService
-                    if (volume >= 0) {
-                        mSeekBar.setProgress(volume);
-                    }
+                if (mSeekBar != null && mAudioManager != null) {
+                    int volume = mAudioManager.isStreamMute(mStreamType) ?
+                            mAudioManager.getLastAudibleStreamVolume(mStreamType)
+                            : mAudioManager.getStreamVolume(mStreamType);
+                    mSeekBar.setProgress(volume);
                 }
             }
         };
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 6981b9c..26f8627 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2224,10 +2224,12 @@
         final View[] children = mChildren;
         for (int i = 0; i < count; i++) {
             final View child = children[i];
-            child.mRecreateDisplayList = (child.mPrivateFlags & INVALIDATED) == INVALIDATED;
-            child.mPrivateFlags &= ~INVALIDATED;
-            child.getDisplayList();
-            child.mRecreateDisplayList = false;
+            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null) {
+                child.mRecreateDisplayList = (child.mPrivateFlags & INVALIDATED) == INVALIDATED;
+                child.mPrivateFlags &= ~INVALIDATED;
+                child.getDisplayList();
+                child.mRecreateDisplayList = false;
+            }
         }
     }
 
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index bb5774f..2aa94dc 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -367,7 +367,10 @@
     }
 
     protected void onShowVolumeChanged(int streamType, int flags) {
-        int index = mAudioService.getStreamVolume(streamType);
+        int index = mAudioService.isStreamMute(streamType) ?
+                mAudioService.getLastAudibleStreamVolume(streamType)
+                : mAudioService.getStreamVolume(streamType);
+
 //        int message = UNKNOWN_VOLUME_TEXT;
 //        int additionalMessage = 0;
         mRingIsSilent = false;
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 1fea65a..9b0d4e0 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -519,11 +519,17 @@
         }
     }
 
-    synchronized void waitForCookieOperationsToComplete() {
-        while (pendingCookieOperations > 0) {
-            try {
-                wait();
-            } catch (InterruptedException e) { }
+    /**
+     * Waits for pending operations to completed.
+     * {@hide}  Too late to release publically.
+     */
+    public void waitForCookieOperationsToComplete() {
+        synchronized (this) {
+            while (pendingCookieOperations > 0) {
+                try {
+                    wait();
+                } catch (InterruptedException e) { }
+            }
         }
     }
 
diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.java b/core/java/com/android/internal/statusbar/StatusBarNotification.java
index cb791be..c03ff1a 100644
--- a/core/java/com/android/internal/statusbar/StatusBarNotification.java
+++ b/core/java/com/android/internal/statusbar/StatusBarNotification.java
@@ -63,8 +63,7 @@
         this.initialPid = initialPid;
         this.notification = notification;
 
-        this.priority = ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0)
-            ? PRIORITY_ONGOING : PRIORITY_NORMAL;
+        this.priority = PRIORITY_NORMAL;
     }
 
     public StatusBarNotification(Parcel in) {
diff --git a/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg b/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg
index 72beb6b..7d7cdbb 100644
--- a/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg
+++ b/core/res/res/drawable-xlarge-nodpi/default_wallpaper.jpg
Binary files differ
diff --git a/data/sounds/effects/ogg/Effect_Tick.ogg b/data/sounds/effects/ogg/Effect_Tick.ogg
index b379019..a997fe1 100644
--- a/data/sounds/effects/ogg/Effect_Tick.ogg
+++ b/data/sounds/effects/ogg/Effect_Tick.ogg
Binary files differ
diff --git a/docs/html/guide/topics/fundamentals/index.jd b/docs/html/guide/topics/fundamentals/index.jd
new file mode 100644
index 0000000..de2e312
--- /dev/null
+++ b/docs/html/guide/topics/fundamentals/index.jd
@@ -0,0 +1,496 @@
+page.title=Application Fundamentals
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+
+<h2>Quickview</h2>
+<ul>
+  <li>Android applications are composed of one or more application components (activities,
+services, content providers, and broadcast receivers)</li>
+  <li>Each component performs a different role in the overall application behavior, and each
+one can be activated individually (even by other applications)</li>
+  <li>The manifest file must declare all components in the application and should also declare
+all application requirements, such as the minimum version of Android required and any hardware
+configurations required</li>
+  <li>Non-code application resources (images, strings, layout files, etc.) should include
+alternatives for different device configurations (such as different strings for different
+languages and different layouts for different screen sizes)</li>
+</ul>
+
+
+<h2>In this document</h2>
+<ol>
+<li><a href="#Components">Application Components</a>
+  <ol>
+    <li><a href="#ActivatingComponents">Activating components</a></li>
+  </ol>
+</li>
+<li><a href="#Manifest">The Manifest File</a>
+  <ol>
+    <li><a href="#DeclaringComponents">Declaring components</a></li>
+    <li><a href="#DeclaringRequirements">Declaring application requirements</a></li>
+  </ol>
+</li>
+<li><a href="#Resources">Application Resources</a></li>
+</ol>
+</div>
+</div>
+
+<p>Android applications are written in the Java programming language. The Android SDK tools compile
+the code&mdash;along with any data and resource files&mdash;into an <i>Android package</i>, an
+archive file with an {@code .apk} suffix. All the code in a single {@code .apk} file is considered
+to be one application and is the file that Android-powered devices use to install the
+application.</p>
+
+<p>Once installed on a device, each Android application lives in its own security sandbox: </p>
+
+<ul>
+ <li>The Android operating system is a multi-user Linux system in which each application is a
+different user.</li>
+
+<li>By default, the system assigns each application a unique Linux user ID (the ID is used only by
+the system and is unknown to the application). The system sets permissions for all the files in an
+application so that only the user ID assigned to that application can access them. </li>
+
+<li>Each process has its own virtual machine (VM), so an application's code runs in isolation from
+other applications.</li>
+
+<li>By default, every application runs in its own Linux process. Android starts the process when any
+of the application's components need to be executed, then shuts down the process when it's no longer
+needed or when the system must recover memory for other applications.</li>
+</ul>
+
+<p>In this way, the Android system implements the <em>principle of least privilege</em>. That is,
+each application, by default, has access only to the components that it requires to do its work and
+no more. This creates a very secure environment in which an application cannot access parts of
+the system for which it is not given permission.</p>
+
+<p>However, there are ways for an application to share data with other applications and for an
+application to access system services:</p>
+
+<ul>
+  <li>It's possible to arrange for two applications to share the same Linux user ID, in which case
+they are able to access each other's files.  To conserve system resources, applications with the
+same user ID can also arrange to run in the same Linux process and share the same VM (the
+applications must also be signed with the same certificate).</li>
+  <li>An application can request permission to access device data such as the user's
+contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All
+application permissions must be granted by the user at install time.</li>
+</ul>
+
+<p>That covers the basics regarding how an Android application exists within the system. The rest of
+this document introduces you to:</p>
+<ul>
+  <li>The core framework components that define your application.</li>
+  <li>The manifest file in which you declare components and required device features for your
+application.</li>
+  <li>Resources that are separate from the application code and allow your application to
+gracefully optimize its behavior for a variety of device configurations.</li>
+</ul>
+
+<p class="note"><strong>Tip:</strong> If you're new to Android development, we suggest that you
+follow the Beginner's Path link at the bottom of this page. For each document in the Application
+Fundamentals, the Beginner's Path points you to the document we suggest you read next, in order
+to get up to speed on the core Android concepts.</p>
+
+
+
+<h2 id="Components">Application Components</h2>
+
+<p>Application components are the essential building blocks of an Android application. Each
+component is a different point through which the system can enter your application. Not all
+components are actual entry points for the user and some depend on each other, but each one exists
+as its own entity and plays a specific role&mdash;each one is a unique building block that
+helps define your application's overall behavior.</p>
+
+<p>There are four different types of application components. Each type serves a distinct purpose
+and has a distinct lifecycle that defines how the component is created and destroyed.</p>
+
+<p>Here are the four types of application components:</p>
+
+<dl>
+
+<dt><b>Activities</b></dt>
+
+<dd>An <i>activity</i> represents a single screen with a user interface. For example,
+an email application might have one activity that shows a list of new
+emails, another activity to compose an email, and another activity for reading emails. Although
+the activities work together to form a cohesive user experience in the email application, each one
+is independent of the others. As such, a different application can start any one of these
+activities (if the email application allows it). For example, a camera application can start the
+activity in the email application that composes new mail, in order for the user to share a picture.
+
+<p>An activity is implemented as a subclass of {@link android.app.Activity} and you can learn more
+about it in the <a href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a>
+developer guide.</p>
+</dd>
+
+
+<dt><b>Services</b></dt>
+
+<dd>A <i>service</i> is a component that runs in the background to perform long-running
+operations or to perform work for remote processes. A service
+does not provide a user interface. For example, a service might play music in the background while
+the user is in a different application, or it might fetch data over the network without
+blocking user interaction with an activity. Another component, such as an activity, can start the
+service and let it run or bind to it in order to interact with it.
+
+<p>A service is implemented as a subclass of {@link android.app.Service} and you can learn more
+about it in the <a href="{@docRoot}guide/topics/fundamentals/services.html">Services</a> developer
+guide.</p>
+</dd>
+
+
+<dt><b>Content providers</b></dt>
+
+<dd>A <i>content provider</i> manages a shared set of application data. You can store the data in
+the file system, an SQLite database, on the web, or any other persistent storage location your
+application can access. Through the content provider, other applications can query or even modify
+the data (if the content provider allows it). For example, the Android system provides a content
+provider that manages the user's contact information. As such, any application with the proper
+permissions can query part of the content provider (such as {@link
+android.provider.ContactsContract.Data}) to read and write information about a particular person.
+
+<p>Content providers are also useful for reading and writing data that is private to your
+application and not shared. For example, the <a
+href="{@docRoot}resources/samples/NotePad/index.html">Note Pad</a> sample application uses a
+content provider to save notes.</p>
+
+<p>A content provider is implemented as a subclass of {@link android.content.ContentProvider}
+and must implement a standard set of APIs that enable other applications to perform
+transactions. For more information, see the <a
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
+guide.</p>
+</dd>
+
+
+<dt><b>Broadcast receivers</b></dt>
+
+<dd>A <i>broadcast receiver</i> is a component that responds to system-wide broadcast
+announcements.  Many broadcasts originate from the system&mdash;for example, a broadcast announcing
+that the screen has turned off, the battery is low, or a picture was captured.
+Applications can also initiate broadcasts&mdash;for example, to let other applications know that
+some data has been downloaded to the device and is available for them to use. Although broadcast
+receivers don't display a user interface, they may <a
+href="{@docRoot}guide/topics/ui/notifiers/notifications.html">create a status bar notification</a>
+to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is
+just a "gateway" to other components and is intended to do a very minimal amount of work. For
+instance, it might initiate a service to perform some work based on the event.
+
+<p>A broadcast receiver is implemented as a subclass of {@link android.content.BroadcastReceiver}
+and each broadcast is delivered as an {@link android.content.Intent} object. For more information,
+see the <a
+href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
+developer guide.</p>
+</dd>
+
+</dl>
+
+
+
+<p>A unique aspect of the Android system design is that any application can start another
+application’s component. For example, if you want the user to capture a
+photo with the device camera, there's probably another application that does that and your
+application can use it, instead of developing an activity to capture a photo yourself. You don't
+need to incorporate or even link to the code from the camera application.
+Instead, you can simply start the activity in the camera application that captures a
+photo. When complete, the photo is even returned to your application so you can use it. To the user,
+it seems as if the camera is actually a part of your application.</p>
+
+<p>When the system starts a component, it starts the process for that application (if it's not
+already running) and instantiates the classes needed for the component. For example, if your
+application starts the activity in the camera application that captures a photo, that activity
+runs in the process that belongs to the camera application, not in your application's process.
+Therefore, unlike applications on most other systems, Android applications don't have a single entry
+point (there's no {@code main()} function, for example).</p>
+
+<p>Because the system runs each application in a separate process with file permissions that
+restrict access to other applications, your application cannot directly activate a component from
+another application. The Android system, however, can. So, to activate a component in
+another application, you must deliver a message to the system that specifies your <em>intent</em> to
+start a particular component. The system then activates the component for you.</p>
+
+
+<h3 id="ActivatingComponents">Activating Components</h3>
+
+<p>Three of the four component types&mdash;activities, services, and
+broadcast receivers&mdash;are activated by an asynchronous message called an <em>intent</em>.
+Intents bind individual components to each other at runtime (you can think of them
+as the messengers that request an action from other components), whether the component belongs
+to your application or another.</p>
+
+<p>An intent is defined by an {@link android.content.Intent} object, which defines a message to
+activate either a specific component or a specific <em>type</em> of component&mdash;an intent
+can be either explicit or implicit, respectively.</p>
+
+<p>For activities and services, an intent defines the action to perform (for example, to "view" or
+"send" something) and may specify the URI of the data to act on (among other things that the
+component being started might need to know). For example, an intent might convey a request for an
+activity to present an image to the user or to open a web page. In some cases, you can start a
+component in order to receive a result, in which case, the component that is started also returns
+the result in an {@link android.content.Intent} object (for example, you can issue an intent to let
+the user pick a personal contact and have it returned to you&mdash;the return intent includes a
+URI pointing to the chosen contact). For broadcast receivers, the intent simply defines the
+announcement being broadcast (for example, a broadcast to indicate the device battery is low
+includes only a known action string that indicates "battery is low").</p>
+
+<p>The remaining type of component, content provider, is not activated by intents. Rather, it is
+activated when targeted by a request from a {@link android.content.ContentResolver}. The content
+resolver handles all direct transactions with the content provider so that the component that's
+performing transactions with the provider doesn't need to and instead calls methods on the {@link
+android.content.ContentResolver} object. This leaves a layer of abstraction between the content
+provider and the component requesting information (for security).</p>
+
+<p>For more information about using intents, see the <a
+href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and
+Intent Filters</a> document. More information about activating specific components is also provided
+in the <a href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a>, <a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a>, and <a
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
+guides.</p>
+
+
+<h2 id="Manifest">The Manifest File</h2>
+
+<p>Before the Android system can start an application component, the system must know that the
+component exists by reading the application's {@code AndroidManifest.xml} file (the "manifest"
+file). Your application must declare all its components in this file, which must be at the root of
+the application project directory.</p>
+
+<p>The manifest does a number of things in addition to declaring the application's components,
+such as:</p>
+<ul>
+  <li>Identify any user permissions the application requires, such as Internet access or
+read-access to the user's contacts.</li>
+  <li>Declare the minimum <a href="{@docRoot}guide/appendix/api-levels.html">API Level</a>
+required by the application, based on which APIs the application uses.</li>
+  <li>Declare hardware and software features used or required by the application, such as a camera,
+bluetooth services, or a multitouch screen.</li>
+  <li>API libraries the application needs to be linked against (other than the Android framework
+APIs), such as the <a
+href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google Maps
+library</a>.</li>
+  <li>And more</li>
+</ul>
+
+
+<h3 id="DeclaringComponents">Declaring components</h3>
+
+<p>The primary task of the manifest is to inform the system about the application's components. For
+example, a manifest file can declare an activity as follows: </p>
+
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;manifest ... &gt;
+    &lt;application android:icon="@drawable/app_icon.png" ... &gt;
+        &lt;activity android:name="com.example.project.ExampleActivity"
+                  android:label="@string/example_label" ... &gt;
+        &lt;/activity&gt;
+        ...
+    &lt;/application&gt;
+&lt;/manifest&gt;</pre>
+
+<p>In the <code><a
+href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
+element, the {@code android:icon} attribute points to resources for an icon that identifies the
+application.</p>
+
+<p>In the <code><a
+href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> element,
+the {@code android:name} attribute specifies the fully qualified class name of the {@link
+android.app.Activity} subclass and the {@code android:label} attributes specifies a string
+to use as the user-visible label for the activity.</p>
+
+<p>You must declare all application components this way:</p>
+<ul>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> elements
+for activities</li>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/service-element.html">&lt;service&gt;</a></code> elements for
+services</li>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></code> elements
+for broadcast receivers</li>
+  <li><code><a
+href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code> elements
+for content providers</li>
+</ul>
+
+<p>Activities, services, and content providers that you include in your source but do not declare
+in the manifest are not visible to the system and, consequently, can never run.  However,
+broadcast
+receivers can be either declared in the manifest or created dynamically in code (as
+{@link android.content.BroadcastReceiver} objects) and registered with the system by calling
+{@link android.content.Context#registerReceiver registerReceiver()}.</p>
+
+<p>For more about how to structure the manifest file for your application, see the <a
+href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a>
+documentation. </p>
+
+
+
+<h3 id="DeclaringComponentCapabilities">Declaring component capabilities</h3>
+
+<p>As discussed above, in <a href="#ActivatingComponents">Activating Components</a>, you can use an
+{@link android.content.Intent} to start activities, services, and broadcast receivers. You can do so
+by explicitly naming the target component (using the component class name) in the intent. However,
+the real power of intents lies in the concept of intent actions. With intent actions, you simply
+describe the type of action you want to perform (and optionally, the data upon which you’d like to
+perform the action) and allow the system to find a component on the device that can perform the
+action and start it. If there are multiple components that can perform the action described by the
+intent, then the user selects which one to use.</p>
+
+<p>The way the system identifies the components that can respond to an intent is by comparing the
+intent received to the <i>intent filters</i> provided in the manifest file of other applications on
+the device.</p>
+
+<p>When you declare a component in your application's manifest, you can optionally include
+intent filters that declare the capabilities of the component so it can respond to intents
+from other applications. You can declare an intent filter for your component by
+adding an <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code
+&lt;intent-filter&gt;}</a> element as a child of the component's declaration element.</p>
+
+<p>For example, an email application with an activity for composing a new email might declare an
+intent filter in its manifest entry to respond to "send" intents (in order to send email). An
+activity in your application can then create an intent with the “send” action ({@link
+android.content.Intent#ACTION_SEND}), which the system matches to the email application’s “send”
+activity and launches it when you invoke the intent with {@link android.app.Activity#startActivity
+startActivity()}.</p>
+
+<p>For more about creating intent filters, see the <a
+href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> document.
+</p>
+
+
+
+<h3 id="DeclaringRequirements">Declaring application requirements</h3>
+
+<p>There are a variety of devices powered by Android and not all of them provide the
+same features and capabilities. In order to prevent your application from being installed on devices
+that lack features needed by your application, it's important that you clearly define a profile for
+the types of devices your application supports by declaring device and software requirements in your
+manifest file. Most of these declarations are informational only and the system does not read
+them, but external services such as Android Market do read them in order to provide filtering
+for users when they search for applications from their device.</p>
+
+<p>For example, if your application requires a camera and uses APIs introduced in Android 2.1 (<a
+href="{@docRoot}guide/appendix/api-levels.html">API Level</a> 7), you should declare these as
+requirements in your manifest file. That way, devices that do <em>not</em> have a camera and have an
+Android version <em>lower</em> than 2.1 cannot install your application from Android Market.</p>
+
+<p>However, you can also declare that your applicaiton uses the camera, but does not
+<em>require</em> it. In that case, your application must perform a check at runtime to determine
+if the device has a camera and disable any features that use the camera if one is not available.</p>
+
+<p>Here are some of the important device characteristics that you should consider as you design and
+develop your application:</p>
+
+<dl>
+  <dt>Screen size and density</dt>
+  <dd>In order to categorize devices by their screen type, Android defines two characteristics for
+each device: screen size (the physical dimensions of the screen) and screen density (the physical
+density of the pixels on the screen, or dpi&mdash;dots per inch). To simplify all the different
+types of screen configurations, the Android system generalizes them into select groups that make
+them easier to target.
+<p>The screen sizes are: small, normal, large, and extra large.<br/>
+The screen densities are: low density, medium density, high density, and extra high density.</p>
+
+<p>By default, your application is compatible with all screen sizes and densities,
+because the Android system makes the appropriate adjustments to your UI layout and image
+resources. However, you should create specialized layouts for certain screen sizes and provide
+specialized images for certain densities, using alternative layout resources, and by declaring in
+your manifest exactly which screen sizes your application supports with the <a
+href="{@docRoot}guide/topics/manifest/supports-screens.html">{@code
+&lt;supports-screens&gt;}</a> element.</p>
+<p>For more information, see the <a
+href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>
+document.</p></dd>
+
+  <dt>Input configurations</dt>
+  <dd>Many devices provide a different type of user input mechanism, such as a hardware keyboard, a
+trackball, or a five-way navigation pad. If your application requires a particular kind of input
+hardware, then you should declare it in your manifest with the <a
+href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">{@code
+&lt;uses-configuration&gt;}</a> element. However, it is rare that an application should require
+a certain input configuration.</dd>
+
+  <dt>Device features</dt>
+  <dd>There are many hardware and software features that may or may not exist on a given
+Android-powered device, such as a camera, a light sensor, bluetooth, a certain
+version of OpenGL, or the fidelity of the touchscreen. You should never assume that a certain
+feature is available on all Android-powered devices (other than the availability of the standard
+Android library), so you should declare any features used by your application with the <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
+element.</dd>
+
+  <dt>Platform Version</dt>
+  <dd>Different Android-powered devices often run different versions of the Android platform,
+such as Android 1.6 or Android 2.3. Each successive version often includes additional APIs not
+available in the previous version. In order to indicate which set of APIs are available, each
+platform version specifies an <a
+href="{@docRoot}guide/appendix/api-levels.html">API Level</a> (for example, Android 1.0 is API Level
+1 and Android 2.3 is API Level 9). If you use any APIs that were added to the platform after
+version 1.0, you should declare the minimum API Level in which those APIs were introduced using the
+<a href="{@docRoot}guide/topics/manifest/uses-sdk.html">{@code &lt;uses-sdk&gt;}</a> element.</dd>
+</dl>
+
+<p>It's important that you declare all such requirements for your application, because, when you
+distribute your application on Android Market, Market uses these declarations to filter which
+applications are available on each device. As such, your application should be available only to
+devices that meet all your application requirements.</p>
+
+<p>For more information about how Android Market filters applications based on these (and other)
+requirements, see the <a href="{@docRoot}guide/appendix/market-filters.html">Market Filters</a>
+document.</p>
+
+
+
+<h2 id="Resources">Application Resources</h2>
+
+<p>An Android application is composed of more than just code&mdash;it requires resources that are
+separate from the source code, such as images, audio files, and anything relating to the visual
+presentation of the application. For example, you should define animations, menus, styles, colors,
+and the layout of activity user interfaces with XML files. 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 different languages and screen sizes).</p>
+
+<p>For every resource that you include in your Android project, the SDK build tools define a unique
+integer ID, which you can use to reference the resource from your application code or from
+other resources defined in XML. For example, if your application contains an image file named {@code
+logo.png} (saved in the {@code res/drawable/} directory), the SDK tools generate a resource ID
+named {@code R.drawable.logo}, which you can use to reference the image and insert it in your
+user interface.</p>
+
+<p>One of the most important aspects of providing resources separate from your source code
+is the ability for you to provide alternative resources for different device
+configurations. For example, by defining UI strings in XML, you can translate the strings into other
+languages and save those strings in separate files. Then, based on a language <em>qualifier</em>
+that you append to the resource directory's name (such as {@code res/values-fr/} for French string
+values) and the user's language setting, the Android system applies the appropriate language strings
+to your UI.</p>
+
+<p>Android supports many different <em>qualifiers</em> for your alternative resources. The
+qualifier is a short string that you include in the name of your resource directories in order to
+define the device configuration for which those resources should be used. As another
+example, you should often create different layouts for your activities, depending on the
+device's screen orientation and size. For example, when the device screen is in portrait
+orientation (tall), you might want a layout with buttons to be vertical, but when the screen is in
+landscape orientation (wide), the buttons should be aligned horizontally. To change the layout
+depending on the orientation, you can define two different layouts and apply the appropriate
+qualifier to each layout's directory name. Then, the system automatically applies the appropriate
+layout depending on the current device orientation.</p>
+
+<p>For more about the different kinds of resources you can include in your application and how
+to create alternative resources for various device configurations, see the <a
+href="{@docRoot}guide/topics/resources/index.html">Application Resources</a> developer guide.</p>
+
+
+<h2>Beginner's Path</h2>
+
+<p>For a close look at implementing activities&mdash;the components your users use to
+interact with your application&mdash;continue with the <b><a
+href="{@docRoot}guide/topics/fundamentals/activities.html">Activities</a></b> document.</p>
+
diff --git a/docs/html/guide/topics/fundamentals/processes-and-threads.jd b/docs/html/guide/topics/fundamentals/processes-and-threads.jd
new file mode 100644
index 0000000..c35108e
--- /dev/null
+++ b/docs/html/guide/topics/fundamentals/processes-and-threads.jd
@@ -0,0 +1,425 @@
+page.title=Processes and Threads
+parent.title=Application Fundamentals
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+<h2>Quickview</h2>
+<ul>
+  <li>Every application runs in its own process and all components of the application run in that
+process, by default</li>
+  <li>Any slow, blocking operations in an activity should be done in a new thread, to avoid slowing
+down the user interface</li>
+</ul>
+
+<h2>In this document</h2>
+<ol>
+<li><a href="#Processes">Processes</a>
+  <ol>
+    <li><a href="#Lifecycle">Process lifecycle</a></li>
+  </ol>
+</li>
+<li><a href="#Threads">Threads</a>
+  <ol>
+    <li><a href="#WorkerThreads">Worker threads</a></li>
+    <li><a href="#ThreadSafe">Thread-safe methods</a></li>
+  </ol>
+</li>
+<li><a href="#IPC">Interprocess Communication</a></li>
+</ol>
+
+</div>
+</div>
+
+<p>When an application component starts and the application does not have any other components
+running, the Android system starts a new Linux process for the application with a single thread of
+execution. By default, all components of the same application run in the same process and thread
+(called the "main" thread). If an application component starts and there already exists a process
+for that application (because another component from the application exists), then the component is
+started within that process and uses the same thread of execution. However, you can arrange for
+different components in your application to run in separate processes, and you can create additional
+threads for any process.</p>
+
+<p>This document discusses how processes and threads work in an Android application.</p>
+
+
+<h2 id="Processes">Processes</h2>
+
+<p>By default, all components of the same application run in the same process and most applications
+should not change this. However, if you find that you need to control which process a certain
+component belongs to, you can do so in the manifest file.</p>
+
+<p>The manifest entry for each type of component element&mdash;<a
+href="{@docRoot}guide/topics/manifest/activity-element.html">{@code
+&lt;activity&gt;}</a>, <a href="{@docRoot}guide/topics/manifest/service-element.html">{@code
+&lt;service&gt;}</a>, <a href="{@docRoot}guide/topics/manifest/receiver-element.html">{@code
+&lt;receiver&gt;}</a>, and <a href="{@docRoot}guide/topics/manifest/provider-element.html">{@code
+&lt;provider&gt;}</a>&mdash;supports an {@code android:process} attribute that can specify a
+process in which that component should run. You can set this attribute so that each component runs
+in its own process or so that some components share a process while others do not.  You can also set
+{@code android:process} so that components of different applications run in the same
+process&mdash;provided that the applications share the same Linux user ID and are signed with the
+same certificates.</p>
+
+<p>The <a href="{@docRoot}guide/topics/manifest/application-element.html">{@code
+&lt;application&gt;}</a> element also supports an {@code android:process} attribute, to set a
+default value that applies to all components.</p>
+
+<p>Android might decide to shut down a process at some point, when memory is low and required by
+other processes that are more immediately serving the user. Application
+components running in the process that's killed are consequently destroyed.  A process is started
+again for those components when there's again work for them to do.</p>
+
+<p>When deciding which processes to kill, the Android system weighs their relative importance to
+the user.  For example, it more readily shuts down a process hosting activities that are no longer
+visible on screen, compared to a process hosting visible activities. The decision whether to
+terminate a process, therefore, depends on the state of the components running in that process. The
+rules used to decide which processes to terminate is discussed below. </p>
+
+
+<h3 id="Lifecycle">Process lifecycle</h3>
+
+<p>The Android system tries to maintain an application process for as long as possible, but
+eventually needs to remove old processes to reclaim memory for new or more important processes.  To
+determine which processes to keep
+and which to kill, the system places each process into an "importance hierarchy" based on the
+components running in the process and the state of those components.  Processes with the lowest
+importance are eliminated first, then those with the next lowest importance, and so on, as necessary
+to recover system resources.</p>
+
+<p>There are five levels in the importance hierarchy. The following list presents the different
+types of processes in order of importance (the first process is <em>most important</em> and is
+<em>killed last</em>):</p>
+
+<ol>
+  <li><b>Foreground process</b>
+    <p>A process that is required for what the user is currently doing.  A
+      process is considered to be in the foreground if any of the following conditions are true:</p>
+
+      <ul>
+        <li>It hosts an {@link android.app.Activity} that the user is interacting with (the {@link
+android.app.Activity}'s {@link android.app.Activity#onResume onResume()} method has been
+called).</li>
+
+        <li>It hosts a {@link android.app.Service} that's bound to the activity that the user is
+interacting with.</li>
+
+        <li>It hosts a {@link android.app.Service} that's running "in the foreground"&mdash;the
+service has called {@link android.app.Service#startForeground startForeground()}.
+
+        <li>It hosts a {@link android.app.Service} that's executing one of its lifecycle
+callbacks ({@link android.app.Service#onCreate onCreate()}, {@link android.app.Service#onStart
+onStart()}, or {@link android.app.Service#onDestroy onDestroy()}).</li>
+
+        <li>It hosts a {@link android.content.BroadcastReceiver} that's executing its {@link
+        android.content.BroadcastReceiver#onReceive onReceive()} method.</li>
+    </ul>
+
+    <p>Generally, only a few foreground processes exist at any given time.  They are killed only as
+a last resort&mdash;if memory is so low that they cannot all continue to run.  Generally, at that
+point, the device has reached a memory paging state, so killing some foreground processes is
+required to keep the user interface responsive.</p></li>
+
+  <li><b>Visible process</b>
+    <p>A process that doesn't have any foreground components, but still can
+      affect what the user sees on screen. A process is considered to be visible if either of the
+      following conditions are true:</p>
+
+      <ul>
+        <li>It hosts an {@link android.app.Activity} that is not in the foreground, but is still
+visible to the user (its {@link android.app.Activity#onPause onPause()} method has been called). 
+This might occur, for example, if the foreground activity started a dialog, which allows the
+previous activity to be seen behind it.</li>
+
+        <li>It hosts a {@link android.app.Service} that's bound to a visible (or foreground)
+activity.</li>
+      </ul>
+
+      <p>A visible process is considered extremely important and will not be killed unless doing so
+is required to keep all foreground processes running. </p>
+    </li>
+
+  <li><b>Service process</b>
+    <p>A process that is running a service that has been started with the {@link
+android.content.Context#startService startService()} method and does not fall into either of the two
+higher categories. Although service processes are not directly tied to anything the user sees, they
+are generally doing things that the user cares about (such as playing music in the background or
+downloading  data on the network), so the system keeps them running unless there's not enough memory
+to retain them along with all foreground and visible processes. </p>
+  </li>
+
+  <li><b>Background process</b>
+    <p>A process holding an activity that's not currently visible to the user  (the activity's
+{@link android.app.Activity#onStop onStop()} method has been called). These processes have no direct
+impact on the user experience, and the system can kill them at any time to reclaim memory for a
+foreground,
+visible, or service process. Usually there are many background processes running, so they are kept
+in an LRU (least recently used) list to ensure that the process with the activity that was most
+recently seen by the user is the last to be killed. If an activity implements its lifecycle methods
+correctly, and saves its current state, killing its process will not have a visible effect on
+the user experience, because when the user navigates back to the activity, the activity restores
+all of its visible state. See the <a
+href="{@docRoot}guide/topics/fundamentals/activities.html#SavingActivityState">Activities</a>
+document for information about saving and restoring state.</p>
+  </li>
+
+  <li><b>Empty process</b>
+    <p>A process that doesn't hold any active application components.  The only reason to keep this
+kind of process alive is for caching purposes, to improve startup time the next time a component
+needs to run in it.  The system often kills these processes in order to balance overall system
+resources between process caches and the underlying kernel caches.</p>
+  </li>
+</ol>
+
+
+  <p>Android ranks a process at the highest level it can, based upon the importance of the
+components currently active in the process.  For example, if a process hosts a service and a visible
+activity, the process is ranked as a visible process, not a service process.</p>
+
+  <p>In addition, a process's ranking might be increased because other processes are dependent on
+it&mdash;a process that is serving another process can never be ranked lower than the process it is
+serving. For example, if a content provider in process A is serving a client in process B, or if a
+service in process A is bound to a component in process B, process A is always considered at least
+as important as process B.</p>
+
+  <p>Because a process running a service is ranked higher than a process with background activities,
+an activity that initiates a long-running operation might do well to start a <a
+href="{@docRoot}guide/topics/fundamentals/services.html">service</a> for that operation, rather than
+simply create a worker thread&mdash;particularly if the operation will likely outlast the activity.
+For example, an activity that's uploading a picture to a web site should start a service to perform
+the upload so that the upload can continue in the background even if the user leaves the activity.
+Using a service guarantees that the operation will have at least "service process" priority,
+regardless of what happens to the activity. This is the same reason that broadcast receivers should
+employ services rather than simply put time-consuming operations in a thread.</p>
+
+
+
+
+<h2 id="Threads">Threads</h2>
+
+<p>When an application is launched, the system creates a thread of execution for the application,
+called "main." This thread is very important because it is in charge of dispatching events to
+the appropriate user interface widgets, including drawing events. It is also the thread in which
+your application interacts with components from the Android UI toolkit (components from the {@link
+android.widget} and {@link android.view} packages). As such, the main thread is also sometimes
+called the UI thread.</p>
+
+<p>The system does <em>not</em> create a separate thread for each instance of a component. All
+components that run in the same process are instantiated in the UI thread, and system calls to
+each component are dispatched from that thread. Consequently, methods that respond to system
+callbacks (such as {@link android.view.View#onKeyDown onKeyDown()} to report user actions
+or a lifecycle callback method) always run in the UI thread of the process.</p>
+
+<p>For instance, when the user touches a button on the screen, your app's UI thread dispatches the
+touch event to the widget, which in turn sets its pressed state and posts an invalidate request to
+the event queue. The UI thread dequeues the request and notifies the widget that it should redraw
+itself.</p>
+
+<p>When your app performs intensive work in response to user interaction, this single thread model
+can yield poor performance unless you implement your application properly. Specifically, if
+everything is happening in the UI thread, performing long operations such as network access or
+database queries will block the whole UI. When the thread is blocked, no events can be dispatched,
+including drawing events. From the user's perspective, the
+application appears to hang. Even worse, if the UI thread is blocked for more than a few seconds
+(about 5 seconds currently) the user is presented with the infamous "<a
+href="http://developer.android.com/guide/practices/design/responsiveness.html">application not
+responding</a>" (ANR) dialog. The user might then decide to quit your application and uninstall it
+if they are unhappy.</p>
+
+<p>Additionally, the Andoid UI toolkit is <em>not</em> thread-safe. So, you must not manipulate
+your UI from a worker thread&mdash;you must do all manipulation to your user interface from the UI
+thread. Thus, there are simply two rules to Android's single thread model:</p>
+
+<ol>
+<li>Do not block the UI thread
+<li>Do not access the Android UI toolkit from outside the UI thread
+</ol>
+
+<h3 id="WorkerThreads">Worker threads</h3>
+
+<p>Because of the single thread model described above, it's vital to the responsiveness of your
+application's UI that you do not block the UI thread. If you have operations to perform
+that are not instantaneous, you should make sure to do them in separate threads ("background" or
+"worker" threads).</p>
+
+<p>For example, below is some code for a click listener that downloads an image from a separate
+thread and displays it in an {@link android.widget.ImageView}:</p>
+
+<pre>
+public void onClick(View v) {
+    new Thread(new Runnable() {
+        public void run() {
+            Bitmap b = loadImageFromNetwork("http://example.com/image.png");
+            mImageView.setImageBitmap(b);
+        }
+    }).start();
+}
+</pre>
+
+<p>At first, this seems to work fine, because it creates a new thread to handle the network
+operation. However, it violates the second rule of the single-threaded model: <em>do not access the
+Android UI toolkit from outside the UI thread</em>&mdash;this sample modifies the {@link
+android.widget.ImageView} from the worker thread instead of the UI thread. This can result in
+undefined and unexpected behavior, which can be difficult and time-consuming to track down.</p>
+
+<p>To fix this problem, Android offers several ways to access the UI thread from other
+threads. Here is a list of methods that can help:</p>
+
+<ul>
+<li>{@link android.app.Activity#runOnUiThread(java.lang.Runnable)
+Activity.runOnUiThread(Runnable)}</li>
+<li>{@link android.view.View#post(java.lang.Runnable) View.post(Runnable)}</li>
+<li>{@link android.view.View#postDelayed(java.lang.Runnable, long) View.postDelayed(Runnable,
+long)}</li>
+</ul>
+
+<p>For example, you can fix the above code by using the {@link
+android.view.View#post(java.lang.Runnable) View.post(Runnable)} method:</p>
+
+<pre>
+public void onClick(View v) {
+    new Thread(new Runnable() {
+        public void run() {
+            final Bitmap bitmap = loadImageFromNetwork("http://example.com/image.png");
+            mImageView.post(new Runnable() {
+                public void run() {
+                    mImageView.setImageBitmap(bitmap);
+                }
+            });
+        }
+    }).start();
+}
+</pre>
+
+<p>Now this implementation is thread-safe: the network operation is done from a separate thread
+while the {@link android.widget.ImageView} is manipulated from the UI thread.</p>
+
+<p>However, as the complexity of the operation grows, this kind of code can get complicated and
+difficult to maintain. To handle more complex interactions with a worker thread, you might consider
+using a {@link android.os.Handler} in your worker thread, to process messages delivered from the UI
+thread. Perhaps the best solution, though, is to extend the {@link android.os.AsyncTask} class,
+which simplifies the execution of worker thread tasks that need to interact with the UI.</p>
+
+
+<h4 id="AsyncTask">Using AsyncTask</h4>
+
+<p>{@link android.os.AsyncTask} allows you to perform asynchronous work on your user
+interface. It performs the blocking operations in a worker thread and then publishes the results on
+the UI thread, without requiring you to handle threads and/or handlers yourself.</p>
+
+<p>To use it, you must subclass {@link android.os.AsyncTask} and implement the {@link
+android.os.AsyncTask#doInBackground doInBackground()} callback method, which runs in a pool of
+background threads. To update your UI, you should implement {@link
+android.os.AsyncTask#onPostExecute onPostExecute()}, which delivers the result from {@link
+android.os.AsyncTask#doInBackground doInBackground()} and runs in the UI thread, so you can safely
+update your UI. You can then run the task by calling {@link android.os.AsyncTask#execute execute()}
+from the UI thread.</p>
+
+<p>For example, you can implement the previous example using {@link android.os.AsyncTask} this
+way:</p>
+
+<pre>
+public void onClick(View v) {
+    new DownloadImageTask().execute("http://example.com/image.png");
+}
+
+private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; {
+    /** The system calls this to perform work in a worker thread and
+      * delivers it the parameters given to AsyncTask.execute() */
+    protected Bitmap doInBackground(String... urls) {
+        return loadImageFromNetwork(urls[0]);
+    }
+    
+    /** The system calls this to perform work in the UI thread and delivers
+      * the result from doInBackground() */
+    protected void onPostExecute(Bitmap result) {
+        mImageView.setImageBitmap(result);
+    }
+}
+</pre>
+
+<p>Now the UI is safe and the code is simpler, because it separates the work into the
+part that should be done on a worker thread and the part that should be done on the UI thread.</p>
+
+<p>You should read the {@link android.os.AsyncTask} reference for a full understanding on
+how to use this class, but here is a quick overview of how it works:</p>
+
+<ul>
+<li>You can specify the type of the parameters, the progress values, and the final
+value of the task, using generics</li>
+<li>The method {@link android.os.AsyncTask#doInBackground doInBackground()} executes automatically
+on a worker thread</li>
+<li>{@link android.os.AsyncTask#onPreExecute onPreExecute()}, {@link
+android.os.AsyncTask#onPostExecute onPostExecute()}, and {@link
+android.os.AsyncTask#onProgressUpdate onProgressUpdate()} are all invoked on the UI thread</li>
+<li>The value returned by {@link android.os.AsyncTask#doInBackground doInBackground()} is sent to
+{@link android.os.AsyncTask#onPostExecute onPostExecute()}</li>
+<li>You can call {@link android.os.AsyncTask#publishProgress publishProgress()} at anytime in {@link
+android.os.AsyncTask#doInBackground doInBackground()} to execute {@link
+android.os.AsyncTask#onProgressUpdate onProgressUpdate()} on the UI thread</li>
+<li>You can cancel the task at any time, from any thread</li>
+</ul>
+
+<p class="caution"><strong>Caution:</strong> Another problem you might encounter when using a worker
+thread is unexpected restarts in your activity due to a <a
+href="{@docRoot}guide/topics/resources/runtime-changes.html">runtime configuration change</a>
+(such as when the user changes the screen orientation), which may destroy your worker thread. To
+see how you can persist your task during one of these restarts and how to properly cancel the task
+when the activity is destroyed, see the source code for the <a
+href="http://code.google.com/p/shelves/">Shelves</a> sample application.</p>
+
+
+<h3 id="ThreadSafe">Thread-safe methods</h3>
+
+<p> In some situations, the methods you implement might be called from more than one thread, and
+therefore must be written to be thread-safe. </p>
+
+<p>This is primarily true for methods that can be called remotely&mdash;such as methods in a <a
+href="{@docRoot}guide/topics/fundamentals/bound-services.html">bound service</a>. When a call on a
+method implemented in an {@link android.os.IBinder} originates in the same process in which the
+{@link android.os.IBinder IBinder} is running, the method is executed in the caller's thread.
+However, when the call originates in another process, the method is executed in a thread chosen from
+a pool of threads that the system maintains in the same process as the {@link android.os.IBinder
+IBinder} (it's not executed in the UI thread of the process).  For example, whereas a service's
+{@link android.app.Service#onBind onBind()} method would be called from the UI thread of the
+service's process, methods implemented in the object that {@link android.app.Service#onBind
+onBind()} returns (for example, a subclass that implements RPC methods) would be called from threads
+in the pool. Because a service can have more than one client, more than one pool thread can engage
+the same {@link android.os.IBinder IBinder} method at the same time.  {@link android.os.IBinder
+IBinder} methods must, therefore, be implemented to be thread-safe.</p>
+
+<p> Similarly, a content provider can receive data requests that originate in other processes.
+Although the {@link android.content.ContentResolver} and {@link android.content.ContentProvider}
+classes hide the details of how the interprocess communication is managed, {@link
+android.content.ContentProvider} methods that respond to those requests&mdash;the methods {@link
+android.content.ContentProvider#query query()}, {@link android.content.ContentProvider#insert
+insert()}, {@link android.content.ContentProvider#delete delete()}, {@link
+android.content.ContentProvider#update update()}, and {@link android.content.ContentProvider#getType
+getType()}&mdash;are called from a pool of threads in the content provider's process, not the UI
+thread for the process.  Because these methods might be called from any number of threads at the
+same time, they too must be implemented to be thread-safe. </p>
+
+
+<h2 id="IPC">Interprocess Communication</h2>
+
+<p>Android offers a mechanism for interprocess communication (IPC) using remote procedure calls
+(RPCs), in which a method is called by an activity or other application component, but executed
+remotely (in another process), with any result returned back to the
+caller. This entails decomposing a method call and its data to a level the operating system can
+understand, transmitting it from the local process and address space to the remote process and
+address space, then reassembling and reenacting the call there.  Return values are then
+transmitted in the opposite direction.  Android provides all the code to perform these IPC
+transactions, so you can focus on defining and implementing the RPC programming interface. </p>
+
+<p>To perform IPC, your application must bind to a service, using {@link
+android.content.Context#bindService bindService()}. For more information, see the <a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a> developer guide.</p>
+
+
+<h2>Beginner's Path</h2>
+
+<p>For information about how to perform work in the background for an indefinite period of time
+(without a user interface), continue with the <b><a
+href="{@docRoot}guide/topics/fundamentals/services.html">Services</a></b> document.</p>
+
diff --git a/docs/html/guide/topics/resources/menu-resource.jd b/docs/html/guide/topics/resources/menu-resource.jd
index 33c782b..d09790b 100644
--- a/docs/html/guide/topics/resources/menu-resource.jd
+++ b/docs/html/guide/topics/resources/menu-resource.jd
@@ -12,9 +12,12 @@
   </div>
 </div>
 
-<p>A menu resource defines an application menu (Options Menu, Context Menu, or Sub Menu) that
+<p>A menu resource defines an application menu (Options Menu, Context Menu, or submenu) that
 can be inflated with {@link android.view.MenuInflater}.</p>
 
+<p>For a guide to using menus, see the <a href="{@docRoot}guide/topics/ui/menus.html">Creating
+Menus</a> document.</p>
+
 <dl class="xml">
 
 <dt>file location:</dt>
@@ -110,12 +113,12 @@
 href="{@docRoot}guide/developing/tools/proguard.html">ProGuard</a> (or a similar tool),
 be sure to exclude the method you specify in this attribute from renaming, because it can break the
 functionality.</p>
-          <p>Introduced in API Level HONEYCOMB.</p></dd>
+          <p>Introduced in API Level 11.</p></dd>
 
         <dt><code>android:showAsAction</code></dt>
           <dd><em>Keyword</em>. When and how this item should appear as an action item in the Action
 Bar. A menu item can appear as an action item only when the activity includes an {@link
-android.app.ActionBar} (introduced in API Level HONEYCOMB). Valid values:
+android.app.ActionBar} (introduced in API Level 11). Valid values:
           <table>
             <tr><th>Value</th><th>Description</th></tr>
             <tr><td><code>ifRoom</code></td><td>Only place this item in the Action Bar if
@@ -131,14 +134,14 @@
           </table>
           <p>See <a href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a> for
 more information.</p>
-          <p>Introduced in API Level HONEYCOMB.</p>
+          <p>Introduced in API Level 11.</p>
         </dd>
 
         <dt><code>android:actionViewLayout</code></dt>
           <dd><em>Layout resource</em>. A layout to use as the action view.
           <p>See <a href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a> for
 more information.</p>
-          <p>Introduced in API Level HONEYCOMB.</p></dd>
+          <p>Introduced in API Level 11.</p></dd>
 
         <dt><code>android:actionViewClassName</code></dt>
           <dd><em>Class name</em>. A fully-qualified class name for the {@link android.view.View}
@@ -149,7 +152,7 @@
 href="{@docRoot}guide/developing/tools/proguard.html">ProGuard</a> (or a similar tool),
 be sure to exclude the class you specify in this attribute from renaming, because it can break the
 functionality.</p>
-          <p>Introduced in API Level HONEYCOMB.</p></dd>
+          <p>Introduced in API Level 11.</p></dd>
 
 
         <dt><code>android:alphabeticShortcut</code></dt>
@@ -277,7 +280,7 @@
 }
 </pre>
 <p class="note"><strong>Note:</strong> The {@code android:showAsAction} attribute is
-available only on Android X.X (API Level HONEYCOMB) and greater.</p>
+available only on Android 3.0 (API Level 11) and greater.</p>
 </dd> <!-- end example -->
 
 
diff --git a/docs/html/guide/topics/ui/menus.jd b/docs/html/guide/topics/ui/menus.jd
index d1c0ff8..984bf8f 100644
--- a/docs/html/guide/topics/ui/menus.jd
+++ b/docs/html/guide/topics/ui/menus.jd
@@ -7,11 +7,11 @@
 <div id="qv">
   <h2>In this document</h2>
   <ol>
-    <li><a href="#xml">Defining Menus</a></li>
+    <li><a href="#xml">Creating a Menu Resource</a></li>
     <li><a href="#Inflating">Inflating a Menu Resource</a>
     <li><a href="#options-menu">Creating an Options Menu</a>
       <ol>
-        <li><a href="#ChangingTheMenu">Changing the menu when it opens</a></li>
+        <li><a href="#ChangingTheMenu">Changing menu items at runtime</a></li>
       </ol>
     </li>
     <li><a href="#context-menu">Creating a Context Menu</a></li>
@@ -21,7 +21,7 @@
         <li><a href="#groups">Menu groups</a></li>
         <li><a href="#checkable">Checkable menu items</a></li>
         <li><a href="#shortcuts">Shortcut keys</a></li>
-        <li><a href="#intents">Intents for menu items</a></li>
+        <li><a href="#intents">Dynamically adding menu intents</a></li>
       </ol>
     </li>
   </ol>
@@ -42,52 +42,60 @@
 </div>
 </div>
 
-<p>Menus are an important part of an application that provide a familiar interface for the user
-to access application functions and settings. Android offers an easy programming interface
-for you to provide application menus in your application.</p>
+<p>Menus are an important part of an activity's user interface, which provide users a familiar
+way to perform actions. Android offers a simple framework for you to add standard
+menus to your application.</p>
 
-<p>Android provides three types of application menus:</p>
+<p>There are three types of application menus:</p>
 <dl>
   <dt><strong>Options Menu</strong></dt>
-    <dd>The primary collection of menu items for an Activity that is associated with the device MENU
-key. To provide instant access to select menu items, you can place some items in the <a
-href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>, if available.</dd>
+    <dd>The primary collection of menu items for an activity, which appears when the user touches
+the MENU button. When your application is running on Android 3.0 or later, you can provide
+quick access to select menu items by placing them directly in the <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>, as "action items."</dd>
   <dt><strong>Context Menu</strong></dt>
-    <dd>A floating list of menu items that appears when the user performs a long-press on a View.
+    <dd>A floating list of menu items that appears when the user touches and holds a view
+that's registered to provide a context menu.
 </dd>
   <dt><strong>Submenu</strong></dt>
-    <dd>A floating list of menu items that the user opens by pressing a menu item in the Options
-Menu or a context menu. A submenu item cannot support a nested submenu. </dd>
+    <dd>A floating list of menu items that appears when the user touches a menu item that contains
+a nested menu.</dd>
 </dl>
 
+<p>This document shows you how to create each type of menu, using XML to define the content of
+the menu and callback methods in your activity to respond when the user selects an item.</p>
 
 
-<h2 id="xml">Defining Menus</h2>
+
+<h2 id="xml">Creating a Menu Resource</h2>
 
 <p>Instead of instantiating a {@link android.view.Menu} in your application code, you should
 define a menu and all its items in an XML <a
 href="{@docRoot}guide/topics/resources/menu-resource.html">menu resource</a>, then inflate the menu
-resource (load it as a programmable object) in your application code. Defining your menus in XML is
-a good practice because it separates your interface design from your application code (the same as
-when you <a href="{@docRoot}guide/topics/ui/declaring-layout.html">define your Activity
-layout</a>).</p>
+resource (load it as a programmable object) in your application code. Using a menu resource to
+define your menu is a good practice because it separates the content for the menu from your
+application code. It's also easier to visualize the structure and content of a menu in XML.</p>
 
-<p>To define a menu, create an XML file inside your project's <code>res/menu/</code>
+<p>To create a menu resource, create an XML file inside your project's <code>res/menu/</code>
 directory and build the menu with the following elements:</p>
 <dl>
   <dt><code>&lt;menu></code></dt>
-    <dd>Creates a {@link android.view.Menu}, which is a container for menu items. It must be
-the root node and holds one or more of the following elements. You can also nest this element
-in an {@code &lt;item&gt;} to create a submenu.</dd>
+    <dd>Defines a {@link android.view.Menu}, which is a container for menu items. A
+<code>&lt;menu></code> element must be the root node for the file and can hold one or more
+<code>&lt;item></code> and <code>&lt;group></code> elements.</dd>
+
   <dt><code>&lt;item></code></dt>
-    <dd>Creates a {@link android.view.MenuItem}, which represents a single item in a menu.</dd>
+    <dd>Creates a {@link android.view.MenuItem}, which represents a single item in a menu. This
+element may contain a nested <code>&lt;menu></code> element in order to create a submenu.</dd>
+    
   <dt><code>&lt;group></code></dt>
     <dd>An optional, invisible container for {@code &lt;item&gt;} elements. It allows you to
-categorize menu items so they share properties such as active state and visibility. See <a
-href="#groups">Menu groups</a>.</dd>
+categorize menu items so they share properties such as active state and visibility. See the
+section about <a href="#groups">Menu groups</a>.</dd>
 </dl>
 
-<p>For example, here is a file in <code>res/menu/</code> named <code>game_menu.xml</code>:</p>
+
+<p>Here's an example menu named <code>game_menu.xml</code>:</p>
 <pre>
 &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
@@ -100,28 +108,33 @@
 &lt;/menu&gt;
 </pre>
 
-<p>This example defines a menu with two menu items. Each item includes the attributes:</p>
+<p>This example defines a menu with two items. Each item includes the attributes:</p>
 <dl>
   <dt>{@code android:id}</dt>
-    <dd>A resource ID that's unique to the item so that the application can recognize the item when
-the user selects it.</dd>
+    <dd>A resource ID that's unique to the item, which allows the application can recognize the item
+when the user selects it.</dd>
   <dt>{@code android:icon}</dt>
-    <dd>A drawable resource that is the icon visible to the user.</dd>
+    <dd>A reference to a drawable to use as the item's icon.</dd>
   <dt>{@code android:title}</dt>
-    <dd>A string resource that is the title visible to the user.</dd>
+    <dd>A reference to a string to use as the item's title.</dd>
 </dl>
 
-<p>For more about the XML syntax and attributes for a menu resource, see the <a
+<p>There are many more attributes you can include in an {@code &lt;item&gt;}, including some that
+ specify how the item may appear in the <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>. For more information about the XML
+syntax and attributes for a menu resource, see the <a
 href="{@docRoot}guide/topics/resources/menu-resource.html">Menu Resource</a> reference.</p>
 
 
+
 <h2 id="Inflating">Inflating a Menu Resource</h2>
 
-<p>You can inflate your menu resource (convert the XML resource into a programmable object) using
+<p>From your application code, you can inflate a menu resource (convert the XML resource into a
+programmable object) using
 {@link android.view.MenuInflater#inflate(int,Menu) MenuInflater.inflate()}. For
-example, the following code inflates the <code>game_menu.xml</code> file defined above during the
-{@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} callback method, to be
-used for the Options Menu:</p>
+example, the following code inflates the <code>game_menu.xml</code> file defined above, during the
+{@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} callback method, to
+use the menu as the activity's Options Menu:</p>
 
 <pre>
 &#64;Override
@@ -133,59 +146,47 @@
 </pre>
 
 <p>The {@link android.app.Activity#getMenuInflater()} method returns a {@link
-android.view.MenuInflater} for the Activity. With this object, you can call {@link
+android.view.MenuInflater} for the activity. With this object, you can call {@link
 android.view.MenuInflater#inflate(int,Menu) inflate()}, which inflates a menu resource into a
 {@link android.view.Menu} object. In this example, the menu resource defined by
 <code>game_menu.xml</code>
 is inflated into the {@link android.view.Menu} that was passed into {@link
 android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()}. (This callback method for
-creating an option menu is discussed more in the next section.)</p>
+the Options Menu is discussed more in the next section.)</p>
 
 
 
 <h2 id="options-menu">Creating an Options Menu</h2>
 
 <div class="figure" style="width:200px">
-  <img src="{@docRoot}images/options_menu.png" height="300" alt="" />
-  <p class="img-caption"><strong>Figure 1.</strong> Screenshot of an Options Menu.</p>
+  <img src="{@docRoot}images/options_menu.png" height="333" alt="" />
+  <p class="img-caption"><strong>Figure 1.</strong> Screenshot of the Options Menu in the
+Browser.</p>
 </div>
 
-
-<p>The Options Menu is where you should include basic application functions and necessary navigation
+<p>The Options Menu is where you should include basic activity actions and necessary navigation
 items (for example, a button to open the application settings). Items in the Options Menu are
-accessible in two distinct ways: in the Action Bar and in the menu revealed by the MENU
-key.</p>
+accessible in two distinct ways: the MENU button or in the <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> (on devices running Android 3.0
+or higher).</p>
 
-<p>The Action Bar is an optional widget that appears at the top of the activity in place of the
-title bar. It can display several menu items that you choose from the Options Menu, but items in
-the Action Bar display only an icon (no title text). Users can reveal the other menu items in the
-Options Menu with the MENU key.</p>
+<p>When running on a device with Android 2.3 and lower, the Options Menu appears at the bottom of
+the screen, as shown in figure 1. When opened, the first visible portion of the Options Menu is
+the icon menu. It holds the first six menu items. If you add more than six items to the
+Options Menu, Android places the sixth item and those after it into the overflow menu, which the
+user can open by touching the "More" menu item.</p>
 
-<p>If you include the Action Bar in your activity, the menu items that are not placed in the Action
-Bar can appear in two different styles:</p>
-<dl>
-  <dt>Action Bar Menu</dt>
-    <dd>If the device has an extra-large screen ({@code xlarge}), then all items in the Options Menu
-that are not placed in the Action Bar are placed into a drop-down list at the right side of the
-Action Bar, with icons and title text. The user can reveal the drop-down list by pressing the
-drop-down icon in the Action Bar or the MENU key.</dd>
-  <dt>Standard Options Menu</dt>
-    <dd>If the device <em>does not</em> have an extra-large screen, then all items in the Options
-Menu that are not placed in the Action Bar are placed into the Standard Options Menu at the bottom
-of the activity. The user can reveal the standard Options Menu by pressing the MENU key.
-    <p>The first visible portion of the Standard Options Menu is called the Icon Menu.
-It holds the first six menu items (excluding any added to the Action Bar), with icons and title
-text. If there are more than six items, Android adds a "More" item as the sixth menu item and places
-the remaining items into the Expanded Menu, which the user can open by selecting "More". The
-Expanded Menu displays menu items only by their title text (no icon)</p>
-    </dd>
-</dl>
+<p>On Android 3.0 and higher, items from the Options Menu is placed in the Action Bar, which appears
+at the top of the activity in place of the traditional title bar. By default all items from the
+Options Menu are placed in the overflow menu, which the user can open by touching the menu icon
+on the right side of the Action Bar. However, you can place select menu items directly in the
+Action Bar as "action items," for instant access, as shown in figure 2.</p>
 
-<p>When the user opens the Options Menu for the first time, Android calls your Activity's
-{@link android.app.Activity#onCreateOptionsMenu(Menu)
-onCreateOptionsMenu()} method. Override this method in your Activity
-and populate the {@link android.view.Menu} that is passed into the method. Populate the
-{@link android.view.Menu} by inflating a menu resource as described in <a
+<p>When the Android system creates the Options Menu for the first time, it calls your
+activity's {@link android.app.Activity#onCreateOptionsMenu(Menu)
+onCreateOptionsMenu()} method. Override this method in your activity
+and populate the {@link android.view.Menu} that is passed into the method,
+{@link android.view.Menu} by inflating a menu resource as described above in <a
 href="#Inflating">Inflating a Menu Resource</a>. For example:</p>
 
 <pre>
@@ -197,17 +198,31 @@
 }
 </pre>
 
-<p>(You can also populate the menu in code, using {@link android.view.Menu#add(int,int,int,int)
-add()} to add items to the {@link android.view.Menu}.)</p>
+<div class="figure" style="width:500px">
+<img src="{@docRoot}images/ui/actionbar.png" height="34" alt="" />
+<p class="img-caption"><strong>Figure 2.</strong> Screenshot of the Action Bar in the Email
+application, with two action items from the Options Menu, plus the overflow menu.</p>
+</div>
 
-<p>When the user selects a menu item from the Options Menu (including items selected from the
-Action Bar), the system calls your Activity's
+<p>You can also populate the menu in code, using {@link android.view.Menu#add(int,int,int,int)
+add()} to add items to the {@link android.view.Menu}.</p>
+
+<p class="note"><strong>Note:</strong> On Android 2.3 and lower, the system calls {@link
+android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} to create the Options Menu
+when the user opens it for the first time, but on Android 3.0 and greater, the system creates it as
+soon as the activity is created, in order to populate the Action Bar.</p>
+
+
+<h3 id="RespondingOptionsMenu">Responding to user action</h3>
+
+<p>When the user selects a menu item from the Options Menu (including action items in the
+Action Bar), the system calls your activity's
 {@link android.app.Activity#onOptionsItemSelected(MenuItem) onOptionsItemSelected()}
 method. This method passes the
 {@link android.view.MenuItem} that the user selected. You can identify the menu item by calling
 {@link android.view.MenuItem#getItemId()}, which returns the unique ID for the menu
-item (defined by the {@code android:id} attribute in the menu resource or with an integer passed
-to the {@link android.view.Menu#add(int,int,int,int) add()} method). You can match this ID
+item (defined by the {@code android:id} attribute in the menu resource or with an integer
+given to the {@link android.view.Menu#add(int,int,int,int) add()} method). You can match this ID
 against known menu items and perform the appropriate action. For example:</p>
 
 <pre>
@@ -229,45 +244,67 @@
 
 <p>In this example, {@link android.view.MenuItem#getItemId()} queries the ID for the selected menu
 item and the switch statement compares the ID against the resource IDs that were assigned to menu
-items in the XML resource. When a switch case successfully handles the item, it
-returns "true" to indicate that the item selection was handled. Otherwise, the default statement
-passes the menu item to the super class in
+items in the XML resource. When a switch case successfully handles the menu item, it
+returns {@code true} to indicate that the item selection was handled. Otherwise, the default
+statement passes the menu item to the super class, in
 case it can handle the item selected. (If you've directly extended the {@link android.app.Activity}
-class, then the super class returns "false", but it's a good practice to
-pass unhandled menu items to the super class instead of directly returning "false".)</p>
+class, then the super class returns {@code false}, but it's a good practice to
+pass unhandled menu items to the super class instead of directly returning {@code false}.)</p>
+
+<p>Additionally, Android 3.0 adds the ability for you to define the on-click behavior for a menu
+item in the <a href="{@docRoot}guide/topics/resources/menu-resource.html">menu resource</a> XML,
+using the {@code android:onClick} attribute. So you don't need to implement {@link
+android.app.Activity#onOptionsItemSelected(MenuItem) onOptionsItemSelected()}. Using the {@code
+android:onClick} attribute, you can specify a method to call when the user selects the menu item.
+Your activity must then implement the method specified in the {@code android:onClick} attribute so 
+that it accepts a single {@link android.view.MenuItem} parameter&mdash;when the system calls this
+method, it passes the menu item selected.</p>
 
 <p class="note"><strong>Tip:</strong> If your application contains multiple activities and
 some of them provide the same Options Menu, consider creating
-an Activity that implements nothing except the {@link android.app.Activity#onCreateOptionsMenu(Menu)
+an activity that implements nothing except the {@link android.app.Activity#onCreateOptionsMenu(Menu)
 onCreateOptionsMenu()} and {@link android.app.Activity#onOptionsItemSelected(MenuItem)
-onOptionsItemSelected()} methods. Then extend this class for each Activity that should share the
+onOptionsItemSelected()} methods. Then extend this class for each activity that should share the
 same Options Menu. This way, you have to manage only one set of code for handling menu
 actions and each descendant class inherits the menu behaviors.<br/><br/>
 If you want to add menu items to one of your descendant activities,
 override {@link android.app.Activity#onCreateOptionsMenu(Menu)
-onCreateOptionsMenu()} in that Activity. Call {@code super.onCreateOptionsMenu(menu)} so the
+onCreateOptionsMenu()} in that activity. Call {@code super.onCreateOptionsMenu(menu)} so the
 original menu items are created, then add new menu items with {@link
 android.view.Menu#add(int,int,int,int) menu.add()}. You can also override the super class's
 behavior for individual menu items.</p>
 
 
-<h3 id="ChangingTheMenu">Changing the menu when it opens</h3>
+<h3 id="ChangingTheMenu">Changing menu items at runtime</h3>
 
-<p>The {@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} method is
-called only the first time the Options Menu is opened. The system keeps and re-uses the {@link
-android.view.Menu} you define in this method until your Activity is destroyed. If you want to change
-the Options Menu each time it opens, you must override the
+<p>Once the activity is created, the {@link android.app.Activity#onCreateOptionsMenu(Menu)
+onCreateOptionsMenu()} method is
+called only once, as described above. The system keeps and re-uses the {@link
+android.view.Menu} you define in this method until your activity is destroyed. If you want to change
+the Options Menu any time after it's first created, you must override the
 {@link android.app.Activity#onPrepareOptionsMenu(Menu) onPrepareOptionsMenu()} method. This passes
 you the {@link android.view.Menu} object as it currently exists. This is useful if you'd like to
 remove, add, disable, or enable menu items depending on the current state of your application.</p>
 
+<p>On Android 2.3 and lower, the system calls {@link android.app.Activity#onPrepareOptionsMenu(Menu)
+onPrepareOptionsMenu()} each time the user opens the Options Menu.</p>
+
+<p>On Android 3.0 and higher, you must call {@link android.app.Activity#invalidateOptionsMenu
+invalidateOptionsMenu()} when you want to update the menu, because the menu is always open. The
+system will then call {@link android.app.Activity#onPrepareOptionsMenu(Menu) onPrepareOptionsMenu()}
+so you can update the menu items.</p>
+
 <p class="note"><strong>Note:</strong> 
 You should never change items in the Options Menu based on the {@link android.view.View} currently
-in focus. When in touch mode (when the user is not using a trackball or d-pad), Views
+in focus. When in touch mode (when the user is not using a trackball or d-pad), views
 cannot take focus, so you should never use focus as the basis for modifying
 items in the Options Menu. If you want to provide menu items that are context-sensitive to a {@link
 android.view.View}, use a <a href="#context-menu">Context Menu</a>.</p>
 
+<p>If you're developing for Android 3.0 or higher, be sure to also read <a
+href="{@docRoot}guide/topics/ui/actionbar.html">Using the Action Bar</a>.</p>
+
+
 
 
 <h2 id="context-menu">Creating a Context Menu</h2>
@@ -287,7 +324,7 @@
 <div class="sidebox-wrapper">
 <div class="sidebox">
 <h3>Register a ListView</h3>
-<p>If your Activity uses a {@link android.widget.ListView} and
+<p>If your activity uses a {@link android.widget.ListView} and
 you want all list items to provide a context menu, register all items for a context
 menu by passing the {@link android.widget.ListView} to {@link
 android.app.Activity#registerForContextMenu(View) registerForContextMenu()}. For
@@ -301,7 +338,7 @@
 pass it the {@link android.view.View} you want to give a context menu. When this View then
 receives a long-press, it displays a context menu.</p>
 
-<p>To define the context menu's appearance and behavior, override your Activity's context menu
+<p>To define the context menu's appearance and behavior, override your activity's context menu
 callback methods, {@link android.app.Activity#onCreateContextMenu(ContextMenu,View,ContextMenuInfo)
 onCreateContextMenu()} and
 {@link android.app.Activity#onContextItemSelected(MenuItem) onContextItemSelected()}.</p>
@@ -325,7 +362,7 @@
 parameters include the {@link android.view.View}
 that the user selected and a {@link android.view.ContextMenu.ContextMenuInfo} object that provides
 additional information about the item selected. You might use these parameters to determine
-which context menu should be created, but in this example, all context menus for the Activity are
+which context menu should be created, but in this example, all context menus for the activity are
 the same.</p>
 
 <p>Then when the user selects an item from the context menu, the system calls {@link
@@ -387,9 +424,9 @@
           android:icon="@drawable/file"
           android:title="@string/file" &gt;
         &lt;!-- "file" submenu --&gt;
-        &lt;menu"&gt;
-            &lt;item android:id="@+id/new"
-                  android:title="@string/new" /&gt;
+        &lt;menu&gt;
+            &lt;item android:id="@+id/create_new"
+                  android:title="@string/create_new" /&gt;
             &lt;item android:id="@+id/open"
                   android:title="@string/open" /&gt;
         &lt;/menu&gt;
@@ -456,8 +493,9 @@
 <h3 id="checkable">Checkable menu items</h3>
 
 <div class="figure" style="width:200px">
-  <img src="{@docRoot}images/radio_buttons.png" height="300" alt="" />
-  <p class="img-caption"><strong>Figure 2.</strong> Screenshot of checkable menu items</p>
+  <img src="{@docRoot}images/radio_buttons.png" height="333" alt="" />
+  <p class="img-caption"><strong>Figure 3.</strong> Screenshot of a submenu with checkable
+items.</p>
 </div>
 
 <p>A menu can be useful as an interface for turning options on and off, using a checkbox for
@@ -525,7 +563,7 @@
 
 <p>If you don't set the checked state this way, then the visible state of the item (the checkbox or
 radio button) will not
-change when the user selects it. When you do set the state, the Activity preserves the checked state
+change when the user selects it. When you do set the state, the activity preserves the checked state
 of the item so that when the user opens the menu later, the checked state that you
 set is visible.</p>
 
@@ -538,7 +576,8 @@
 
 <h3 id="shortcuts">Shortcut keys</h3>
 
-<p>You can add quick-access shortcut keys using letters and/or numbers to menu items with the
+<p>To facilitate quick access to items in the Options Menu when the user's device has a hardware
+keyboard, you can add quick-access shortcut keys using letters and/or numbers, with the
 {@code android:alphabeticShortcut} and {@code android:numericShortcut} attributes in the {@code
 &lt;item&gt;} element. You can also use the methods {@link
 android.view.MenuItem#setAlphabeticShortcut(char)} and {@link
@@ -546,57 +585,46 @@
 case sensitive.</p>
 
 <p>For example, if you apply the "s" character as an alphabetic shortcut to a "save" menu item, then
-when the menu is open (or while the user holds the MENU key) and the user presses the "s" key,
+when the menu is open (or while the user holds the MENU button) and the user presses the "s" key,
 the "save" menu item is selected.</p>
 
 <p>This shortcut key is displayed as a tip in the menu item, below the menu item name
 (except for items in the Icon Menu, which are displayed only if the user holds the MENU
-key).</p>
+button).</p>
 
 <p class="note"><strong>Note:</strong> Shortcut keys for menu items only work on devices with a
 hardware keyboard. Shortcuts cannot be added to items in a Context Menu.</p>
 
 
-<h3 id="intents">Intents for menu items</h3>
 
-<p>Sometimes you'll want a menu item to launch an Activity using an Intent (whether it's an
-Activity in your application or another application). When you know the Intent you want to use and
-have a specific menu item that should initiate the Intent, you can execute the Intent with {@link
-android.app.Activity#startActivity(Intent) startActivity()} during the appropriate on-item-selected
-callback method (such as the {@link android.app.Activity#onOptionsItemSelected(MenuItem)
-onOptionsItemSelected()} callback).</p>
+<h3 id="intents">Dynamically adding menu intents</h3>
+
+<p>Sometimes you'll want a menu item to launch an activity using an {@link android.content.Intent}
+(whether it's an activity in your application or another application). When you know the intent you
+want to use and have a specific menu item that should initiate the intent, you can execute the
+intent with {@link android.app.Activity#startActivity(Intent) startActivity()} during the
+appropriate on-item-selected callback method (such as the {@link
+android.app.Activity#onOptionsItemSelected(MenuItem) onOptionsItemSelected()} callback).</p>
 
 <p>However, if you are not certain that the user's device
-contains an application that handles the Intent, then adding a menu item that executes the
-Intent can result in a non-functioning menu item, because the Intent might not resolve to an
-Activity that accepts it. To solve this, Android lets you dynamically add menu items to your menu
-when Android finds activities on the device that handle your Intent.</p>
+contains an application that handles the intent, then adding a menu item that invokes it can result
+in a non-functioning menu item, because the intent might not resolve to an
+activity. To solve this, Android lets you dynamically add menu items to your menu
+when Android finds activities on the device that handle your intent.</p>
 
-<p>If you're not familiar with creating Intents, read the <a
-href="/guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>.</p>
-
-
-<h4>Dynamically adding Intents</h4>
-
-<p>When you don't know if the user's device has an application that handles a specific Intent,
-you can define the Intent and let Android search the device for activities that accept the Intent.
-When it finds activies that handle the Intent, it adds a menu item for
-each one to your menu and attaches the appropriate Intent to open the Activity when the user
-selects it.</p>
-
-<p>To add menu items based on available activities that accept an Intent:</p>
+<p>To add menu items based on available activities that accept an intent:</p>
 <ol>
   <li>Define an
-Intent with the category {@link android.content.Intent#CATEGORY_ALTERNATIVE} and/or
+intent with the category {@link android.content.Intent#CATEGORY_ALTERNATIVE} and/or
 {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE}, plus any other requirements.</li>
   <li>Call {@link
 android.view.Menu#addIntentOptions(int,int,int,ComponentName,Intent[],Intent,int,MenuItem[])
-Menu.addIntentOptions()}. Android then searches for any applications that can perform the Intent
+Menu.addIntentOptions()}. Android then searches for any applications that can perform the intent
 and adds them to your menu.</li>
 </ol>
 
 <p>If there are no applications installed
-that satisfy the Intent, then no menu items are added.</p>
+that satisfy the intent, then no menu items are added.</p>
 
 <p class="note"><strong>Note:</strong>
 {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE} is used to handle the currently
@@ -621,7 +649,7 @@
          R.id.intent_group,  // Menu group to which new items will be added
          0,      // Unique item ID (none)
          0,      // Order for the items (none)
-         this.getComponentName(),   // The current Activity name
+         this.getComponentName(),   // The current activity name
          null,   // Specific items to place first (none)
          intent, // Intent created above that describes our requirements
          0,      // Additional flags to control items (none)
@@ -630,8 +658,8 @@
     return true;
 }</pre>
 
-<p>For each Activity found that provides an Intent filter matching the Intent defined, a menu
-item is added, using the value in the Intent filter's <code>android:label</code> as the
+<p>For each activity found that provides an intent filter matching the intent defined, a menu
+item is added, using the value in the intent filter's <code>android:label</code> as the
 menu item title and the application icon as the menu item icon. The
 {@link android.view.Menu#addIntentOptions(int,int,int,ComponentName,Intent[],Intent,int,MenuItem[])
 addIntentOptions()} method returns the number of menu items added.</p>
@@ -642,14 +670,14 @@
 argument.</p>
 
 
-<h4>Allowing your Activity to be added to menus</h4>
+<h4>Allowing your activity to be added to other menus</h4>
 
-<p>You can also offer the services of your Activity to other applications, so your
+<p>You can also offer the services of your activity to other applications, so your
 application can be included in the menu of others (reverse the roles described above).</p>
 
-<p>To be included in other application menus, you need to define an Intent
+<p>To be included in other application menus, you need to define an intent
 filter as usual, but be sure to include the {@link android.content.Intent#CATEGORY_ALTERNATIVE}
-and/or {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE} values for the Intent filter
+and/or {@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE} values for the intent filter
 category. For example:</p>
 <pre>
 &lt;intent-filter label="Resize Image">
@@ -660,7 +688,7 @@
 &lt;/intent-filter>
 </pre>
 
-<p>Read more about writing Intent filters in the
+<p>Read more about writing intent filters in the
 <a href="/guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> document.</p>
 
 <p>For a sample application using this technique, see the 
diff --git a/docs/html/images/options_menu.png b/docs/html/images/options_menu.png
index ecb9394..6c49906 100755
--- a/docs/html/images/options_menu.png
+++ b/docs/html/images/options_menu.png
Binary files differ
diff --git a/docs/html/images/radio_buttons.png b/docs/html/images/radio_buttons.png
index b755e42..415ccca 100755
--- a/docs/html/images/radio_buttons.png
+++ b/docs/html/images/radio_buttons.png
Binary files differ
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index 595ad4e..bd70319 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -150,6 +150,10 @@
                 break;
             case SkRegion::kIntersect_Op:
                 clipped = clipRect->intersect(r);
+                if (!clipped) {
+                    clipRect->setEmpty();
+                    clipped = true;
+                }
                 break;
             case SkRegion::kUnion_Op:
                 clipped = clipRect->unionWith(r);
diff --git a/media/jni/mediaeditor/VideoBrowserMain.c b/media/jni/mediaeditor/VideoBrowserMain.c
index f54a16e..bb13fba 100755
--- a/media/jni/mediaeditor/VideoBrowserMain.c
+++ b/media/jni/mediaeditor/VideoBrowserMain.c
@@ -246,9 +246,13 @@
                     pContext->m_pCodecLoaderContext = M4OSA_NULL;
                     decoderType = M4DECODER_kVideoTypeMPEG4;
 
-                    err = VideoEditorVideoDecoder_getInterface_MPEG4(
-                        &decoderType, &pContext->m_pDecoder);
-
+#ifdef USE_SOFTWARE_DECODER
+                        err = VideoEditorVideoDecoder_getSoftwareInterface_MPEG4(
+                            &decoderType, &pContext->m_pDecoder);
+#else
+                        err = VideoEditorVideoDecoder_getInterface_MPEG4(
+                            &decoderType, &pContext->m_pDecoder);
+#endif
                     CHECK_ERR(videoBrowserCreate, err) ;
 
                     err = pContext->m_pDecoder->m_pFctCreate(
@@ -267,8 +271,14 @@
                     pContext->m_pCodecLoaderContext = M4OSA_NULL;
 
                     decoderType = M4DECODER_kVideoTypeAVC;
-                    err = VideoEditorVideoDecoder_getInterface_H264(
-                        &decoderType, &pContext->m_pDecoder);
+
+#ifdef USE_SOFTWARE_DECODER
+                        err = VideoEditorVideoDecoder_getSoftwareInterface_H264(
+                            &decoderType, &pContext->m_pDecoder);
+#else
+                        err = VideoEditorVideoDecoder_getInterface_H264(
+                            &decoderType, &pContext->m_pDecoder);
+#endif
                    CHECK_ERR(videoBrowserCreate, err) ;
 
                     err = pContext->m_pDecoder->m_pFctCreate(
diff --git a/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml b/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml
index 00b951e..7ba493d 100644
--- a/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml
+++ b/packages/SystemUI/res/values-es-rUS-xlarge/strings.xml
@@ -22,4 +22,10 @@
     <string name="status_bar_clear_all_button" msgid="4722520806446512408">"Eliminar todos"</string>
     <string name="status_bar_settings_signal_meter_disconnected" msgid="4684094636492991496">"Sin conexión a Int."</string>
     <string name="status_bar_settings_signal_meter_wifi_nossid" msgid="1456658018593445677">"WiFi conectado"</string>
+
+    <!-- manually translated -->
+    <string name="gps_notification_searching_text">Buscando señal de GPS</string>
+
+    <!-- manually translated -->
+    <string name="gps_notification_found_text">Ubicación establecida por el GPS</string>
 </resources>
diff --git a/packages/SystemUI/res/values-xlarge/colors.xml b/packages/SystemUI/res/values-xlarge/colors.xml
index 1fd396d..a7a70c3 100644
--- a/packages/SystemUI/res/values-xlarge/colors.xml
+++ b/packages/SystemUI/res/values-xlarge/colors.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <drawable name="status_bar_background">#000000</drawable>
-    <drawable name="notification_icon_area_smoke">#CC000000</drawable>
+    <drawable name="notification_icon_area_smoke">#aa000000</drawable>
 </resources>
 
diff --git a/packages/SystemUI/res/values-xlarge/strings.xml b/packages/SystemUI/res/values-xlarge/strings.xml
index f7b642d..dfd5851 100644
--- a/packages/SystemUI/res/values-xlarge/strings.xml
+++ b/packages/SystemUI/res/values-xlarge/strings.xml
@@ -38,4 +38,9 @@
     <!-- Separator for PLMN and SPN in network name. -->
     <string name="status_bar_network_name_separator" translatable="false">" – "</string>
 
+    <!-- Notification text: when GPS is getting a fix [CHAR LIMIT=50] -->
+    <string name="gps_notification_searching_text">Searching for GPS</string>
+
+    <!-- Notification text: when GPS has found a fix [CHAR LIMIT=50] -->
+    <string name="gps_notification_found_text">Location set by GPS</string>
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java
new file mode 100644
index 0000000..bb326fe
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.policy;
+
+import java.util.ArrayList;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.location.LocationManager;
+import android.provider.Settings;
+import android.util.Slog;
+import android.view.View;
+import android.widget.ImageView;
+
+// private NM API
+import android.app.INotificationManager;
+import com.android.internal.statusbar.StatusBarNotification;
+
+import com.android.systemui.R;
+
+public class LocationController extends BroadcastReceiver {
+    private static final String TAG = "StatusBar.LocationController";
+
+    private static final int GPS_NOTIFICATION_ID = 374203-122084;
+
+    private Context mContext;
+
+    private INotificationManager mNotificationService;
+
+    public LocationController(Context context) {
+        mContext = context;
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(LocationManager.GPS_ENABLED_CHANGE_ACTION);
+        filter.addAction(LocationManager.GPS_FIX_CHANGE_ACTION);
+        context.registerReceiver(this, filter);
+
+        NotificationManager nm = (NotificationManager)context.getSystemService(
+                Context.NOTIFICATION_SERVICE);
+        mNotificationService = nm.getService();
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        final String action = intent.getAction();
+        final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false);
+
+        boolean visible;
+        int iconId, textResId;
+
+        if (action.equals(LocationManager.GPS_FIX_CHANGE_ACTION) && enabled) {
+            // GPS is getting fixes
+            iconId = com.android.internal.R.drawable.stat_sys_gps_on;
+            textResId = R.string.gps_notification_found_text;
+            visible = true;
+        } else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) && !enabled) {
+            // GPS is off
+            visible = false;
+            iconId = textResId = 0;
+        } else {
+            // GPS is on, but not receiving fixes
+            iconId = R.drawable.stat_sys_gps_acquiring_anim;
+            textResId = R.string.gps_notification_searching_text;
+            visible = true;
+        }
+        
+        try {
+            if (visible) {
+                Intent gpsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+                gpsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, gpsIntent, 0);
+
+                Notification n = new Notification.Builder(mContext)
+                    .setSmallIcon(iconId)
+                    .setContentTitle(mContext.getText(textResId))
+                    .setOngoing(true)
+                    .setContentIntent(pendingIntent)
+                    .getNotification();
+
+                // Notification.Builder will helpfully fill these out for you no matter what you do
+                n.tickerView = null;
+                n.tickerText = null;
+
+                int[] idOut = new int[1];
+                mNotificationService.enqueueNotificationWithTagPriority(
+                        mContext.getPackageName(),
+                        null, 
+                        GPS_NOTIFICATION_ID, 
+                        StatusBarNotification.PRIORITY_SYSTEM, // !!!1!one!!!
+                        n,
+                        idOut);
+            } else {
+                mNotificationService.cancelNotification(
+                        mContext.getPackageName(),
+                        GPS_NOTIFICATION_ID);
+            }
+        } catch (android.os.RemoteException ex) {
+            // well, it was worth a shot
+        }
+    }
+}
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 4bac07f..7a13fde 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -65,6 +65,7 @@
 import com.android.systemui.statusbar.*;
 import com.android.systemui.statusbar.policy.BatteryController;
 import com.android.systemui.statusbar.policy.BluetoothController;
+import com.android.systemui.statusbar.policy.LocationController;
 import com.android.systemui.statusbar.policy.NetworkController;
 import com.android.systemui.recent.RecentApplicationsActivity;
 
@@ -135,6 +136,7 @@
     HeightReceiver mHeightReceiver;
     BatteryController mBatteryController;
     BluetoothController mBluetoothController;
+    LocationController mLocationController;
     NetworkController mNetworkController;
 
     View mBarContents;
@@ -359,6 +361,8 @@
         mTicker = new TabletTicker(this);
 
         // The icons
+        mLocationController = new LocationController(mContext); // will post a notification
+
         mBatteryController = new BatteryController(mContext);
         mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery));
         mBluetoothController = new BluetoothController(mContext);
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 0490190..47dce41 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -156,10 +156,11 @@
         final int id;
         final int uid;
         final int initialPid;
+        final int priority;
         final Notification notification;
         IBinder statusBarKey;
 
-        NotificationRecord(String pkg, String tag, int id, int uid, int initialPid,
+        NotificationRecord(String pkg, String tag, int id, int uid, int initialPid, int priority,
                 Notification notification)
         {
             this.pkg = pkg;
@@ -167,6 +168,7 @@
             this.id = id;
             this.uid = uid;
             this.initialPid = initialPid;
+            this.priority = priority;
             this.notification = notification;
         }
 
@@ -194,7 +196,9 @@
                 + Integer.toHexString(System.identityHashCode(this))
                 + " pkg=" + pkg
                 + " id=" + Integer.toHexString(id)
-                + " tag=" + tag + "}";
+                + " tag=" + tag 
+                + " pri=" + priority 
+                + "}";
         }
     }
 
@@ -649,11 +653,27 @@
                 tag, id, notification, idOut);
     }
 
+    public void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority,
+            Notification notification, int[] idOut)
+    {
+        enqueueNotificationInternal(pkg, Binder.getCallingUid(), Binder.getCallingPid(),
+                tag, id, priority, notification, idOut);
+    }
+
     // Not exposed via Binder; for system use only (otherwise malicious apps could spoof the
     // uid/pid of another application)
     public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,
             String tag, int id, Notification notification, int[] idOut)
     {
+        enqueueNotificationInternal(pkg, callingUid, callingPid, tag, id, 
+                ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0)
+                    ? StatusBarNotification.PRIORITY_ONGOING
+                    : StatusBarNotification.PRIORITY_NORMAL,
+                notification, idOut);
+    }
+    public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,
+            String tag, int id, int priority, Notification notification, int[] idOut)
+    {
         checkIncomingCall(pkg);
 
         // Limit the number of notifications that any given package except the android
@@ -695,8 +715,10 @@
         }
 
         synchronized (mNotificationList) {
-            NotificationRecord r = new NotificationRecord(pkg, tag, id,
-                    callingUid, callingPid, notification);
+            NotificationRecord r = new NotificationRecord(pkg, tag, id, 
+                    callingUid, callingPid, 
+                    priority,
+                    notification);
             NotificationRecord old = null;
 
             int index = indexOfNotificationLocked(pkg, tag, id);
@@ -722,6 +744,8 @@
             if (notification.icon != 0) {
                 StatusBarNotification n = new StatusBarNotification(pkg, id, tag,
                         r.uid, r.initialPid, notification);
+                n.priority = r.priority;
+
                 if (old != null && old.statusBarKey != null) {
                     r.statusBarKey = old.statusBarKey;
                     long identity = Binder.clearCallingIdentity();
@@ -743,6 +767,7 @@
                 }
                 sendAccessibilityEvent(notification, pkg);
             } else {
+                Slog.e(TAG, "Ignoring notification with icon==0: " + notification);
                 if (old != null && old.statusBarKey != null) {
                     long identity = Binder.clearCallingIdentity();
                     try {
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 3535809..f72de127 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -32,6 +32,15 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        
+        <activity
+                android:name="MarqueeActivity"
+                android:label="_Marquee">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
 
         <activity
                 android:name="ShapesActivity"
diff --git a/tests/HwAccelerationTest/res/anim/accelerate_interpolator_2.xml b/tests/HwAccelerationTest/res/anim/accelerate_interpolator_2.xml
new file mode 100644
index 0000000..e4a8d48
--- /dev/null
+++ b/tests/HwAccelerationTest/res/anim/accelerate_interpolator_2.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<accelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+    android:factor="2.0"/>
diff --git a/tests/HwAccelerationTest/res/anim/slide_off_left.xml b/tests/HwAccelerationTest/res/anim/slide_off_left.xml
new file mode 100644
index 0000000..f05de39
--- /dev/null
+++ b/tests/HwAccelerationTest/res/anim/slide_off_left.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fromXDelta="0%"
+    android:toXDelta="-100%"
+    android:interpolator="@anim/accelerate_interpolator_2"
+    android:duration="600"/>
\ No newline at end of file
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/MarqueeActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/MarqueeActivity.java
new file mode 100644
index 0000000..715cdbb
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/MarqueeActivity.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class MarqueeActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final LinearLayout linearLayout = new LinearLayout(this);
+        linearLayout.setOrientation(LinearLayout.VERTICAL);
+        
+        final TextView text1 = new TextView(this);
+        text1.setText("This is a marquee inside a TextView");
+        text1.setSingleLine(true);
+        text1.setHorizontalFadingEdgeEnabled(true);
+        text1.setEllipsize(TextUtils.TruncateAt.MARQUEE);
+        linearLayout.addView(text1, new LinearLayout.LayoutParams(
+                100, LinearLayout.LayoutParams.WRAP_CONTENT));
+
+        final TextView text2 = new TextView(this);
+        text2.setText("This is a marquee inside a TextView");
+        text2.setSingleLine(true);
+        text2.setHorizontalFadingEdgeEnabled(true);
+        text2.setEllipsize(TextUtils.TruncateAt.MARQUEE);
+        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+                100, LinearLayout.LayoutParams.WRAP_CONTENT);
+        linearLayout.addView(text2, params);
+
+        setContentView(linearLayout);
+        
+        getWindow().getDecorView().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                text2.setVisibility(View.INVISIBLE);
+                Animation animation = AnimationUtils.loadAnimation(text2.getContext(),
+                        R.anim.slide_off_left);
+                animation.setFillEnabled(true);
+                animation.setFillAfter(true);
+                text2.startAnimation(animation);
+            }
+        }, 1000);
+    }
+}
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
index 90c2a1a..f463a19 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
@@ -35,6 +35,10 @@
 import android.widget.ProgressBar;
 import android.os.PowerManager;
 
+// private NM API
+import android.app.INotificationManager;
+import com.android.internal.statusbar.StatusBarNotification;
+
 public class NotificationTestList extends TestActivity
 {
     private final static String TAG = "NotificationTestList";
@@ -205,6 +209,15 @@
             }
         },
 
+        new Test("Null Icon #1 (when=now)") {
+            public void run() {
+                Notification n = new Notification(0, null, System.currentTimeMillis());
+                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+                            "This is the same notification!!!", makeIntent());
+                mNM.notify(1, n);
+            }
+        },
+
         new Test("Bad resource #1 (when=create)") {
             public void run() {
                 Notification n = new Notification(R.drawable.icon2,
@@ -752,6 +765,30 @@
             }
         },
 
+        new Test("System priority notification") {
+            public void run() {
+                Notification n = new Notification.Builder(NotificationTestList.this)
+                    .setSmallIcon(R.drawable.notification1)
+                    .setContentTitle("System priority")
+                    .setContentText("This should appear before all others")
+                    .getNotification();
+
+                int[] idOut = new int[1];
+                try {
+                    INotificationManager directLine = mNM.getService();
+                    directLine.enqueueNotificationWithTagPriority(
+                            getPackageName(),
+                            null, 
+                            1, 
+                            StatusBarNotification.PRIORITY_SYSTEM,
+                            n,
+                            idOut);
+                } catch (android.os.RemoteException ex) {
+                    // oh well
+                }
+            }
+        },
+
         new Test("Crash") {
             public void run()
             {
diff --git a/tools/layoutlib/bridge/Android.mk b/tools/layoutlib/bridge/Android.mk
index 3d4c76a..ca7db8c 100644
--- a/tools/layoutlib/bridge/Android.mk
+++ b/tools/layoutlib/bridge/Android.mk
@@ -17,6 +17,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
+LOCAL_JAVA_RESOURCE_DIRS := resources
+
 
 LOCAL_JAVA_LIBRARIES := \
 	kxml2-2.3.0 \
diff --git a/tools/layoutlib/bridge/resources/bars/action_bar.xml b/tools/layoutlib/bridge/resources/bars/action_bar.xml
new file mode 100644
index 0000000..cd99a09
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/action_bar.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+	<ImageView
+			android:layout_height="wrap_content"
+			android:layout_width="wrap_content"
+			android:layout_gravity="center"/>
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:layout_gravity="center"/>
+</merge>
diff --git a/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_back_default.png b/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_back_default.png
new file mode 100644
index 0000000..4bcd2be
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_back_default.png
Binary files differ
diff --git a/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_home_default.png b/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_home_default.png
new file mode 100644
index 0000000..cfeba3e
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_home_default.png
Binary files differ
diff --git a/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_recent_default.png b/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_recent_default.png
new file mode 100644
index 0000000..1d97e05
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_recent_default.png
Binary files differ
diff --git a/tools/layoutlib/bridge/resources/bars/mdpi/stat_sys_wifi_signal_4_fully.png b/tools/layoutlib/bridge/resources/bars/mdpi/stat_sys_wifi_signal_4_fully.png
new file mode 100644
index 0000000..c629387
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/mdpi/stat_sys_wifi_signal_4_fully.png
Binary files differ
diff --git a/tools/layoutlib/bridge/resources/bars/phone_system_bar.xml b/tools/layoutlib/bridge/resources/bars/phone_system_bar.xml
new file mode 100644
index 0000000..29df909
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/phone_system_bar.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:layout_weight="1"
+			android:text=" "/>
+	<ImageView
+			android:layout_height="wrap_content"
+			android:layout_width="wrap_content"
+			android:layout_gravity="center"/>
+</merge>
diff --git a/tools/layoutlib/bridge/resources/bars/tablet_system_bar.xml b/tools/layoutlib/bridge/resources/bars/tablet_system_bar.xml
new file mode 100644
index 0000000..8a3b87a
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/tablet_system_bar.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+	<ImageView
+			android:layout_height="wrap_content"
+			android:layout_width="wrap_content"/>
+	<ImageView
+			android:layout_height="wrap_content"
+			android:layout_width="wrap_content"/>
+	<ImageView
+			android:layout_height="wrap_content"
+			android:layout_width="wrap_content"/>
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:layout_weight="1"/>
+	<ImageView
+			android:layout_height="wrap_content"
+			android:layout_width="wrap_content"
+			android:layout_gravity="center"/>
+</merge>
diff --git a/tools/layoutlib/bridge/resources/bars/title_bar.xml b/tools/layoutlib/bridge/resources/bars/title_bar.xml
new file mode 100644
index 0000000..29fcc4b
--- /dev/null
+++ b/tools/layoutlib/bridge/resources/bars/title_bar.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:layout_gravity="center"/>
+</merge>
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
index 993c305..ee60eb4 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
@@ -18,6 +18,9 @@
 
 import com.android.ide.common.rendering.api.LayoutLog;
 import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.android.BridgeResources.NinePatchInputStream;
+import com.android.ninepatch.NinePatch;
+import com.android.ninepatch.NinePatchChunk;
 import com.android.resources.Density;
 
 import android.content.res.AssetManager;
@@ -438,6 +441,8 @@
             return null;
         }
 
+        boolean isNinePatch = is instanceof NinePatchInputStream;
+
         // we need mark/reset to work properly
 
         if (!is.markSupported()) {
@@ -466,7 +471,29 @@
                 if (opts != null) {
                     density = Density.getEnum(opts.inDensity);
                 }
-                bm = Bitmap_Delegate.createBitmap(is, true, density);
+
+                if (isNinePatch) {
+                    // load the bitmap as a nine patch
+                    NinePatch ninePatch = NinePatch.load(is, true /*is9Patch*/, false /*convert*/);
+
+                    // get the bitmap and chunk objects.
+                    bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), true /*isMutable*/,
+                            density);
+                    NinePatchChunk chunk = ninePatch.getChunk();
+
+                    // put the chunk in the bitmap
+                    bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
+
+                    // read the padding
+                    int[] padding = chunk.getPadding();
+                    outPadding.left = padding[0];
+                    outPadding.top = padding[1];
+                    outPadding.right = padding[2];
+                    outPadding.bottom = padding[3];
+                } else {
+                    // load the bitmap directly.
+                    bm = Bitmap_Delegate.createBitmap(is, true, density);
+                }
             } catch (IOException e) {
                 return null;
             }
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 93c81d1..65f6bed 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -21,7 +21,7 @@
 
 import com.android.ide.common.rendering.api.Capability;
 import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.ide.common.rendering.api.Params;
+import com.android.ide.common.rendering.api.RenderParams;
 import com.android.ide.common.rendering.api.RenderSession;
 import com.android.ide.common.rendering.api.Result;
 import com.android.layoutlib.bridge.android.BridgeAssetManager;
@@ -293,15 +293,15 @@
 
     /**
      * Starts a layout session by inflating and rendering it. The method returns a
-     * {@link ILayoutScene} on which further actions can be taken.
+     * {@link RenderSession} on which further actions can be taken.
      *
-     * @param params the {@link SceneParams} object with all the information necessary to create
+     * @param params the {@link RenderParams} object with all the information necessary to create
      *           the scene.
-     * @return a new {@link ILayoutScene} object that contains the result of the layout.
+     * @return a new {@link RenderSession} object that contains the result of the layout.
      * @since 5
      */
     @Override
-    public RenderSession createSession(Params params) {
+    public RenderSession createSession(RenderParams params) {
         try {
             Result lastResult = SUCCESS.createResult();
             RenderSessionImpl scene = new RenderSessionImpl(params);
@@ -331,10 +331,6 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see com.android.layoutlib.api.ILayoutLibBridge#clearCaches(java.lang.Object)
-     */
     @Override
     public void clearCaches(Object projectKey) {
         if (projectKey != null) {
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 0c6fa20..765fd99 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -18,7 +18,7 @@
 
 import com.android.ide.common.rendering.api.IAnimationListener;
 import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.Params;
+import com.android.ide.common.rendering.api.RenderParams;
 import com.android.ide.common.rendering.api.RenderSession;
 import com.android.ide.common.rendering.api.Result;
 import com.android.ide.common.rendering.api.ViewInfo;
@@ -128,7 +128,7 @@
             boolean isFrameworkAnimation, IAnimationListener listener) {
         try {
             Bridge.prepareThread();
-            mLastResult = mSession.acquire(Params.DEFAULT_TIMEOUT);
+            mLastResult = mSession.acquire(RenderParams.DEFAULT_TIMEOUT);
             if (mLastResult.isSuccess()) {
                 mLastResult = mSession.animate(targetObject, animationName, isFrameworkAnimation,
                         listener);
@@ -150,7 +150,7 @@
 
         try {
             Bridge.prepareThread();
-            mLastResult = mSession.acquire(Params.DEFAULT_TIMEOUT);
+            mLastResult = mSession.acquire(RenderParams.DEFAULT_TIMEOUT);
             if (mLastResult.isSuccess()) {
                 mLastResult = mSession.insertChild((ViewGroup) parentView, childXml, index,
                         listener);
@@ -176,7 +176,7 @@
 
         try {
             Bridge.prepareThread();
-            mLastResult = mSession.acquire(Params.DEFAULT_TIMEOUT);
+            mLastResult = mSession.acquire(RenderParams.DEFAULT_TIMEOUT);
             if (mLastResult.isSuccess()) {
                 mLastResult = mSession.moveChild((ViewGroup) parentView, (View) childView, index,
                         layoutParams, listener);
@@ -197,7 +197,7 @@
 
         try {
             Bridge.prepareThread();
-            mLastResult = mSession.acquire(Params.DEFAULT_TIMEOUT);
+            mLastResult = mSession.acquire(RenderParams.DEFAULT_TIMEOUT);
             if (mLastResult.isSuccess()) {
                 mLastResult = mSession.removeChild((View) childView, listener);
             }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
index 5ea0a8df..d31fcc8 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
@@ -22,6 +22,7 @@
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.BridgeConstants;
 import com.android.layoutlib.bridge.impl.ResourceHelper;
+import com.android.ninepatch.NinePatch;
 import com.android.resources.ResourceType;
 import com.android.util.Pair;
 
@@ -58,6 +59,18 @@
     private boolean[] mPlatformResourceFlag = new boolean[1];
 
     /**
+     * Simpler wrapper around FileInputStream. This is used when the input stream represent
+     * not a normal bitmap but a nine patch.
+     * This is useful when the InputStream is created in a method but used in another that needs
+     * to know whether this is 9-patch or not, such as BitmapFactory.
+     */
+    public class NinePatchInputStream extends FileInputStream {
+        public NinePatchInputStream(File file) throws FileNotFoundException {
+            super(file);
+        }
+    }
+
+    /**
      * This initializes the static field {@link Resources#mSystem} which is used
      * by methods who get global resources using {@link Resources#getSystem()}.
      * <p/>
@@ -129,7 +142,7 @@
         ResourceValue value = getResourceValue(id, mPlatformResourceFlag);
 
         if (value != null) {
-            return ResourceHelper.getDrawable(value, mContext, value.isFramework());
+            return ResourceHelper.getDrawable(value, mContext);
         }
 
         // id was not found or not resolved. Throw a NotFoundException.
@@ -165,44 +178,9 @@
         ResourceValue resValue = getResourceValue(id, mPlatformResourceFlag);
 
         if (resValue != null) {
-            String value = resValue.getValue();
-            if (value != null) {
-                // first check if the value is a file (xml most likely)
-                File f = new File(value);
-                if (f.isFile()) {
-                    try {
-                        // let the framework inflate the ColorStateList from the XML file, by
-                        // providing an XmlPullParser
-                        KXmlParser parser = new KXmlParser();
-                        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
-                        parser.setInput(new FileReader(f));
-
-                        return ColorStateList.createFromXml(this,
-                                new BridgeXmlBlockParser(parser, mContext, resValue.isFramework()));
-                    } catch (XmlPullParserException e) {
-                        Bridge.getLog().error(LayoutLog.TAG_BROKEN,
-                                "Failed to configure parser for " + value, e, null /*data*/);
-                        // we'll return null below.
-                    } catch (Exception e) {
-                        // this is an error and not warning since the file existence is
-                        // checked before attempting to parse it.
-                        Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ,
-                                "Failed to parse file " + value, e, null /*data*/);
-
-                        return null;
-                    }
-                } else {
-                    // try to load the color state list from an int
-                    try {
-                        int color = ResourceHelper.getColor(value);
-                        return ColorStateList.valueOf(color);
-                    } catch (NumberFormatException e) {
-                        Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT,
-                                "Failed to convert " + value + " into a ColorStateList", e,
-                                null /*data*/);
-                        return null;
-                    }
-                }
+            ColorStateList stateList = ResourceHelper.getColorStateList(resValue, mContext);
+            if (stateList != null) {
+                return stateList;
             }
         }
 
@@ -562,13 +540,19 @@
         ResourceValue value = getResourceValue(id, mPlatformResourceFlag);
 
         if (value != null) {
-            String v = value.getValue();
+            String path = value.getValue();
 
-            if (v != null) {
+            if (path != null) {
                 // check this is a file
-                File f = new File(value.getValue());
+                File f = new File(path);
                 if (f.isFile()) {
                     try {
+                        // if it's a nine-patch return a custom input stream so that
+                        // other methods (mainly bitmap factory) can detect it's a 9-patch
+                        // and actually load it as a 9-patch instead of a normal bitmap
+                        if (path.toLowerCase().endsWith(NinePatch.EXTENSION_9PATCH)) {
+                            return new NinePatchInputStream(f);
+                        }
                         return new FileInputStream(f);
                     } catch (FileNotFoundException e) {
                         NotFoundException newE = new NotFoundException();
@@ -590,9 +574,17 @@
     public InputStream openRawResource(int id, TypedValue value) throws NotFoundException {
         getValue(id, value, true);
 
-        File f = new File(value.string.toString());
+        String path = value.string.toString();
+
+        File f = new File(path);
         if (f.isFile()) {
             try {
+                // if it's a nine-patch return a custom input stream so that
+                // other methods (mainly bitmap factory) can detect it's a 9-patch
+                // and actually load it as a 9-patch instead of a normal bitmap
+                if (path.toLowerCase().endsWith(NinePatch.EXTENSION_9PATCH)) {
+                    return new NinePatchInputStream(f);
+                }
                 return new FileInputStream(f);
             } catch (FileNotFoundException e) {
                 NotFoundException exception = new NotFoundException();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
index cf2c0ff..c226b8b 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
@@ -690,7 +690,7 @@
             return null;
         }
 
-        return ResourceHelper.getDrawable(value, mContext, mResourceData[index].isFramework());
+        return ResourceHelper.getDrawable(value, mContext);
     }
 
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
new file mode 100644
index 0000000..f039994
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.bars;
+
+import com.android.ide.common.rendering.api.RenderResources;
+import com.android.ide.common.rendering.api.ResourceValue;
+import com.android.ide.common.rendering.api.StyleResourceValue;
+import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
+import com.android.layoutlib.bridge.impl.ResourceHelper;
+import com.android.resources.Density;
+
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap_Delegate;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Base "bar" class for the window decor around the the edited layout.
+ * This is basically an horizontal layout that loads a given layout on creation (it is read
+ * through {@link Class#getResourceAsStream(String)}).
+ *
+ * The given layout should be a merge layout so that all the children belong to this class directly.
+ *
+ * It also provides a few utility methods to configure the content of the layout.
+ */
+abstract class CustomBar extends LinearLayout {
+
+    protected abstract TextView getStyleableTextView();
+
+    protected CustomBar(Context context, Density density, String layoutPath)
+            throws XmlPullParserException {
+        super(context);
+        setOrientation(LinearLayout.HORIZONTAL);
+        setBackgroundColor(0xFF000000);
+
+        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+
+        KXmlParser parser = new KXmlParser();
+        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+        parser.setInput(
+                getClass().getResourceAsStream(layoutPath),
+                "UTF8");
+
+        BridgeXmlBlockParser bridgeParser = new BridgeXmlBlockParser(
+                parser, (BridgeContext) context, false);
+
+        inflater.inflate(bridgeParser, this, true);
+    }
+
+    protected void loadIcon(int index, String iconName, Density density) {
+        View child = getChildAt(index);
+        if (child instanceof ImageView) {
+            ImageView imageView = (ImageView) child;
+
+            // bitmap url relative to this class
+            String path = "/bars/" + density.getResourceValue() + "/" + iconName;
+
+            // create a bitmap
+            Bitmap bitmap = Bridge.getCachedBitmap(path, true /*isFramework*/);
+
+            if (bitmap == null) {
+                InputStream stream = getClass().getResourceAsStream(path);
+
+                if (stream != null) {
+                    try {
+                        bitmap = Bitmap_Delegate.createBitmap(stream, false /*isMutable*/, density);
+                        Bridge.setCachedBitmap(path, bitmap, true /*isFramework*/);
+                    } catch (IOException e) {
+                        return;
+                    }
+                }
+            }
+
+            if (bitmap != null) {
+                BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(), bitmap);
+                imageView.setBackgroundDrawable(drawable);
+            }
+        }
+    }
+
+    protected void loadIcon(int index, String iconReference) {
+        ResourceValue value = getResourceValue(iconReference);
+        if (value != null) {
+            View child = getChildAt(index);
+            if (child instanceof ImageView) {
+                ImageView imageView = (ImageView) child;
+
+                Drawable drawable = ResourceHelper.getDrawable(
+                        value, (BridgeContext) mContext);
+                if (drawable != null) {
+                    imageView.setBackgroundDrawable(drawable);
+                }
+            }
+        }
+    }
+
+    protected TextView setText(int index, String stringReference) {
+        View child = getChildAt(index);
+        if (child instanceof TextView) {
+            TextView textView = (TextView) child;
+            ResourceValue value = getResourceValue(stringReference);
+            if (value != null) {
+                textView.setText(value.getValue());
+            } else {
+                textView.setText(stringReference);
+            }
+            return textView;
+        }
+
+        return null;
+    }
+
+    protected void setStyle(String themeEntryName) {
+
+        BridgeContext bridgeContext = (BridgeContext) mContext;
+        RenderResources res = bridgeContext.getRenderResources();
+
+        ResourceValue value = res.findItemInTheme(themeEntryName);
+        value = res.resolveResValue(value);
+
+        if (value instanceof StyleResourceValue == false) {
+            return;
+        }
+
+        StyleResourceValue style = (StyleResourceValue) value;
+
+        // get the background
+        ResourceValue backgroundValue = res.findItemInStyle(style, "background");
+        backgroundValue = res.resolveResValue(backgroundValue);
+        if (backgroundValue != null) {
+            Drawable d = ResourceHelper.getDrawable(backgroundValue, bridgeContext);
+            if (d != null) {
+                setBackgroundDrawable(d);
+            }
+        }
+
+        TextView textView = getStyleableTextView();
+        if (textView != null) {
+            // get the text style
+            ResourceValue textStyleValue = res.findItemInStyle(style, "titleTextStyle");
+            textStyleValue = res.resolveResValue(textStyleValue);
+            if (textStyleValue instanceof StyleResourceValue) {
+                StyleResourceValue textStyle = (StyleResourceValue) textStyleValue;
+
+                ResourceValue textSize = res.findItemInStyle(textStyle, "textSize");
+                textSize = res.resolveResValue(textSize);
+
+                if (textSize != null) {
+                    TypedValue out = new TypedValue();
+                    if (ResourceHelper.stringToFloat(textSize.getValue(), out)) {
+                        textView.setTextSize(
+                                out.getDimension(bridgeContext.getResources().mMetrics));
+                    }
+                }
+
+
+                ResourceValue textColor = res.findItemInStyle(textStyle, "textColor");
+                textColor = res.resolveResValue(textColor);
+                if (textColor != null) {
+                    ColorStateList stateList = ResourceHelper.getColorStateList(
+                            textColor, bridgeContext);
+                    if (stateList != null) {
+                        textView.setTextColor(stateList);
+                    }
+                }
+            }
+        }
+    }
+
+    private ResourceValue getResourceValue(String reference) {
+        BridgeContext bridgeContext = (BridgeContext) mContext;
+        RenderResources res = bridgeContext.getRenderResources();
+
+        // find the resource
+        ResourceValue value = res.findResValue(reference, false /*isFramework*/);
+
+        // resolve it if needed
+        return res.resolveResValue(value);
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java
new file mode 100644
index 0000000..3af4e3a
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/FakeActionBar.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.bars;
+
+import com.android.resources.Density;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.Context;
+import android.widget.TextView;
+
+public class FakeActionBar extends CustomBar {
+
+    private TextView mTextView;
+
+    public FakeActionBar(Context context, Density density, String label, String icon)
+            throws XmlPullParserException {
+        super(context, density, "/bars/action_bar.xml");
+
+        // Cannot access the inside items through id because no R.id values have been
+        // created for them.
+        // We do know the order though.
+        loadIcon(0, icon);
+        mTextView = setText(1, label);
+
+        setStyle("actionBarStyle");
+    }
+
+    @Override
+    protected TextView getStyleableTextView() {
+        return mTextView;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
new file mode 100644
index 0000000..92615dc
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.bars;
+
+import com.android.resources.Density;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.Context;
+import android.widget.TextView;
+
+public class PhoneSystemBar extends CustomBar {
+
+    public PhoneSystemBar(Context context, Density density) throws XmlPullParserException {
+        super(context, density, "/bars/tablet_system_bar.xml");
+
+        // Cannot access the inside items through id because no R.id values have been
+        // created for them.
+        // We do know the order though.
+        // 0 is the spacer
+        loadIcon(1, "stat_sys_wifi_signal_4_fully.png", density);
+    }
+
+    @Override
+    protected TextView getStyleableTextView() {
+        return null;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java
new file mode 100644
index 0000000..bc61799
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.bars;
+
+import com.android.resources.Density;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.Context;
+import android.widget.TextView;
+
+public class TabletSystemBar extends CustomBar {
+
+    public TabletSystemBar(Context context, Density density) throws XmlPullParserException {
+        super(context, density, "/bars/tablet_system_bar.xml");
+
+        // Cannot access the inside items through id because no R.id values have been
+        // created for them.
+        // We do know the order though.
+        loadIcon(0, "ic_sysbar_back_default.png", density);
+        loadIcon(1, "ic_sysbar_home_default.png", density);
+        loadIcon(2, "ic_sysbar_recent_default.png", density);
+        // 3 is the spacer
+        loadIcon(4, "stat_sys_wifi_signal_4_fully.png", density);
+    }
+
+    @Override
+    protected TextView getStyleableTextView() {
+        return null;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java
new file mode 100644
index 0000000..d7401d9
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TitleBar.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge.bars;
+
+import com.android.resources.Density;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.Context;
+import android.widget.TextView;
+
+public class TitleBar extends CustomBar {
+
+    private TextView mTextView;
+
+    public TitleBar(Context context, Density density, String label)
+            throws XmlPullParserException {
+        super(context, density, "/bars/title_bar.xml");
+
+        // Cannot access the inside items through id because no R.id values have been
+        // created for them.
+        // We do know the order though.
+        mTextView = setText(0, label);
+
+        setStyle("windowTitleBackgroundStyle");
+    }
+
+    @Override
+    protected TextView getStyleableTextView() {
+        return mTextView;
+    }
+}
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 c8ad1d6..0aa2e6d 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
@@ -29,14 +29,13 @@
 import com.android.ide.common.rendering.api.ILayoutPullParser;
 import com.android.ide.common.rendering.api.IProjectCallback;
 import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.ide.common.rendering.api.Params;
+import com.android.ide.common.rendering.api.RenderParams;
 import com.android.ide.common.rendering.api.RenderResources;
 import com.android.ide.common.rendering.api.RenderSession;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.ide.common.rendering.api.Result;
-import com.android.ide.common.rendering.api.StyleResourceValue;
 import com.android.ide.common.rendering.api.ViewInfo;
-import com.android.ide.common.rendering.api.Params.RenderingMode;
+import com.android.ide.common.rendering.api.RenderParams.RenderingMode;
 import com.android.ide.common.rendering.api.RenderResources.FrameworkResourceIdProvider;
 import com.android.ide.common.rendering.api.Result.Status;
 import com.android.internal.util.XmlUtils;
@@ -47,11 +46,16 @@
 import com.android.layoutlib.bridge.android.BridgeWindow;
 import com.android.layoutlib.bridge.android.BridgeWindowSession;
 import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
-import com.android.resources.Density;
+import com.android.layoutlib.bridge.bars.FakeActionBar;
+import com.android.layoutlib.bridge.bars.PhoneSystemBar;
+import com.android.layoutlib.bridge.bars.TabletSystemBar;
+import com.android.layoutlib.bridge.bars.TitleBar;
 import com.android.resources.ResourceType;
 import com.android.resources.ScreenSize;
 import com.android.util.Pair;
 
+import org.xmlpull.v1.XmlPullParserException;
+
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
 import android.animation.LayoutTransition;
@@ -105,7 +109,7 @@
      */
     private static BridgeContext sCurrentContext = null;
 
-    private final Params mParams;
+    private final RenderParams mParams;
 
     // scene state
     private RenderSession mScene;
@@ -113,17 +117,18 @@
     private BridgeXmlBlockParser mBlockParser;
     private BridgeInflater mInflater;
     private ResourceValue mWindowBackground;
-    private FrameLayout mViewRoot;
+    private ViewGroup mViewRoot;
+    private FrameLayout mContentRoot;
     private Canvas mCanvas;
     private int mMeasuredScreenWidth = -1;
     private int mMeasuredScreenHeight = -1;
-    private boolean mIsAlphaChannelImage = true;
+    private boolean mIsAlphaChannelImage;
+    private boolean mWindowIsFloating;
 
     private int mStatusBarSize;
-    private int mTopBarSize;
     private int mSystemBarSize;
-    private int mTopOffset;
-    private int mTotalBarSize;
+    private int mTitleBarSize;
+    private int mActionBarSize;
 
 
     // information being returned through the API
@@ -146,9 +151,9 @@
      *
      * @see LayoutBridge#createScene(com.android.layoutlib.api.SceneParams)
      */
-    public RenderSessionImpl(Params params) {
+    public RenderSessionImpl(RenderParams params) {
         // copy the params.
-        mParams = new Params(params);
+        mParams = new RenderParams(params);
     }
 
     /**
@@ -172,8 +177,8 @@
 
         // setup the display Metrics.
         DisplayMetrics metrics = new DisplayMetrics();
-        metrics.densityDpi = mParams.getDensity();
-        metrics.density = mParams.getDensity() / (float) DisplayMetrics.DENSITY_DEFAULT;
+        metrics.densityDpi = mParams.getDensity().getDpiValue();
+        metrics.density = metrics.densityDpi / (float) DisplayMetrics.DENSITY_DEFAULT;
         metrics.scaledDensity = metrics.density;
         metrics.widthPixels = mParams.getScreenWidth();
         metrics.heightPixels = mParams.getScreenHeight();
@@ -190,17 +195,16 @@
         mIsAlphaChannelImage  = getBooleanThemeValue(resources,
                 "windowIsFloating", true /*defaultValue*/);
 
+        mWindowIsFloating = getBooleanThemeValue(resources, "windowIsFloating",
+                true /*defaultValue*/);
 
         setUp();
 
         findBackground(resources);
         findStatusBar(resources, metrics);
-        findTopBar(resources, metrics);
+        findActionBar(resources, metrics);
         findSystemBar(resources, metrics);
 
-        mTopOffset = mStatusBarSize + mTopBarSize;
-        mTotalBarSize = mTopOffset + mSystemBarSize;
-
         // build the inflater and parser.
         mInflater = new BridgeInflater(mContext, mParams.getProjectCallback());
         mContext.setBridgeInflater(mInflater);
@@ -353,13 +357,100 @@
 
         try {
 
-            mViewRoot = new FrameLayout(mContext);
+            if (mWindowIsFloating || mParams.isForceNoDecor()) {
+                mViewRoot = mContentRoot = new FrameLayout(mContext);
+            } else {
+                /*
+                 * we're creating the following layout
+                 *
+                   +-------------------------------------------------+
+                   | System bar (only in phone UI)                   |
+                   +-------------------------------------------------+
+                   | Title/Action bar (optional)                     |
+                   +-------------------------------------------------+
+                   | Content, vertical extending                     |
+                   |                                                 |
+                   +-------------------------------------------------+
+                   | System bar (only in tablet UI)                  |
+                   +-------------------------------------------------+
+
+                 */
+
+                LinearLayout topLayout = new LinearLayout(mContext);
+                mViewRoot = topLayout;
+                topLayout.setOrientation(LinearLayout.VERTICAL);
+
+                if (mStatusBarSize > 0) {
+                    // system bar
+                    try {
+                        PhoneSystemBar systemBar = new PhoneSystemBar(mContext,
+                                mParams.getDensity());
+                        systemBar.setLayoutParams(
+                                new LinearLayout.LayoutParams(
+                                        LayoutParams.MATCH_PARENT, mStatusBarSize));
+                        topLayout.addView(systemBar);
+                    } catch (XmlPullParserException e) {
+
+                    }
+                }
+
+                // if the theme says no title/action bar, then the size will be 0
+                if (mActionBarSize > 0) {
+                    try {
+                        FakeActionBar actionBar = new FakeActionBar(mContext,
+                                mParams.getDensity(),
+                                mParams.getAppLabel(), mParams.getAppIcon());
+                        actionBar.setLayoutParams(
+                                new LinearLayout.LayoutParams(
+                                        LayoutParams.MATCH_PARENT, mActionBarSize));
+                        topLayout.addView(actionBar);
+                    } catch (XmlPullParserException e) {
+
+                    }
+                } else if (mTitleBarSize > 0) {
+                    try {
+                        TitleBar titleBar = new TitleBar(mContext,
+                                mParams.getDensity(), mParams.getAppLabel());
+                        titleBar.setLayoutParams(
+                                new LinearLayout.LayoutParams(
+                                        LayoutParams.MATCH_PARENT, mTitleBarSize));
+                        topLayout.addView(titleBar);
+                    } catch (XmlPullParserException e) {
+
+                    }
+                }
+
+
+                // content frame
+                mContentRoot = new FrameLayout(mContext);
+                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+                        LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+                params.weight = 1;
+                mContentRoot.setLayoutParams(params);
+                topLayout.addView(mContentRoot);
+
+                if (mSystemBarSize > 0) {
+                    // system bar
+                    try {
+                        TabletSystemBar systemBar = new TabletSystemBar(mContext,
+                                mParams.getDensity());
+                        systemBar.setLayoutParams(
+                                new LinearLayout.LayoutParams(
+                                        LayoutParams.MATCH_PARENT, mSystemBarSize));
+                        topLayout.addView(systemBar);
+                    } catch (XmlPullParserException e) {
+
+                    }
+                }
+
+            }
+
 
             // Sets the project callback (custom view loader) to the fragment delegate so that
             // it can instantiate the custom Fragment.
             Fragment_Delegate.setProjectCallback(mParams.getProjectCallback());
 
-            View view = mInflater.inflate(mBlockParser, mViewRoot);
+            View view = mInflater.inflate(mBlockParser, mContentRoot);
 
             Fragment_Delegate.setProjectCallback(null);
 
@@ -377,9 +468,8 @@
 
             // get the background drawable
             if (mWindowBackground != null) {
-                Drawable d = ResourceHelper.getDrawable(mWindowBackground,
-                        mContext, true /* isFramework */);
-                mViewRoot.setBackgroundDrawable(d);
+                Drawable d = ResourceHelper.getDrawable(mWindowBackground, mContext);
+                mContentRoot.setBackgroundDrawable(d);
             }
 
             return SUCCESS.createResult();
@@ -408,8 +498,8 @@
      * @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)
+     * @see RenderParams#getRenderingMode()
+     * @see RenderSession#render(long)
      */
     public Result render(boolean freshRender) {
         checkLock();
@@ -428,7 +518,7 @@
             if (mMeasuredScreenWidth == -1) {
                 newRenderSize = true;
                 mMeasuredScreenWidth = mParams.getScreenWidth();
-                mMeasuredScreenHeight = mParams.getScreenHeight() - mTotalBarSize;
+                mMeasuredScreenHeight = mParams.getScreenHeight();
 
                 if (renderingMode != RenderingMode.NORMAL) {
                     // measure the full size needed by the layout.
@@ -476,11 +566,11 @@
                 if (mParams.getImageFactory() != null) {
                     mImage = mParams.getImageFactory().getImage(
                             mMeasuredScreenWidth,
-                            mMeasuredScreenHeight + mTotalBarSize);
+                            mMeasuredScreenHeight);
                 } else {
                     mImage = new BufferedImage(
                             mMeasuredScreenWidth,
-                            mMeasuredScreenHeight + mTotalBarSize,
+                            mMeasuredScreenHeight,
                             BufferedImage.TYPE_INT_ARGB);
                     newImage = true;
                 }
@@ -491,46 +581,26 @@
                     Graphics2D gc = mImage.createGraphics();
                     gc.setColor(new Color(mParams.getOverrideBgColor(), true));
                     gc.setComposite(AlphaComposite.Src);
-                    gc.fillRect(0, 0, mMeasuredScreenWidth,
-                            mMeasuredScreenHeight + mTotalBarSize);
+                    gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight);
                     gc.dispose();
                 }
 
                 // create an Android bitmap around the BufferedImage
                 Bitmap bitmap = Bitmap_Delegate.createBitmap(mImage,
-                        true /*isMutable*/,
-                        Density.getEnum(mParams.getDensity()));
+                        true /*isMutable*/, mParams.getDensity());
 
                 // create a Canvas around the Android bitmap
                 mCanvas = new Canvas(bitmap);
-                mCanvas.setDensity(mParams.getDensity());
-                mCanvas.translate(0, mTopOffset);
+                mCanvas.setDensity(mParams.getDensity().getDpiValue());
             }
 
             if (freshRender && newImage == false) {
                 Graphics2D gc = mImage.createGraphics();
                 gc.setComposite(AlphaComposite.Src);
 
-                if (mStatusBarSize > 0) {
-                    gc.setColor(new Color(0xFF3C3C3C, true));
-                    gc.fillRect(0, 0, mMeasuredScreenWidth, mStatusBarSize);
-                }
-
-                if (mTopBarSize > 0) {
-                    gc.setColor(new Color(0xFF7F7F7F, true));
-                    gc.fillRect(0, mStatusBarSize, mMeasuredScreenWidth, mTopOffset);
-                }
-
-                // erase the rest
                 gc.setColor(new Color(0x00000000, true));
-                gc.fillRect(0, mTopOffset,
-                        mMeasuredScreenWidth, mMeasuredScreenHeight + mTopOffset);
-
-                if (mSystemBarSize > 0) {
-                    gc.setColor(new Color(0xFF3C3C3C, true));
-                    gc.fillRect(0, mMeasuredScreenHeight + mTopOffset,
-                            mMeasuredScreenWidth, mMeasuredScreenHeight + mTotalBarSize);
-                }
+                gc.fillRect(0, 0,
+                        mMeasuredScreenWidth, mMeasuredScreenHeight);
 
                 // done
                 gc.dispose();
@@ -538,7 +608,7 @@
 
             mViewRoot.draw(mCanvas);
 
-            mViewInfoList = visitAllChildren((ViewGroup)mViewRoot, mContext, mTopOffset);
+            mViewInfoList = startVisitingViews(mViewRoot, 0);
 
             // success!
             return SUCCESS.createResult();
@@ -561,7 +631,7 @@
      * @throws IllegalStateException if the current context is different than the one owned by
      *      the scene, or if {@link #acquire(long)} was not called.
      *
-     * @see LayoutScene#animate(Object, String, boolean, IAnimationListener)
+     * @see RenderSession#animate(Object, String, boolean, IAnimationListener)
      */
     public Result animate(Object targetObject, String animationName,
             boolean isFrameworkAnimation, IAnimationListener listener) {
@@ -617,7 +687,7 @@
      * @throws IllegalStateException if the current context is different than the one owned by
      *      the scene, or if {@link #acquire(long)} was not called.
      *
-     * @see LayoutScene#insertChild(Object, ILayoutPullParser, int, IAnimationListener)
+     * @see RenderSession#insertChild(Object, ILayoutPullParser, int, IAnimationListener)
      */
     public Result insertChild(final ViewGroup parentView, ILayoutPullParser childXml,
             final int index, IAnimationListener listener) {
@@ -696,7 +766,7 @@
      * @throws IllegalStateException if the current context is different than the one owned by
      *      the scene, or if {@link #acquire(long)} was not called.
      *
-     * @see LayoutScene#moveChild(Object, Object, int, Map, IAnimationListener)
+     * @see RenderSession#moveChild(Object, Object, int, Map, IAnimationListener)
      */
     public Result moveChild(final ViewGroup newParentView, final View childView, final int index,
             Map<String, String> layoutParamsMap, final IAnimationListener listener) {
@@ -892,7 +962,7 @@
      * @throws IllegalStateException if the current context is different than the one owned by
      *      the scene, or if {@link #acquire(long)} was not called.
      *
-     * @see LayoutScene#removeChild(Object, IAnimationListener)
+     * @see RenderSession#removeChild(Object, IAnimationListener)
      */
     public Result removeChild(final View childView, IAnimationListener listener) {
         checkLock();
@@ -989,40 +1059,12 @@
         return mParams.getConfigScreenSize() == ScreenSize.XLARGE;
     }
 
-    private boolean isHCApp() {
-        RenderResources resources = mContext.getRenderResources();
-
-        // the app must say it targets 11+ and the theme name must extend Theme.Holo or
-        // Theme.Holo.Light (which does not extend Theme.Holo, but Theme.Light)
-        if (mParams.getTargetSdkVersion() < 11) {
-            return false;
-        }
-
-        StyleResourceValue currentTheme = resources.getCurrentTheme();
-        StyleResourceValue holoTheme = resources.getTheme("Theme.Holo", true /*frameworkTheme*/);
-
-        if (currentTheme == holoTheme ||
-                resources.themeIsParentOf(holoTheme, currentTheme)) {
-            return true;
-        }
-
-        StyleResourceValue holoLightTheme = resources.getTheme("Theme.Holo.Light",
-                true /*frameworkTheme*/);
-
-        if (currentTheme == holoLightTheme ||
-                resources.themeIsParentOf(holoLightTheme, currentTheme)) {
-            return true;
-        }
-
-        return false;
-    }
-
     private void findStatusBar(RenderResources resources, DisplayMetrics metrics) {
         if (isTabletUi() == false) {
             boolean windowFullscreen = getBooleanThemeValue(resources,
                     "windowFullscreen", false /*defaultValue*/);
 
-            if (windowFullscreen == false) {
+            if (windowFullscreen == false && mWindowIsFloating == false) {
                 // default value
                 mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT;
 
@@ -1041,20 +1083,11 @@
         }
     }
 
-    private void findTopBar(RenderResources resources, DisplayMetrics metrics) {
-        boolean windowIsFloating = getBooleanThemeValue(resources,
-                "windowIsFloating", true /*defaultValue*/);
-
-        if (windowIsFloating == false) {
-            if (isHCApp()) {
-                findActionBar(resources, metrics);
-            } else {
-                findTitleBar(resources, metrics);
-            }
-        }
-    }
-
     private void findActionBar(RenderResources resources, DisplayMetrics metrics) {
+        if (mWindowIsFloating) {
+            return;
+        }
+
         boolean windowActionBar = getBooleanThemeValue(resources,
                 "windowActionBar", true /*defaultValue*/);
 
@@ -1062,7 +1095,7 @@
         if (windowActionBar) {
 
             // default size of the window title bar
-            mTopBarSize = DEFAULT_TITLE_BAR_HEIGHT;
+            mActionBarSize = DEFAULT_TITLE_BAR_HEIGHT;
 
             // get value from the theme.
             ResourceValue value = resources.findItemInTheme("actionBarSize");
@@ -1075,44 +1108,43 @@
                 TypedValue typedValue = ResourceHelper.getValue(value.getValue());
                 if (typedValue != null) {
                     // compute the pixel value based on the display metrics
-                    mTopBarSize = (int)typedValue.getDimension(metrics);
+                    mActionBarSize = (int)typedValue.getDimension(metrics);
                 }
             }
-        }
-    }
+        } else {
+            // action bar overrides title bar so only look for this one if action bar is hidden
+            boolean windowNoTitle = getBooleanThemeValue(resources,
+                    "windowNoTitle", false /*defaultValue*/);
 
-    private void findTitleBar(RenderResources resources, DisplayMetrics metrics) {
-        boolean windowNoTitle = getBooleanThemeValue(resources,
-                "windowNoTitle", false /*defaultValue*/);
+            if (windowNoTitle == false) {
 
-        if (windowNoTitle == false) {
+                // default size of the window title bar
+                mTitleBarSize = DEFAULT_TITLE_BAR_HEIGHT;
 
-            // default size of the window title bar
-            mTopBarSize = DEFAULT_TITLE_BAR_HEIGHT;
+                // get value from the theme.
+                ResourceValue value = resources.findItemInTheme("windowTitleSize");
 
-            // get value from the theme.
-            ResourceValue value = resources.findItemInTheme("windowTitleSize");
+                // resolve it
+                value = resources.resolveResValue(value);
 
-            // resolve it
-            value = resources.resolveResValue(value);
-
-            if (value != null) {
-                // get the numerical value, if available
-                TypedValue typedValue = ResourceHelper.getValue(value.getValue());
-                if (typedValue != null) {
-                    // compute the pixel value based on the display metrics
-                    mTopBarSize = (int)typedValue.getDimension(metrics);
+                if (value != null) {
+                    // get the numerical value, if available
+                    TypedValue typedValue = ResourceHelper.getValue(value.getValue());
+                    if (typedValue != null) {
+                        // compute the pixel value based on the display metrics
+                        mTitleBarSize = (int)typedValue.getDimension(metrics);
+                    }
                 }
             }
+
         }
     }
 
     private void findSystemBar(RenderResources resources, DisplayMetrics metrics) {
-        if (isTabletUi() && getBooleanThemeValue(
-                resources, "windowIsFloating", true /*defaultValue*/) == false) {
+        if (isTabletUi() && mWindowIsFloating == false) {
 
             // default value
-            mSystemBarSize = 56; // ??
+            mSystemBarSize = 48; // ??
 
             // get the real value
             ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
@@ -1244,40 +1276,71 @@
         }
     }
 
+    private List<ViewInfo> startVisitingViews(View view, int offset) {
+        if (view == null) {
+            return null;
+        }
+
+        // adjust the offset to this view.
+        offset += view.getTop();
+
+        if (view == mContentRoot) {
+            return visitAllChildren(mContentRoot, offset);
+        }
+
+        // otherwise, look for mContentRoot in the children
+        if (view instanceof ViewGroup) {
+            ViewGroup group = ((ViewGroup) view);
+
+            for (int i = 0; i < group.getChildCount(); i++) {
+                List<ViewInfo> list = startVisitingViews(group.getChildAt(i), offset);
+                if (list != null) {
+                    return list;
+                }
+            }
+        }
+
+        return null;
+    }
 
     /**
      * Visits a View and its children and generate a {@link ViewInfo} containing the
      * bounds of all the views.
      * @param view the root View
-     * @param context the context.
+     * @param offset an offset for the view bounds.
      */
-    private ViewInfo visit(View view, BridgeContext context, int offset) {
+    private ViewInfo visit(View view, int offset) {
         if (view == null) {
             return null;
         }
 
         ViewInfo result = new ViewInfo(view.getClass().getName(),
-                context.getViewKey(view),
+                mContext.getViewKey(view),
                 view.getLeft(), view.getTop() + offset, view.getRight(), view.getBottom() + offset,
                 view, view.getLayoutParams());
 
         if (view instanceof ViewGroup) {
             ViewGroup group = ((ViewGroup) view);
-            result.setChildren(visitAllChildren(group, context, 0 /*offset*/));
+            result.setChildren(visitAllChildren(group, 0 /*offset*/));
         }
 
         return result;
     }
 
-    private List<ViewInfo> visitAllChildren(ViewGroup viewGroup, BridgeContext context,
-            int offset) {
+    /**
+     * Visits all the children of a given ViewGroup generate a list of {@link ViewInfo}
+     * containing the bounds of all the views.
+     * @param view the root View
+     * @param offset an offset for the view bounds.
+     */
+    private List<ViewInfo> visitAllChildren(ViewGroup viewGroup, int offset) {
         if (viewGroup == null) {
             return null;
         }
 
         List<ViewInfo> children = new ArrayList<ViewInfo>();
         for (int i = 0; i < viewGroup.getChildCount(); i++) {
-            children.add(visit(viewGroup.getChildAt(i), context, offset));
+            children.add(visit(viewGroup.getChildAt(i), offset));
         }
         return children;
     }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 25bb81c..cea7cf3 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -18,6 +18,7 @@
 
 import com.android.ide.common.rendering.api.DensityBasedResourceValue;
 import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.RenderResources;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.android.BridgeContext;
@@ -28,7 +29,9 @@
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
 
+import android.content.res.ColorStateList;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap_Delegate;
 import android.graphics.NinePatch_Delegate;
@@ -108,19 +111,63 @@
         throw new NumberFormatException();
     }
 
+    public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) {
+        String value = resValue.getValue();
+        if (value != null) {
+            // first check if the value is a file (xml most likely)
+            File f = new File(value);
+            if (f.isFile()) {
+                try {
+                    // let the framework inflate the ColorStateList from the XML file, by
+                    // providing an XmlPullParser
+                    KXmlParser parser = new KXmlParser();
+                    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+                    parser.setInput(new FileReader(f));
+
+                    return ColorStateList.createFromXml(context.getResources(),
+                            new BridgeXmlBlockParser(parser, context, resValue.isFramework()));
+                } catch (XmlPullParserException e) {
+                    Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+                            "Failed to configure parser for " + value, e, null /*data*/);
+                    // we'll return null below.
+                } catch (Exception e) {
+                    // this is an error and not warning since the file existence is
+                    // checked before attempting to parse it.
+                    Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ,
+                            "Failed to parse file " + value, e, null /*data*/);
+
+                    return null;
+                }
+            } else {
+                // try to load the color state list from an int
+                try {
+                    int color = ResourceHelper.getColor(value);
+                    return ColorStateList.valueOf(color);
+                } catch (NumberFormatException e) {
+                    Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT,
+                            "Failed to convert " + value + " into a ColorStateList", e,
+                            null /*data*/);
+                    return null;
+                }
+            }
+        }
+
+        return null;
+    }
+
     /**
      * Returns a drawable from the given value.
      * @param value The value that contains a path to a 9 patch, a bitmap or a xml based drawable,
      * or an hexadecimal color
-     * @param context
-     * @param isFramework indicates whether the resource is a framework resources.
-     * Framework resources are cached, and loaded only once.
+     * @param context the current context
      */
-    public static Drawable getDrawable(ResourceValue value, BridgeContext context,
-            boolean isFramework) {
+    public static Drawable getDrawable(ResourceValue value, BridgeContext context) {
         Drawable d = null;
 
         String stringValue = value.getValue();
+        if (RenderResources.REFERENCE_NULL.equals(stringValue)) {
+            return null;
+        }
 
         String lowerCaseValue = stringValue.toLowerCase();
 
@@ -129,9 +176,9 @@
             if (file.isFile()) {
                 // see if we still have both the chunk and the bitmap in the caches
                 NinePatchChunk chunk = Bridge.getCached9Patch(stringValue,
-                        isFramework ? null : context.getProjectKey());
+                        value.isFramework() ? null : context.getProjectKey());
                 Bitmap bitmap = Bridge.getCachedBitmap(stringValue,
-                        isFramework ? null : context.getProjectKey());
+                        value.isFramework() ? null : context.getProjectKey());
 
                 // if either chunk or bitmap is null, then we reload the 9-patch file.
                 if (chunk == null || bitmap == null) {
@@ -143,7 +190,7 @@
                                 chunk = ninePatch.getChunk();
 
                                 Bridge.setCached9Patch(stringValue, chunk,
-                                        isFramework ? null : context.getProjectKey());
+                                        value.isFramework() ? null : context.getProjectKey());
                             }
 
                             if (bitmap == null) {
@@ -158,7 +205,7 @@
                                         density);
 
                                 Bridge.setCachedBitmap(stringValue, bitmap,
-                                        isFramework ? null : context.getProjectKey());
+                                        value.isFramework() ? null : context.getProjectKey());
                             }
                         }
                     } catch (MalformedURLException e) {
@@ -192,7 +239,7 @@
                     parser.setInput(new FileReader(f));
 
                     d = Drawable.createFromXml(context.getResources(),
-                            new BridgeXmlBlockParser(parser, context, isFramework));
+                            new BridgeXmlBlockParser(parser, context, value.isFramework()));
                     return d;
                 } catch (Exception e) {
                     // this is an error and not warning since the file existence is checked before
@@ -212,7 +259,7 @@
             if (bmpFile.isFile()) {
                 try {
                     Bitmap bitmap = Bridge.getCachedBitmap(stringValue,
-                            isFramework ? null : context.getProjectKey());
+                            value.isFramework() ? null : context.getProjectKey());
 
                     if (bitmap == null) {
                         Density density = Density.MEDIUM;
@@ -223,7 +270,7 @@
                         bitmap = Bitmap_Delegate.createBitmap(bmpFile, false /*isMutable*/,
                                 density);
                         Bridge.setCachedBitmap(stringValue, bitmap,
-                                isFramework ? null : context.getProjectKey());
+                                value.isFramework() ? null : context.getProjectKey());
                     }
 
                     return new BitmapDrawable(context.getResources(), bitmap);