Merge "Fix a severe cleanup bug where teardown of the GL driver could occur on the wrong thread."
diff --git a/api/11.xml b/api/11.xml
index 368bfc8..0edb67c 100644
--- a/api/11.xml
+++ b/api/11.xml
@@ -247155,7 +247155,7 @@
 </exception>
 </method>
 <method name="getClass"
- return="java.lang.Class&lt;? extends java.lang.Object&gt;"
+ return="java.lang.Class&lt;?&gt;"
  abstract="false"
  native="true"
  synchronized="false"
diff --git a/api/current.xml b/api/current.xml
index 2624b64..a33d30f 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -8886,6 +8886,17 @@
  visibility="public"
 >
 </field>
+<field name="staticWallpaperPreview"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843584"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="stepSize"
  type="int"
  transient="false"
@@ -36149,6 +36160,17 @@
  visibility="public"
 >
 </field>
+<field name="WALLPAPER_PREVIEW_META_DATA"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.wallpaper.preview&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 </package>
 <package name="android.app.admin"
@@ -36915,6 +36937,21 @@
 <parameter name="admin" type="android.content.ComponentName">
 </parameter>
 </method>
+<method name="hasGrantedPolicy"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="admin" type="android.content.ComponentName">
+</parameter>
+<parameter name="usesPolicy" type="int">
+</parameter>
+</method>
 <method name="isActivePasswordSufficient"
  return="boolean"
  abstract="false"
@@ -161279,468 +161316,6 @@
 >
 </field>
 </interface>
-<class name="Ptp"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="Ptp"
- type="android.provider.Ptp"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<field name="AUTHORITY"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;ptp&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
-<class name="Ptp.Device"
- extends="java.lang.Object"
- abstract="false"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.provider.BaseColumns">
-</implements>
-<constructor name="Ptp.Device"
- type="android.provider.Ptp.Device"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="getContentUri"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-</method>
-<field name="CONTENT_URI"
- type="android.net.Uri"
- transient="false"
- volatile="false"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="MANUFACTURER"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;manufacturer&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="MODEL"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;model&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
-<class name="Ptp.Object"
- extends="java.lang.Object"
- abstract="false"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.provider.BaseColumns">
-</implements>
-<constructor name="Ptp.Object"
- type="android.provider.Ptp.Object"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="getContentUri"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-<parameter name="objectID" type="long">
-</parameter>
-</method>
-<method name="getContentUriForImport"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-<parameter name="objectID" type="long">
-</parameter>
-<parameter name="destPath" type="java.lang.String">
-</parameter>
-</method>
-<method name="getContentUriForObjectChildren"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-<parameter name="objectID" type="long">
-</parameter>
-</method>
-<method name="getContentUriForStorageChildren"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-<parameter name="storageID" type="long">
-</parameter>
-</method>
-<field name="ASSOCIATION_DESC"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;association_desc&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ASSOCIATION_TYPE"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;association_type&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="DATE_CREATED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;date_created&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="DATE_MODIFIED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;date_modified&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="FORMAT"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;format&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="IMAGE_DEPTH"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;image_depth&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="IMAGE_HEIGHT"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;image_height&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="IMAGE_WIDTH"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;image_width&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="KEYWORDS"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;keywords&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="NAME"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;name&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="PARENT"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;parent&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="PROTECTION_STATUS"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;protection_status&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="SEQUENCE_NUMBER"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;sequence_number&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="SIZE"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;size&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="STORAGE_ID"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;storage_id&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="THUMB"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;thumb&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="THUMB_FORMAT"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;thumb_format&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="THUMB_HEIGHT"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;thumb_height&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="THUMB_SIZE"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;thumb_size&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="THUMB_WIDTH"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;thumb_width&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
-<class name="Ptp.Storage"
- extends="java.lang.Object"
- abstract="false"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.provider.BaseColumns">
-</implements>
-<constructor name="Ptp.Storage"
- type="android.provider.Ptp.Storage"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="getContentUri"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-</method>
-<method name="getContentUri"
- return="android.net.Uri"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="deviceID" type="int">
-</parameter>
-<parameter name="storageID" type="long">
-</parameter>
-</method>
-<field name="DESCRIPTION"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;description&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="IDENTIFIER"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;identifier&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
 <class name="SearchRecentSuggestions"
  extends="java.lang.Object"
  abstract="false"
@@ -204706,7 +204281,7 @@
  value="512"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -204997,7 +204572,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="type" type="int">
@@ -205045,7 +204620,7 @@
  value="0"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -205056,7 +204631,7 @@
  value="3"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -216101,7 +215676,7 @@
  value="0"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -216112,7 +215687,7 @@
  value="3"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -216642,7 +216217,7 @@
  volatile="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -234575,7 +234150,7 @@
 >
 <parameter name="year" type="int">
 </parameter>
-<parameter name="month" type="int">
+<parameter name="monthOfYear" type="int">
 </parameter>
 <parameter name="dayOfMonth" type="int">
 </parameter>
@@ -234594,7 +234169,7 @@
 >
 <parameter name="year" type="int">
 </parameter>
-<parameter name="monthOfYear" type="int">
+<parameter name="month" type="int">
 </parameter>
 <parameter name="dayOfMonth" type="int">
 </parameter>
@@ -265200,9 +264775,9 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="beginIndex" type="int">
+<parameter name="start" type="int">
 </parameter>
-<parameter name="endIndex" type="int">
+<parameter name="end" type="int">
 </parameter>
 </method>
 <method name="ensureCapacity"
@@ -267900,7 +267475,7 @@
  native="false"
  synchronized="false"
  static="true"
- final="true"
+ final="false"
  deprecated="not deprecated"
  visibility="public"
 >
@@ -274223,7 +273798,7 @@
 </exception>
 </method>
 <method name="getClass"
- return="java.lang.Class&lt;? extends java.lang.Object&gt;"
+ return="java.lang.Class&lt;?&gt;"
  abstract="false"
  native="true"
  synchronized="false"
@@ -277013,9 +276588,9 @@
 >
 <parameter name="data" type="byte[]">
 </parameter>
-<parameter name="start" type="int">
+<parameter name="offset" type="int">
 </parameter>
-<parameter name="length" type="int">
+<parameter name="byteCount" type="int">
 </parameter>
 </constructor>
 <constructor name="String"
@@ -277029,9 +276604,9 @@
 </parameter>
 <parameter name="high" type="int">
 </parameter>
-<parameter name="start" type="int">
+<parameter name="offset" type="int">
 </parameter>
-<parameter name="length" type="int">
+<parameter name="byteCount" type="int">
 </parameter>
 </constructor>
 <constructor name="String"
@@ -277043,9 +276618,9 @@
 >
 <parameter name="data" type="byte[]">
 </parameter>
-<parameter name="start" type="int">
+<parameter name="offset" type="int">
 </parameter>
-<parameter name="length" type="int">
+<parameter name="byteCount" type="int">
 </parameter>
 <parameter name="charsetName" type="java.lang.String">
 </parameter>
@@ -277075,9 +276650,9 @@
 >
 <parameter name="data" type="byte[]">
 </parameter>
-<parameter name="start" type="int">
+<parameter name="offset" type="int">
 </parameter>
-<parameter name="length" type="int">
+<parameter name="byteCount" type="int">
 </parameter>
 <parameter name="charset" type="java.nio.charset.Charset">
 </parameter>
@@ -277113,9 +276688,9 @@
 >
 <parameter name="data" type="char[]">
 </parameter>
-<parameter name="start" type="int">
+<parameter name="offset" type="int">
 </parameter>
-<parameter name="length" type="int">
+<parameter name="charCount" type="int">
 </parameter>
 </constructor>
 <constructor name="String"
@@ -277135,7 +276710,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="stringbuffer" type="java.lang.StringBuffer">
+<parameter name="stringBuffer" type="java.lang.StringBuffer">
 </parameter>
 </constructor>
 <constructor name="String"
@@ -277159,7 +276734,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="sb" type="java.lang.StringBuilder">
+<parameter name="stringBuilder" type="java.lang.StringBuilder">
 </parameter>
 </constructor>
 <method name="charAt"
@@ -277211,9 +276786,9 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="beginIndex" type="int">
+<parameter name="start" type="int">
 </parameter>
-<parameter name="endIndex" type="int">
+<parameter name="end" type="int">
 </parameter>
 </method>
 <method name="compareTo"
diff --git a/cmds/servicemanager/service_manager.c b/cmds/servicemanager/service_manager.c
index 14536bd..ba7f807 100644
--- a/cmds/servicemanager/service_manager.c
+++ b/cmds/servicemanager/service_manager.c
@@ -161,9 +161,9 @@
     si = find_svc(s, len);
     if (si) {
         if (si->ptr) {
-            LOGE("add_service('%s',%p) uid=%d - ALREADY REGISTERED\n",
+            LOGE("add_service('%s',%p) uid=%d - ALREADY REGISTERED, OVERRIDE\n",
                  str8(s), ptr, uid);
-            return -1;
+            svcinfo_death(bs, si);
         }
         si->ptr = ptr;
     } else {
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index d679ef6..aaebbd0 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1403,6 +1403,8 @@
     public void onConfigurationChanged(Configuration newConfig) {
         mCalled = true;
 
+        mFragments.dispatchConfigurationChanged(newConfig);
+
         if (mWindow != null) {
             // Pass the configuration changed event to the window
             mWindow.onConfigurationChanged(newConfig);
@@ -1566,6 +1568,7 @@
     
     public void onLowMemory() {
         mCalled = true;
+        mFragments.dispatchLowMemory();
     }
     
     /**
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 45500bc..3dfb8016 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -2415,8 +2415,6 @@
                 state = new Bundle();
                 mInstrumentation.callActivityOnSaveInstanceState(r.activity, state);
                 r.state = state;
-            } else {
-                r.state = null;
             }
             // Now we are idle.
             r.activity.mCalled = false;
@@ -2956,9 +2954,13 @@
 
         r.activity.mChangingConfigurations = true;
 
-        Bundle savedState = null;
+        // Need to ensure state is saved.
         if (!r.paused) {
-            savedState = performPauseActivity(r.token, false, r.isPreHoneycomb());
+            performPauseActivity(r.token, false, r.isPreHoneycomb());
+        }
+        if (r.state == null && !r.stopped && !r.isPreHoneycomb()) {
+            r.state = new Bundle();
+            mInstrumentation.callActivityOnSaveInstanceState(r.activity, r.state);
         }
 
         handleDestroyActivity(r.token, false, configChanges, true);
@@ -2983,9 +2985,6 @@
             }
         }
         r.startsNotResumed = tmp.startsNotResumed;
-        if (savedState != null) {
-            r.state = savedState;
-        }
 
         handleLaunchActivity(r, currentIntent);
     }
diff --git a/core/java/android/app/FragmentBreadCrumbs.java b/core/java/android/app/FragmentBreadCrumbs.java
index 139095f..8d76ffe 100644
--- a/core/java/android/app/FragmentBreadCrumbs.java
+++ b/core/java/android/app/FragmentBreadCrumbs.java
@@ -41,6 +41,7 @@
     Activity mActivity;
     LayoutInflater mInflater;
     LinearLayout mContainer;
+    int mMaxVisible = -1;
 
     // Hahah
     BackStackRecord mTopEntry;
@@ -74,6 +75,14 @@
     }
 
     /**
+     * The maximum number of crumbs to show.
+     * @hide
+     */
+    public void setMaxVisible(int visibleCrumbs) {
+        mMaxVisible = visibleCrumbs;
+    }
+
+    /**
      * Set a custom title for the bread crumbs.  This will be the first entry
      * shown at the left, representing the root of the bread crumbs.  If the
      * title is null, it will not be shown.
@@ -160,17 +169,17 @@
                 }
             }
             if (viewI >= numViews) {
-                View item = mInflater.inflate(
+                final View item = mInflater.inflate(
                         com.android.internal.R.layout.fragment_bread_crumb_item,
                         this, false);
-                TextView text = (TextView)item.findViewById(com.android.internal.R.id.title);
+                final TextView text = (TextView) item.findViewById(com.android.internal.R.id.title);
                 text.setText(bse.getBreadCrumbTitle());
-                item.setTag(bse);
+                text.setTag(bse);
                 if (viewI == 0) {
-                    text.setCompoundDrawables(null, null, null, null);
+                    item.findViewById(com.android.internal.R.id.left_icon).setVisibility(View.GONE);
                 }
                 mContainer.addView(item);
-                item.setOnClickListener(mOnClickListener);
+                text.setOnClickListener(mOnClickListener);
             }
         }
         int viewI = mTopEntry != null ? numEntries + 1 : numEntries;
@@ -179,6 +188,20 @@
             mContainer.removeViewAt(numViews-1);
             numViews--;
         }
+        // Adjust the visibility and availability of the bread crumbs and divider
+        for (int i = 0; i < numViews; i++) {
+            final View child = mContainer.getChildAt(i);
+            // Disable the last one
+            child.findViewById(com.android.internal.R.id.title).setEnabled(i < numViews - 1);
+            if (mMaxVisible > 0) {
+                // Make only the last mMaxVisible crumbs visible
+                child.setVisibility(i < numViews - mMaxVisible ? View.GONE : View.VISIBLE);
+                final View leftIcon = child.findViewById(com.android.internal.R.id.left_icon);
+                // Remove the divider for all but the last mMaxVisible - 1
+                leftIcon.setVisibility(i > numViews - mMaxVisible && i != 0 ? View.VISIBLE
+                        : View.GONE);
+            }
+        }
     }
 
     private OnClickListener mOnClickListener = new OnClickListener() {
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index fbad2fe..1b2d4df 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -19,6 +19,7 @@
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
 import android.animation.AnimatorListenerAdapter;
+import android.content.res.Configuration;
 import android.content.res.TypedArray;
 import android.os.Bundle;
 import android.os.Handler;
@@ -1415,6 +1416,28 @@
         mActivity = null;
     }
     
+    public void dispatchConfigurationChanged(Configuration newConfig) {
+        if (mActive != null) {
+            for (int i=0; i<mAdded.size(); i++) {
+                Fragment f = mAdded.get(i);
+                if (f != null) {
+                    f.onConfigurationChanged(newConfig);
+                }
+            }
+        }
+    }
+
+    public void dispatchLowMemory() {
+        if (mActive != null) {
+            for (int i=0; i<mAdded.size(); i++) {
+                Fragment f = mAdded.get(i);
+                if (f != null) {
+                    f.onLowMemory();
+                }
+            }
+        }
+    }
+
     public boolean dispatchCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         boolean show = false;
         ArrayList<Fragment> newMenus = null;
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index b95b123..13a8b78 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -62,7 +62,13 @@
      */
     public static final String ACTION_LIVE_WALLPAPER_CHOOSER
             = "android.service.wallpaper.LIVE_WALLPAPER_CHOOSER";
-    
+
+    /**
+     * Manifest entry for activities that respond to {@link Intent#ACTION_SET_WALLPAPER}
+     * which allows them to provide a custom large icon associated with this action.
+     */
+    public static final String WALLPAPER_PREVIEW_META_DATA = "android.wallpaper.preview";
+
     /**
      * Command for {@link #sendWallpaperCommand}: reported by the wallpaper
      * host when the user taps on an empty area (not performing an action
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index f169cd7..1edbdb8 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -43,17 +43,12 @@
  */
 public class DevicePolicyManager {
     private static String TAG = "DevicePolicyManager";
-    private static boolean DEBUG = false;
-    private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
 
     private final Context mContext;
     private final IDevicePolicyManager mService;
 
-    private final Handler mHandler;
-
     private DevicePolicyManager(Context context, Handler handler) {
         mContext = context;
-        mHandler = handler;
         mService = IDevicePolicyManager.Stub.asInterface(
                 ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));
     }
@@ -74,6 +69,11 @@
      * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION}
      * field to provide the user with additional explanation (in addition
      * to your component's description) about what is being added.
+     *
+     * <p>If your administrator is already active, this will ordinarily return immediately (without
+     * user intervention).  However, if your administrator has been updated and is requesting
+     * additional uses-policy flags, the user will be presented with the new list.  New policies
+     * will not be available to the updated administrator until the user has accepted the new list.
      */
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_ADD_DEVICE_ADMIN
@@ -179,6 +179,26 @@
     }
 
     /**
+     * Returns true if an administrator has been granted a particular device policy.  This can
+     * be used to check if the administrator was activated under an earlier set of policies,
+     * but requires additional policies after an upgrade.
+     *
+     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.  Must be
+     * an active administrator, or an exception will be thrown.
+     * @param usesPolicy Which uses-policy to check, as defined in {@link DeviceAdminInfo}.
+     */
+    public boolean hasGrantedPolicy(ComponentName admin, int usesPolicy) {
+        if (mService != null) {
+            try {
+                return mService.hasGrantedPolicy(admin, usesPolicy);
+            } catch (RemoteException e) {
+                Log.w(TAG, "Failed talking with device policy service", e);
+            }
+        }
+        return false;
+    }
+
+    /**
      * Constant for {@link #setPasswordQuality}: the policy has no requirements
      * for the password.  Note that quality constants are ordered so that higher
      * values are more restrictive.
@@ -1075,10 +1095,10 @@
     /**
      * @hide
      */
-    public void setActiveAdmin(ComponentName policyReceiver) {
+    public void setActiveAdmin(ComponentName policyReceiver, boolean refreshing) {
         if (mService != null) {
             try {
-                mService.setActiveAdmin(policyReceiver);
+                mService.setActiveAdmin(policyReceiver, refreshing);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1086,6 +1106,7 @@
     }
 
     /**
+     * Returns the DeviceAdminInfo as defined by the administrator's package info & meta-data
      * @hide
      */
     public DeviceAdminInfo getAdminInfo(ComponentName cn) {
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 7acc83e..7504f5b 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -75,12 +75,13 @@
     ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
     ComponentName getGlobalProxyAdmin();
     
-    void setActiveAdmin(in ComponentName policyReceiver);
+    void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing);
     boolean isAdminActive(in ComponentName policyReceiver);
     List<ComponentName> getActiveAdmins();
     boolean packageHasActiveAdmins(String packageName);
     void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result);
     void removeActiveAdmin(in ComponentName policyReceiver);
+    boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy);
     
     void setActivePasswordState(int quality, int length, int letters, int uppercase, int lowercase,
         int numbers, int symbols, int nonletter);
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 7492c96..6172ce9 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -21,6 +21,7 @@
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
+import android.app.ActionBar;
 import android.app.Fragment;
 import android.app.FragmentBreadCrumbs;
 import android.app.FragmentManager;
@@ -170,7 +171,7 @@
 
     private FrameLayout mListFooter;
 
-    private View mPrefsContainer;
+    private ViewGroup mPrefsContainer;
 
     private FragmentBreadCrumbs mFragmentBreadCrumbs;
 
@@ -394,7 +395,7 @@
             if (summaryRes != 0) {
                 return res.getText(summaryRes);
             }
-            return title;
+            return summary;
         }
 
         /**
@@ -490,7 +491,7 @@
         setContentView(com.android.internal.R.layout.preference_list_content);
 
         mListFooter = (FrameLayout)findViewById(com.android.internal.R.id.list_footer);
-        mPrefsContainer = findViewById(com.android.internal.R.id.prefs);
+        mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
         boolean hidingHeaders = onIsHidingHeaders();
         mSinglePane = hidingHeaders || !onIsMultiPane();
         String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
@@ -558,7 +559,7 @@
             // of preferences" mode.
             setContentView(com.android.internal.R.layout.preference_list_content_single);
             mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
-            mPrefsContainer = findViewById(com.android.internal.R.id.prefs);
+            mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs);
             mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE);
             mPreferenceManager.setOnPreferenceTreeClickListener(this);
         }
@@ -989,9 +990,16 @@
      */
     public void showBreadCrumbs(CharSequence title, CharSequence shortTitle) {
         if (mFragmentBreadCrumbs == null) {
-            mFragmentBreadCrumbs = new FragmentBreadCrumbs(this);
+            mFragmentBreadCrumbs = (FragmentBreadCrumbs) findViewById(android.R.id.title);
+            if (mFragmentBreadCrumbs == null) {
+                mFragmentBreadCrumbs = new FragmentBreadCrumbs(this);
+                ActionBar actionBar = getActionBar();
+                if (actionBar != null) {
+                    actionBar.setCustomNavigationMode(mFragmentBreadCrumbs);
+                }
+            }
+            mFragmentBreadCrumbs.setMaxVisible(2);
             mFragmentBreadCrumbs.setActivity(this);
-            getActionBar().setCustomNavigationMode(mFragmentBreadCrumbs);
         }
         mFragmentBreadCrumbs.setTitle(title, shortTitle);
     }
diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java
index 33f37f8..b96defe 100644
--- a/core/java/android/preference/PreferenceFragment.java
+++ b/core/java/android/preference/PreferenceFragment.java
@@ -194,6 +194,7 @@
     public void onDestroy() {
         super.onDestroy();
         mPreferenceManager.dispatchActivityDestroy();
+        mPreferenceManager.setOnPreferenceTreeClickListener(null);
     }
 
     @Override
diff --git a/core/java/android/preference/PreferenceFrameLayout.java b/core/java/android/preference/PreferenceFrameLayout.java
index f6d01d3..75372aa 100644
--- a/core/java/android/preference/PreferenceFrameLayout.java
+++ b/core/java/android/preference/PreferenceFrameLayout.java
@@ -16,13 +16,12 @@
 
 package android.preference;
 
+import android.app.FragmentBreadCrumbs;
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.view.View;
-import android.view.ViewGroup.MarginLayoutParams;
 import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
 
 /**
  * @hide
@@ -36,7 +35,7 @@
     private final int mBorderBottom;
     private final int mBorderLeft;
     private final int mBorderRight;
-    private boolean mPaddingApplied = false;
+    private boolean mPaddingApplied;
 
     public PreferenceFrameLayout(Context context) {
         this(context, null);
@@ -70,7 +69,6 @@
                 com.android.internal.R.styleable.PreferenceFrameLayout_borderRight,
                 defaultRightPadding);
 
-
         a.recycle();
     }
 
@@ -89,7 +87,9 @@
         int borderLeft = getPaddingLeft();
         int borderRight = getPaddingRight();
 
-        LayoutParams layoutParams = (PreferenceFrameLayout.LayoutParams) child.getLayoutParams();
+        android.view.ViewGroup.LayoutParams params = child.getLayoutParams();
+        LayoutParams layoutParams = params instanceof PreferenceFrameLayout.LayoutParams
+            ? (PreferenceFrameLayout.LayoutParams) child.getLayoutParams() : null;
         // Check on the id of the child before adding it.
         if (layoutParams != null && layoutParams.removeBorders) {
             if (mPaddingApplied) {
diff --git a/core/java/android/provider/Ptp.java b/core/java/android/provider/Ptp.java
index 0f0919e..0072f3d 100644
--- a/core/java/android/provider/Ptp.java
+++ b/core/java/android/provider/Ptp.java
@@ -27,6 +27,8 @@
  * - deleting files and directories on PTP devices
  * - importing a file from PTP device into the host device's storage
  *   and adding it to the media provider
+ *
+ * @hide
  */
 public final class Ptp
 {
diff --git a/core/java/android/text/method/MetaKeyKeyListener.java b/core/java/android/text/method/MetaKeyKeyListener.java
index 923a555..0a097f9 100644
--- a/core/java/android/text/method/MetaKeyKeyListener.java
+++ b/core/java/android/text/method/MetaKeyKeyListener.java
@@ -105,10 +105,6 @@
      */
     public static final int META_SELECTING = KeyEvent.META_SELECTING;
 
-    private static final int META_SHIFT_ON_AND_LOCKED = META_SHIFT_ON | META_CAP_LOCKED;
-    private static final int META_ALT_ON_AND_LOCKED = META_ALT_ON | META_ALT_LOCKED;
-    private static final int META_SYM_ON_AND_LOCKED = META_SYM_ON | META_SYM_LOCKED;
-
     // These bits are privately used by the meta key key listener.
     // They are deliberately assigned values outside of the representable range of an 'int'
     // so as not to conflict with any meta key states publicly defined by KeyEvent.
@@ -565,13 +561,13 @@
      * {@link #META_ALT_ON} or {@link #META_SYM_ON}.
      */
     public long clearMetaKeyState(long state, int which) {
-        if ((which & META_SHIFT_ON_AND_LOCKED) == META_SHIFT_ON_AND_LOCKED) {
+        if ((which & META_SHIFT_ON) != 0 && (state & META_CAP_LOCKED) != 0) {
             state &= ~META_SHIFT_MASK;
         }
-        if ((which & META_ALT_ON_AND_LOCKED) == META_ALT_ON_AND_LOCKED) {
+        if ((which & META_ALT_ON) != 0 && (state & META_ALT_LOCKED) != 0) {
             state &= ~META_ALT_MASK;
         }
-        if ((which & META_SYM_ON_AND_LOCKED) == META_SYM_ON_AND_LOCKED) {
+        if ((which & META_SYM_ON) != 0 && (state & META_SYM_LOCKED) != 0) {
             state &= ~META_SYM_MASK;
         }
         return state;
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index e967522..86cd3b0 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -84,7 +84,10 @@
      * of the surface must be pushed by an external entity. This is type
      * of surface can be used for efficient camera preview or movie
      * play back.
+     *
+     * @deprecated not support by the system anymore
      */
+    @Deprecated
     public static final int PUSH_BUFFERS        = 0x00000200;
     /**
      * Indicates that the surface must be considered opaque, even if its
diff --git a/core/java/android/view/SurfaceHolder.java b/core/java/android/view/SurfaceHolder.java
index 0d38f7b..1b242b3 100644
--- a/core/java/android/view/SurfaceHolder.java
+++ b/core/java/android/view/SurfaceHolder.java
@@ -18,10 +18,6 @@
 
 import android.graphics.Canvas;
 import android.graphics.Rect;
-import static android.view.WindowManager.LayoutParams.MEMORY_TYPE_NORMAL;
-import static android.view.WindowManager.LayoutParams.MEMORY_TYPE_HARDWARE;
-import static android.view.WindowManager.LayoutParams.MEMORY_TYPE_GPU;
-import static android.view.WindowManager.LayoutParams.MEMORY_TYPE_PUSH_BUFFERS;
 
 /**
  * Abstract interface to someone holding a display surface.  Allows you to
@@ -34,30 +30,19 @@
  * {@link #lockCanvas} and {@link Callback#surfaceCreated Callback.surfaceCreated}.
  */
 public interface SurfaceHolder {
-    /**
-     * Surface type.
-     * 
-     * @see #SURFACE_TYPE_NORMAL
-     * @see #SURFACE_TYPE_PUSH_BUFFERS
-     */
-    
-    /** Surface type: creates a regular surface, usually in main, non
-     * contiguous, cached/buffered RAM. */
-    public static final int SURFACE_TYPE_NORMAL = MEMORY_TYPE_NORMAL;
-    /** Surface type: creates a suited to be used with DMA engines and
-     * hardware accelerators. 
-     * @deprecated this is ignored, this value is set automatically when needed.
-     */
+
+    /** @deprecated this is ignored, this value is set automatically when needed. */
     @Deprecated
-    public static final int SURFACE_TYPE_HARDWARE = MEMORY_TYPE_HARDWARE;
-    /** Surface type: creates a surface suited to be used with the GPU 
-     * @deprecated this is ignored, this value is set automatically when needed.
-     */
+    public static final int SURFACE_TYPE_NORMAL = 0;
+    /** @deprecated this is ignored, this value is set automatically when needed. */
     @Deprecated
-    public static final int SURFACE_TYPE_GPU = MEMORY_TYPE_GPU;
-    /** Surface type: creates a "push" surface, that is a surface that 
-     * doesn't owns its buffers. With such a surface lockCanvas will fail. */
-    public static final int SURFACE_TYPE_PUSH_BUFFERS = MEMORY_TYPE_PUSH_BUFFERS;
+    public static final int SURFACE_TYPE_HARDWARE = 1;
+    /** @deprecated this is ignored, this value is set automatically when needed. */
+    @Deprecated
+    public static final int SURFACE_TYPE_GPU = 2;
+    /** @deprecated this is ignored, this value is set automatically when needed. */
+    @Deprecated
+    public static final int SURFACE_TYPE_PUSH_BUFFERS = 3;
 
     /**
      * Exception that is thrown from {@link #lockCanvas} when called on a Surface
@@ -160,10 +145,11 @@
     public boolean isCreating();
     
     /**
-     * Sets the surface's type. 
-     * 
-     * @param type The surface's memory type.
+     * Sets the surface's type.
+     *  
+     * @deprecated this is ignored, this value is set automatically when needed.
      */
+    @Deprecated
     public void setType(int type);
 
     /**
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index b9a9674..7021604 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -145,7 +145,6 @@
      * compatibility with applications assuming this format.
      */
     int mRequestedFormat = PixelFormat.RGB_565;
-    int mRequestedType = -1;
 
     boolean mHaveFrame = false;
     boolean mDestroyReportNeeded = false;
@@ -158,7 +157,6 @@
     int mWidth = -1;
     int mHeight = -1;
     int mFormat = -1;
-    int mType = -1;
     final Rect mSurfaceFrame = new Rect();
     int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1;
     boolean mUpdateWindowNeeded;
@@ -428,9 +426,9 @@
         final boolean sizeChanged = mWidth != myWidth || mHeight != myHeight;
         final boolean visibleChanged = mVisible != mRequestedVisible
                 || mNewSurfaceNeeded;
-        final boolean typeChanged = mType != mRequestedType;
+
         if (force || creating || formatChanged || sizeChanged || visibleChanged
-            || typeChanged || mLeft != mLocation[0] || mTop != mLocation[1]
+            || mLeft != mLocation[0] || mTop != mLocation[1]
             || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) {
 
             if (localLOGV) Log.i(TAG, "Changes: creating=" + creating
@@ -446,7 +444,6 @@
                 mWidth = myWidth;
                 mHeight = myHeight;
                 mFormat = mRequestedFormat;
-                mType = mRequestedType;
 
                 // Scaling/Translate window's layout here because mLayout is not used elsewhere.
                 
@@ -471,8 +468,6 @@
                     mLayout.flags |= WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
                 }
 
-                mLayout.memoryType = mRequestedType;
-
                 if (mWindow == null) {
                     mWindow = new MyWindow(this);
                     mLayout.type = mWindowType;
@@ -716,24 +711,11 @@
             }
         }
 
-        public void setType(int type) {
-            switch (type) {
-            case SURFACE_TYPE_HARDWARE:
-            case SURFACE_TYPE_GPU:
-                // these are deprecated, treat as "NORMAL"
-                type = SURFACE_TYPE_NORMAL;
-                break;
-            }
-            switch (type) {
-            case SURFACE_TYPE_NORMAL:
-            case SURFACE_TYPE_PUSH_BUFFERS:
-                mRequestedType = type;
-                if (mWindow != null) {
-                    updateWindow(false, false);
-                }
-                break;
-            }
-        }
+        /**
+         * @deprecated setType is now ignored.
+         */
+        @Deprecated
+        public void setType(int type) { }
 
         public void setKeepScreenOn(boolean screenOn) {
             Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG);
@@ -750,10 +732,6 @@
         }
 
         private final Canvas internalLockCanvas(Rect dirty) {
-            if (mType == SURFACE_TYPE_PUSH_BUFFERS) {
-                throw new BadSurfaceTypeException(
-                        "Surface type is SURFACE_TYPE_PUSH_BUFFERS");
-            }
             mSurfaceLock.lock();
 
             if (localLOGV) Log.i(TAG, "Locking canvas... stopped="
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 51016f5..e8792ff 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -388,31 +388,22 @@
         public static final int LAST_SYSTEM_WINDOW      = 2999;
         
         /**
-         * Specifies what type of memory buffers should be used by this window.
-         * Default is normal.
-         * 
-         * @see #MEMORY_TYPE_NORMAL
-         * @see #MEMORY_TYPE_PUSH_BUFFERS
+         * @deprecated this is ignored
          */
+        @Deprecated
         public int memoryType;
 
-        /** Memory type: The window's surface is allocated in main memory. */
+        /** @deprecated this is ignored, this value is set automatically when needed. */
+        @Deprecated
         public static final int MEMORY_TYPE_NORMAL = 0;
-        /** Memory type: The window's surface is configured to be accessible
-         * by DMA engines and hardware accelerators.
-         * @deprecated this is ignored, this value is set automatically when needed.
-         */
+        /** @deprecated this is ignored, this value is set automatically when needed. */
         @Deprecated
         public static final int MEMORY_TYPE_HARDWARE = 1;
-        /** Memory type: The window's surface is configured to be accessible
-         * by graphics accelerators. 
-         * @deprecated this is ignored, this value is set automatically when needed.
-         */
+        /** @deprecated this is ignored, this value is set automatically when needed. */
         @Deprecated
         public static final int MEMORY_TYPE_GPU = 2;
-        /** Memory type: The window's surface doesn't own its buffers and
-         * therefore cannot be locked. Instead the buffers are pushed to
-         * it through native binder calls. */
+        /** @deprecated this is ignored, this value is set automatically when needed. */
+        @Deprecated
         public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
 
         /**
@@ -994,7 +985,6 @@
             out.writeInt(x);
             out.writeInt(y);
             out.writeInt(type);
-            out.writeInt(memoryType);
             out.writeInt(flags);
             out.writeInt(softInputMode);
             out.writeInt(gravity);
@@ -1030,7 +1020,6 @@
             x = in.readInt();
             y = in.readInt();
             type = in.readInt();
-            memoryType = in.readInt();
             flags = in.readInt();
             softInputMode = in.readInt();
             gravity = in.readInt();
@@ -1106,10 +1095,6 @@
                 type = o.type;
                 changes |= TYPE_CHANGED;
             }
-            if (memoryType != o.memoryType) {
-                memoryType = o.memoryType;
-                changes |= MEMORY_TYPE_CHANGED;
-            }
             if (flags != o.flags) {
                 flags = o.flags;
                 changes |= FLAGS_CHANGED;
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 0cbd51b..3ba7f81 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -19,6 +19,7 @@
 import android.net.ParseException;
 import android.net.WebAddress;
 import android.net.http.AndroidHttpClient;
+import android.os.AsyncTask;
 import android.util.Log;
 
 
@@ -102,6 +103,8 @@
     // http:/b/3118772
     private static Boolean sUseChromiumHttpStack;
 
+    private int pendingCookieOperations = 0;
+
     /**
      * This contains a list of 2nd-level domains that aren't allowed to have
      * wildcards when combined with country-codes. For example: [.co.uk].
@@ -523,12 +526,37 @@
         }
     }
 
+    synchronized void waitForCookieOperationsToComplete() {
+        while (pendingCookieOperations > 0) {
+            try {
+                wait();
+            } catch (InterruptedException e) { }
+        }
+    }
+
+    private synchronized void signalCookieOperationsComplete() {
+        pendingCookieOperations--;
+        assert pendingCookieOperations > -1;
+        notify();
+    }
+
+    private synchronized void signalCookieOperationsStart() {
+        pendingCookieOperations++;
+    }
+
     /**
      * Remove all session cookies, which are cookies without expiration date
      */
     public void removeSessionCookie() {
+        signalCookieOperationsStart();
         if (useChromiumHttpStack()) {
-            nativeRemoveSessionCookie();
+            new AsyncTask<Void, Void, Void>() {
+                protected Void doInBackground(Void... none) {
+                    nativeRemoveSessionCookie();
+                    signalCookieOperationsComplete();
+                    return null;
+                }
+            }.execute();
             return;
         }
 
@@ -548,6 +576,7 @@
                         }
                     }
                     CookieSyncManager.getInstance().clearSessionCookies();
+                    signalCookieOperationsComplete();
                 }
             }
         };
diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java
index 641604e..7c25987 100644
--- a/core/java/android/webkit/FindActionModeCallback.java
+++ b/core/java/android/webkit/FindActionModeCallback.java
@@ -182,6 +182,11 @@
 
     @Override
     public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+        if (mWebView == null) {
+            throw new AssertionError(
+                    "No WebView for FindActionModeCallback::onActionItemClicked");
+        }
+        mInput.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
         if (!mMatchesFound) {
             findAll();
             return true;
diff --git a/core/java/android/webkit/HTML5Audio.java b/core/java/android/webkit/HTML5Audio.java
index d292881..a3906ddb 100644
--- a/core/java/android/webkit/HTML5Audio.java
+++ b/core/java/android/webkit/HTML5Audio.java
@@ -179,7 +179,7 @@
     }
 
     private void play() {
-        if ((mState == ERROR || mState == IDLE) && mUrl != null) {
+        if ((mState >= ERROR && mState < PREPARED) && mUrl != null) {
             resetMediaPlayer();
             setDataSource(mUrl);
             mAskToPlay = true;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index d2c7fce..942fe0b 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -1056,17 +1056,20 @@
                             break;
 
                         case LOAD_URL: {
+                            CookieManager.getInstance().waitForCookieOperationsToComplete();
                             GetUrlData param = (GetUrlData) msg.obj;
                             loadUrl(param.mUrl, param.mExtraHeaders);
                             break;
                         }
 
                         case POST_URL: {
+                            CookieManager.getInstance().waitForCookieOperationsToComplete();
                             PostUrlData param = (PostUrlData) msg.obj;
                             mBrowserFrame.postUrl(param.mUrl, param.mPostData);
                             break;
                         }
                         case LOAD_DATA:
+                            CookieManager.getInstance().waitForCookieOperationsToComplete();
                             BaseUrlData loadParams = (BaseUrlData) msg.obj;
                             String baseUrl = loadParams.mBaseUrl;
                             if (baseUrl != null) {
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 3766856..135ace6 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -3144,9 +3144,8 @@
                 final int width = getWidth();
                 final int height = getHeight();
 
-                canvas.translate(-width, 0);
-                canvas.rotate(-180, width, 0);
-                canvas.translate(0, -height);
+                canvas.translate(-width, Math.max(height, scrollY + mLastPositionDistanceGuess));
+                canvas.rotate(180, width, 0);
                 mEdgeGlowBottom.setSize(width, height);
                 if (mEdgeGlowBottom.draw(canvas)) {
                     invalidate();
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 4e5bc6e..e98c0bd 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -99,8 +99,8 @@
 
         OnChangeListener onChangeListener = new OnChangeListener() {
             public void onChange(NumberPicker picker, int oldVal, int newVal) {
-                notifyDateChanged();
-                updateMiniMonth();
+                updateDateUnchecked(mYearPicker.getCurrent(), mMonthPicker.getCurrent(),
+                        mDayPicker.getCurrent());
             }
         };
 
@@ -135,7 +135,7 @@
         mMiniMonthDayPicker.setRange(mTempCalendar, endRangeDate);
         mMiniMonthDayPicker.setOnDateChangeListener(new DayPicker.OnSelectedDayChangeListener() {
             public void onSelectedDayChange(DayPicker view, int year, int month, int monthDay) {
-                updateDate(year, month, monthDay);
+                updateDateUnchecked(year, month, monthDay);
             }
         });
         
@@ -238,26 +238,7 @@
         if (mYearPicker.getCurrent() != year
                 || mDayPicker.getCurrent() != dayOfMonth
                 || mMonthPicker.getCurrent() != month) {
-            updatePickers(year, month, dayOfMonth);
-            updateMiniMonth();
-            notifyDateChanged();
-        }
-    }
-
-    /**
-     * @return The short month abbreviations.
-     */
-    private String[] getShortMonths() {
-        final Locale currentLocale = Locale.getDefault();
-        if (currentLocale.equals(mMonthLocale)) {
-            return mShortMonths;
-        } else {
-            for (int i = 0; i < mNumberOfMonths; i++) {
-                mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i,
-                        DateUtils.LENGTH_MEDIUM);
-            }
-            mMonthLocale = currentLocale;
-            return mShortMonths;
+            updateDateUnchecked(year, month, dayOfMonth);
         }
     }
 
@@ -298,14 +279,46 @@
     }
 
     /**
+     * Updates the current date.
+     *
+     * @param year The year.
+     * @param month The month which is <strong>starting from zero</strong>.
+     * @param dayOfMonth The day of the month.
+     */
+    private void updateDateUnchecked(int year, int month, int dayOfMonth) {
+        updatePickers(year, month, dayOfMonth);
+        updateMiniMonth();
+        notifyDateChanged();
+    }
+
+    /**
+     * @return The short month abbreviations.
+     */
+    private String[] getShortMonths() {
+        final Locale currentLocale = Locale.getDefault();
+        if (currentLocale.equals(mMonthLocale)) {
+            return mShortMonths;
+        } else {
+            for (int i = 0; i < mNumberOfMonths; i++) {
+                mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i,
+                        DateUtils.LENGTH_MEDIUM);
+            }
+            mMonthLocale = currentLocale;
+            return mShortMonths;
+        }
+    }
+
+    /**
      * Updates the pickers with the given <code>year</code>, <code>month</code>,
      * and <code>dayOfMonth</code>. If the provided values designate an inconsistent
      * date the values are normalized before updating the pickers.
      */
     private void updatePickers(int year, int month, int dayOfMonth) {
-        // make sure the date is normalized
-        mTempCalendar.clear();
-        mTempCalendar.set(year, month, dayOfMonth);
+        // larger fields are not updated and the day is adjusted without wrapping
+        mTempCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+        mTempCalendar.roll(Calendar.MONTH, month - mTempCalendar.get(Calendar.MONTH));
+        mTempCalendar.roll(Calendar.YEAR, year - mTempCalendar.get(Calendar.YEAR));
+
         mYearPicker.setCurrent(mTempCalendar.get(Calendar.YEAR));
         mMonthPicker.setCurrent(mTempCalendar.get(Calendar.MONTH));
         mDayPicker.setRange(1, mTempCalendar.getActualMaximum(Calendar.DAY_OF_MONTH));
diff --git a/core/java/android/widget/DayPicker.java b/core/java/android/widget/DayPicker.java
index 11c23ab..e804022 100644
--- a/core/java/android/widget/DayPicker.java
+++ b/core/java/android/widget/DayPicker.java
@@ -278,14 +278,14 @@
      *
      * @hide
      */
-    protected Calendar mStartRangeDate = Calendar.getInstance();
+    protected Calendar mRangeStartDate = Calendar.getInstance();
 
     /**
      * The end date of the range supported by this picker.
      *
      * @hide
      */
-    protected Calendar mEndRangeDate = Calendar.getInstance();
+    protected Calendar mRangeEndDate = Calendar.getInstance();
 
     /**
      * String for formatting the month name in the title text view.
@@ -341,10 +341,10 @@
         }
 
         // set default range
-        mStartRangeDate.clear();
-        mStartRangeDate.set(1900, 0, 1);
-        mEndRangeDate.clear();
-        mEndRangeDate.set(2100, 0, 1);
+        mRangeStartDate.clear();
+        mRangeStartDate.set(1900, 0, 1);
+        mRangeEndDate.clear();
+        mRangeEndDate.set(2100, 0, 1);
 
         setUpHeader();
         updateHeader();
@@ -367,14 +367,16 @@
      */
     public void setRange(Calendar startRangeDate, Calendar endRangeDate) {
         boolean doSetupAdapter = false;
-        if (mStartRangeDate.get(Calendar.DAY_OF_YEAR) != startRangeDate.get(Calendar.DAY_OF_YEAR)
-                || mStartRangeDate.get(Calendar.YEAR) != startRangeDate.get(Calendar.YEAR)) {
-            mStartRangeDate = startRangeDate;
+        if (mRangeStartDate.get(Calendar.DAY_OF_YEAR) != startRangeDate.get(Calendar.DAY_OF_YEAR)
+                || mRangeStartDate.get(Calendar.YEAR) != startRangeDate.get(Calendar.YEAR)) {
+            mRangeStartDate.setTimeInMillis(startRangeDate.getTimeInMillis());
+            mRangeStartDate.setTimeZone(startRangeDate.getTimeZone());
             doSetupAdapter = true;
         }
-        if (mEndRangeDate.get(Calendar.DAY_OF_YEAR) != endRangeDate.get(Calendar.DAY_OF_YEAR)
-                || mEndRangeDate.get(Calendar.YEAR) != endRangeDate.get(Calendar.YEAR)) {
-            mEndRangeDate = endRangeDate;
+        if (mRangeEndDate.get(Calendar.DAY_OF_YEAR) != endRangeDate.get(Calendar.DAY_OF_YEAR)
+                || mRangeEndDate.get(Calendar.YEAR) != endRangeDate.get(Calendar.YEAR)) {
+            mRangeEndDate.setTimeInMillis(endRangeDate.getTimeInMillis());
+            mRangeEndDate.setTimeZone(endRangeDate.getTimeZone());
             doSetupAdapter = true;
             
         }
@@ -398,7 +400,7 @@
      * @return The selected day.
      */
     public Calendar getSelectedDay() {
-        return mAdapter.mSelectedDay;
+        return (Calendar) mAdapter.mSelectedDay.clone();
     }
 
     /**
@@ -524,6 +526,11 @@
      * @param setSelected Whether to set the given time as selected
      * @param forceScroll Whether to recenter even if the time is already
      *            visible.
+     *
+     * @throws IllegalArgumentException of the provided date is before the
+     *        range start of after the range end.
+     *
+     * @see #setRange(Calendar, Calendar)
      */
     public void goTo(int year, int month, int dayOfMonth, boolean animate, boolean setSelected,
             boolean forceScroll) {
@@ -538,20 +545,23 @@
      * the time is at the top of the view. If the new time is already in view
      * the list will not be scrolled unless forceScroll is true. This time may
      * optionally be highlighted as selected as well.
-     * 
+     *
      * @param date The time to move to.
      * @param animate Whether to scroll to the given time or just redraw at the
      *            new location.
      * @param setSelected Whether to set the given time as selected.
      * @param forceScroll Whether to recenter even if the time is already
      *            visible.
+     *
+     * @throws IllegalArgumentException of the provided date is before the
+     *        range start of after the range end.
+     *
+     * @see #setRange(Calendar, Calendar)
      */
     public void goTo(Calendar date, boolean animate, boolean setSelected, boolean forceScroll) {
-        long timeInMillis = date.getTimeInMillis();
-        if (timeInMillis < mStartRangeDate.getTimeInMillis()
-                || timeInMillis > mEndRangeDate.getTimeInMillis()) {
-            throw new IllegalArgumentException("Time not between " + mStartRangeDate.getTime()
-                    + " and " + mEndRangeDate.getTime());
+        if (date.before(mRangeStartDate) || date.after(mRangeEndDate)) { 
+            throw new IllegalArgumentException("Time not between " + mRangeStartDate.getTime()
+                    + " and " + mRangeEndDate.getTime());
         }
         // Find the first and last entirely visible weeks
         int firstFullyVisiblePosition = mListView.getFirstVisiblePosition();
@@ -698,16 +708,16 @@
      * @hide
      */
     protected int getWeeksDelta(Calendar toDate) {
-        if (toDate.before(mStartRangeDate)) {
-            throw new IllegalArgumentException("fromDate: " + mStartRangeDate.getTime()
+        if (toDate.before(mRangeStartDate)) {
+            throw new IllegalArgumentException("fromDate: " + mRangeStartDate.getTime()
                     + " does not precede toDate: " + toDate.getTime());
         }
-        int fromDateDayOfWeek = mStartRangeDate.get(Calendar.DAY_OF_WEEK);
+        int fromDateDayOfWeek = mRangeStartDate.get(Calendar.DAY_OF_WEEK);
         long diff = (fromDateDayOfWeek - toDate.getFirstDayOfWeek()) * MILLIS_IN_DAY;
         if (diff < 0) {
             diff = diff + MILLIS_IN_WEEK;
         }
-        long refDay = mStartRangeDate.getTimeInMillis() - diff;
+        long refDay = mRangeStartDate.getTimeInMillis() - diff;
         return (int) ((toDate.getTimeInMillis() - refDay) / MILLIS_IN_WEEK);
     }
 
@@ -864,7 +874,7 @@
         protected void init() {
             mGestureDetector = new GestureDetector(mContext, new CalendarGestureListener());
             mSelectedWeek = getWeeksDelta(mSelectedDay);
-            mTotalWeekCount = getWeeksDelta(mEndRangeDate);
+            mTotalWeekCount = getWeeksDelta(mRangeEndDate);
         }
 
         /**
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java
index 84bc5f2..df01da7 100644
--- a/core/java/android/widget/GridView.java
+++ b/core/java/android/widget/GridView.java
@@ -889,10 +889,11 @@
         return sel;
     }
 
-    private void determineColumns(int availableSpace) {
+    private boolean determineColumns(int availableSpace) {
         final int requestedHorizontalSpacing = mRequestedHorizontalSpacing;
         final int stretchMode = mStretchMode;
         final int requestedColumnWidth = mRequestedColumnWidth;
+        boolean didNotInitiallyFit = false;
         
         if (mRequestedNumColumns == AUTO_FIT) {
             if (requestedColumnWidth > 0) {
@@ -922,6 +923,11 @@
         default:
             int spaceLeftOver = availableSpace - (mNumColumns * requestedColumnWidth) -
                     ((mNumColumns - 1) * requestedHorizontalSpacing);
+
+            if (spaceLeftOver < 0) {
+                didNotInitiallyFit = true;
+            }
+
             switch (stretchMode) {
             case STRETCH_COLUMN_WIDTH:
                 // Stretch the columns
@@ -954,6 +960,7 @@
 
             break;
         }
+        return didNotInitiallyFit;
     }
 
     @Override
@@ -976,7 +983,7 @@
         }
         
         int childWidth = widthSize - mListPadding.left - mListPadding.right;
-        determineColumns(childWidth);
+        boolean didNotInitiallyFit = determineColumns(childWidth);
 
         int childHeight = 0;
         int childState = 0;
@@ -1035,7 +1042,7 @@
             int ourSize = (mRequestedNumColumns*mColumnWidth)
                     + ((mRequestedNumColumns-1)*mHorizontalSpacing)
                     + mListPadding.left + mListPadding.right;
-            if (ourSize > widthSize) {
+            if (ourSize > widthSize || didNotInitiallyFit) {
                 widthSize |= MEASURED_STATE_TOO_SMALL;
             }
         }
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index 805bc08..4766c53 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -843,10 +843,14 @@
      * @see #setWrapSelectorWheel(boolean)
      */
     public void setRange(int start, int end, String[] displayedValues, boolean wrapSelectorWheel) {
+        if (start == mStart && end == mEnd) {
+            return;
+        }
+
         if (start < 0 || end < 0) {
             throw new IllegalArgumentException("start and end must be > 0");
         }
-
+        
         mDisplayedValues = displayedValues;
         mStart = start;
         mEnd = end;
@@ -863,8 +867,7 @@
             mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
         }
 
-        // make sure cached string representations are dropped
-        mSelectorIndexToStringCache.clear();
+        resetSelectorIndices();
     }
 
     /**
@@ -876,6 +879,9 @@
      *             of the number picker.
      */
     public void setCurrent(int current) {
+        if (mCurrent == current) {
+            return;
+        }
         if (current < mStart || current > mEnd) {
             throw new IllegalArgumentException("current should be >= start and <= end");
         }
@@ -1011,6 +1017,18 @@
     }
 
     /**
+     * Resets the selector indices and clear the cached
+     * string representation of these indices.
+     */
+    private void resetSelectorIndices() {
+        mSelectorIndexToStringCache.clear();
+        int[] selectorIdices = getSelectorIndices();
+        for (int i = 0; i < selectorIdices.length; i++) {
+            selectorIdices[i] = Integer.MIN_VALUE; 
+        }
+    }
+
+    /**
      * Sets the current value of this NumberPicker, and sets mPrevious to the
      * previous value. If current is greater than mEnd less than mStart, the
      * value of mCurrent is wrapped around. Subclasses can override this to
@@ -1177,9 +1195,9 @@
      */
     private int getWrappedSelectorIndex(int selectorIndex) {
         if (selectorIndex > mEnd) {
-            return (Math.abs(selectorIndex) - mEnd);
+            return mStart + selectorIndex - mEnd - 1;
         } else if (selectorIndex < mStart) {
-            return (mEnd - Math.abs(selectorIndex));
+            return mEnd + selectorIndex - mStart + 1;
         }
         return selectorIndex;
     }
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 85ca5f3..5b143fe 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -436,6 +436,14 @@
      * @see #setIndeterminate(boolean)
      */
     public void setProgressDrawable(Drawable d) {
+        boolean needUpdate;
+        if (mProgressDrawable != null && d != mProgressDrawable) {
+            mProgressDrawable.setCallback(null);
+            needUpdate = true;
+        } else {
+            needUpdate = false;
+        }
+
         if (d != null) {
             d.setCallback(this);
 
@@ -451,6 +459,13 @@
             mCurrentDrawable = d;
             postInvalidate();
         }
+
+        if (needUpdate) {
+            updateDrawableBounds(getWidth(), getHeight());
+            updateDrawableState();
+            doRefreshProgress(R.id.progress, mProgress, false, false);
+            doRefreshProgress(R.id.secondaryProgress, mSecondaryProgress, false, false);
+        }
     }
     
     /**
@@ -493,7 +508,7 @@
         }
         
         public void run() {
-            doRefreshProgress(mId, mProgress, mFromUser);
+            doRefreshProgress(mId, mProgress, mFromUser, true);
             // Put ourselves back in the cache when we are done
             mRefreshProgressRunnable = this;
         }
@@ -506,7 +521,8 @@
         
     }
     
-    private synchronized void doRefreshProgress(int id, int progress, boolean fromUser) {
+    private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
+            boolean callBackToApp) {
         float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
         final Drawable d = mCurrentDrawable;
         if (d != null) {
@@ -522,7 +538,7 @@
             invalidate();
         }
         
-        if (id == R.id.progress) {
+        if (callBackToApp && id == R.id.progress) {
             onProgressRefresh(scale, fromUser);
         }
     }
@@ -532,7 +548,7 @@
 
     private synchronized void refreshProgress(int id, int progress, boolean fromUser) {
         if (mUiThreadId == Thread.currentThread().getId()) {
-            doRefreshProgress(id, progress, fromUser);
+            doRefreshProgress(id, progress, fromUser, true);
         } else {
             RefreshProgressRunnable r;
             if (mRefreshProgressRunnable != null) {
@@ -831,6 +847,10 @@
 
     @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        updateDrawableBounds(w, h);
+    }
+
+    private void updateDrawableBounds(int w, int h) {
         // onDraw will translate the canvas so we draw starting at 0,0
         int right = w - mPaddingRight - mPaddingLeft;
         int bottom = h - mPaddingBottom - mPaddingTop;
@@ -888,6 +908,7 @@
             dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth()));
             dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight()));
         }
+        updateDrawableState();
         dw += mPaddingLeft + mPaddingRight;
         dh += mPaddingTop + mPaddingBottom;
 
@@ -898,7 +919,10 @@
     @Override
     protected void drawableStateChanged() {
         super.drawableStateChanged();
+        updateDrawableState();
+    }
         
+    private void updateDrawableState() {
         int[] state = getDrawableState();
         
         if (mProgressDrawable != null && mProgressDrawable.isStateful()) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 144cf9c..3cf945d 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -7103,7 +7103,8 @@
                     }
 
                     stopSelectionActionMode();
-                    if (hasInsertionController()) {
+                    boolean selectAllGotFocus = mSelectAllOnFocus && mTouchFocusSelected;
+                    if (hasInsertionController() && !selectAllGotFocus) {
                         getInsertionController().show();
                     }
                 }
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 98bdb52..07505a5 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -626,14 +626,16 @@
     mOptions.add(opt);
     //options[curOpt++].optionString = "-verbose:class";
 
+    /*
+     * The default starting and maximum size of the heap.  Larger
+     * values should be specified in a product property override.
+     */
     strcpy(heapstartsizeOptsBuf, "-Xms");
-    property_get("dalvik.vm.heapstartsize", heapstartsizeOptsBuf+4, "2m");
+    property_get("dalvik.vm.heapstartsize", heapstartsizeOptsBuf+4, "4m");
     opt.optionString = heapstartsizeOptsBuf;
     mOptions.add(opt);
-
     strcpy(heapsizeOptsBuf, "-Xmx");
     property_get("dalvik.vm.heapsize", heapsizeOptsBuf+4, "16m");
-    //LOGI("Heap size: %s", heapsizeOptsBuf);
     opt.optionString = heapsizeOptsBuf;
     mOptions.add(opt);
 
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index e72e2b6f..b9c93b8 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -322,12 +322,12 @@
 }
 
 static ssize_t getFDSize(int fd) {
-    off_t curr = ::lseek(fd, 0, SEEK_CUR);
+    off64_t curr = ::lseek64(fd, 0, SEEK_CUR);
     if (curr < 0) {
         return 0;
     }
     size_t size = ::lseek(fd, 0, SEEK_END);
-    ::lseek(fd, curr, SEEK_SET);
+    ::lseek64(fd, curr, SEEK_SET);
     return size;
 }
 
@@ -374,8 +374,8 @@
  */
 static SkStream* copyAssetToStream(Asset* asset) {
     // if we could "ref/reopen" the asset, we may not need to copy it here
-    off_t size = asset->seek(0, SEEK_SET);
-    if ((off_t)-1 == size) {
+    off64_t size = asset->seek(0, SEEK_SET);
+    if ((off64_t)-1 == size) {
         SkDebugf("---- copyAsset: asset rewind failed\n");
         return NULL;
     }
@@ -388,7 +388,7 @@
 
     SkStream* stream = new SkMemoryStream(size);
     void* data = const_cast<void*>(stream->getMemoryBase());
-    off_t len = asset->read(data, size);
+    off64_t len = asset->read(data, size);
     if (len != size) {
         SkDebugf("---- copyAsset: asset->read(%d) returned %d\n", size, len);
         delete stream;
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index 1fe72e6..53a5c0a 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -72,8 +72,8 @@
 
 	virtual bool rewind()
     {
-        off_t pos = fAsset->seek(0, SEEK_SET);
-        return pos != (off_t)-1;
+        off64_t pos = fAsset->seek(0, SEEK_SET);
+        return pos != (off64_t)-1;
     }
     
 	virtual size_t read(void* buffer, size_t size)
@@ -88,10 +88,10 @@
             // asset->seek returns new total offset
             // we want to return amount that was skipped
             
-            off_t oldOffset = fAsset->seek(0, SEEK_CUR);
+            off64_t oldOffset = fAsset->seek(0, SEEK_CUR);
             if (-1 == oldOffset)
                 return 0;
-            off_t newOffset = fAsset->seek(size, SEEK_CUR);
+            off64_t newOffset = fAsset->seek(size, SEEK_CUR);
             if (-1 == newOffset)
                 return 0;
             
diff --git a/core/jni/android/graphics/Utils.cpp b/core/jni/android/graphics/Utils.cpp
index b6ead19..cf6977e 100644
--- a/core/jni/android/graphics/Utils.cpp
+++ b/core/jni/android/graphics/Utils.cpp
@@ -20,8 +20,8 @@
 using namespace android;
 
 bool AssetStreamAdaptor::rewind() {
-    off_t pos = fAsset->seek(0, SEEK_SET);
-    if (pos == (off_t)-1) {
+    off64_t pos = fAsset->seek(0, SEEK_SET);
+    if (pos == (off64_t)-1) {
         SkDebugf("----- fAsset->seek(rewind) failed\n");
         return false;
     }
@@ -38,12 +38,12 @@
         // asset->seek returns new total offset
         // we want to return amount that was skipped
 
-        off_t oldOffset = fAsset->seek(0, SEEK_CUR);
+        off64_t oldOffset = fAsset->seek(0, SEEK_CUR);
         if (-1 == oldOffset) {
             SkDebugf("---- fAsset->seek(oldOffset) failed\n");
             return 0;
         }
-        off_t newOffset = fAsset->seek(size, SEEK_CUR);
+        off64_t newOffset = fAsset->seek(size, SEEK_CUR);
         if (-1 == newOffset) {
             SkDebugf("---- fAsset->seek(%d) failed\n", size);
             return 0;
diff --git a/core/jni/android/graphics/Utils.h b/core/jni/android/graphics/Utils.h
index 2de41a1..9a7a697 100644
--- a/core/jni/android/graphics/Utils.h
+++ b/core/jni/android/graphics/Utils.h
@@ -51,7 +51,7 @@
     }
 private:
     int     fFD;
-    off_t   fCurr;
+    off64_t   fCurr;
 };
 
 jobject nullObjectReturn(const char msg[]);
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 2528db1..619a293 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -149,7 +149,7 @@
 
 static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outOffsets)
 {
-    off_t startOffset, length;
+    off64_t startOffset, length;
     int fd = a->openFileDescriptor(&startOffset, &length);
     delete a;
     
diff --git a/core/res/res/layout/fragment_bread_crumb_item.xml b/core/res/res/layout/fragment_bread_crumb_item.xml
index 517c570..e97508f 100644
--- a/core/res/res/layout/fragment_bread_crumb_item.xml
+++ b/core/res/res/layout/fragment_bread_crumb_item.xml
@@ -13,14 +13,28 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
-        android:id="@+id/title"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
-        android:gravity="center_vertical"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:drawableLeft="@drawable/nav_divider"
-        android:paddingLeft="12dp"
-        android:drawablePadding="12dp"
+        android:orientation="horizontal"
+        >
+    <ImageView
+            android:id="@android:id/left_icon"
+            android:src="@drawable/nav_divider"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_marginTop="8dip"
+            android:layout_marginBottom="8dip"
         />
+
+    <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:paddingLeft="8dip"
+            android:paddingRight="8dip"
+            android:gravity="center_vertical"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:background="?android:attr/selectableItemBackground"
+            />
+</LinearLayout>
\ No newline at end of file
diff --git a/core/res/res/layout/preference_list_content.xml b/core/res/res/layout/preference_list_content.xml
index fd488bd..e7783da 100644
--- a/core/res/res/layout/preference_list_content.xml
+++ b/core/res/res/layout/preference_list_content.xml
@@ -56,7 +56,8 @@
 
         </LinearLayout>
 
-        <android.preference.PreferenceFrameLayout android:id="@+id/prefs"
+        <LinearLayout
+                android:id="@+id/prefs_frame"
                 android:layout_width="0px"
                 android:layout_height="match_parent"
                 android:layout_weight="20"
@@ -65,7 +66,35 @@
                 android:layout_marginTop="16dp"
                 android:layout_marginBottom="16dp"
                 android:background="?attr/preferencePanelBackground"
-                android:visibility="gone" />
+                android:orientation="vertical"
+                android:visibility="gone" >
+
+            <!-- Breadcrumb inserted here -->
+            <android.app.FragmentBreadCrumbs
+                android:id="@android:id/title"
+                android:layout_height="72dip"
+                android:layout_width="match_parent"
+                android:paddingTop="16dip"
+                android:paddingBottom="8dip"
+                android:gravity="center_vertical|left"
+                android:layout_marginLeft="48dip"
+                android:layout_marginRight="48dip"
+                />
+
+            <ImageView
+                    android:layout_width="match_parent"
+                    android:layout_height="1dip"
+                    android:paddingLeft="32dip"
+                    android:paddingRight="32dip"
+                    android:src="#404040"
+                />
+            <android.preference.PreferenceFrameLayout android:id="@+id/prefs"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dip"
+                    android:layout_weight="1"
+                    android:layout_marginTop="-1dip"
+                />
+        </LinearLayout>
     </LinearLayout>
 
     <RelativeLayout android:id="@+id/button_bar"
diff --git a/core/res/res/layout/preference_list_fragment.xml b/core/res/res/layout/preference_list_fragment.xml
index 69fb73a..393cecf 100644
--- a/core/res/res/layout/preference_list_fragment.xml
+++ b/core/res/res/layout/preference_list_fragment.xml
@@ -28,7 +28,7 @@
         android:layout_width="match_parent"
         android:layout_height="0px"
         android:layout_weight="1"
-        android:paddingTop="48dip"
+        android:paddingTop="0dip"
         android:paddingBottom="48dip"
         android:paddingLeft="32dip"
         android:paddingRight="32dip"
diff --git a/core/res/res/values-xlarge/dimens.xml b/core/res/res/values-xlarge/dimens.xml
index c67bbb7..8f590b7 100644
--- a/core/res/res/values-xlarge/dimens.xml
+++ b/core/res/res/values-xlarge/dimens.xml
@@ -34,9 +34,9 @@
     <dimen name="password_keyboard_key_height_numeric">0.47in</dimen>
 
     <!-- The width that is used when creating thumbnails of applications. -->
-    <dimen name="thumbnail_width">160dp</dimen>
+    <dimen name="thumbnail_width">230dp</dimen>
     <!-- The height that is used when creating thumbnails of applications. -->
-    <dimen name="thumbnail_height">100dp</dimen>
+    <dimen name="thumbnail_height">135dp</dimen>
     <!-- The standard size (both width and height) of an application icon that
          will be displayed in the app launcher and elsewhere. -->
     <dimen name="app_icon_size">64dip</dimen>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 4bd91b3..9aabfc4 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -4282,6 +4282,18 @@
     </declare-styleable>
 
     <!-- =============================== -->
+    <!-- Wallpaper preview attributes    -->
+    <!-- =============================== -->
+    <eat-comment />
+
+    <!-- Use <code>wallpaper-preview</code> as the root tag of the XML resource that
+         describes a wallpaper preview. -->
+    <declare-styleable name="WallpaperPreviewInfo">
+        <!-- A resource id of a static drawable. -->
+        <attr name="staticWallpaperPreview" format="reference" />
+    </declare-styleable>
+
+    <!-- =============================== -->
     <!-- App package class attributes -->
     <!-- =============================== -->
     <eat-comment />
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 8fa1d32..22fe535 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1398,6 +1398,7 @@
   <public type="attr" name="buttonBarStyle" />
   <public type="attr" name="buttonBarButtonStyle" />
   <public type="attr" name="segmentedButtonStyle" />
+  <public type="attr" name="staticWallpaperPreview" />
 
   <public type="anim" name="animator_fade_in" />
   <public type="anim" name="animator_fade_out" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 8d7556f..fd51c0b 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -251,7 +251,7 @@
 
     <style name="Widget.AbsListView">
         <item name="android:scrollbars">vertical</item>
-        <item name="android:fadingEdge">none</item>
+        <item name="android:fadingEdge">vertical</item>
     </style>
 
     <style name="Widget.GestureOverlayView">
@@ -1381,7 +1381,7 @@
         <item name="background">@android:drawable/btn_default_holo_dark</item>
     </style>
 
-    <style name="Holo.SegmentedButton">
+    <style name="Holo.SegmentedButton" parent="SegmentedButton">
         <item name="android:background">@android:drawable/btn_default_holo_dark</item>
     </style>
 
@@ -1759,7 +1759,7 @@
         <item name="android:background">@null</item>
     </style>
 
-    <style name="Holo.Light.SegmentedButton">
+    <style name="Holo.Light.SegmentedButton" parent="SegmentedButton">
         <item name="android:background">@android:drawable/btn_default_holo_light</item>
     </style>
 
@@ -2070,7 +2070,7 @@
     </style>
 
     <style name="Widget.Holo.PreferenceFrameLayout">
-        <item name="android:borderTop">48dip</item>
+        <item name="android:borderTop">0dip</item>
         <item name="android:borderBottom">48dip</item>
         <item name="android:borderLeft">32dip</item>
         <item name="android:borderRight">32dip</item>
diff --git a/data/sounds/AudioPackage6.mk b/data/sounds/AudioPackage6.mk
new file mode 100755
index 0000000..bceaba8
--- /dev/null
+++ b/data/sounds/AudioPackage6.mk
@@ -0,0 +1,108 @@
+#
+# Audio Package 6 - Trygon/Stingray
+# 
+# Include this file in a product makefile to include these audio files
+#
+# 
+
+LOCAL_PATH:= frameworks/base/data/sounds
+
+PRODUCT_COPY_FILES += \
+	$(LOCAL_PATH)/Alarm_Buzzer.ogg:system/media/audio/alarms/Alarm_Buzzer.ogg \
+	$(LOCAL_PATH)/Alarm_Beep_01.ogg:system/media/audio/alarms/Alarm_Beep_01.ogg \
+	$(LOCAL_PATH)/Alarm_Beep_02.ogg:system/media/audio/alarms/Alarm_Beep_02.ogg \
+	$(LOCAL_PATH)/Alarm_Classic.ogg:system/media/audio/alarms/Alarm_Classic.ogg \
+	$(LOCAL_PATH)/Alarm_Beep_03.ogg:system/media/audio/alarms/Alarm_Beep_03.ogg \
+	$(LOCAL_PATH)/effects/Effect_Tick.ogg:system/media/audio/ui/Effect_Tick.ogg \
+	$(LOCAL_PATH)/effects/KeypressStandard.ogg:system/media/audio/ui/KeypressStandard.ogg \
+	$(LOCAL_PATH)/effects/KeypressSpacebar.ogg:system/media/audio/ui/KeypressSpacebar.ogg \
+	$(LOCAL_PATH)/effects/KeypressDelete.ogg:system/media/audio/ui/KeypressDelete.ogg \
+	$(LOCAL_PATH)/effects/KeypressReturn.ogg:system/media/audio/ui/KeypressReturn.ogg \
+	$(LOCAL_PATH)/effects/VideoRecord.ogg:system/media/audio/ui/VideoRecord.ogg \
+	$(LOCAL_PATH)/effects/camera_click.ogg:system/media/audio/ui/camera_click.ogg \
+	$(LOCAL_PATH)/effects/LowBattery.ogg:system/media/audio/ui/LowBattery.ogg \
+	$(LOCAL_PATH)/effects/Dock.ogg:system/media/audio/ui/Dock.ogg \
+	$(LOCAL_PATH)/effects/Undock.ogg:system/media/audio/ui/Undock.ogg \
+	$(LOCAL_PATH)/effects/Lock.ogg:system/media/audio/ui/Lock.ogg \
+	$(LOCAL_PATH)/effects/Unlock.ogg:system/media/audio/ui/Unlock.ogg \
+	$(LOCAL_PATH)/notifications/Aldebaran.ogg:system/media/audio/notifications/Aldebaran.ogg \
+	$(LOCAL_PATH)/notifications/Altair.ogg:system/media/audio/notifications/Altair.ogg \
+	$(LOCAL_PATH)/notifications/Antares.ogg:system/media/audio/notifications/Antares.ogg \
+	$(LOCAL_PATH)/notifications/arcturus.ogg:system/media/audio/notifications/arcturus.ogg \
+	$(LOCAL_PATH)/notifications/Betelgeuse.ogg:system/media/audio/notifications/Betelgeuse.ogg \
+	$(LOCAL_PATH)/notifications/Canopus.ogg:system/media/audio/notifications/Canopus.ogg \
+	$(LOCAL_PATH)/notifications/Capella.ogg:system/media/audio/notifications/Capella.ogg \
+	$(LOCAL_PATH)/notifications/Castor.ogg:system/media/audio/notifications/Castor.ogg \
+	$(LOCAL_PATH)/notifications/CetiAlpha.ogg:system/media/audio/notifications/CetiAlpha.ogg \
+	$(LOCAL_PATH)/notifications/Deneb.ogg:system/media/audio/notifications/Deneb.ogg \
+	$(LOCAL_PATH)/notifications/Electra.ogg:system/media/audio/notifications/Electra.ogg \
+	$(LOCAL_PATH)/notifications/Fomalhaut.ogg:system/media/audio/notifications/Fomalhaut.ogg \
+	$(LOCAL_PATH)/notifications/Merope.ogg:system/media/audio/notifications/Merope.ogg \
+	$(LOCAL_PATH)/notifications/Polaris.ogg:system/media/audio/notifications/Polaris.ogg \
+	$(LOCAL_PATH)/notifications/Pollux.ogg:system/media/audio/notifications/Pollux.ogg \
+	$(LOCAL_PATH)/notifications/Procyon.ogg:system/media/audio/notifications/Procyon.ogg \
+	$(LOCAL_PATH)/notifications/regulus.ogg:system/media/audio/notifications/regulus.ogg \
+	$(LOCAL_PATH)/notifications/sirius.ogg:system/media/audio/notifications/sirius.ogg \
+	$(LOCAL_PATH)/notifications/Sirrah.ogg:system/media/audio/notifications/Sirrah.ogg \
+	$(LOCAL_PATH)/notifications/vega.ogg:system/media/audio/notifications/vega.ogg \
+	$(LOCAL_PATH)/ringtones/ANDROMEDA.ogg:system/media/audio/ringtones/ANDROMEDA.ogg \
+	$(LOCAL_PATH)/ringtones/Aquila.ogg:system/media/audio/ringtones/Aquila.ogg \
+	$(LOCAL_PATH)/ringtones/ArgoNavis.ogg:system/media/audio/ringtones/ArgoNavis.ogg \
+	$(LOCAL_PATH)/ringtones/BOOTES.ogg:system/media/audio/ringtones/BOOTES.ogg \
+	$(LOCAL_PATH)/ringtones/CANISMAJOR.ogg:system/media/audio/ringtones/CANISMAJOR.ogg \
+	$(LOCAL_PATH)/ringtones/Carina.ogg:system/media/audio/ringtones/Carina.ogg \
+	$(LOCAL_PATH)/ringtones/CASSIOPEIA.ogg:system/media/audio/ringtones/CASSIOPEIA.ogg \
+	$(LOCAL_PATH)/ringtones/Centaurus.ogg:system/media/audio/ringtones/Centaurus.ogg \
+	$(LOCAL_PATH)/ringtones/Cygnus.ogg:system/media/audio/ringtones/Cygnus.ogg \
+	$(LOCAL_PATH)/ringtones/Draco.ogg:system/media/audio/ringtones/Draco.ogg \
+	$(LOCAL_PATH)/ringtones/Eridani.ogg:system/media/audio/ringtones/Eridani.ogg \
+	$(LOCAL_PATH)/ringtones/hydra.ogg:system/media/audio/ringtones/hydra.ogg \
+	$(LOCAL_PATH)/ringtones/Lyra.ogg:system/media/audio/ringtones/Lyra.ogg \
+	$(LOCAL_PATH)/ringtones/Machina.ogg:system/media/audio/ringtones/Machina.ogg \
+	$(LOCAL_PATH)/ringtones/Orion.ogg:system/media/audio/ringtones/Orion.ogg \
+	$(LOCAL_PATH)/ringtones/Pegasus.ogg:system/media/audio/ringtones/Pegasus.ogg \
+	$(LOCAL_PATH)/ringtones/PERSEUS.ogg:system/media/audio/ringtones/PERSEUS.ogg \
+	$(LOCAL_PATH)/ringtones/Pyxis.ogg:system/media/audio/ringtones/Pyxis.ogg \
+	$(LOCAL_PATH)/ringtones/Rigel.ogg:system/media/audio/ringtones/Rigel.ogg \
+	$(LOCAL_PATH)/ringtones/Scarabaeus.ogg:system/media/audio/ringtones/Scarabaeus.ogg \
+	$(LOCAL_PATH)/ringtones/Sceptrum.ogg:system/media/audio/ringtones/Sceptrum.ogg \
+	$(LOCAL_PATH)/ringtones/Solarium.ogg:system/media/audio/ringtones/Solarium.ogg \
+	$(LOCAL_PATH)/ringtones/Testudo.ogg:system/media/audio/ringtones/Testudo.ogg \
+	$(LOCAL_PATH)/ringtones/URSAMINOR.ogg:system/media/audio/ringtones/URSAMINOR.ogg \
+	$(LOCAL_PATH)/ringtones/Vespa.ogg:system/media/audio/ringtones/Vespa.ogg \
+	$(LOCAL_PATH)/notifications/alert01.ogg:system/media/audio/notifications/alert01.ogg \
+	$(LOCAL_PATH)/notifications/alert02.ogg:system/media/audio/notifications/alert02.ogg \
+	$(LOCAL_PATH)/notifications/alert03.ogg:system/media/audio/notifications/alert03.ogg \
+	$(LOCAL_PATH)/notifications/alert04.ogg:system/media/audio/notifications/alert04.ogg \
+	$(LOCAL_PATH)/notifications/alert05.ogg:system/media/audio/notifications/alert05.ogg \
+	$(LOCAL_PATH)/notifications/alert06.ogg:system/media/audio/notifications/alert06.ogg \
+	$(LOCAL_PATH)/notifications/alert07.ogg:system/media/audio/notifications/alert07.ogg \
+	$(LOCAL_PATH)/notifications/alert08.ogg:system/media/audio/notifications/alert08.ogg \
+	$(LOCAL_PATH)/notifications/alert09.ogg:system/media/audio/notifications/alert09.ogg \
+	$(LOCAL_PATH)/notifications/alert10.ogg:system/media/audio/notifications/alert10.ogg \
+	$(LOCAL_PATH)/notifications/alert11.ogg:system/media/audio/notifications/alert11.ogg \
+	$(LOCAL_PATH)/notifications/alert12.ogg:system/media/audio/notifications/alert12.ogg \
+	$(LOCAL_PATH)/notifications/alert13.ogg:system/media/audio/notifications/alert13.ogg \
+	$(LOCAL_PATH)/notifications/alert14.ogg:system/media/audio/notifications/alert14.ogg \
+	$(LOCAL_PATH)/notifications/alert15.ogg:system/media/audio/notifications/alert15.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone18.ogg:system/media/audio/ringtones/ringtone18.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone19.ogg:system/media/audio/ringtones/ringtone19.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone20.ogg:system/media/audio/ringtones/ringtone20.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone21.ogg:system/media/audio/ringtones/ringtone21.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone22.ogg:system/media/audio/ringtones/ringtone22.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone23.ogg:system/media/audio/ringtones/ringtone23.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone24.ogg:system/media/audio/ringtones/ringtone24.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone25.ogg:system/media/audio/ringtones/ringtone25.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone26.ogg:system/media/audio/ringtones/ringtone26.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone27.ogg:system/media/audio/ringtones/ringtone27.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone28.ogg:system/media/audio/ringtones/ringtone28.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone29.ogg:system/media/audio/ringtones/ringtone29.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone30.ogg:system/media/audio/ringtones/ringtone30.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone31.ogg:system/media/audio/ringtones/ringtone31.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone32.ogg:system/media/audio/ringtones/ringtone32.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone33.ogg:system/media/audio/ringtones/ringtone33.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone34.ogg:system/media/audio/ringtones/ringtone34.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone35.ogg:system/media/audio/ringtones/ringtone35.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone36.ogg:system/media/audio/ringtones/ringtone36.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone37.ogg:system/media/audio/ringtones/ringtone37.ogg \
+	$(LOCAL_PATH)/ringtones/ringtone38.ogg:system/media/audio/ringtones/ringtone38.ogg
diff --git a/data/sounds/notifications/alert01.ogg b/data/sounds/notifications/alert01.ogg
old mode 100644
new mode 100755
index 310424a..4b900b0
--- a/data/sounds/notifications/alert01.ogg
+++ b/data/sounds/notifications/alert01.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert02.ogg b/data/sounds/notifications/alert02.ogg
old mode 100644
new mode 100755
index 6c6d5c7..469ea6a
--- a/data/sounds/notifications/alert02.ogg
+++ b/data/sounds/notifications/alert02.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert03.ogg b/data/sounds/notifications/alert03.ogg
old mode 100644
new mode 100755
index cd8811f..58f418b
--- a/data/sounds/notifications/alert03.ogg
+++ b/data/sounds/notifications/alert03.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert04.ogg b/data/sounds/notifications/alert04.ogg
old mode 100644
new mode 100755
index 3cdb0b1..4730d6d
--- a/data/sounds/notifications/alert04.ogg
+++ b/data/sounds/notifications/alert04.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert05.ogg b/data/sounds/notifications/alert05.ogg
old mode 100644
new mode 100755
index 2022cc3..663da31
--- a/data/sounds/notifications/alert05.ogg
+++ b/data/sounds/notifications/alert05.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert06.ogg b/data/sounds/notifications/alert06.ogg
old mode 100644
new mode 100755
index 8da9420..2861b84
--- a/data/sounds/notifications/alert06.ogg
+++ b/data/sounds/notifications/alert06.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert07.ogg b/data/sounds/notifications/alert07.ogg
index 1bb6370..6fe905d 100644
--- a/data/sounds/notifications/alert07.ogg
+++ b/data/sounds/notifications/alert07.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert08.ogg b/data/sounds/notifications/alert08.ogg
index 7ebd4aa..ee30c26 100644
--- a/data/sounds/notifications/alert08.ogg
+++ b/data/sounds/notifications/alert08.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert09.ogg b/data/sounds/notifications/alert09.ogg
index dcf9c2b..86b2f2e 100644
--- a/data/sounds/notifications/alert09.ogg
+++ b/data/sounds/notifications/alert09.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert10.ogg b/data/sounds/notifications/alert10.ogg
index 9960ad7..1d93143 100644
--- a/data/sounds/notifications/alert10.ogg
+++ b/data/sounds/notifications/alert10.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert11.ogg b/data/sounds/notifications/alert11.ogg
index 0b907e1..c7327db 100644
--- a/data/sounds/notifications/alert11.ogg
+++ b/data/sounds/notifications/alert11.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert12.ogg b/data/sounds/notifications/alert12.ogg
index 2ebadec..352a049 100644
--- a/data/sounds/notifications/alert12.ogg
+++ b/data/sounds/notifications/alert12.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert13.ogg b/data/sounds/notifications/alert13.ogg
index 6acc2df..0987360 100644
--- a/data/sounds/notifications/alert13.ogg
+++ b/data/sounds/notifications/alert13.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert14.ogg b/data/sounds/notifications/alert14.ogg
index a34a1f0..6e49307 100644
--- a/data/sounds/notifications/alert14.ogg
+++ b/data/sounds/notifications/alert14.ogg
Binary files differ
diff --git a/data/sounds/notifications/alert15.ogg b/data/sounds/notifications/alert15.ogg
index 108aa45..b140427 100644
--- a/data/sounds/notifications/alert15.ogg
+++ b/data/sounds/notifications/alert15.ogg
Binary files differ
diff --git a/include/camera/CameraHardwareInterface.h b/include/camera/CameraHardwareInterface.h
index 16f572c..3c6c94f 100644
--- a/include/camera/CameraHardwareInterface.h
+++ b/include/camera/CameraHardwareInterface.h
@@ -28,8 +28,6 @@
 
 namespace android {
 
-class Overlay;
-
 /**
  *  The size of image for display.
  */
@@ -130,12 +128,6 @@
     virtual status_t    startPreview() = 0;
 
     /**
-     * Only used if overlays are used for camera preview.
-     */
-    virtual bool         useOverlay() {return false;}
-    virtual status_t     setOverlay(const sp<Overlay> &overlay) {return BAD_VALUE;}
-
-    /**
      * Stop a previously started preview.
      */
     virtual void        stopPreview() = 0;
diff --git a/include/private/ui/sw_gralloc_handle.h b/include/private/ui/sw_gralloc_handle.h
deleted file mode 100644
index b3d333e..0000000
--- a/include/private/ui/sw_gralloc_handle.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_UI_PRIVATE_SW_GRALLOC_HANDLE_H
-#define ANDROID_UI_PRIVATE_SW_GRALLOC_HANDLE_H
-
-#include <stdint.h>
-#include <limits.h>
-#include <sys/cdefs.h>
-#include <hardware/gralloc.h>
-#include <errno.h>
-
-#include <cutils/native_handle.h>
-
-namespace android {
-
-/*****************************************************************************/
-
-struct sw_gralloc_handle_t : public native_handle 
-{
-    // file-descriptors
-    int     fd;
-    // ints
-    int     magic;
-    int     size;
-    int     base;
-    int     prot;
-    int     pid;
-
-    static const int sNumInts = 5;
-    static const int sNumFds = 1;
-    static const int sMagic = '_sgh';
-
-    sw_gralloc_handle_t() :
-        fd(-1), magic(sMagic), size(0), base(0), prot(0), pid(getpid())
-    {
-        version = sizeof(native_handle);
-        numInts = sNumInts;
-        numFds = sNumFds;
-    }
-    ~sw_gralloc_handle_t() {
-        magic = 0;
-    }
-
-    static int validate(const native_handle* h) {
-        const sw_gralloc_handle_t* hnd = (const sw_gralloc_handle_t*)h;
-        if (!h || h->version != sizeof(native_handle) ||
-                h->numInts != sNumInts || h->numFds != sNumFds ||
-                hnd->magic != sMagic) 
-        {
-            return -EINVAL;
-        }
-        return 0;
-    }
-
-    static status_t alloc(uint32_t w, uint32_t h, int format,
-            int usage, buffer_handle_t* handle, int32_t* stride);
-    static status_t free(sw_gralloc_handle_t* hnd);
-    static status_t registerBuffer(sw_gralloc_handle_t* hnd);
-    static status_t unregisterBuffer(sw_gralloc_handle_t* hnd);
-    static status_t lock(sw_gralloc_handle_t* hnd, int usage,
-            int l, int t, int w, int h, void** vaddr);
-    static status_t unlock(sw_gralloc_handle_t* hnd);
-};
-
-/*****************************************************************************/
-
-}; // namespace android
-
-#endif /* ANDROID_UI_PRIVATE_SW_GRALLOC_HANDLE_H */
diff --git a/include/surfaceflinger/ISurface.h b/include/surfaceflinger/ISurface.h
index ddbe03d..cd0ee40 100644
--- a/include/surfaceflinger/ISurface.h
+++ b/include/surfaceflinger/ISurface.h
@@ -34,18 +34,15 @@
 
 typedef int32_t    SurfaceID;
 
-class IMemoryHeap;
-class OverlayRef;
 class GraphicBuffer;
 
 class ISurface : public IInterface
 {
 protected:
     enum {
-        REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
-        UNREGISTER_BUFFERS,
-        POST_BUFFER, // one-way transaction
-        CREATE_OVERLAY,
+        RESERVED0 = IBinder::FIRST_CALL_TRANSACTION,
+        RESERVED1,
+        RESERVED2,
         REQUEST_BUFFER,
         SET_BUFFER_COUNT,
     };
@@ -66,49 +63,6 @@
      * sets the number of buffers dequeuable for this surface.
      */
     virtual status_t setBufferCount(int bufferCount) = 0;
-    
-    // ------------------------------------------------------------------------
-    // Deprecated...
-    // ------------------------------------------------------------------------
-
-    class BufferHeap {
-    public:
-        enum {
-            /* rotate source image */
-            ROT_0     = 0,
-            ROT_90    = HAL_TRANSFORM_ROT_90,
-            ROT_180   = HAL_TRANSFORM_ROT_180,
-            ROT_270   = HAL_TRANSFORM_ROT_270,
-        };
-        BufferHeap();
-        
-        BufferHeap(uint32_t w, uint32_t h,
-                int32_t hor_stride, int32_t ver_stride, 
-                PixelFormat format, const sp<IMemoryHeap>& heap);
-        
-        BufferHeap(uint32_t w, uint32_t h,
-                int32_t hor_stride, int32_t ver_stride, 
-                PixelFormat format, uint32_t transform, uint32_t flags,
-                const sp<IMemoryHeap>& heap);
-        
-        ~BufferHeap(); 
-        
-        uint32_t w;
-        uint32_t h;
-        int32_t hor_stride;
-        int32_t ver_stride;
-        PixelFormat format;
-        uint32_t transform;
-        uint32_t flags;
-        sp<IMemoryHeap> heap;
-    };
-    
-    virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
-    virtual void postBuffer(ssize_t offset) = 0; // one-way
-    virtual void unregisterBuffers() = 0;
-    
-    virtual sp<OverlayRef> createOverlay(
-            uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h
index db57859..382cbda 100644
--- a/include/surfaceflinger/ISurfaceComposer.h
+++ b/include/surfaceflinger/ISurfaceComposer.h
@@ -42,7 +42,6 @@
         eDestroyBackbuffer  = 0x00000020,
         eSecure             = 0x00000080,
         eNonPremultiplied   = 0x00000100,
-        ePushBuffers        = 0x00000200,
         eOpaque             = 0x00000400,
 
         eFXSurfaceNormal    = 0x00000000,
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h
index 2cd0911..16117ad 100644
--- a/include/ui/FramebufferNativeWindow.h
+++ b/include/ui/FramebufferNativeWindow.h
@@ -23,6 +23,7 @@
 #include <EGL/egl.h>
 
 #include <utils/threads.h>
+#include <utils/String8.h>
 #include <ui/Rect.h>
 
 #include <pixelflinger/pixelflinger.h>
@@ -56,7 +57,9 @@
     bool isUpdateOnDemand() const { return mUpdateOnDemand; }
     status_t setUpdateRectangle(const Rect& updateRect);
     status_t compositionComplete();
-    
+
+    void dump(String8& result);
+
     // for debugging only
     int getCurrentBufferIndex() const;
 
diff --git a/include/ui/IOverlay.h b/include/ui/IOverlay.h
deleted file mode 100644
index af3add1..0000000
--- a/include/ui/IOverlay.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_IOVERLAY_H
-#define ANDROID_IOVERLAY_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <binder/IInterface.h>
-#include <utils/RefBase.h>
-#include <ui/PixelFormat.h>
-
-namespace android {
-
-class IOverlay : public IInterface
-{
-public: 
-    DECLARE_META_INTERFACE(Overlay);
-
-    virtual void destroy() = 0; // one-way
-};
-
-// ----------------------------------------------------------------------------
-
-class BnOverlay : public BnInterface<IOverlay>
-{
-public:
-    virtual status_t    onTransact( uint32_t code,
-                                    const Parcel& data,
-                                    Parcel* reply,
-                                    uint32_t flags = 0);
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_IOVERLAY_H
diff --git a/include/ui/Overlay.h b/include/ui/Overlay.h
deleted file mode 100644
index a9ae1c4..0000000
--- a/include/ui/Overlay.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_OVERLAY_H
-#define ANDROID_OVERLAY_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <binder/IInterface.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-#include <ui/PixelFormat.h>
-#include <ui/IOverlay.h>
-
-#include <hardware/overlay.h>
-
-namespace android {
-
-class IMemory;
-class IMemoryHeap;
-
-// ----------------------------------------------------------------------------
-
-class OverlayRef : public LightRefBase<OverlayRef>
-{
-public:
-    OverlayRef(overlay_handle_t, const sp<IOverlay>&,
-            uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs);
-
-    static sp<OverlayRef> readFromParcel(const Parcel& data);
-    static status_t writeToParcel(Parcel* reply, const sp<OverlayRef>& o);    
-
-private:
-    friend class LightRefBase<OverlayRef>;
-    friend class Overlay;
-
-    OverlayRef();
-    virtual ~OverlayRef();
-
-    overlay_handle_t mOverlayHandle;
-    sp<IOverlay> mOverlayChannel;
-    uint32_t mWidth;
-    uint32_t mHeight;
-    int32_t  mFormat;
-    int32_t  mWidthStride;
-    int32_t  mHeightStride;
-    bool mOwnHandle;
-};
-
-// ----------------------------------------------------------------------------
-
-class Overlay : public virtual RefBase
-{
-public:
-    Overlay(const sp<OverlayRef>& overlayRef);
-
-    /* destroys this overlay */
-    void destroy();
-    
-    /* get the HAL handle for this overlay */
-    overlay_handle_t getHandleRef() const;
-
-    /* blocks until an overlay buffer is available and return that buffer. */
-    status_t dequeueBuffer(overlay_buffer_t* buffer);
-
-    /* release the overlay buffer and post it */
-    status_t queueBuffer(overlay_buffer_t buffer);
-
-    /* change the width and height of the overlay */
-    status_t resizeInput(uint32_t width, uint32_t height);
-
-    status_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h) ;
-
-    status_t getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ;
-
-    /* set the buffer attributes */
-    status_t setParameter(int param, int value);
-
-    /* returns the address of a given buffer if supported, NULL otherwise. */
-    void* getBufferAddress(overlay_buffer_t buffer);
-
-    /* get physical informations about the overlay */
-    uint32_t getWidth() const;
-    uint32_t getHeight() const;
-    int32_t getFormat() const;
-    int32_t getWidthStride() const;
-    int32_t getHeightStride() const;
-    int32_t getBufferCount() const;
-    status_t getStatus() const;
-    
-private:
-    virtual ~Overlay();
-
-    sp<OverlayRef> mOverlayRef;
-    overlay_data_device_t *mOverlayData;
-    status_t mStatus;
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_OVERLAY_H
diff --git a/include/utils/Asset.h b/include/utils/Asset.h
index 2a09095..1fe0e06 100644
--- a/include/utils/Asset.h
+++ b/include/utils/Asset.h
@@ -23,9 +23,11 @@
 
 #include <stdio.h>
 #include <sys/types.h>
-#include "FileMap.h"
-#include "String8.h"
-#include "Errors.h"
+
+#include <utils/Compat.h>
+#include <utils/Errors.h>
+#include <utils/FileMap.h>
+#include <utils/String8.h>
 
 namespace android {
 
@@ -69,10 +71,10 @@
 
     /*
      * Seek to the specified offset.  "whence" uses the same values as
-     * lseek/fseek.  Returns the new position on success, or (off_t) -1
+     * lseek/fseek.  Returns the new position on success, or (off64_t) -1
      * on failure.
      */
-    virtual off_t seek(off_t offset, int whence) = 0;
+    virtual off64_t seek(off64_t offset, int whence) = 0;
 
     /*
      * Close the asset, freeing all associated resources.
@@ -87,26 +89,26 @@
     /*
      * Get the total amount of data that can be read.
      */
-    virtual off_t getLength(void) const = 0;
+    virtual off64_t getLength(void) const = 0;
 
     /*
      * Get the total amount of data that can be read from the current position.
      */
-    virtual off_t getRemainingLength(void) const = 0;
+    virtual off64_t getRemainingLength(void) const = 0;
 
     /*
      * Open a new file descriptor that can be used to read this asset.
      * Returns -1 if you can not use the file descriptor (for example if the
      * asset is compressed).
      */
-    virtual int openFileDescriptor(off_t* outStart, off_t* outLength) const = 0;
-    
+    virtual int openFileDescriptor(off64_t* outStart, off64_t* outLength) const = 0;
+
     /*
      * Return whether this asset's buffer is allocated in RAM (not mmapped).
      * Note: not virtual so it is safe to call even when being destroyed.
      */
     virtual bool isAllocated(void) const { return false; }
-    
+
     /*
      * Get a string identifying the asset's source.  This might be a full
      * path, it might be a colon-separated list of identifiers.
@@ -120,7 +122,7 @@
     Asset(void);        // constructor; only invoked indirectly
 
     /* handle common seek() housekeeping */
-    off_t handleSeek(off_t offset, int whence, off_t curPosn, off_t maxPosn);
+    off64_t handleSeek(off64_t offset, int whence, off64_t curPosn, off64_t maxPosn);
 
     /* set the asset source string */
     void setAssetSource(const String8& path) { mAssetSource = path; }
@@ -153,7 +155,7 @@
      *
      * The asset takes ownership of the file descriptor.
      */
-    static Asset* createFromFileSegment(int fd, off_t offset, size_t length,
+    static Asset* createFromFileSegment(int fd, off64_t offset, size_t length,
         AccessMode mode);
 
     /*
@@ -166,7 +168,7 @@
      * This may not verify the validity of the compressed data until first
      * use.
      */
-    static Asset* createFromCompressedData(int fd, off_t offset,
+    static Asset* createFromCompressedData(int fd, off64_t offset,
         int compressionMethod, size_t compressedLength,
         size_t uncompressedLength, AccessMode mode);
 #endif
@@ -221,7 +223,7 @@
      *
      * On success, the object takes ownership of "fd".
      */
-    status_t openChunk(const char* fileName, int fd, off_t offset, size_t length);
+    status_t openChunk(const char* fileName, int fd, off64_t offset, size_t length);
 
     /*
      * Use a memory-mapped region.
@@ -234,18 +236,18 @@
      * Standard Asset interfaces.
      */
     virtual ssize_t read(void* buf, size_t count);
-    virtual off_t seek(off_t offset, int whence);
+    virtual off64_t seek(off64_t offset, int whence);
     virtual void close(void);
     virtual const void* getBuffer(bool wordAligned);
-    virtual off_t getLength(void) const { return mLength; }
-    virtual off_t getRemainingLength(void) const { return mLength-mOffset; }
-    virtual int openFileDescriptor(off_t* outStart, off_t* outLength) const;
+    virtual off64_t getLength(void) const { return mLength; }
+    virtual off64_t getRemainingLength(void) const { return mLength-mOffset; }
+    virtual int openFileDescriptor(off64_t* outStart, off64_t* outLength) const;
     virtual bool isAllocated(void) const { return mBuf != NULL; }
 
 private:
-    off_t       mStart;         // absolute file offset of start of chunk
-    off_t       mLength;        // length of the chunk
-    off_t       mOffset;        // current local offset, 0 == mStart
+    off64_t     mStart;         // absolute file offset of start of chunk
+    off64_t     mLength;        // length of the chunk
+    off64_t     mOffset;        // current local offset, 0 == mStart
     FILE*       mFp;            // for read/seek
     char*       mFileName;      // for opening
 
@@ -276,7 +278,7 @@
      *
      * On success, the object takes ownership of "fd".
      */
-    status_t openChunk(int fd, off_t offset, int compressionMethod,
+    status_t openChunk(int fd, off64_t offset, int compressionMethod,
         size_t uncompressedLen, size_t compressedLen);
 
     /*
@@ -291,19 +293,19 @@
      * Standard Asset interfaces.
      */
     virtual ssize_t read(void* buf, size_t count);
-    virtual off_t seek(off_t offset, int whence);
+    virtual off64_t seek(off64_t offset, int whence);
     virtual void close(void);
     virtual const void* getBuffer(bool wordAligned);
-    virtual off_t getLength(void) const { return mUncompressedLen; }
-    virtual off_t getRemainingLength(void) const { return mUncompressedLen-mOffset; }
-    virtual int openFileDescriptor(off_t* outStart, off_t* outLength) const { return -1; }
+    virtual off64_t getLength(void) const { return mUncompressedLen; }
+    virtual off64_t getRemainingLength(void) const { return mUncompressedLen-mOffset; }
+    virtual int openFileDescriptor(off64_t* outStart, off64_t* outLength) const { return -1; }
     virtual bool isAllocated(void) const { return mBuf != NULL; }
 
 private:
-    off_t       mStart;         // offset to start of compressed data
-    off_t       mCompressedLen; // length of the compressed data
-    off_t       mUncompressedLen; // length of the uncompressed data
-    off_t       mOffset;        // current offset, 0 == start of uncomp data
+    off64_t     mStart;         // offset to start of compressed data
+    off64_t     mCompressedLen; // length of the compressed data
+    off64_t     mUncompressedLen; // length of the uncompressed data
+    off64_t     mOffset;        // current offset, 0 == start of uncomp data
 
     FileMap*    mMap;           // for memory-mapped input
     int         mFd;            // for file input
diff --git a/include/utils/Compat.h b/include/utils/Compat.h
new file mode 100644
index 0000000..1819266
--- /dev/null
+++ b/include/utils/Compat.h
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#ifndef __LIB_UTILS_COMPAT_H
+#define __LIB_UTILS_COMPAT_H
+
+#include <unistd.h>
+
+/* Compatibility definitions for non-Linux (i.e., BSD-based) hosts. */
+#ifndef HAVE_OFF64_T
+#if _FILE_OFFSET_BITS < 64
+#error "_FILE_OFFSET_BITS < 64; large files are not supported on this platform"
+#endif /* _FILE_OFFSET_BITS < 64 */
+
+typedef off_t off64_t;
+
+static inline off64_t lseek64(int fd, off64_t offset, int whence) {
+    return lseek(fd, offset, whence);
+}
+
+#ifdef HAVE_PREAD
+static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) {
+    return pread(fd, buf, nbytes, offset);
+}
+#endif
+
+#endif /* !HAVE_OFF64_T */
+
+#endif /* __LIB_UTILS_COMPAT_H */
diff --git a/include/utils/FileMap.h b/include/utils/FileMap.h
index 8dfd3be..dfe6d51 100644
--- a/include/utils/FileMap.h
+++ b/include/utils/FileMap.h
@@ -22,6 +22,8 @@
 
 #include <sys/types.h>
 
+#include <utils/Compat.h>
+
 #ifdef HAVE_WIN32_FILEMAP
 #include <windows.h>
 #endif
@@ -55,7 +57,7 @@
      * Returns "false" on failure.
      */
     bool create(const char* origFileName, int fd,
-                off_t offset, size_t length, bool readOnly);
+                off64_t offset, size_t length, bool readOnly);
 
     /*
      * Return the name of the file this map came from, if known.
@@ -75,7 +77,7 @@
     /*
      * Get the data offset used to create this map.
      */
-    off_t getDataOffset(void) const { return mDataOffset; }
+    off64_t getDataOffset(void) const { return mDataOffset; }
 
     /*
      * Get a "copy" of the object.
@@ -118,7 +120,7 @@
     char*       mFileName;      // original file name, if known
     void*       mBasePtr;       // base of mmap area; page aligned
     size_t      mBaseLength;    // length, measured from "mBasePtr"
-    off_t       mDataOffset;    // offset used when map was created
+    off64_t     mDataOffset;    // offset used when map was created
     void*       mDataPtr;       // start of requested data, offset from base
     size_t      mDataLength;    // length, measured from "mDataPtr"
 #ifdef HAVE_WIN32_FILEMAP
diff --git a/include/utils/StreamingZipInflater.h b/include/utils/StreamingZipInflater.h
index 16867d8..3ace5d5 100644
--- a/include/utils/StreamingZipInflater.h
+++ b/include/utils/StreamingZipInflater.h
@@ -21,6 +21,8 @@
 #include <inttypes.h>
 #include <zlib.h>
 
+#include <utils/Compat.h>
+
 namespace android {
 
 class StreamingZipInflater {
@@ -29,7 +31,7 @@
     static const size_t OUTPUT_CHUNK_SIZE = 64 * 1024;
 
     // Flavor that pages in the compressed data from a fd
-    StreamingZipInflater(int fd, off_t compDataStart, size_t uncompSize, size_t compSize);
+    StreamingZipInflater(int fd, off64_t compDataStart, size_t uncompSize, size_t compSize);
 
     // Flavor that gets the compressed data from an in-memory buffer
     StreamingZipInflater(class FileMap* dataMap, size_t uncompSize);
@@ -43,7 +45,7 @@
     // seeking backwards requires uncompressing fom the beginning, so is very
     // expensive.  seeking forwards only requires uncompressing from the current
     // position to the destination.
-    off_t seekAbsolute(off_t absoluteInputPosition);
+    off64_t seekAbsolute(off64_t absoluteInputPosition);
 
 private:
     void initInflateState();
@@ -51,7 +53,7 @@
 
     // where to find the uncompressed data
     int mFd;
-    off_t mInFileStart;         // where the compressed data lives in the file
+    off64_t mInFileStart;         // where the compressed data lives in the file
     class FileMap* mDataMap;
 
     z_stream mInflateState;
@@ -63,7 +65,7 @@
     size_t mOutTotalSize;       // total uncompressed size of the blob
 
     // current output state bookkeeping
-    off_t mOutCurPosition;      // current position in total offset
+    off64_t mOutCurPosition;      // current position in total offset
     size_t mOutLastDecoded;     // last decoded byte + 1 in mOutbuf
     size_t mOutDeliverable;     // next undelivered byte of decoded output in mOutBuf
 
diff --git a/include/utils/ZipFileCRO.h b/include/utils/ZipFileCRO.h
index e38bf66..3e42a95 100644
--- a/include/utils/ZipFileCRO.h
+++ b/include/utils/ZipFileCRO.h
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <utils/Compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -48,7 +50,7 @@
 
 extern bool ZipFileCRO_getEntryInfo(ZipFileCRO zip, ZipEntryCRO entry,
         int* pMethod, size_t* pUncompLen,
-        size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32);
+        size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32);
 
 extern bool ZipFileCRO_uncompressEntry(ZipFileCRO zip, ZipEntryCRO entry, int fd);
 
diff --git a/include/utils/ZipFileRO.h b/include/utils/ZipFileRO.h
index 3c1f3ca..3a99979 100644
--- a/include/utils/ZipFileRO.h
+++ b/include/utils/ZipFileRO.h
@@ -30,6 +30,7 @@
 #ifndef __LIBS_ZIPFILERO_H
 #define __LIBS_ZIPFILERO_H
 
+#include <utils/Compat.h>
 #include <utils/Errors.h>
 #include <utils/FileMap.h>
 #include <utils/threads.h>
@@ -128,7 +129,7 @@
      * appears to be bad.
      */
     bool getEntryInfo(ZipEntryRO entry, int* pMethod, size_t* pUncompLen,
-        size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) const;
+        size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32) const;
 
     /*
      * Create a new FileMap object that maps a subset of the archive.  For
@@ -231,7 +232,7 @@
     int         mNumEntries;
 
     /* CD directory offset in the Zip archive */
-    off_t       mDirectoryOffset;
+    off64_t     mDirectoryOffset;
 
     /*
      * We know how many entries are in the Zip archive, so we have a
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index e8ced9c..318c120 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -34,7 +34,6 @@
 #include "PathCache.h"
 #include "TextDropShadowCache.h"
 #include "FboCache.h"
-#include "Line.h"
 #include "ResourceCache.h"
 
 namespace android {
@@ -158,8 +157,6 @@
     GammaFontRenderer fontRenderer;
     ResourceCache resourceCache;
 
-    Line line;
-
 private:
     DebugLevel mDebugLevel;
 }; // class Caches
diff --git a/libs/hwui/Line.h b/libs/hwui/Line.h
deleted file mode 100644
index 264fd19..0000000
--- a/libs/hwui/Line.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ANDROID_HWUI_LINE_H
-#define ANDROID_HWUI_LINE_H
-
-#include <GLES2/gl2.h>
-
-#include <cmath>
-
-#include <sys/types.h>
-
-#include "Patch.h"
-
-namespace android {
-namespace uirenderer {
-
-///////////////////////////////////////////////////////////////////////////////
-// Globals
-///////////////////////////////////////////////////////////////////////////////
-
-// Alpha8 texture used to perform texture anti-aliasing
-static const uint8_t gLineTexture[] = {
-        0,   0,   0,   0, 0,
-        0, 255, 255, 255, 0,
-        0, 255, 255, 255, 0,
-        0, 255, 255, 255, 0,
-        0,   0,   0,   0, 0
-};
-static const GLsizei gLineTextureWidth = 5;
-static const GLsizei gLineTextureHeight = 5;
-static const float gLineAABias = 1.0f;
-
-///////////////////////////////////////////////////////////////////////////////
-// Line
-///////////////////////////////////////////////////////////////////////////////
-
-class Line {
-public:
-    Line(): mXDivsCount(2), mYDivsCount(2) {
-        mPatch = new Patch(mXDivsCount, mYDivsCount);
-        mXDivs = new int32_t[mXDivsCount];
-        mYDivs = new int32_t[mYDivsCount];
-
-        mXDivs[0] = mYDivs[0] = 2;
-        mXDivs[1] = mYDivs[1] = 3;
-
-        mPatch->copy(mXDivs, mYDivs);
-
-        glGenTextures(1, &mTexture);
-        glBindTexture(GL_TEXTURE_2D, mTexture);
-
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gLineTextureWidth, gLineTextureHeight, 0,
-                GL_ALPHA, GL_UNSIGNED_BYTE, gLineTexture);
-    }
-
-    ~Line() {
-        delete mPatch;
-        delete[] mXDivs;
-        delete[] mYDivs;
-
-        glDeleteTextures(1, &mTexture);
-    }
-
-    inline float getLength(float x1, float y1, float x2, float y2) {
-        return sqrtf((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
-    }
-
-    void update(float x1, float y1, float x2, float y2, float lineWidth, float& tx, float& ty) {
-        const float length = getLength(x1, y1, x2, y2);
-        const float half = lineWidth * 0.5f;
-
-        mPatch->updateVertices(gLineTextureWidth, gLineTextureHeight,
-                -gLineAABias, -half - gLineAABias, length + gLineAABias, half + gLineAABias);
-
-        tx = -gLineAABias;
-        ty = lineWidth <= 1.0f ? -gLineAABias : -half - gLineAABias;
-    }
-
-    inline GLuint getMeshBuffer() const {
-        return mPatch->meshBuffer;
-    }
-
-    inline GLsizei getElementsCount() const {
-        return mPatch->verticesCount;
-    }
-
-    inline GLuint getTexture() const {
-        return mTexture;
-    }
-
-private:
-    uint32_t mXDivsCount;
-    uint32_t mYDivsCount;
-
-    int32_t* mXDivs;
-    int32_t* mYDivs;
-
-    Patch* mPatch;
-
-    GLuint mTexture;
-}; // class Line
-
-}; // namespace uirenderer
-}; // namespace android
-
-#endif // ANDROID_HWUI_LINE_H
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 1a89ca0..b357973 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -30,6 +30,7 @@
 
 #include "OpenGLRenderer.h"
 #include "DisplayListRenderer.h"
+#include "Vector.h"
 
 namespace android {
 namespace uirenderer {
@@ -989,6 +990,12 @@
     // TODO: Should do quickReject for each line
     if (mSnapshot->invisible) return;
 
+    const bool isAA = paint->isAntiAlias();
+    const float strokeWidth = paint->getStrokeWidth() * 0.5f;
+    // A stroke width of 0 has a special meaningin Skia:
+    // it draws an unscaled 1px wide line
+    const bool isHairLine = paint->getStrokeWidth() == 0.0f;
+
     setupDraw();
 
     int alpha;
@@ -1001,59 +1008,105 @@
     const GLfloat g = a * ((color >>  8) & 0xFF) / 255.0f;
     const GLfloat b = a * ((color      ) & 0xFF) / 255.0f;
 
-    const bool isAA = paint->isAntiAlias();
-    if (isAA) {
-        GLuint textureUnit = 0;
-        glActiveTexture(gTextureUnits[textureUnit]);
-        setupTextureAlpha8(mCaches.line.getTexture(), 0, 0, textureUnit, 0.0f, 0.0f, r, g, b, a,
-                mode, false, true, (GLvoid*) 0, (GLvoid*) gMeshTextureOffset,
-                mCaches.line.getMeshBuffer());
+    // Used only with AA lines
+    GLuint textureUnit = 0;
+
+    // Describe the required shaders
+    ProgramDescription description;
+    const bool setColor = description.setColor(r, g, b, a);
+
+    if (mShader) {
+        mShader->describe(description, mCaches.extensions);
+    }
+    if (mColorFilter) {
+        mColorFilter->describe(description, mCaches.extensions);
+    }
+
+    // Setup the blending mode
+    chooseBlending(a < 1.0f || (mShader && mShader->blend()), mode, description);
+
+    // We're not drawing with VBOs here
+    mCaches.unbindMeshBuffer();
+
+    int verticesCount = count >> 2;
+    if (!isHairLine) {
+        // TODO: AA needs more vertices
+        verticesCount *= 6;
     } else {
-        setupColorRect(0.0f, 0.0f, 1.0f, 1.0f, r, g, b, a, mode, false, true);
+        // TODO: AA will be different
+        verticesCount *= 2;
     }
 
-    const float strokeWidth = paint->getStrokeWidth();
-    const GLsizei elementsCount = isAA ? mCaches.line.getElementsCount() : gMeshCount;
-    const GLenum drawMode = isAA ? GL_TRIANGLES : GL_TRIANGLE_STRIP;
+    TextureVertex lines[verticesCount];
+    TextureVertex* vertex = &lines[0];
 
-    for (int i = 0; i < count; i += 4) {
-        float tx = 0.0f;
-        float ty = 0.0f;
+    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE,
+            gMeshStride, vertex);
 
-        if (isAA) {
-            mCaches.line.update(points[i], points[i + 1], points[i + 2], points[i + 3],
-                    strokeWidth, tx, ty);
-        } else {
-            ty = strokeWidth <= 1.0f ? 0.0f : -strokeWidth * 0.5f;
-        }
+    mModelView.loadIdentity();
 
-        const float dx = points[i + 2] - points[i];
-        const float dy = points[i + 3] - points[i + 1];
-        const float mag = sqrtf(dx * dx + dy * dy);
-        const float angle = acos(dx / mag);
+    // Build and use the appropriate shader
+    useProgram(mCaches.programCache.get(description));
+    mCaches.currentProgram->set(mOrthoMatrix, mModelView, *mSnapshot->transform);
 
-        mModelView.loadTranslate(points[i], points[i + 1], 0.0f);
-        if (angle > MIN_ANGLE || angle < -MIN_ANGLE) {
-            mModelView.rotate(angle * RAD_TO_DEG, 0.0f, 0.0f, 1.0f);
-        }
-        mModelView.translate(tx, ty, 0.0f);
-        if (!isAA) {
-            float length = mCaches.line.getLength(points[i], points[i + 1],
-                    points[i + 2], points[i + 3]);
-            mModelView.scale(length, strokeWidth, 1.0f);
-        }
-        mCaches.currentProgram->set(mOrthoMatrix, mModelView, *mSnapshot->transform);
-        // TODO: Add bounds to the layer's region
-
-        if (mShader) {
-            mShader->updateTransforms(mCaches.currentProgram, mModelView, *mSnapshot);
-        }
-
-        glDrawArrays(drawMode, 0, elementsCount);
+    if (!mShader || (mShader && setColor)) {
+        mCaches.currentProgram->setColor(r, g, b, a);
     }
 
-    if (isAA) {
-        glDisableVertexAttribArray(mCaches.currentProgram->getAttrib("texCoords"));
+    if (mShader) {
+        mShader->setupProgram(mCaches.currentProgram, mModelView, *mSnapshot, &textureUnit);
+    }
+    if (mColorFilter) {
+        mColorFilter->setupProgram(mCaches.currentProgram);
+    }
+
+    if (!isHairLine) {
+        // TODO: Handle the AA case
+        for (int i = 0; i < count; i += 4) {
+            // a = start point, b = end point
+            vec2 a(points[i], points[i + 1]);
+            vec2 b(points[i + 2], points[i + 3]);
+
+            // Bias to snap to the same pixels as Skia
+            a += 0.375;
+            b += 0.375;
+
+            // Find the normal to the line
+            vec2 n = (b - a).copyNormalized() * strokeWidth;
+            float x = n.x;
+            n.x = -n.y;
+            n.y = x;
+
+            // Four corners of the rectangle defining a thick line
+            vec2 p1 = a - n;
+            vec2 p2 = a + n;
+            vec2 p3 = b + n;
+            vec2 p4 = b - n;
+
+            // Draw the line as 2 triangles, could be optimized
+            // by using only 4 vertices and the correct indices
+            // Also we should probably used non textured vertices
+            // when line AA is disabled to save on bandwidth
+            TextureVertex::set(vertex++, p1.x, p1.y, 0.0f, 0.0f);
+            TextureVertex::set(vertex++, p2.x, p2.y, 0.0f, 0.0f);
+            TextureVertex::set(vertex++, p3.x, p3.y, 0.0f, 0.0f);
+            TextureVertex::set(vertex++, p1.x, p1.y, 0.0f, 0.0f);
+            TextureVertex::set(vertex++, p3.x, p3.y, 0.0f, 0.0f);
+            TextureVertex::set(vertex++, p4.x, p4.y, 0.0f, 0.0f);
+
+            // TODO: Mark the dirty regions when RENDER_LAYERS_AS_REGIONS is set
+        }
+
+        // GL_LINE does not give the result we want to match Skia
+        glDrawArrays(GL_TRIANGLES, 0, verticesCount);
+    } else {
+        // TODO: Handle the AA case
+        for (int i = 0; i < count; i += 4) {
+            TextureVertex::set(vertex++, points[i], points[i + 1], 0.0f, 0.0f);
+            TextureVertex::set(vertex++, points[i + 2], points[i + 3], 0.0f, 0.0f);
+        }
+        glLineWidth(1.0f);
+        glDrawArrays(GL_LINES, 0, verticesCount);
     }
 }
 
diff --git a/libs/hwui/Vector.h b/libs/hwui/Vector.h
new file mode 100644
index 0000000..46dded5
--- /dev/null
+++ b/libs/hwui/Vector.h
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HWUI_VECTOR_H
+#define ANDROID_HWUI_VECTOR_H
+
+namespace android {
+namespace uirenderer {
+
+///////////////////////////////////////////////////////////////////////////////
+// Classes
+///////////////////////////////////////////////////////////////////////////////
+
+struct Vector2 {
+    float x;
+    float y;
+
+    Vector2() :
+        x(0.0f), y(0.0f) {
+    }
+
+    Vector2(float px, float py) :
+        x(px), y(py) {
+    }
+
+    float length() const {
+        return sqrt(x * x + y * y);
+    }
+
+    void operator+=(const Vector2& v) {
+        x += v.x;
+        y += v.y;
+    }
+
+    void operator-=(const Vector2& v) {
+        x -= v.x;
+        y -= v.y;
+    }
+
+    void operator+=(const float v) {
+        x += v;
+        y += v;
+    }
+
+    void operator-=(const float v) {
+        x -= v;
+        y -= v;
+    }
+
+    void operator/=(float s) {
+        x /= s;
+        y /= s;
+    }
+
+    void operator*=(float s) {
+        x *= s;
+        y *= s;
+    }
+
+    Vector2 operator+(const Vector2& v) const {
+        return Vector2(x + v.x, y + v.y);
+    }
+
+    Vector2 operator-(const Vector2& v) const {
+        return Vector2(x - v.x, y - v.y);
+    }
+
+    Vector2 operator/(float s) const {
+        return Vector2(x / s, y / s);
+    }
+
+    Vector2 operator*(float s) const {
+        return Vector2(x * s, y * s);
+    }
+
+    void normalize() {
+        float s = 1.0f / length();
+        x *= s;
+        y *= s;
+    }
+
+    Vector2 copyNormalized() const {
+        Vector2 v(x, y);
+        v.normalize();
+        return v;
+    }
+
+    float dot(const Vector2& v) const {
+        return x * v.x + y * v.y;
+    }
+
+    void dump() {
+        LOGD("Vector2[%.2f, %.2f]", x, y);
+    }
+}; // class Vector2
+
+///////////////////////////////////////////////////////////////////////////////
+// Types
+///////////////////////////////////////////////////////////////////////////////
+
+typedef Vector2 vec2;
+
+}; // namespace uirenderer
+}; // namespace android
+
+#endif // ANDROID_HWUI_VECTOR_H
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
index 04b7f1b..a5d06e9 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -38,8 +38,8 @@
         pfb.setVaryingColor(true);
         rs.bindProgramFragment(pfb.create());
 
-        ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT,
-                                                         Allocation.USAGE_GRAPHICS_VERTEX);
+        ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);//
+ //                                                        Allocation.USAGE_GRAPHICS_VERTEX);
 
         Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
         smb.addVertexAllocation(points.getAllocation());
diff --git a/libs/surfaceflinger_client/ISurface.cpp b/libs/surfaceflinger_client/ISurface.cpp
index 7049d9e..23b90af 100644
--- a/libs/surfaceflinger_client/ISurface.cpp
+++ b/libs/surfaceflinger_client/ISurface.cpp
@@ -21,9 +21,7 @@
 #include <sys/types.h>
 
 #include <binder/Parcel.h>
-#include <binder/IMemory.h>
 
-#include <ui/Overlay.h>
 #include <ui/GraphicBuffer.h>
 
 #include <surfaceflinger/Surface.h>
@@ -33,36 +31,6 @@
 
 // ----------------------------------------------------------------------
 
-ISurface::BufferHeap::BufferHeap() 
-    : w(0), h(0), hor_stride(0), ver_stride(0), format(0),
-    transform(0), flags(0) 
-{     
-}
-
-ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h,
-        int32_t hor_stride, int32_t ver_stride,
-        PixelFormat format, const sp<IMemoryHeap>& heap)
-    : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride),
-      format(format), transform(0), flags(0), heap(heap) 
-{
-}
-
-ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h,
-        int32_t hor_stride, int32_t ver_stride,
-        PixelFormat format, uint32_t transform, uint32_t flags,
-        const sp<IMemoryHeap>& heap)
-        : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride),
-          format(format), transform(transform), flags(flags), heap(heap) 
-{
-}
-
-
-ISurface::BufferHeap::~BufferHeap() 
-{     
-}
-
-// ----------------------------------------------------------------------
-
 class BpSurface : public BpInterface<ISurface>
 {
 public:
@@ -96,51 +64,6 @@
         status_t err = reply.readInt32();
         return err;
     }
-
-    virtual status_t registerBuffers(const BufferHeap& buffers)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
-        data.writeInt32(buffers.w);
-        data.writeInt32(buffers.h);
-        data.writeInt32(buffers.hor_stride);
-        data.writeInt32(buffers.ver_stride);
-        data.writeInt32(buffers.format);
-        data.writeInt32(buffers.transform);
-        data.writeInt32(buffers.flags);
-        data.writeStrongBinder(buffers.heap->asBinder());
-        remote()->transact(REGISTER_BUFFERS, data, &reply);
-        status_t result = reply.readInt32();
-        return result;
-    }
-
-    virtual void postBuffer(ssize_t offset)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
-        data.writeInt32(offset);
-        remote()->transact(POST_BUFFER, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    virtual void unregisterBuffers()
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
-        remote()->transact(UNREGISTER_BUFFERS, data, &reply);
-    }
-
-    virtual sp<OverlayRef> createOverlay(
-             uint32_t w, uint32_t h, int32_t format, int32_t orientation)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
-        data.writeInt32(w);
-        data.writeInt32(h);
-        data.writeInt32(format);
-        data.writeInt32(orientation);
-        remote()->transact(CREATE_OVERLAY, data, &reply);
-        return OverlayRef::readFromParcel(reply);
-    }
 };
 
 IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
@@ -170,41 +93,6 @@
             reply->writeInt32(err);
             return NO_ERROR;
         }
-        case REGISTER_BUFFERS: {
-            CHECK_INTERFACE(ISurface, data, reply);
-            BufferHeap buffer;
-            buffer.w = data.readInt32();
-            buffer.h = data.readInt32();
-            buffer.hor_stride = data.readInt32();
-            buffer.ver_stride= data.readInt32();
-            buffer.format = data.readInt32();
-            buffer.transform = data.readInt32();
-            buffer.flags = data.readInt32();
-            buffer.heap = interface_cast<IMemoryHeap>(data.readStrongBinder());
-            status_t err = registerBuffers(buffer);
-            reply->writeInt32(err);
-            return NO_ERROR;
-        } break;
-        case UNREGISTER_BUFFERS: {
-            CHECK_INTERFACE(ISurface, data, reply);
-            unregisterBuffers();
-            return NO_ERROR;
-        } break;
-        case POST_BUFFER: {
-            CHECK_INTERFACE(ISurface, data, reply);
-            ssize_t offset = data.readInt32();
-            postBuffer(offset);
-            return NO_ERROR;
-        } break;
-        case CREATE_OVERLAY: {
-            CHECK_INTERFACE(ISurface, data, reply);
-            int w = data.readInt32();
-            int h = data.readInt32();
-            int f = data.readInt32();
-            int orientation = data.readInt32();
-            sp<OverlayRef> o = createOverlay(w, h, f, orientation);
-            return OverlayRef::writeToParcel(reply, o);
-        } break;
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index d0e041a..4ba8b5b 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -54,8 +54,6 @@
 	InputManager.cpp \
 	InputReader.cpp \
 	InputTransport.cpp \
-	IOverlay.cpp \
-	Overlay.cpp \
 	PixelFormat.cpp \
 	Rect.cpp \
 	Region.cpp
@@ -64,7 +62,6 @@
 	libcutils \
 	libutils \
 	libEGL \
-	libbinder \
 	libpixelflinger \
 	libhardware \
 	libhardware_legacy
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 04a0195..0702d49 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -182,6 +182,16 @@
     return fb->setSwapInterval(fb, interval);
 }
 
+void FramebufferNativeWindow::dump(String8& result) {
+    if (fbDev->common.version >= 1 && fbDev->dump) {
+        const size_t SIZE = 4096;
+        char buffer[SIZE];
+
+        fbDev->dump(fbDev, buffer, SIZE);
+        result.append(buffer);
+    }
+}
+
 // only for debugging / logging
 int FramebufferNativeWindow::getCurrentBufferIndex() const
 {
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index fa46ab7..ce84683 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -24,8 +24,6 @@
 
 #include <ui/GraphicBufferAllocator.h>
 
-#include <private/ui/sw_gralloc_handle.h>
-
 namespace android {
 // ---------------------------------------------------------------------------
 
@@ -56,7 +54,7 @@
     Mutex::Autolock _l(sLock);
     KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
     size_t total = 0;
-    const size_t SIZE = 512;
+    const size_t SIZE = 4096;
     char buffer[SIZE];
     snprintf(buffer, SIZE, "Allocated buffers:\n");
     result.append(buffer);
@@ -71,6 +69,10 @@
     }
     snprintf(buffer, SIZE, "Total allocated: %.2f KB\n", total/1024.0f);
     result.append(buffer);
+    if (mAllocDev->common.version >= 1 && mAllocDev->dump) {
+        mAllocDev->dump(mAllocDev, buffer, SIZE);
+        result.append(buffer);
+    }
 }
 
 void GraphicBufferAllocator::dumpToSystemLog()
@@ -91,11 +93,7 @@
     // we have a h/w allocator and h/w buffer is requested
     status_t err; 
     
-    if (usage & GRALLOC_USAGE_HW_MASK) {
-        err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
-    } else {
-        err = sw_gralloc_handle_t::alloc(w, h, format, usage, handle, stride);
-    }
+    err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
 
     LOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
             w, h, format, usage, err, strerror(-err));
@@ -119,11 +117,8 @@
 status_t GraphicBufferAllocator::free(buffer_handle_t handle)
 {
     status_t err;
-    if (sw_gralloc_handle_t::validate(handle) < 0) {
-        err = mAllocDev->free(mAllocDev, handle);
-    } else {
-        err = sw_gralloc_handle_t::free((sw_gralloc_handle_t*)handle);
-    }
+
+    err = mAllocDev->free(mAllocDev, handle);
 
     LOGW_IF(err, "free(...) failed %d (%s)", err, strerror(-err));
     if (err == NO_ERROR) {
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index ce2acd0..07c0674 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -17,15 +17,7 @@
 #define LOG_TAG "GraphicBufferMapper"
 
 #include <stdint.h>
-#ifdef HAVE_ANDROID_OS      // just want PAGE_SIZE define
-# include <asm/page.h>
-#else
-# include <sys/user.h>
-#endif
 #include <errno.h>
-#include <sys/mman.h>
-
-#include <cutils/ashmem.h>
 
 #include <utils/Errors.h>
 #include <utils/Log.h>
@@ -35,8 +27,6 @@
 
 #include <hardware/gralloc.h>
 
-#include <private/ui/sw_gralloc_handle.h>
-
 
 namespace android {
 // ---------------------------------------------------------------------------
@@ -57,11 +47,9 @@
 status_t GraphicBufferMapper::registerBuffer(buffer_handle_t handle)
 {
     status_t err;
-    if (sw_gralloc_handle_t::validate(handle) < 0) {
-        err = mAllocMod->registerBuffer(mAllocMod, handle);
-    } else {
-        err = sw_gralloc_handle_t::registerBuffer((sw_gralloc_handle_t*)handle);
-    }
+
+    err = mAllocMod->registerBuffer(mAllocMod, handle);
+
     LOGW_IF(err, "registerBuffer(%p) failed %d (%s)",
             handle, err, strerror(-err));
     return err;
@@ -70,11 +58,9 @@
 status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle)
 {
     status_t err;
-    if (sw_gralloc_handle_t::validate(handle) < 0) {
-        err = mAllocMod->unregisterBuffer(mAllocMod, handle);
-    } else {
-        err = sw_gralloc_handle_t::unregisterBuffer((sw_gralloc_handle_t*)handle);
-    }
+
+    err = mAllocMod->unregisterBuffer(mAllocMod, handle);
+
     LOGW_IF(err, "unregisterBuffer(%p) failed %d (%s)",
             handle, err, strerror(-err));
     return err;
@@ -84,15 +70,11 @@
         int usage, const Rect& bounds, void** vaddr)
 {
     status_t err;
-    if (sw_gralloc_handle_t::validate(handle) < 0) {
-        err = mAllocMod->lock(mAllocMod, handle, usage,
-                bounds.left, bounds.top, bounds.width(), bounds.height(),
-                vaddr);
-    } else {
-        err = sw_gralloc_handle_t::lock((sw_gralloc_handle_t*)handle, usage,
-                bounds.left, bounds.top, bounds.width(), bounds.height(),
-                vaddr);
-    }
+
+    err = mAllocMod->lock(mAllocMod, handle, usage,
+            bounds.left, bounds.top, bounds.width(), bounds.height(),
+            vaddr);
+
     LOGW_IF(err, "lock(...) failed %d (%s)", err, strerror(-err));
     return err;
 }
@@ -100,129 +82,12 @@
 status_t GraphicBufferMapper::unlock(buffer_handle_t handle)
 {
     status_t err;
-    if (sw_gralloc_handle_t::validate(handle) < 0) {
-        err = mAllocMod->unlock(mAllocMod, handle);
-    } else {
-        err = sw_gralloc_handle_t::unlock((sw_gralloc_handle_t*)handle);
-    }
+
+    err = mAllocMod->unlock(mAllocMod, handle);
+
     LOGW_IF(err, "unlock(...) failed %d (%s)", err, strerror(-err));
     return err;
 }
 
 // ---------------------------------------------------------------------------
-
-status_t sw_gralloc_handle_t::alloc(uint32_t w, uint32_t h, int format,
-        int usage, buffer_handle_t* pHandle, int32_t* pStride)
-{
-    int align = 4;
-    int bpp = 0;
-    switch (format) {
-        case HAL_PIXEL_FORMAT_RGBA_8888:
-        case HAL_PIXEL_FORMAT_RGBX_8888:
-        case HAL_PIXEL_FORMAT_BGRA_8888:
-            bpp = 4;
-            break;
-        case HAL_PIXEL_FORMAT_RGB_888:
-            bpp = 3;
-            break;
-        case HAL_PIXEL_FORMAT_RGB_565:
-        case HAL_PIXEL_FORMAT_RGBA_5551:
-        case HAL_PIXEL_FORMAT_RGBA_4444:
-            bpp = 2;
-            break;
-        default:
-            return -EINVAL;
-    }
-    size_t bpr = (w*bpp + (align-1)) & ~(align-1);
-    size_t size = bpr * h;
-    size_t stride = bpr / bpp;
-    size = (size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
-    
-    int fd = ashmem_create_region("sw-gralloc-buffer", size);
-    if (fd < 0) {
-        LOGE("ashmem_create_region(size=%d) failed (%s)",
-                size, strerror(-errno));
-        return -errno;
-    }
-    
-    int prot = PROT_READ;
-    if (usage & GRALLOC_USAGE_SW_WRITE_MASK)
-        prot |= PROT_WRITE;
-    
-    if (ashmem_set_prot_region(fd, prot) < 0) {
-        LOGE("ashmem_set_prot_region(fd=%d, prot=%x) failed (%s)",
-                fd, prot, strerror(-errno));
-        close(fd);
-        return -errno;
-    }
-
-    void* base = mmap(0, size, prot, MAP_SHARED, fd, 0);
-    if (base == MAP_FAILED) {
-        LOGE("alloc mmap(fd=%d, size=%d, prot=%x) failed (%s)",
-                fd, size, prot, strerror(-errno));
-        close(fd);
-        return -errno;
-    }
-
-    sw_gralloc_handle_t* hnd = new sw_gralloc_handle_t();
-    hnd->fd = fd;
-    hnd->size = size;
-    hnd->base = intptr_t(base);
-    hnd->prot = prot;
-    *pStride = stride;
-    *pHandle = hnd; 
-    
-    return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::free(sw_gralloc_handle_t* hnd)
-{
-    if (hnd->base) {
-        munmap((void*)hnd->base, hnd->size);
-    }
-    if (hnd->fd >= 0) {
-        close(hnd->fd);
-    }
-    delete hnd;    
-    return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::registerBuffer(sw_gralloc_handle_t* hnd)
-{
-    if (hnd->pid != getpid()) {
-        void* base = mmap(0, hnd->size, hnd->prot, MAP_SHARED, hnd->fd, 0);
-        if (base == MAP_FAILED) {
-            LOGE("registerBuffer mmap(fd=%d, size=%d, prot=%x) failed (%s)",
-                    hnd->fd, hnd->size, hnd->prot, strerror(-errno));
-            return -errno;
-        }
-        hnd->base = intptr_t(base);
-    }
-    return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::unregisterBuffer(sw_gralloc_handle_t* hnd)
-{
-    if (hnd->pid != getpid()) {
-        if (hnd->base) {
-            munmap((void*)hnd->base, hnd->size);
-        }
-        hnd->base = 0;
-    }
-    return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::lock(sw_gralloc_handle_t* hnd, int usage,
-        int l, int t, int w, int h, void** vaddr)
-{
-    *vaddr = (void*)hnd->base;
-    return NO_ERROR;
-}
-
-status_t sw_gralloc_handle_t::unlock(sw_gralloc_handle_t* hnd)
-{
-    return NO_ERROR;
-}
-
-// ---------------------------------------------------------------------------
 }; // namespace android
diff --git a/libs/ui/IOverlay.cpp b/libs/ui/IOverlay.cpp
deleted file mode 100644
index 65e6b4f..0000000
--- a/libs/ui/IOverlay.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <binder/Parcel.h>
-#include <binder/IInterface.h>
-
-#include <ui/IOverlay.h>
-
-namespace android {
-
-enum {
-    DESTROY = IBinder::FIRST_CALL_TRANSACTION, // one-way transaction
-};
-
-class BpOverlay : public BpInterface<IOverlay>
-{
-public:
-    BpOverlay(const sp<IBinder>& impl)
-        : BpInterface<IOverlay>(impl)
-    {
-    }
-
-    virtual void destroy()
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IOverlay::getInterfaceDescriptor());
-        remote()->transact(DESTROY, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-};
-
-IMPLEMENT_META_INTERFACE(Overlay, "android.ui.IOverlay");
-
-// ----------------------------------------------------------------------
-
-status_t BnOverlay::onTransact(
-    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
-    switch(code) {
-        case DESTROY: {
-            CHECK_INTERFACE(IOverlay, data, reply);
-            destroy();
-            return NO_ERROR;
-        } break;
-        default:
-            return BBinder::onTransact(code, data, reply, flags);
-    }
-}
-
-}; // namespace android
diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp
deleted file mode 100644
index b082c53..0000000
--- a/libs/ui/Overlay.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <binder/IMemory.h>
-#include <binder/Parcel.h>
-#include <utils/Errors.h>
-#include <binder/MemoryHeapBase.h>
-
-#include <ui/IOverlay.h>
-#include <ui/Overlay.h>
-
-#include <hardware/overlay.h>
-
-namespace android {
-
-Overlay::Overlay(const sp<OverlayRef>& overlayRef)
-    : mOverlayRef(overlayRef), mOverlayData(0), mStatus(NO_INIT)
-{
-    mOverlayData = NULL;
-    hw_module_t const* module;
-    if (overlayRef != 0) {
-        if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) {
-            if (overlay_data_open(module, &mOverlayData) == NO_ERROR) {
-                mStatus = mOverlayData->initialize(mOverlayData,
-                        overlayRef->mOverlayHandle);
-            }
-        }
-    }
-}
-
-Overlay::~Overlay() {
-    if (mOverlayData) {
-        overlay_data_close(mOverlayData);
-    }
-}
-
-status_t Overlay::dequeueBuffer(overlay_buffer_t* buffer)
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return  mOverlayData->dequeueBuffer(mOverlayData, buffer);
-}
-
-status_t Overlay::queueBuffer(overlay_buffer_t buffer)
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return mOverlayData->queueBuffer(mOverlayData, buffer);
-}
-
-status_t Overlay::resizeInput(uint32_t width, uint32_t height)
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return mOverlayData->resizeInput(mOverlayData, width, height);
-}
-
-status_t Overlay::setParameter(int param, int value)
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return mOverlayData->setParameter(mOverlayData, param, value);
-}
-
-status_t Overlay::setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return mOverlayData->setCrop(mOverlayData, x, y, w, h);
-}
-
-status_t Overlay::getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h)
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return mOverlayData->getCrop(mOverlayData, x, y, w, h);
-}
-
-int32_t Overlay::getBufferCount() const
-{
-    if (mStatus != NO_ERROR) return mStatus;
-    return mOverlayData->getBufferCount(mOverlayData);
-}
-
-void* Overlay::getBufferAddress(overlay_buffer_t buffer)
-{
-    if (mStatus != NO_ERROR) return NULL;
-    return mOverlayData->getBufferAddress(mOverlayData, buffer);
-}
-
-void Overlay::destroy() {  
-
-    // Must delete the objects in reverse creation order, thus the
-    //  data side must be closed first and then the destroy send to
-    //  the control side.
-    if (mOverlayData) {
-        overlay_data_close(mOverlayData);
-        mOverlayData = NULL;
-    } else {
-        LOGD("Overlay::destroy mOverlayData is NULL");
-    }
-
-    if (mOverlayRef != 0) {
-        mOverlayRef->mOverlayChannel->destroy();
-    } else {
-        LOGD("Overlay::destroy mOverlayRef is NULL");
-    }
-}
-
-status_t Overlay::getStatus() const {
-    return mStatus;
-}
-
-overlay_handle_t Overlay::getHandleRef() const {
-    if (mStatus != NO_ERROR) return NULL;
-    return mOverlayRef->mOverlayHandle;
-}
-
-uint32_t Overlay::getWidth() const {
-    if (mStatus != NO_ERROR) return 0;
-    return mOverlayRef->mWidth;
-}
-
-uint32_t Overlay::getHeight() const {
-    if (mStatus != NO_ERROR) return 0;
-    return mOverlayRef->mHeight;
-}
-
-int32_t Overlay::getFormat() const {
-    if (mStatus != NO_ERROR) return -1;
-    return mOverlayRef->mFormat;
-}
-
-int32_t Overlay::getWidthStride() const {
-    if (mStatus != NO_ERROR) return 0;
-    return mOverlayRef->mWidthStride;
-}
-
-int32_t Overlay::getHeightStride() const {
-    if (mStatus != NO_ERROR) return 0;
-    return mOverlayRef->mHeightStride;
-}
-// ----------------------------------------------------------------------------
-
-OverlayRef::OverlayRef() 
- : mOverlayHandle(0),
-    mWidth(0), mHeight(0), mFormat(0), mWidthStride(0), mHeightStride(0),
-    mOwnHandle(true)
-{    
-}
-
-OverlayRef::OverlayRef(overlay_handle_t handle, const sp<IOverlay>& channel,
-         uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs)
-    : mOverlayHandle(handle), mOverlayChannel(channel),
-    mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs),
-    mOwnHandle(false)
-{
-}
-
-OverlayRef::~OverlayRef()
-{
-    if (mOwnHandle) {
-        native_handle_close(mOverlayHandle);
-        native_handle_delete(const_cast<native_handle*>(mOverlayHandle));
-    }
-}
-
-sp<OverlayRef> OverlayRef::readFromParcel(const Parcel& data) {
-    sp<OverlayRef> result;
-    sp<IOverlay> overlay = IOverlay::asInterface(data.readStrongBinder());
-    if (overlay != NULL) {
-        uint32_t w = data.readInt32();
-        uint32_t h = data.readInt32();
-        uint32_t f = data.readInt32();
-        uint32_t ws = data.readInt32();
-        uint32_t hs = data.readInt32();
-        native_handle* handle = data.readNativeHandle();
-
-        result = new OverlayRef();
-        result->mOverlayHandle = handle;
-        result->mOverlayChannel = overlay;
-        result->mWidth = w;
-        result->mHeight = h;
-        result->mFormat = f;
-        result->mWidthStride = ws;
-        result->mHeightStride = hs;
-    }
-    return result;
-}
-
-status_t OverlayRef::writeToParcel(Parcel* reply, const sp<OverlayRef>& o) {
-    if (o != NULL) {
-        reply->writeStrongBinder(o->mOverlayChannel->asBinder());
-        reply->writeInt32(o->mWidth);
-        reply->writeInt32(o->mHeight);
-        reply->writeInt32(o->mFormat);
-        reply->writeInt32(o->mWidthStride);
-        reply->writeInt32(o->mHeightStride);
-        reply->writeNativeHandle(o->mOverlayHandle);
-    } else {
-        reply->writeStrongBinder(NULL);
-    }
-    return NO_ERROR;
-}
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/libs/utils/Android.mk b/libs/utils/Android.mk
index 8bd833b..e8d40ba 100644
--- a/libs/utils/Android.mk
+++ b/libs/utils/Android.mk
@@ -70,11 +70,6 @@
 endif
 endif
 
-ifeq ($(HOST_OS),darwin)
-# MacOS doesn't have lseek64. However, off_t is 64-bit anyway.
-LOCAL_CFLAGS += -DOFF_T_IS_64_BIT
-endif
-
 include $(BUILD_HOST_STATIC_LIBRARY)
 
 
diff --git a/libs/utils/Asset.cpp b/libs/utils/Asset.cpp
index cef7db4..a18294b 100644
--- a/libs/utils/Asset.cpp
+++ b/libs/utils/Asset.cpp
@@ -35,6 +35,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <assert.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 using namespace android;
 
@@ -62,7 +65,7 @@
         if (cur->isAllocated()) {
             res.append("    ");
             res.append(cur->getAssetSource());
-            off_t size = (cur->getLength()+512)/1024;
+            off64_t size = (cur->getLength()+512)/1024;
             char buf[64];
             sprintf(buf, ": %dK\n", (int)size);
             res.append(buf);
@@ -119,7 +122,7 @@
 {
     _FileAsset* pAsset;
     status_t result;
-    off_t length;
+    off64_t length;
     int fd;
 
     fd = open(fileName, O_RDONLY | O_BINARY);
@@ -132,12 +135,26 @@
      * always open things read-only it doesn't really matter, so there's
      * no value in incurring the extra overhead of an fstat() call.
      */
-    length = lseek(fd, 0, SEEK_END);
+    // TODO(kroot): replace this with fstat despite the plea above.
+#if 1
+    length = lseek64(fd, 0, SEEK_END);
     if (length < 0) {
         ::close(fd);
         return NULL;
     }
-    (void) lseek(fd, 0, SEEK_SET);
+    (void) lseek64(fd, 0, SEEK_SET);
+#else
+    struct stat st;
+    if (fstat(fd, &st) < 0) {
+        ::close(fd);
+        return NULL;
+    }
+
+    if (!S_ISREG(st.st_mode)) {
+        ::close(fd);
+        return NULL;
+    }
+#endif
 
     pAsset = new _FileAsset;
     result = pAsset->openChunk(fileName, fd, 0, length);
@@ -162,7 +179,7 @@
 {
     _CompressedAsset* pAsset;
     status_t result;
-    off_t fileLen;
+    off64_t fileLen;
     bool scanResult;
     long offset;
     int method;
@@ -215,7 +232,7 @@
 /*
  * Create a new Asset from part of an open file.
  */
-/*static*/ Asset* Asset::createFromFileSegment(int fd, off_t offset,
+/*static*/ Asset* Asset::createFromFileSegment(int fd, off64_t offset,
     size_t length, AccessMode mode)
 {
     _FileAsset* pAsset;
@@ -233,7 +250,7 @@
 /*
  * Create a new Asset from compressed data in an open file.
  */
-/*static*/ Asset* Asset::createFromCompressedData(int fd, off_t offset,
+/*static*/ Asset* Asset::createFromCompressedData(int fd, off64_t offset,
     int compressionMethod, size_t uncompressedLen, size_t compressedLen,
     AccessMode mode)
 {
@@ -295,9 +312,9 @@
  *
  * Returns the new chunk offset, or -1 if the seek is illegal.
  */
-off_t Asset::handleSeek(off_t offset, int whence, off_t curPosn, off_t maxPosn)
+off64_t Asset::handleSeek(off64_t offset, int whence, off64_t curPosn, off64_t maxPosn)
 {
-    off_t newOffset;
+    off64_t newOffset;
 
     switch (whence) {
     case SEEK_SET:
@@ -311,15 +328,15 @@
         break;
     default:
         LOGW("unexpected whence %d\n", whence);
-        // this was happening due to an off_t size mismatch
+        // this was happening due to an off64_t size mismatch
         assert(false);
-        return (off_t) -1;
+        return (off64_t) -1;
     }
 
     if (newOffset < 0 || newOffset > maxPosn) {
         LOGW("seek out of range: want %ld, end=%ld\n",
             (long) newOffset, (long) maxPosn);
-        return (off_t) -1;
+        return (off64_t) -1;
     }
 
     return newOffset;
@@ -353,7 +370,7 @@
  *
  * Zero-length chunks are allowed.
  */
-status_t _FileAsset::openChunk(const char* fileName, int fd, off_t offset, size_t length)
+status_t _FileAsset::openChunk(const char* fileName, int fd, off64_t offset, size_t length)
 {
     assert(mFp == NULL);    // no reopen
     assert(mMap == NULL);
@@ -363,15 +380,15 @@
     /*
      * Seek to end to get file length.
      */
-    off_t fileLength;
-    fileLength = lseek(fd, 0, SEEK_END);
-    if (fileLength == (off_t) -1) {
+    off64_t fileLength;
+    fileLength = lseek64(fd, 0, SEEK_END);
+    if (fileLength == (off64_t) -1) {
         // probably a bad file descriptor
         LOGD("failed lseek (errno=%d)\n", errno);
         return UNKNOWN_ERROR;
     }
 
-    if ((off_t) (offset + length) > fileLength) {
+    if ((off64_t) (offset + length) > fileLength) {
         LOGD("start (%ld) + len (%ld) > end (%ld)\n",
             (long) offset, (long) length, (long) fileLength);
         return BAD_INDEX;
@@ -482,21 +499,21 @@
 /*
  * Seek to a new position.
  */
-off_t _FileAsset::seek(off_t offset, int whence)
+off64_t _FileAsset::seek(off64_t offset, int whence)
 {
-    off_t newPosn;
-    long actualOffset;
+    off64_t newPosn;
+    off64_t actualOffset;
 
     // compute new position within chunk
     newPosn = handleSeek(offset, whence, mOffset, mLength);
-    if (newPosn == (off_t) -1)
+    if (newPosn == (off64_t) -1)
         return newPosn;
 
-    actualOffset = (long) (mStart + newPosn);
+    actualOffset = mStart + newPosn;
 
     if (mFp != NULL) {
         if (fseek(mFp, (long) actualOffset, SEEK_SET) != 0)
-            return (off_t) -1;
+            return (off64_t) -1;
     }
 
     mOffset = actualOffset - mStart;
@@ -603,7 +620,7 @@
     }
 }
 
-int _FileAsset::openFileDescriptor(off_t* outStart, off_t* outLength) const
+int _FileAsset::openFileDescriptor(off64_t* outStart, off64_t* outLength) const
 {
     if (mMap != NULL) {
         const char* fname = mMap->getFileName();
@@ -678,7 +695,7 @@
  * This currently just sets up some values and returns.  On the first
  * read, we expand the entire file into a buffer and return data from it.
  */
-status_t _CompressedAsset::openChunk(int fd, off_t offset,
+status_t _CompressedAsset::openChunk(int fd, off64_t offset,
     int compressionMethod, size_t uncompressedLen, size_t compressedLen)
 {
     assert(mFd < 0);        // no re-open
@@ -782,13 +799,13 @@
  * expensive, because it requires plowing through a bunch of compressed
  * data.
  */
-off_t _CompressedAsset::seek(off_t offset, int whence)
+off64_t _CompressedAsset::seek(off64_t offset, int whence)
 {
-    off_t newPosn;
+    off64_t newPosn;
 
     // compute new position within chunk
     newPosn = handleSeek(offset, whence, mOffset, mUncompressedLen);
-    if (newPosn == (off_t) -1)
+    if (newPosn == (off64_t) -1)
         return newPosn;
 
     if (mZipInflater) {
diff --git a/libs/utils/FileMap.cpp b/libs/utils/FileMap.cpp
index f1f8bda..c220a90 100644
--- a/libs/utils/FileMap.cpp
+++ b/libs/utils/FileMap.cpp
@@ -88,11 +88,12 @@
  *
  * Returns "false" on failure.
  */
-bool FileMap::create(const char* origFileName, int fd, off_t offset, size_t length, bool readOnly)
+bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t length,
+        bool readOnly)
 {
 #ifdef HAVE_WIN32_FILEMAP
     int     adjust;
-    off_t   adjOffset;
+    off64_t adjOffset;
     size_t  adjLength;
 
     if (mPageSize == -1) {
@@ -131,7 +132,7 @@
 #endif
 #ifdef HAVE_POSIX_FILEMAP
     int     prot, flags, adjust;
-    off_t   adjOffset;
+    off64_t adjOffset;
     size_t  adjLength;
 
     void* ptr;
diff --git a/libs/utils/ObbFile.cpp b/libs/utils/ObbFile.cpp
index 2c3724c..2907b56 100644
--- a/libs/utils/ObbFile.cpp
+++ b/libs/utils/ObbFile.cpp
@@ -22,6 +22,8 @@
 #include <unistd.h>
 
 #define LOG_TAG "ObbFile"
+
+#include <utils/Compat.h>
 #include <utils/Log.h>
 #include <utils/ObbFile.h>
 
@@ -67,17 +69,6 @@
     _rc; })
 #endif
 
-/*
- * Work around situations where off_t is 64-bit and use off64_t in
- * situations where it's 32-bit.
- */
-#ifdef OFF_T_IS_64_BIT
-#define my_lseek64 lseek
-typedef off_t my_off64_t;
-#else
-#define my_lseek64 lseek64
-typedef off64_t my_off64_t;
-#endif
 
 namespace android {
 
@@ -125,7 +116,7 @@
 
 bool ObbFile::parseObbFile(int fd)
 {
-    my_off64_t fileLength = my_lseek64(fd, 0, SEEK_END);
+    off64_t fileLength = lseek64(fd, 0, SEEK_END);
 
     if (fileLength < kFooterMinSize) {
         if (fileLength < 0) {
@@ -140,7 +131,7 @@
     size_t footerSize;
 
     {
-        my_lseek64(fd, fileLength - kFooterTagSize, SEEK_SET);
+        lseek64(fd, fileLength - kFooterTagSize, SEEK_SET);
 
         char *footer = new char[kFooterTagSize];
         actual = TEMP_FAILURE_RETRY(read(fd, footer, kFooterTagSize));
@@ -171,8 +162,8 @@
         }
     }
 
-    my_off64_t fileOffset = fileLength - footerSize - kFooterTagSize;
-    if (my_lseek64(fd, fileOffset, SEEK_SET) != fileOffset) {
+    off64_t fileOffset = fileLength - footerSize - kFooterTagSize;
+    if (lseek64(fd, fileOffset, SEEK_SET) != fileOffset) {
         LOGW("seek %lld failed: %s\n", fileOffset, strerror(errno));
         return false;
     }
@@ -211,10 +202,10 @@
 
     memcpy(&mSalt, (unsigned char*)scanBuf + kSaltOffset, sizeof(mSalt));
 
-    uint32_t packageNameLen = get4LE((unsigned char*)scanBuf + kPackageNameLenOffset);
-    if (packageNameLen <= 0
+    size_t packageNameLen = get4LE((unsigned char*)scanBuf + kPackageNameLenOffset);
+    if (packageNameLen == 0
             || packageNameLen > (footerSize - kPackageNameOffset)) {
-        LOGW("bad ObbFile package name length (0x%04x; 0x%04x possible)\n",
+        LOGW("bad ObbFile package name length (0x%04zx; 0x%04zx possible)\n",
                 packageNameLen, footerSize - kPackageNameOffset);
         free(scanBuf);
         return false;
@@ -257,7 +248,7 @@
         return false;
     }
 
-    my_lseek64(fd, 0, SEEK_END);
+    lseek64(fd, 0, SEEK_END);
 
     if (mPackageName.size() == 0 || mVersion == -1) {
         LOGW("tried to write uninitialized ObbFile data\n");
diff --git a/libs/utils/StreamingZipInflater.cpp b/libs/utils/StreamingZipInflater.cpp
index 1f62ac5..5a162cc 100644
--- a/libs/utils/StreamingZipInflater.cpp
+++ b/libs/utils/StreamingZipInflater.cpp
@@ -31,7 +31,7 @@
 /*
  * Streaming access to compressed asset data in an open fd
  */
-StreamingZipInflater::StreamingZipInflater(int fd, off_t compDataStart,
+StreamingZipInflater::StreamingZipInflater(int fd, off64_t compDataStart,
         size_t uncompSize, size_t compSize) {
     mFd = fd;
     mDataMap = NULL;
@@ -210,7 +210,7 @@
 // seeking backwards requires uncompressing fom the beginning, so is very
 // expensive.  seeking forwards only requires uncompressing from the current
 // position to the destination.
-off_t StreamingZipInflater::seekAbsolute(off_t absoluteInputPosition) {
+off64_t StreamingZipInflater::seekAbsolute(off64_t absoluteInputPosition) {
     if (absoluteInputPosition < mOutCurPosition) {
         // rewind and reprocess the data from the beginning
         if (!mStreamNeedsInit) {
diff --git a/libs/utils/ZipFileCRO.cpp b/libs/utils/ZipFileCRO.cpp
index 16b219c..55dfd9f 100644
--- a/libs/utils/ZipFileCRO.cpp
+++ b/libs/utils/ZipFileCRO.cpp
@@ -40,7 +40,7 @@
 
 bool ZipFileCRO_getEntryInfo(ZipFileCRO zipToken, ZipEntryRO entryToken,
         int* pMethod, size_t* pUncompLen,
-        size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) {
+        size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32) {
     ZipFileRO* zip = (ZipFileRO*)zipToken;
     ZipEntryRO entry = (ZipEntryRO)entryToken;
     return zip->getEntryInfo(entry, pMethod, pUncompLen, pCompLen, pOffset,
diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp
index 4261196..b18c383 100644
--- a/libs/utils/ZipFileRO.cpp
+++ b/libs/utils/ZipFileRO.cpp
@@ -146,7 +146,7 @@
         return NAME_NOT_FOUND;
     }
 
-    mFileLength = lseek(fd, 0, SEEK_END);
+    mFileLength = lseek64(fd, 0, SEEK_END);
     if (mFileLength < kEOCDLen) {
         TEMP_FAILURE_RETRY(close(fd));
         return UNKNOWN_ERROR;
@@ -202,7 +202,7 @@
     /*
      * Make sure this is a Zip archive.
      */
-    if (lseek(mFd, 0, SEEK_SET) != 0) {
+    if (lseek64(mFd, 0, SEEK_SET) != 0) {
         LOGW("seek to start failed: %s", strerror(errno));
         free(scanBuf);
         return false;
@@ -240,9 +240,9 @@
      *
      * We start by pulling in the last part of the file.
      */
-    off_t searchStart = mFileLength - readAmount;
+    off64_t searchStart = mFileLength - readAmount;
 
-    if (lseek(mFd, searchStart, SEEK_SET) != searchStart) {
+    if (lseek64(mFd, searchStart, SEEK_SET) != searchStart) {
         LOGW("seek %ld failed: %s\n",  (long) searchStart, strerror(errno));
         free(scanBuf);
         return false;
@@ -274,7 +274,7 @@
         return false;
     }
 
-    off_t eocdOffset = searchStart + i;
+    off64_t eocdOffset = searchStart + i;
     const unsigned char* eocdPtr = scanBuf + i;
 
     assert(eocdOffset < mFileLength);
@@ -473,7 +473,7 @@
  * appear to be bogus.
  */
 bool ZipFileRO::getEntryInfo(ZipEntryRO entry, int* pMethod, size_t* pUncompLen,
-    size_t* pCompLen, off_t* pOffset, long* pModWhen, long* pCrc32) const
+    size_t* pCompLen, off64_t* pOffset, long* pModWhen, long* pCrc32) const
 {
     bool ret = false;
 
@@ -489,7 +489,7 @@
      * so we can just subtract back from that.
      */
     const unsigned char* ptr = (const unsigned char*) hashEntry.name;
-    off_t cdOffset = mDirectoryOffset;
+    off64_t cdOffset = mDirectoryOffset;
 
     ptr -= kCDELen;
 
@@ -536,12 +536,12 @@
 #ifdef HAVE_PREAD
         /*
          * This file descriptor might be from zygote's preloaded assets,
-         * so we need to do an pread() instead of a lseek() + read() to
+         * so we need to do an pread64() instead of a lseek64() + read() to
          * guarantee atomicity across the processes with the shared file
          * descriptors.
          */
         ssize_t actual =
-                TEMP_FAILURE_RETRY(pread(mFd, lfhBuf, sizeof(lfhBuf), localHdrOffset));
+                TEMP_FAILURE_RETRY(pread64(mFd, lfhBuf, sizeof(lfhBuf), localHdrOffset));
 
         if (actual != sizeof(lfhBuf)) {
             LOGW("failed reading lfh from offset %ld\n", localHdrOffset);
@@ -556,17 +556,17 @@
         }
 #else /* HAVE_PREAD */
         /*
-         * For hosts don't have pread() we cannot guarantee atomic reads from
+         * For hosts don't have pread64() we cannot guarantee atomic reads from
          * an offset in a file. Android should never run on those platforms.
          * File descriptors inherited from a fork() share file offsets and
          * there would be nothing to protect from two different processes
-         * calling lseek() concurrently.
+         * calling lseek64() concurrently.
          */
 
         {
             AutoMutex _l(mFdLock);
 
-            if (lseek(mFd, localHdrOffset, SEEK_SET) != localHdrOffset) {
+            if (lseek64(mFd, localHdrOffset, SEEK_SET) != localHdrOffset) {
                 LOGW("failed seeking to lfh at offset %ld\n", localHdrOffset);
                 return false;
             }
@@ -579,7 +579,7 @@
             }
 
             if (get4LE(lfhBuf) != kLFHSignature) {
-                off_t actualOffset = lseek(mFd, 0, SEEK_CUR);
+                off64_t actualOffset = lseek64(mFd, 0, SEEK_CUR);
                 LOGW("didn't find signature at start of lfh; wanted: offset=%ld data=0x%08x; "
                         "got: offset=" ZD " data=0x%08lx\n",
                         localHdrOffset, kLFHSignature, (ZD_TYPE) actualOffset, get4LE(lfhBuf));
@@ -588,7 +588,7 @@
         }
 #endif /* HAVE_PREAD */
 
-        off_t dataOffset = localHdrOffset + kLFHLen
+        off64_t dataOffset = localHdrOffset + kLFHLen
             + get2LE(lfhBuf + kLFHNameLen) + get2LE(lfhBuf + kLFHExtraLen);
         if (dataOffset >= cdOffset) {
             LOGW("bad data offset %ld in zip\n", (long) dataOffset);
@@ -596,14 +596,14 @@
         }
 
         /* check lengths */
-        if ((off_t)(dataOffset + compLen) > cdOffset) {
+        if ((off64_t)(dataOffset + compLen) > cdOffset) {
             LOGW("bad compressed length in zip (%ld + " ZD " > %ld)\n",
                 (long) dataOffset, (ZD_TYPE) compLen, (long) cdOffset);
             return false;
         }
 
         if (method == kCompressStored &&
-            (off_t)(dataOffset + uncompLen) > cdOffset)
+            (off64_t)(dataOffset + uncompLen) > cdOffset)
         {
             LOGE("ERROR: bad uncompressed length in zip (%ld + " ZD " > %ld)\n",
                 (long) dataOffset, (ZD_TYPE) uncompLen, (long) cdOffset);
@@ -649,7 +649,7 @@
 
     FileMap* newMap;
     size_t compLen;
-    off_t offset;
+    off64_t offset;
 
     if (!getEntryInfo(entry, NULL, NULL, &compLen, &offset, NULL, NULL))
         return NULL;
@@ -679,7 +679,7 @@
 
     int method;
     size_t uncompLen, compLen;
-    off_t offset;
+    off64_t offset;
     const unsigned char* ptr;
 
     getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL);
@@ -739,7 +739,7 @@
 
     int method;
     size_t uncompLen, compLen;
-    off_t offset;
+    off64_t offset;
     const unsigned char* ptr;
 
     getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL);
diff --git a/media/java/android/media/MtpDatabase.java b/media/java/android/media/MtpDatabase.java
index 6056a0f..4a9e483 100644
--- a/media/java/android/media/MtpDatabase.java
+++ b/media/java/android/media/MtpDatabase.java
@@ -76,10 +76,11 @@
             Files.FileColumns._ID, // 0
             Files.FileColumns.DATA, // 1
     };
-    private static final String[] PATH_SIZE_PROJECTION = new String[] {
+    private static final String[] PATH_SIZE_FORMAT_PROJECTION = new String[] {
             Files.FileColumns._ID, // 0
             Files.FileColumns.DATA, // 1
             Files.FileColumns.SIZE, // 2
+            Files.FileColumns.FORMAT, // 3
     };
     private static final String[] OBJECT_INFO_PROJECTION = new String[] {
             Files.FileColumns._ID, // 0
@@ -670,24 +671,26 @@
         return false;
     }
 
-    private int getObjectFilePath(int handle, char[] outFilePath, long[] outFileLength) {
+    private int getObjectFilePath(int handle, char[] outFilePath, long[] outFileLengthFormat) {
         Log.d(TAG, "getObjectFilePath: " + handle);
         if (handle == 0) {
             // special case root directory
             mMediaStoragePath.getChars(0, mMediaStoragePath.length(), outFilePath, 0);
             outFilePath[mMediaStoragePath.length()] = 0;
-            outFileLength[0] = 0;
+            outFileLengthFormat[0] = 0;
+            outFileLengthFormat[1] = MtpConstants.FORMAT_ASSOCIATION;
             return MtpConstants.RESPONSE_OK;
         }
         Cursor c = null;
         try {
-            c = mMediaProvider.query(mObjectsUri, PATH_SIZE_PROJECTION,
+            c = mMediaProvider.query(mObjectsUri, PATH_SIZE_FORMAT_PROJECTION,
                             ID_WHERE, new String[] {  Integer.toString(handle) }, null);
             if (c != null && c.moveToNext()) {
                 String path = externalToMediaPath(c.getString(1));
                 path.getChars(0, path.length(), outFilePath, 0);
                 outFilePath[path.length()] = 0;
-                outFileLength[0] = c.getLong(2);
+                outFileLengthFormat[0] = c.getLong(2);
+                outFileLengthFormat[1] = c.getLong(3);
                 return MtpConstants.RESPONSE_OK;
             } else {
                 return MtpConstants.RESPONSE_INVALID_OBJECT_HANDLE;
diff --git a/media/jni/android_media_MtpDatabase.cpp b/media/jni/android_media_MtpDatabase.cpp
index 9bb93fd..bce1241 100644
--- a/media/jni/android_media_MtpDatabase.cpp
+++ b/media/jni/android_media_MtpDatabase.cpp
@@ -142,8 +142,9 @@
                                             MtpDataPacket& packet);
 
     virtual MtpResponseCode         getObjectFilePath(MtpObjectHandle handle,
-                                            MtpString& filePath,
-                                            int64_t& fileLength);
+                                            MtpString& outFilePath,
+                                            int64_t& outFileLength,
+                                            MtpObjectFormat& outFormat);
     virtual MtpResponseCode         deleteFile(MtpObjectHandle handle);
 
     bool                            getObjectPropertyInfo(MtpObjectProperty property, int& type);
@@ -801,8 +802,9 @@
 }
 
 MtpResponseCode MyMtpDatabase::getObjectFilePath(MtpObjectHandle handle,
-                                            MtpString& filePath,
-                                            int64_t& fileLength) {
+                                            MtpString& outFilePath,
+                                            int64_t& outFileLength,
+                                            MtpObjectFormat& outFormat) {
     JNIEnv* env = AndroidRuntime::getJNIEnv();
     jint result = env->CallIntMethod(mDatabase, method_getObjectFilePath,
                 (jint)handle, mStringBuffer, mLongBuffer);
@@ -812,11 +814,12 @@
     }
 
     jchar* str = env->GetCharArrayElements(mStringBuffer, 0);
-    filePath.setTo(str, strlen16(str));
+    outFilePath.setTo(str, strlen16(str));
     env->ReleaseCharArrayElements(mStringBuffer, str, 0);
 
     jlong* longValues = env->GetLongArrayElements(mLongBuffer, 0);
-    fileLength = longValues[0];
+    outFileLength = longValues[0];
+    outFormat = longValues[1];
     env->ReleaseLongArrayElements(mLongBuffer, longValues, 0);
     
     checkAndClearExceptionFromCallback(env, __FUNCTION__);
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index c28de93..ee3eefc 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -144,7 +144,10 @@
             static_cast<MediaSource::ReadOptions::SeekMode>(seekMode);
 
     int64_t thumbNailTime;
-    if (frameTimeUs < 0 && trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)) {
+    if (frameTimeUs < 0) {
+        if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)) {
+            thumbNailTime = 0;
+        }
         options.setSeekTo(thumbNailTime, mode);
     } else {
         thumbNailTime = -1;
diff --git a/media/mtp/MtpDatabase.h b/media/mtp/MtpDatabase.h
index 9929805..6dcb931 100644
--- a/media/mtp/MtpDatabase.h
+++ b/media/mtp/MtpDatabase.h
@@ -85,8 +85,9 @@
                                             MtpDataPacket& packet) = 0;
 
     virtual MtpResponseCode         getObjectFilePath(MtpObjectHandle handle,
-                                            MtpString& filePath,
-                                            int64_t& fileLength) = 0;
+                                            MtpString& outFilePath,
+                                            int64_t& outFileLength,
+                                            MtpObjectFormat& outFormat) = 0;
 
     virtual MtpResponseCode         deleteFile(MtpObjectHandle handle) = 0;
 
diff --git a/media/mtp/MtpProperty.cpp b/media/mtp/MtpProperty.cpp
index b095ce1..8016c35 100644
--- a/media/mtp/MtpProperty.cpp
+++ b/media/mtp/MtpProperty.cpp
@@ -343,6 +343,7 @@
             print(mMaximumValue, buffer);
             buffer += ", ";
             print(mStepSize, buffer);
+            buffer += ")";
             LOGI("%s", (const char *)buffer);
             break;
         case kFormEnum:
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 5c1e02a..d65845d 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -112,8 +112,10 @@
 }
 
 MtpStorage* MtpServer::getStorage(MtpStorageID id) {
+    if (id == 0)
+        return mStorages[0];
     for (int i = 0; i < mStorages.size(); i++) {
-        MtpStorage* storage =  mStorages[i];
+        MtpStorage* storage = mStorages[i];
         if (storage->getStorageID() == id)
             return storage;
     }
@@ -557,7 +559,8 @@
     MtpObjectHandle handle = mRequest.getParameter(1);
     MtpString pathBuf;
     int64_t fileLength;
-    int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength);
+    MtpObjectFormat format;
+    int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength, format);
     if (result != MTP_RESPONSE_OK)
         return result;
 
@@ -593,7 +596,8 @@
     uint32_t length = mRequest.getParameter(3);
     MtpString pathBuf;
     int64_t fileLength;
-    int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength);
+    MtpObjectFormat format;
+    int result = mDatabase->getObjectFilePath(handle, pathBuf, fileLength, format);
     if (result != MTP_RESPONSE_OK)
         return result;
     if (offset + length > fileLength)
@@ -639,10 +643,13 @@
         path = storage->getPath();
         parent = 0;
     } else {
-        int64_t dummy;
-        int result = mDatabase->getObjectFilePath(parent, path, dummy);
+        int64_t length;
+        MtpObjectFormat format;
+        int result = mDatabase->getObjectFilePath(parent, path, length, format);
         if (result != MTP_RESPONSE_OK)
             return result;
+        if (format != MTP_FORMAT_ASSOCIATION)
+            return MTP_RESPONSE_INVALID_PARENT_OBJECT;
     }
 
     // read only the fields we need
@@ -676,6 +683,10 @@
         path += "/";
     path += (const char *)name;
 
+    // file should not already exist
+    if (access(path, R_OK) == 0)
+        return MTP_RESPONSE_GENERAL_ERROR;
+
     MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path,
             format, parent, storageID, mSendObjectFileSize, modifiedTime);
     if (handle == kInvalidObjectHandle) {
@@ -835,7 +846,7 @@
 
     MtpString filePath;
     int64_t fileLength;
-    int result = mDatabase->getObjectFilePath(handle, filePath, fileLength);
+    int result = mDatabase->getObjectFilePath(handle, filePath, fileLength, format);
     if (result == MTP_RESPONSE_OK) {
         LOGV("deleting %s", (const char *)filePath);
         deletePath((const char *)filePath);
diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp
index 3f7c1b6..33f088d 100644
--- a/native/android/asset_manager.cpp
+++ b/native/android/asset_manager.cpp
@@ -201,7 +201,7 @@
 
 int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength)
 {
-    return asset->mAsset->openFileDescriptor(outStart, outLength);
+    return asset->mAsset->openFileDescriptor((off64_t*)outStart, (off64_t*)outLength);
 }
 
 int AAsset_isAllocated(AAsset* asset)
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 7c496e7..7ac6f92 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -40,7 +40,6 @@
 #include <pixelflinger/pixelflinger.h>
 
 #include <private/ui/android_natives_priv.h>
-#include <private/ui/sw_gralloc_handle.h>
 
 #include <hardware/copybit.h>
 
@@ -446,15 +445,10 @@
         android_native_buffer_t* buf, int usage, void** vaddr)
 {
     int err;
-    if (sw_gralloc_handle_t::validate(buf->handle) < 0) {
-        err = module->lock(module, buf->handle,
-                usage, 0, 0, buf->width, buf->height, vaddr);
-    } else {
-        sw_gralloc_handle_t const* hnd =
-                reinterpret_cast<sw_gralloc_handle_t const*>(buf->handle);
-        *vaddr = (void*)hnd->base;
-        err = NO_ERROR;
-    }
+
+    err = module->lock(module, buf->handle,
+            usage, 0, 0, buf->width, buf->height, vaddr);
+
     return err;
 }
 
@@ -462,9 +456,9 @@
 {
     if (!buf) return BAD_VALUE;
     int err = NO_ERROR;
-    if (sw_gralloc_handle_t::validate(buf->handle) < 0) {
-        err = module->unlock(module, buf->handle);
-    }
+
+    err = module->unlock(module, buf->handle);
+
     return err;
 }
 
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index d71ec1b..7acce02 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -220,8 +220,8 @@
     
     egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
             int impl, egl_connection_t const* cnx, int version) 
-    : dpy(dpy), context(context), read(0), draw(0), impl(impl), cnx(cnx),
-      version(version)
+    : dpy(dpy), context(context), config(config), read(0), draw(0), impl(impl),
+      cnx(cnx), version(version)
     {
     }
     EGLDisplay                  dpy;
diff --git a/packages/SystemUI/res/drawable-mdpi/scrubber_track_holo_dark.9.png b/packages/SystemUI/res/drawable-mdpi/scrubber_track_holo_dark.9.png
new file mode 100644
index 0000000..baf70cd
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/scrubber_track_holo_dark.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/recents_bg_protect_tile.png b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_bg_protect_tile.png
new file mode 100644
index 0000000..66a54f0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_bg_protect_tile.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/recents_blue_glow.9.png b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_blue_glow.9.png
new file mode 100644
index 0000000..4f4ae78
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_blue_glow.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/recents_callout_line.png b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_callout_line.png
new file mode 100644
index 0000000..5f4c035
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_callout_line.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xlarge-mdpi/recents_thumbnail_bg.png b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_thumbnail_bg.png
new file mode 100644
index 0000000..9f72549
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xlarge-mdpi/recents_thumbnail_bg.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/status_bar_settings_slider_disabled.xml b/packages/SystemUI/res/drawable/status_bar_settings_slider_disabled.xml
new file mode 100644
index 0000000..17d48b7
--- /dev/null
+++ b/packages/SystemUI/res/drawable/status_bar_settings_slider_disabled.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@android:id/background"
+            android:drawable="@*android:drawable/scrubber_track_holo_dark" />
+    <item android:id="@android:id/secondaryProgress">
+        <scale android:scaleWidth="100%"
+                android:drawable="@*android:drawable/scrubber_track_holo_dark" />
+    </item>
+    <item android:id="@android:id/progress">
+        <scale android:scaleWidth="100%"
+                android:drawable="@*android:drawable/scrubber_track_holo_dark" />
+    </item>
+</layer-list>
+
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml
index 4ca8084..8a01a12 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml
@@ -41,7 +41,7 @@
                 android:layout_height="match_parent"
                 android:layout_marginLeft="8dip"
                 android:src="@drawable/ic_sysbar_ime_default"
-                android:visibility="invisible"
+                android:visibility="gone"
                 />
             <com.android.systemui.statusbar.tablet.NotificationIconArea
                 android:id="@+id/notificationIcons"
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml b/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml
index e7a3a61..2989be0 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_recent_item.xml
@@ -19,41 +19,63 @@
 -->
 
 <!--    android:background="@drawable/status_bar_closed_default_background" -->
-<LinearLayout
+<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="wrap_content"
-    android:layout_width="wrap_content"
-    android:orientation="horizontal"
-    android:layout_margin="10dip">
+    android:layout_width="156dip">
 
     <ImageView android:id="@+id/app_thumbnail"
-        android:layout_width="88dip"
-        android:layout_height="56dip"
-        android:layout_margin="10dip"
-        android:background="#80808080">
-    </ImageView>
-
-    <LinearLayout
-        android:layout_height="wrap_content"
         android:layout_width="wrap_content"
-        android:orientation="horizontal"
-        android:layout_marginTop="10dip"
-        android:layout_marginBottom="10dip"
-        android:layout_marginRight="10dip">
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginLeft="105dip"
+        android:scaleType="center"
+        android:background="@drawable/recents_thumbnail_bg"
+    />
 
-        <ImageView android:id="@+id/app_icon"
-            android:layout_width="23dip"
-            android:layout_height="23dip"
-            android:gravity="bottom"
-            android:layout_margin="5dip"
-            />
+    <ImageView android:id="@+id/app_icon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginLeft="123dip"
+        android:layout_marginTop="16dip"
+    />
 
-        <TextView android:id="@+id/app_label"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textSize="22dip"
-        />
+    <View android:id="@+id/recents_callout_line"
+        android:layout_width="97dip"
+        android:layout_height="1dip"
+        android:layout_alignParentTop="true"
+        android:layout_marginTop="61dip"
+        android:layout_alignParentLeft="true"
+        android:layout_marginLeft="16dip"
+        android:layout_toLeftOf="@id/app_thumbnail"
+        android:layout_marginRight="3dip"
+        android:background="@drawable/recents_callout_line"
+    />
 
-    </LinearLayout>
+    <TextView android:id="@+id/app_label"
+        android:layout_width="113dip"
+        android:layout_height="wrap_content"
+        android:textSize="18dip"
+        android:fadingEdge="none"
+        android:fadingEdgeLength="0dp"
+        android:scrollHorizontally="true"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginLeft="16dip"
+        android:layout_marginTop="32dip"
+    />
 
-</LinearLayout>
+    <TextView android:id="@+id/app_description"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="18dip"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
+        android:layout_marginLeft="16dip"
+        android:layout_marginTop="61dip"
+    />
+
+</RelativeLayout>
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml
index ac038a7..c7e6dbd 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_recent_panel.xml
@@ -20,34 +20,37 @@
 
 <com.android.systemui.statusbar.tablet.RecentAppsPanel
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     android:layout_width="wrap_content"
-    android:background="@drawable/sysbar_panel_recents_bg"
+    android:layout_marginBottom="48dip"
+    android:background="@drawable/recents_bg_protect_tile"
+    android:id="@+id/recents_bg_protect"
     android:orientation="vertical">
 
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/recent_tasks_app_label"
-        android:textSize="22dip"
-        android:drawableLeft="@drawable/app_icon"
-        android:layout_margin="10dip"
-    />
-
     <TextView android:id="@+id/recents_no_recents"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:text="@string/recent_tasks_empty"
         android:textSize="22dip"
         android:gravity="center_horizontal|center_vertical"
-        android:visibility="gone"
-        android:layout_margin="10dip">
+        android:visibility="gone">
     </TextView>
 
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+        android:layout_weight="1"
+    />
+
     <LinearLayout android:id="@+id/recents_container"
-        android:layout_width="wrap_content"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="16dip"
+        android:layout_alignParentLeft="true"
+        android:layout_marginRight="100dip"
+        android:background="@drawable/recents_blue_glow"
     />
 
 </com.android.systemui.statusbar.tablet.RecentAppsPanel>
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_settings_view.xml b/packages/SystemUI/res/layout-xlarge/status_bar_settings_view.xml
index 5e867e5..5e36da3 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_settings_view.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_settings_view.xml
@@ -64,6 +64,7 @@
         <TextView
                 android:id="@+id/network_label"
                 style="@style/StatusBarPanelSettingsContents"
+                android:text="@string/status_bar_settings_wifi_button"
                 />
         <ImageView
             android:layout_width="wrap_content"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 644cca0..9737028 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -74,6 +74,9 @@
     <!-- Name of the button that links to the Settings app. [CHAR LIMIT=NONE] -->
     <string name="status_bar_settings_settings_button">Settings</string>
 
+    <!-- Name of the button that links to the Wifi settings screen. [CHAR LIMIT=NONE] -->
+    <string name="status_bar_settings_wifi_button">Wi-Fi</string>
+
     <!-- Label in the system panel for airplane mode (all radios are turned off)[CHAR LIMIT=30] -->
     <string name="status_bar_settings_airplane">Airplane mode</string>
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ToggleSlider.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ToggleSlider.java
index 46207ee..0eb2be6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ToggleSlider.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ToggleSlider.java
@@ -24,10 +24,10 @@
 import android.util.Slog;
 import android.view.View;
 import android.widget.CompoundButton;
+import android.widget.ProgressBar;
 import android.widget.RelativeLayout;
 import android.widget.SeekBar;
 import android.widget.TextView;
-import android.widget.CompoundButton;
 
 import com.android.systemui.R;
 
@@ -77,13 +77,18 @@
 
     public void onCheckedChanged(CompoundButton toggle, boolean checked) {
         Drawable thumb;
+        Drawable slider;
         final Resources res = getContext().getResources();
         if (checked) {
             thumb = res.getDrawable(R.drawable.scrubber_control_disabled_holo);
+            slider = res.getDrawable(R.drawable.status_bar_settings_slider_disabled);
         } else {
             thumb = res.getDrawable(R.drawable.scrubber_control_holo);
+            slider = res.getDrawable(
+                    com.android.internal.R.drawable.scrubber_progress_horizontal_holo_dark);
         }
         mSlider.setThumb(thumb);
+        mSlider.setProgressDrawable(slider);
 
         if (mListener != null) {
             mListener.onChanged(this, mTracking, checked, mSlider.getProgress());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
index 546750b..25a2f2b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
@@ -19,9 +19,14 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.LayoutTransition;
+import android.animation.ObjectAnimator;
+import android.animation.PropertyValuesHolder;
 import android.app.ActivityManager;
 import android.app.ActivityManagerNative;
-import android.app.IActivityManager;
 import android.app.IThumbnailReceiver;
 import android.app.ActivityManager.RunningTaskInfo;
 import android.content.Context;
@@ -29,30 +34,44 @@
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
+import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.Canvas;
 import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.Shader.TileMode;
+import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.RemoteException;
 import android.util.AttributeSet;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.animation.AnimationSet;
+import android.view.animation.DecelerateInterpolator;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+import android.widget.ImageView.ScaleType;
 
 import com.android.systemui.R;
 
 public class RecentAppsPanel extends LinearLayout implements StatusBarPanel, OnClickListener {
     private static final String TAG = "RecentAppsPanel";
     private static final boolean DEBUG = TabletStatusBar.DEBUG;
-    private static final int DISPLAY_TASKS = 4; // number of recent tasks to display
-    private static final int MAX_TASKS = 2 * DISPLAY_TASKS; // give some slack for non-apps
-    private static final boolean DBG = true;
+    private static final int DISPLAY_TASKS_PORTRAIT = 8;
+    private static final int DISPLAY_TASKS_LANDSCAPE = 5; // number of recent tasks to display
+    private static final int MAX_TASKS = 2 * DISPLAY_TASKS_PORTRAIT; // allow extra for non-apps
     private TabletStatusBar mBar;
     private TextView mNoRecents;
     private LinearLayout mRecentsContainer;
     private ArrayList<ActivityDescription> mActivityDescriptions;
+    private int mIconDpi;
+    private AnimatorSet mAnimationSet;
+    private View mBackgroundProtector;
 
     static class ActivityDescription {
         int id;
@@ -62,10 +81,12 @@
         CharSequence description; // generated by Activity.onCreateDescription()
         Intent intent; // launch intent for application
         Matrix matrix; // arbitrary rotation matrix to correct orientation
+        String packageName; // used to override animations (see onClick())
         int position; // position in list
 
         public ActivityDescription(Bitmap _thumbnail,
-                Drawable _icon, String _label, String _desc, Intent _intent, int _id, int _pos)
+                Drawable _icon, String _label, String _desc, Intent _intent, int _id, int _pos,
+                String _packageName)
         {
             thumbnail = _thumbnail;
             icon = _icon;
@@ -74,6 +95,7 @@
             intent = _intent;
             id = _id;
             position = _pos;
+            packageName = _packageName;
         }
     };
 
@@ -93,10 +115,10 @@
     };
 
     public boolean isInContentArea(int x, int y) {
-        final int l = getPaddingLeft();
-        final int r = getWidth() - getPaddingRight();
-        final int t = getPaddingTop();
-        final int b = getHeight() - getPaddingBottom();
+        final int l = mRecentsContainer.getPaddingLeft();
+        final int r = mRecentsContainer.getWidth() - mRecentsContainer.getPaddingRight();
+        final int t = mRecentsContainer.getPaddingTop();
+        final int b = mRecentsContainer.getHeight() - mRecentsContainer.getPaddingBottom();
         return x >= l && x < r && y >= t && y < b;
     }
 
@@ -110,6 +132,12 @@
 
     public RecentAppsPanel(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
+
+        Resources res = context.getResources();
+        boolean xlarge = (res.getConfiguration().screenLayout
+                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
+
+        mIconDpi = xlarge ? DisplayMetrics.DENSITY_HIGH : res.getDisplayMetrics().densityDpi;
     }
 
     @Override
@@ -117,12 +145,26 @@
         super.onFinishInflate();
         mNoRecents = (TextView) findViewById(R.id.recents_no_recents);
         mRecentsContainer = (LinearLayout) findViewById(R.id.recents_container);
+        mBackgroundProtector = (View) findViewById(R.id.recents_bg_protect);
+
+        // In order to save space, we make the background texture repeat in the Y direction
+        View view = findViewById(R.id.recents_bg_protect);
+        if (view != null && view.getBackground() instanceof BitmapDrawable) {
+            ((BitmapDrawable) view.getBackground()).setTileModeY(TileMode.REPEAT);
+        }
+    }
+
+    @Override
+    protected void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        // we show more in portrait mode, so update UI if orientation changes
+        updateUiElements(newConfig, false);
     }
 
     @Override
     protected void onVisibilityChanged(View changedView, int visibility) {
         super.onVisibilityChanged(changedView, visibility);
-        Log.v(TAG, "onVisibilityChanged(" + changedView + ", " + visibility + ")");
+        if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + changedView + ", " + visibility + ")");
         if (visibility == View.VISIBLE && changedView == this) {
             refreshApplicationList();
             mRecentsContainer.setScrollbarFadingEnabled(true);
@@ -130,6 +172,32 @@
         }
     }
 
+    private Drawable getFullResDefaultActivityIcon() {
+        return getFullResIcon(Resources.getSystem(),
+                com.android.internal.R.drawable.sym_def_app_icon);
+    }
+
+    private Drawable getFullResIcon(Resources resources, int iconId) {
+        return resources.getDrawableForDensity(iconId, mIconDpi);
+    }
+
+    private Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager) {
+        Resources resources;
+        try {
+            resources = packageManager.getResourcesForApplication(
+                    info.activityInfo.applicationInfo);
+        } catch (PackageManager.NameNotFoundException e) {
+            resources = null;
+        }
+        if (resources != null) {
+            int iconId = info.activityInfo.getIconResource();
+            if (iconId != 0) {
+                return getFullResIcon(resources, iconId);
+            }
+        }
+        return getFullResDefaultActivityIcon();
+    }
+
     private ArrayList<ActivityDescription> getRecentTasks() {
         ArrayList<ActivityDescription> activityDescriptions = new ArrayList<ActivityDescription>();
         final PackageManager pm = mContext.getPackageManager();
@@ -164,16 +232,17 @@
             if (resolveInfo != null) {
                 final ActivityInfo info = resolveInfo.activityInfo;
                 final String title = info.loadLabel(pm).toString();
-                Drawable icon = info.loadIcon(pm);
+                // Drawable icon = info.loadIcon(pm);
+                Drawable icon = getFullResIcon(resolveInfo, pm);
                 int id = recentTasks.get(i).id;
                 if (title != null && title.length() > 0 && icon != null) {
-                    Log.v(TAG, "creating activity desc for id=" + id + ", label=" + title);
+                    if (DEBUG) Log.v(TAG, "creating activity desc for id=" + id + ", label=" + title);
                     ActivityDescription item = new ActivityDescription(
-                            null, icon, title, null, intent, id, index);
+                            null, icon, title, null, intent, id, index, info.packageName);
                     activityDescriptions.add(item);
                     ++index;
                 } else {
-                    if (DBG) Log.v(TAG, "SKIPPING item " + id);
+                    if (DEBUG) Log.v(TAG, "SKIPPING item " + id);
                 }
             }
         }
@@ -196,18 +265,18 @@
     private void getThumbnails(ArrayList<ActivityDescription> tasks) {
         ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
         List<RunningTaskInfo> runningTasks = am.getRunningTasks(MAX_TASKS, 0, mThumbnailReceiver);
-        for (RunningTaskInfo r : runningTasks) {
+        for (RunningTaskInfo runningTaskInfo : runningTasks) {
             // Find the activity description associted with the given id
-            ActivityDescription desc = findActivityDescription(r.id);
+            ActivityDescription desc = findActivityDescription(runningTaskInfo.id);
             if (desc != null) {
-                if (r.thumbnail != null) {
-                    desc.thumbnail = r.thumbnail;
-                    desc.description = r.description;
+                if (runningTaskInfo.thumbnail != null) {
+                    desc.thumbnail = crop(runningTaskInfo.thumbnail);
+                    desc.description = runningTaskInfo.description;
                 } else {
-                    if (DBG) Log.v(TAG, "*** RUNNING THUMBNAIL WAS NULL ***");
+                    if (DEBUG) Log.v(TAG, "*** RUNNING THUMBNAIL WAS NULL ***");
                 }
             } else {
-                if (DBG) Log.v(TAG, "Couldn't find ActivityDesc for id=" + r.id);
+                if (DEBUG) Log.v(TAG, "Couldn't find ActivityDesc for id=" + runningTaskInfo.id);
             }
         }
     }
@@ -215,45 +284,101 @@
     private void refreshApplicationList() {
         mActivityDescriptions = getRecentTasks();
         getThumbnails(mActivityDescriptions);
-        updateUiElements();
+        updateUiElements(getResources().getConfiguration(), true);
     }
 
-    private void updateUiElements() {
+    private Bitmap crop(Bitmap bitmap) {
+        if (bitmap == null || bitmap.getWidth() >= bitmap.getHeight()) {
+            return bitmap;
+        }
+        final int width = bitmap.getWidth();
+        final int height = bitmap.getHeight();
+        Bitmap outBitmap = Bitmap.createBitmap(height, width, bitmap.getConfig());
+        Canvas canvas = new Canvas(outBitmap);
+        Paint paint = new Paint();
+        paint.setAntiAlias(true);
+        paint.setFilterBitmap(true);
+        canvas.drawBitmap(bitmap,
+                new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight() - height * width / height),
+                new Rect(0, 0, outBitmap.getWidth(), outBitmap.getHeight()),
+                paint);
+        return outBitmap;
+    }
+
+    private void updateUiElements(Configuration config, boolean animate) {
         mRecentsContainer.removeAllViews();
+
+
+        // TODO: disabled until I have a chance to tune animations with UX
+        animate = false;
+
+
+        final float initialAlpha = 0.0f;
         final int first = 0;
-        final int last = Math.min(mActivityDescriptions.size(), DISPLAY_TASKS) - 1;
+        final boolean isPortrait = config.orientation == Configuration.ORIENTATION_PORTRAIT;
+        final int taskCount = isPortrait ? DISPLAY_TASKS_PORTRAIT : DISPLAY_TASKS_LANDSCAPE;
+        final int last = Math.min(mActivityDescriptions.size(), taskCount) - 1;
+        ArrayList<Animator> anims = new ArrayList<Animator>(last+1);
+        DecelerateInterpolator interp = new DecelerateInterpolator();
         for (int i = last; i >= first; i--) {
             ActivityDescription activityDescription = mActivityDescriptions.get(i);
             View view = View.inflate(mContext, R.layout.status_bar_recent_item, null);
             ImageView appThumbnail = (ImageView) view.findViewById(R.id.app_thumbnail);
             ImageView appIcon = (ImageView) view.findViewById(R.id.app_icon);
-            TextView appDescription = (TextView) view.findViewById(R.id.app_label);
-            if (activityDescription.thumbnail != null) {
-                Log.v(TAG, "thumbnail res = " + activityDescription.thumbnail.getWidth()
-                        + "x" + activityDescription.thumbnail.getHeight());
-            } else {
-                Log.v(TAG, "thumbnail for " + activityDescription.label + " was null");
-            }
-            appThumbnail.setImageBitmap(activityDescription.thumbnail);
+            TextView appLabel = (TextView) view.findViewById(R.id.app_label);
+            TextView appDesc = (TextView) view.findViewById(R.id.app_description);
+            final Bitmap thumb = activityDescription.thumbnail;
+            appThumbnail.setImageBitmap(crop(thumb));
             appIcon.setImageDrawable(activityDescription.icon);
-            appDescription.setText(activityDescription.label);
+            appLabel.setText(activityDescription.label);
+            appDesc.setText(activityDescription.description);
             view.setOnClickListener(this);
             view.setTag(activityDescription);
-            Log.v(TAG, "Adding task: " + activityDescription.label);
             mRecentsContainer.addView(view);
+
+            if (animate) {
+                view.setAlpha(initialAlpha);
+                ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", initialAlpha, 1.0f);
+                anim.setDuration(25);
+                anim.setStartDelay((last-i)*25);
+                anim.setInterpolator(interp);
+                anims.add(anim);
+            }
         }
 
         int views = mRecentsContainer.getChildCount();
-        mNoRecents.setVisibility(views == 0 ? View.VISIBLE : View.GONE);
+        mNoRecents.setVisibility(View.GONE); // views == 0 ? View.VISIBLE : View.GONE);
         mRecentsContainer.setVisibility(views > 0 ? View.VISIBLE : View.GONE);
+
+        if (animate) {
+            ObjectAnimator anim = ObjectAnimator.ofFloat(mRecentsContainer, "alpha",
+                    initialAlpha, 1.0f);
+            anim.setDuration(last*25);
+            anim.setInterpolator(interp);
+            anims.add(anim);
+        }
+
+        if (animate) {
+            ObjectAnimator anim = ObjectAnimator.ofFloat(mBackgroundProtector, "alpha",
+                    initialAlpha, 1.0f);
+            anim.setDuration(last*25);
+            anim.setInterpolator(interp);
+            anims.add(anim);
+        }
+
+        if (anims.size() > 0) {
+            mAnimationSet = new AnimatorSet();
+            mAnimationSet.playTogether(anims);
+            mAnimationSet.start();
+        }
     }
 
     public void onClick(View v) {
         ActivityDescription ad = (ActivityDescription)v.getTag();
+        final ActivityManager am = (ActivityManager)
+                getContext().getSystemService(Context.ACTIVITY_SERVICE);
         if (ad.id >= 0) {
             // This is an active task; it should just go to the foreground.
-            final ActivityManager am = (ActivityManager)
-                    getContext().getSystemService(Context.ACTIVITY_SERVICE);
             am.moveTaskToFront(ad.id, ActivityManager.MOVE_TASK_WITH_HOME);
         } else {
             Intent intent = ad.intent;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
index 0491baa..01436f8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
@@ -99,6 +99,9 @@
     // ----------------------------
     private void onClickNetwork() {
         Slog.d(TAG, "onClickNetwork");
+        getContext().startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)
+                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+        getStatusBarManager().collapse();
     }
 
     // Settings
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index e61dd6c..79bf9d0 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1344,11 +1344,11 @@
             return true;
         }
         
-        // Shortcuts are invoked through Search+key or Meta+key, so intercept those here
-        if ((mShortcutKeyPressed != -1 && !mConsumeShortcutKeyUp)
-                || (metaState & KeyEvent.META_META_ON) != 0) {
+        // Shortcuts are invoked through Search+key, so intercept those here
+        if (mShortcutKeyPressed != -1 && !mConsumeShortcutKeyUp) {
             if (down && repeatCount == 0 && !keyguardOn) {
-                Intent shortcutIntent = mShortcutManager.getIntent(event);
+                final KeyCharacterMap kcm = event.getKeyCharacterMap();
+                Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState);
                 if (shortcutIntent != null) {
                     shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                     mContext.startActivity(shortcutIntent);
@@ -1382,11 +1382,23 @@
         }
 
         if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
+            // Invoke shortcuts using Meta as a fallback.
             final KeyCharacterMap kcm = event.getKeyCharacterMap();
-            boolean fallback = kcm.getFallbackAction(event.getKeyCode(), event.getMetaState(),
-                    mFallbackAction);
+            final int keyCode = event.getKeyCode();
+            final int metaState = event.getMetaState();
+            if ((metaState & KeyEvent.META_META_ON) != 0) {
+                Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode,
+                        metaState & ~(KeyEvent.META_META_ON
+                                | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON));
+                if (shortcutIntent != null) {
+                    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                    mContext.startActivity(shortcutIntent);
+                    return null;
+                }
+            }
 
-            if (fallback) {
+            // Check for fallback actions.
+            if (kcm.getFallbackAction(keyCode, metaState, mFallbackAction)) {
                 if (DEBUG_FALLBACK) {
                     Slog.d(TAG, "Fallback: keyCode=" + mFallbackAction.keyCode
                             + " metaState=" + Integer.toHexString(mFallbackAction.metaState));
diff --git a/policy/src/com/android/internal/policy/impl/ShortcutManager.java b/policy/src/com/android/internal/policy/impl/ShortcutManager.java
index fc66a20..75a1b01 100644
--- a/policy/src/com/android/internal/policy/impl/ShortcutManager.java
+++ b/policy/src/com/android/internal/policy/impl/ShortcutManager.java
@@ -101,18 +101,30 @@
      * This will first try an exact match (with modifiers), and then try a
      * match without modifiers (primary character on a key).
      * 
-     * @param event The key event of the key that was pressed.
+     * @param kcm The key character map of the device on which the key was pressed.
+     * @param keyCode The key code.
+     * @param metaState The meta state, omitting any modifiers that were used
+     * to invoke the shortcut.
      * @return The intent that matches the shortcut, or null if not found.
      */
-    public Intent getIntent(KeyEvent event) {
-        // First try the exact keycode (with modifiers)
-        int shortcut = event.getUnicodeChar();
-        Intent intent = shortcut != 0 ? mShortcutIntents.get(shortcut) : null; 
-        if (intent != null) return intent;
+    public Intent getIntent(KeyCharacterMap kcm, int keyCode, int metaState) {
+        Intent intent = null;
 
-        // Next try the keycode without modifiers (the primary character on that key)
-        shortcut = Character.toLowerCase(event.getUnicodeChar(0));
-        return shortcut != 0 ? mShortcutIntents.get(shortcut) : null;
+        // First try the exact keycode (with modifiers).
+        int shortcut = kcm.get(keyCode, metaState);
+        if (shortcut != 0) {
+            intent = mShortcutIntents.get(shortcut);
+        }
+
+        // Next try the primary character on that key.
+        if (intent == null) {
+            shortcut = Character.toLowerCase(kcm.getDisplayLabel(keyCode));
+            if (shortcut != 0) {
+                intent = mShortcutIntents.get(shortcut);
+            }
+        }
+
+        return intent;
     }
 
 }
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index f1fa0ff..98b934c 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -31,7 +31,6 @@
 #include <media/AudioSystem.h>
 #include <media/mediaplayer.h>
 #include <surfaceflinger/ISurface.h>
-#include <ui/Overlay.h>
 #include <utils/Errors.h>
 #include <utils/Log.h>
 #include <utils/String16.h>
@@ -306,7 +305,6 @@
     mCameraId = cameraId;
     mCameraFacing = cameraFacing;
     mClientPid = clientPid;
-    mUseOverlay = mHardware->useOverlay();
     mMsgEnabled = 0;
     mHardware->setCallbacks(notifyCallback,
                             dataCallback,
@@ -317,26 +315,16 @@
     enableMsgType(CAMERA_MSG_ERROR |
                   CAMERA_MSG_ZOOM |
                   CAMERA_MSG_FOCUS);
-    mOverlayW = 0;
-    mOverlayH = 0;
 
     // Callback is disabled by default
     mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
     mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
-    mOrientationChanged = false;
     mPlayShutterSound = true;
     cameraService->setCameraBusy(cameraId);
     cameraService->loadSound();
     LOG1("Client::Client X (pid %d)", callingPid);
 }
 
-static void *unregister_surface(void *arg) {
-    ISurface *surface = (ISurface *)arg;
-    surface->unregisterBuffers();
-    IPCThreadState::self()->flushCommands();
-    return NULL;
-}
-
 // tear down the client
 CameraService::Client::~Client() {
     int callingPid = getCallingPid();
@@ -455,10 +443,7 @@
     mHardware->cancelPicture();
     // Release the hardware resources.
     mHardware->release();
-    // Release the held overlay resources.
-    if (mUseOverlay) {
-        mOverlayRef = 0;
-    }
+
     // Release the held ANativeWindow resources.
     if (mPreviewWindow != 0) {
         mPreviewWindow = 0;
@@ -491,12 +476,6 @@
 
     if (mSurface != 0) {
         LOG1("clearing old preview surface %p", mSurface.get());
-        if (mUseOverlay) {
-            // Force the destruction of any previous overlay
-            sp<Overlay> dummy;
-            mHardware->setOverlay(dummy);
-            mOverlayRef = 0;
-        }
     }
     if (surface != 0) {
         mSurface = getISurface(surface);
@@ -504,13 +483,10 @@
         mSurface = 0;
     }
     mPreviewWindow = surface;
-    mOverlayRef = 0;
-    // If preview has been already started, set overlay or register preview
+    // If preview has been already started, register preview
     // buffers now.
     if (mHardware->previewEnabled()) {
-        if (mUseOverlay) {
-            result = setOverlay();
-        } else if (mPreviewWindow != 0) {
+        if (mPreviewWindow != 0) {
             native_window_set_buffers_transform(mPreviewWindow.get(),
                                                 mOrientation);
             result = mHardware->setPreviewWindow(mPreviewWindow);
@@ -520,55 +496,6 @@
     return result;
 }
 
-status_t CameraService::Client::setOverlay() {
-    int w, h;
-    CameraParameters params(mHardware->getParameters());
-    params.getPreviewSize(&w, &h);
-
-    if (w != mOverlayW || h != mOverlayH || mOrientationChanged) {
-        // Force the destruction of any previous overlay
-        sp<Overlay> dummy;
-        mHardware->setOverlay(dummy);
-        mOverlayRef = 0;
-        mOrientationChanged = false;
-    }
-
-    status_t result = NO_ERROR;
-    if (mSurface == 0) {
-        result = mHardware->setOverlay(NULL);
-    } else {
-        if (mOverlayRef == 0) {
-            // FIXME:
-            // Surfaceflinger may hold onto the previous overlay reference for some
-            // time after we try to destroy it. retry a few times. In the future, we
-            // should make the destroy call block, or possibly specify that we can
-            // wait in the createOverlay call if the previous overlay is in the
-            // process of being destroyed.
-            for (int retry = 0; retry < 50; ++retry) {
-                mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT,
-                                                      mOrientation);
-                if (mOverlayRef != 0) break;
-                LOGW("Overlay create failed - retrying");
-                usleep(20000);
-            }
-            if (mOverlayRef == 0) {
-                LOGE("Overlay Creation Failed!");
-                return -EINVAL;
-            }
-            result = mHardware->setOverlay(new Overlay(mOverlayRef));
-        }
-    }
-    if (result != NO_ERROR) {
-        LOGE("mHardware->setOverlay() failed with status %d\n", result);
-        return result;
-    }
-
-    mOverlayW = w;
-    mOverlayH = h;
-
-    return result;
-}
-
 // set the preview callback flag to affect how the received frames from
 // preview are handled.
 void CameraService::Client::setPreviewCallbackFlag(int callback_flag) {
@@ -630,21 +557,13 @@
         return NO_ERROR;
     }
 
-    if (mUseOverlay) {
-        // If preview display has been set, set overlay now.
-        if (mSurface != 0) {
-            result = setOverlay();
-        }
-        if (result != NO_ERROR) return result;
-        result = mHardware->startPreview();
-    } else {
-        if (mPreviewWindow != 0) {
-            native_window_set_buffers_transform(mPreviewWindow.get(),
-                                                mOrientation);
-        }
-        mHardware->setPreviewWindow(mPreviewWindow);
-        result = mHardware->startPreview();
+    if (mPreviewWindow != 0) {
+        native_window_set_buffers_transform(mPreviewWindow.get(),
+                mOrientation);
     }
+    mHardware->setPreviewWindow(mPreviewWindow);
+    result = mHardware->startPreview();
+
     return result;
 }
 
@@ -853,7 +772,6 @@
 
         if (mOrientation != orientation) {
             mOrientation = orientation;
-            if (mOverlayRef != 0) mOrientationChanged = true;
         }
         return OK;
     } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) {
@@ -1047,7 +965,7 @@
 
     // It takes some time before yuvPicture callback to be called.
     // Register the buffer for raw image here to reduce latency.
-    if (mSurface != 0 && !mUseOverlay) {
+    if (mSurface != 0) {
         int w, h;
         CameraParameters params(mHardware->getParameters());
         if (size == NULL) {
@@ -1059,11 +977,6 @@
             h &= ~1;
             LOG1("Snapshot image width=%d, height=%d", w, h);
         }
-        // FIXME: don't use hardcoded format constants here
-        ISurface::BufferHeap buffers(w, h, w, h,
-            HAL_PIXEL_FORMAT_YCrCb_420_SP, mOrientation, 0,
-            mHardware->getRawHeap());
-
         IPCThreadState::self()->flushCommands();
     }
 
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 60e0d04..d78d7e5 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -130,7 +130,6 @@
 
         // these are internal functions used to set up preview buffers
         status_t                registerPreviewBuffers();
-        status_t                setOverlay();
 
         // camera operation mode
         enum camera_mode {
@@ -175,14 +174,8 @@
         int                             mCameraFacing;   // immutable after constructor
         pid_t                           mClientPid;
         sp<CameraHardwareInterface>     mHardware;       // cleared after disconnect()
-        bool                            mUseOverlay;     // immutable after constructor
-        sp<OverlayRef>                  mOverlayRef;
-        int                             mOverlayW;
-        int                             mOverlayH;
         int                             mPreviewCallbackFlag;
         int                             mOrientation;     // Current display orientation
-        // True if display orientation has been changed. This is only used in overlay.
-        int                             mOrientationChanged;
         bool                            mPlayShutterSound;
 
         // Ensures atomicity among the public methods
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java
index 0dead1c..470af67 100644
--- a/services/java/com/android/server/DevicePolicyManagerService.java
+++ b/services/java/com/android/server/DevicePolicyManagerService.java
@@ -816,7 +816,11 @@
         }
     }
 
-    public void setActiveAdmin(ComponentName adminReceiver) {
+    /**
+     * @param adminReceiver The admin to add
+     * @param refreshing true = update an active admin, no error
+     */
+    public void setActiveAdmin(ComponentName adminReceiver, boolean refreshing) {
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.BIND_DEVICE_ADMIN, null);
 
@@ -827,15 +831,29 @@
         synchronized (this) {
             long ident = Binder.clearCallingIdentity();
             try {
-                if (getActiveAdminUncheckedLocked(adminReceiver) != null) {
+                if (!refreshing && getActiveAdminUncheckedLocked(adminReceiver) != null) {
                     throw new IllegalArgumentException("Admin is already added");
                 }
-                ActiveAdmin admin = new ActiveAdmin(info);
-                mAdminMap.put(adminReceiver, admin);
-                mAdminList.add(admin);
+                ActiveAdmin newAdmin = new ActiveAdmin(info);
+                mAdminMap.put(adminReceiver, newAdmin);
+                int replaceIndex = -1;
+                if (refreshing) {
+                    final int N = mAdminList.size();
+                    for (int i=0; i < N; i++) {
+                        ActiveAdmin oldAdmin = mAdminList.get(i);
+                        if (oldAdmin.info.getComponent().equals(adminReceiver)) {
+                            replaceIndex = i;
+                            break;
+                        }
+                    }
+                }
+                if (replaceIndex == -1) {
+                    mAdminList.add(newAdmin);
+                } else {
+                    mAdminList.set(replaceIndex, newAdmin);
+                }
                 saveSettingsLocked();
-                sendAdminCommandLocked(admin,
-                        DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED);
+                sendAdminCommandLocked(newAdmin, DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED);
             } finally {
                 Binder.restoreCallingIdentity(ident);
             }
@@ -848,6 +866,16 @@
         }
     }
 
+    public boolean hasGrantedPolicy(ComponentName adminReceiver, int policyId) {
+        synchronized (this) {
+            ActiveAdmin administrator = getActiveAdminUncheckedLocked(adminReceiver);
+            if (administrator == null) {
+                throw new SecurityException("No active admin " + adminReceiver);
+            }
+            return administrator.info.usesPolicy(policyId);
+        }
+    }
+
     public List<ComponentName> getActiveAdmins() {
         synchronized (this) {
             final int N = mAdminList.size();
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 7a2c0c6..78bc263 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -28,7 +28,6 @@
 import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
 import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
 import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
-import static android.view.WindowManager.LayoutParams.MEMORY_TYPE_PUSH_BUFFERS;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
 import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
@@ -7088,9 +7087,6 @@
                 }
 
                 int flags = 0;
-                if (mAttrs.memoryType == MEMORY_TYPE_PUSH_BUFFERS) {
-                    flags |= Surface.PUSH_BUFFERS;
-                }
 
                 if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) {
                     flags |= Surface.SECURE;
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 1c2a2c8..74d1ac9 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -6,12 +6,9 @@
     DisplayHardware/DisplayHardware.cpp \
     DisplayHardware/DisplayHardwareBase.cpp \
     DisplayHardware/HWComposer.cpp \
-    BlurFilter.cpp.arm \
     GLExtensions.cpp \
     Layer.cpp \
     LayerBase.cpp \
-    LayerBuffer.cpp \
-    LayerBlur.cpp \
     LayerDim.cpp \
     MessageQueue.cpp \
     SurfaceFlinger.cpp \
@@ -22,7 +19,7 @@
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
 
 ifeq ($(TARGET_BOARD_PLATFORM), omap3)
-	LOCAL_CFLAGS += -DNO_RGBX_8888 -DHAS_PUSH_BUFFERS
+	LOCAL_CFLAGS += -DNO_RGBX_8888
 endif
 ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
 	LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
diff --git a/services/surfaceflinger/BlurFilter.cpp b/services/surfaceflinger/BlurFilter.cpp
deleted file mode 100644
index 1ffbd5b..0000000
--- a/services/surfaceflinger/BlurFilter.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/* 
-**
-** Copyright 2006, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <utils/Errors.h>
-
-#include <pixelflinger/pixelflinger.h>
-
-#include "clz.h"
-
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
-
-namespace android {
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-inline uint32_t BLUR_RGBA_TO_HOST(uint32_t v) {
-    return v;
-}
-inline uint32_t BLUR_HOST_TO_RGBA(uint32_t v) {
-    return v;
-}
-#else
-inline uint32_t BLUR_RGBA_TO_HOST(uint32_t v) {
-    return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-}
-inline uint32_t BLUR_HOST_TO_RGBA(uint32_t v) {
-    return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-}
-#endif
-
-const int BLUR_DITHER_BITS = 6;  // dither weights stored on 6 bits
-const int BLUR_DITHER_ORDER_SHIFT= 3;
-const int BLUR_DITHER_ORDER      = (1<<BLUR_DITHER_ORDER_SHIFT);
-const int BLUR_DITHER_SIZE       = BLUR_DITHER_ORDER * BLUR_DITHER_ORDER;
-const int BLUR_DITHER_MASK       = BLUR_DITHER_ORDER-1;
-
-static const uint8_t gDitherMatrix[BLUR_DITHER_SIZE] = {
-     0, 32,  8, 40,  2, 34, 10, 42,
-    48, 16, 56, 24, 50, 18, 58, 26,
-    12, 44,  4, 36, 14, 46,  6, 38,
-    60, 28, 52, 20, 62, 30, 54, 22,
-     3, 35, 11, 43,  1, 33,  9, 41,
-    51, 19, 59, 27, 49, 17, 57, 25,
-    15, 47,  7, 39, 13, 45,  5, 37,
-    63, 31, 55, 23, 61, 29, 53, 21
-};
-
-
-template <int FACTOR = 0>
-struct BlurColor565
-{
-    typedef uint16_t type;
-    int r, g, b;    
-    inline BlurColor565() { }
-    inline BlurColor565(uint16_t v) {
-        r = v >> 11;
-        g = (v >> 5) & 0x3E;
-        b = v & 0x1F;
-    }
-    inline void clear() { r=g=b=0; }
-    inline uint16_t to(int shift, int last, int dither) const {
-        int R = r;
-        int G = g;
-        int B = b;
-        if  (UNLIKELY(last)) {
-            if (FACTOR>0) {
-                int L = (R+G+B)>>1;
-                R += (((L>>1) - R) * FACTOR) >> 8;
-                G += (((L   ) - G) * FACTOR) >> 8;
-                B += (((L>>1) - B) * FACTOR) >> 8;
-            }
-            R += (dither << shift) >> BLUR_DITHER_BITS;
-            G += (dither << shift) >> BLUR_DITHER_BITS;
-            B += (dither << shift) >> BLUR_DITHER_BITS;
-        }
-        R >>= shift;
-        G >>= shift;
-        B >>= shift;
-        return (R<<11) | (G<<5) | B;
-    }    
-    inline BlurColor565& operator += (const BlurColor565& rhs) {
-        r += rhs.r;
-        g += rhs.g;
-        b += rhs.b;
-        return *this;
-    }
-    inline BlurColor565& operator -= (const BlurColor565& rhs) {
-        r -= rhs.r;
-        g -= rhs.g;
-        b -= rhs.b;
-        return *this;
-    }
-};
-
-template <int FACTOR = 0>
-struct BlurColor888X
-{
-    typedef uint32_t type;
-    int r, g, b;    
-    inline BlurColor888X() { }
-    inline BlurColor888X(uint32_t v) {
-        v = BLUR_RGBA_TO_HOST(v);
-        r = v & 0xFF;
-        g = (v >>  8) & 0xFF;
-        b = (v >> 16) & 0xFF;
-    }
-    inline void clear() { r=g=b=0; }
-    inline uint32_t to(int shift, int last, int dither) const {
-        int R = r;
-        int G = g;
-        int B = b;
-        if  (UNLIKELY(last)) {
-            if (FACTOR>0) {
-                int L = (R+G+G+B)>>2;
-                R += ((L - R) * FACTOR) >> 8;
-                G += ((L - G) * FACTOR) >> 8;
-                B += ((L - B) * FACTOR) >> 8;
-            }
-        }
-        R >>= shift;
-        G >>= shift;
-        B >>= shift;
-        return BLUR_HOST_TO_RGBA((0xFF<<24) | (B<<16) | (G<<8) | R);
-    }    
-    inline BlurColor888X& operator += (const BlurColor888X& rhs) {
-        r += rhs.r;
-        g += rhs.g;
-        b += rhs.b;
-        return *this;
-    }
-    inline BlurColor888X& operator -= (const BlurColor888X& rhs) {
-        r -= rhs.r;
-        g -= rhs.g;
-        b -= rhs.b;
-        return *this;
-    }
-};
-
-struct BlurGray565
-{
-    typedef uint16_t type;
-    int l;    
-    inline BlurGray565() { }
-    inline BlurGray565(uint16_t v) {
-        int r = v >> 11;
-        int g = (v >> 5) & 0x3F;
-        int b = v & 0x1F;
-        l = (r + g + b + 1)>>1;
-    }
-    inline void clear() { l=0; }
-    inline uint16_t to(int shift, int last, int dither) const {
-        int L = l;
-        if  (UNLIKELY(last)) {
-            L += (dither << shift) >> BLUR_DITHER_BITS;
-        }
-        L >>= shift;
-        return ((L>>1)<<11) | (L<<5) | (L>>1);
-    }
-    inline BlurGray565& operator += (const BlurGray565& rhs) {
-        l += rhs.l;
-        return *this;
-    }
-    inline BlurGray565& operator -= (const BlurGray565& rhs) {
-        l -= rhs.l;
-        return *this;
-    }
-};
-
-struct BlurGray8888
-{
-    typedef uint32_t type;
-    int l, a;    
-    inline BlurGray8888() { }
-    inline BlurGray8888(uint32_t v) {
-        v = BLUR_RGBA_TO_HOST(v);
-        int r = v & 0xFF;
-        int g = (v >>  8) & 0xFF;
-        int b = (v >> 16) & 0xFF;
-        a = v >> 24;
-        l = r + g + g + b;
-    }    
-    inline void clear() { l=a=0; }
-    inline uint32_t to(int shift, int last, int dither) const {
-        int L = l;
-        int A = a;
-        if  (UNLIKELY(last)) {
-            L += (dither << (shift+2)) >> BLUR_DITHER_BITS;
-            A += (dither << shift) >> BLUR_DITHER_BITS;
-        }
-        L >>= (shift+2);
-        A >>= shift;
-        return BLUR_HOST_TO_RGBA((A<<24) | (L<<16) | (L<<8) | L);
-    }
-    inline BlurGray8888& operator += (const BlurGray8888& rhs) {
-        l += rhs.l;
-        a += rhs.a;
-        return *this;
-    }
-    inline BlurGray8888& operator -= (const BlurGray8888& rhs) {
-        l -= rhs.l;
-        a -= rhs.a;
-        return *this;
-    }
-};
-
-
-template<typename PIXEL>
-static status_t blurFilter(
-        GGLSurface const* dst,
-        GGLSurface const* src,
-        int kernelSizeUser,
-        int repeat)
-{
-    typedef typename PIXEL::type TYPE;
-
-    const int shift             = 31 - clz(kernelSizeUser);
-    const int areaShift         = shift*2;
-    const int kernelSize        = 1<<shift;
-    const int kernelHalfSize    = kernelSize/2;
-    const int mask              = kernelSize-1;
-    const int w                 = src->width;
-    const int h                 = src->height;
-    const uint8_t* ditherMatrix = gDitherMatrix;
-
-    // we need a temporary buffer to store one line of blurred columns
-    // as well as kernelSize lines of source pixels organized as a ring buffer.
-    void* const temporary_buffer = malloc(
-            (w + kernelSize) * sizeof(PIXEL) +
-            (src->stride * kernelSize) * sizeof(TYPE));
-    if (!temporary_buffer)
-        return NO_MEMORY;
-
-    PIXEL* const sums = (PIXEL*)temporary_buffer;
-    TYPE* const scratch = (TYPE*)(sums + w + kernelSize);
-
-    // Apply the blur 'repeat' times, this is used to approximate
-    // gaussian blurs. 3 times gives good results.
-    for (int k=0 ; k<repeat ; k++) {
-
-        // Clear the columns sums for this round
-        memset(sums, 0, (w + kernelSize) * sizeof(PIXEL));
-        TYPE* head;
-        TYPE pixel;
-        PIXEL current;
-
-        // Since we're going to override the source data we need
-        // to copy it in a temporary buffer. Only kernelSize lines are
-        // required. But since we start in the center of the kernel,
-        // we only copy half of the data, and fill the rest with zeros
-        // (assuming black/transparent pixels).
-        memcpy( scratch + src->stride*kernelHalfSize,
-                src->data,
-                src->stride*kernelHalfSize*sizeof(TYPE));
-
-        // sum half of each column, because we assume the first half is
-        // zeros (black/transparent).
-        for (int y=0 ; y<kernelHalfSize ; y++) {
-            head = (TYPE*)src->data + y*src->stride;
-            for (int x=0 ; x<w ; x++)
-                sums[x] += PIXEL( *head++ );
-        }
-
-        for (int y=0 ; y<h ; y++) {
-            TYPE* fb = (TYPE*)dst->data + y*dst->stride;
-
-            // compute the dither matrix line
-            uint8_t const * ditherY = ditherMatrix
-                    + (y & BLUR_DITHER_MASK)*BLUR_DITHER_ORDER;
-
-            // Horizontal blur pass on the columns sums
-            int count, dither, x=0;
-            PIXEL const * out= sums;
-            PIXEL const * in = sums;
-            current.clear();
-
-            count = kernelHalfSize;
-            do {
-                current += *in;
-                in++;
-            } while (--count);
-            
-            count = kernelHalfSize;
-            do {
-                current += *in;
-                dither = *(ditherY + ((x++)&BLUR_DITHER_MASK));
-                *fb++ = current.to(areaShift, k==repeat-1, dither);
-                in++;
-            } while (--count);
-
-            count = w-kernelSize;
-            do {
-                current += *in;
-                current -= *out;
-                dither = *(ditherY + ((x++)&BLUR_DITHER_MASK));
-                *fb++ = current.to(areaShift, k==repeat-1, dither);
-                in++, out++;
-            } while (--count);
-
-            count = kernelHalfSize;
-            do {
-                current -= *out;
-                dither = *(ditherY + ((x++)&BLUR_DITHER_MASK));
-                *fb++ = current.to(areaShift, k==repeat-1, dither);
-                out++;
-            } while (--count);
-
-            // vertical blur pass, subtract the oldest line from each columns
-            // and add a new line. Subtract or add zeros at the top
-            // and bottom edges.
-            TYPE* const tail = scratch + (y & mask) * src->stride;
-            if (y >= kernelHalfSize) {
-                for (int x=0 ; x<w ; x++)
-                    sums[x] -= PIXEL( tail[x] );
-            }
-            if (y < h-kernelSize) {
-                memcpy( tail,
-                        (TYPE*)src->data + (y+kernelHalfSize)*src->stride,
-                        src->stride*sizeof(TYPE));
-                for (int x=0 ; x<w ; x++)
-                    sums[x] += PIXEL( tail[x] );
-            }
-        }
-
-        // The subsequent passes are always done in-place.
-        src = dst;
-    }
-    
-    free(temporary_buffer);
-
-    return NO_ERROR;
-}
-
-template status_t blurFilter< BlurColor565<0x80> >(
-        GGLSurface const* dst,
-        GGLSurface const* src,
-        int kernelSizeUser,
-        int repeat);
-
-status_t blurFilter(
-        GGLSurface const* image,
-        int kernelSizeUser,
-        int repeat)
-{
-    status_t err = BAD_VALUE;
-    if (image->format == GGL_PIXEL_FORMAT_RGB_565) {
-        err = blurFilter< BlurColor565<0x80> >(image, image, kernelSizeUser, repeat);
-    } else if (image->format == GGL_PIXEL_FORMAT_RGBX_8888) {
-        err = blurFilter< BlurColor888X<0x80> >(image, image, kernelSizeUser, repeat);
-    }
-    return err;
-}
-
-} // namespace android
-
-//err = blur< BlurColor565<0x80> >(dst, src, kernelSizeUser, repeat);
-//err = blur<BlurGray565>(dst, src, kernelSizeUser, repeat);
-//err = blur<BlurGray8888>(dst, src, kernelSizeUser, repeat);
diff --git a/services/surfaceflinger/BlurFilter.h b/services/surfaceflinger/BlurFilter.h
deleted file mode 100644
index 294db43..0000000
--- a/services/surfaceflinger/BlurFilter.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* 
-**
-** Copyright 2006, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
-
-#ifndef ANDROID_BLUR_FILTER_H
-#define ANDROID_BLUR_FILTER_H
-
-#include <stdint.h>
-#include <utils/Errors.h>
-
-#include <pixelflinger/pixelflinger.h>
-
-namespace android {
-
-status_t blurFilter(
-        GGLSurface const* image,
-        int kernelSizeUser,
-        int repeat);
-
-} // namespace android
-
-#endif // ANDROID_BLUR_FILTER_H
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index 8926c03..64cff96 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -36,7 +36,6 @@
 
 #include "DisplayHardware/DisplayHardware.h"
 
-#include <hardware/overlay.h>
 #include <hardware/gralloc.h>
 
 #include "GLExtensions.h"
@@ -104,12 +103,6 @@
     mDpiY = mNativeWindow->ydpi;
     mRefreshRate = fbDev->fps;
 
-    mOverlayEngine = NULL;
-    hw_module_t const* module;
-    if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) {
-        overlay_control_open(module, &mOverlayEngine);
-    }
-
     EGLint w, h, dummy;
     EGLint numConfigs=0;
     EGLSurface surface;
@@ -296,7 +289,6 @@
 {
     eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
     eglTerminate(mDisplay);
-    overlay_control_close(mOverlayEngine);
 }
 
 void DisplayHardware::releaseScreen() const
@@ -367,3 +359,8 @@
 {
     eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
 }
+
+void DisplayHardware::dump(String8& res) const
+{
+    mNativeWindow->dump(res);
+}
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
index 75b55df..ee7a2af 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
@@ -33,8 +33,6 @@
 
 #include "DisplayHardware/DisplayHardwareBase.h"
 
-struct overlay_control_device_t;
-
 namespace android {
 
 class FramebufferNativeWindow;
@@ -78,7 +76,8 @@
 
     uint32_t getPageFlipCount() const;
     EGLDisplay getEGLDisplay() const { return mDisplay; }
-    overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
+
+    void dump(String8& res) const;
 
     // Hardware Composer
     HWComposer& getHwComposer() const;
@@ -115,7 +114,6 @@
     HWComposer*     mHwc;
 
     sp<FramebufferNativeWindow> mNativeWindow;
-    overlay_control_device_t* mOverlayEngine;
 };
 
 }; // namespace android
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 4af274b..4a3b20d 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -120,6 +120,11 @@
                     l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom);
             result.append(buffer);
         }
+
+    }
+    if (mHwc && mHwc->common.version >= 1 && mHwc->dump) {
+        mHwc->dump(mHwc, buffer, SIZE);
+        result.append(buffer);
     }
 }
 
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index fe4379d..80aef5f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -204,7 +204,8 @@
         return;
     }
 
-    hwcl->transform = mOrientation;
+    Transform tr(Transform(mOrientation) * Transform(mBufferTransform));
+    hwcl->transform = tr.getOrientation();
 
     if (needsBlending()) {
         hwcl->blending = mPremultipliedAlpha ?
@@ -232,11 +233,18 @@
         return;
     }
     hwcl->handle = buffer->handle;
-    // TODO: set the crop value properly
-    hwcl->sourceCrop.left   = 0;
-    hwcl->sourceCrop.top    = 0;
-    hwcl->sourceCrop.right  = buffer->width;
-    hwcl->sourceCrop.bottom = buffer->height;
+
+    if (!mBufferCrop.isEmpty()) {
+        hwcl->sourceCrop.left   = mBufferCrop.left;
+        hwcl->sourceCrop.top    = mBufferCrop.top;
+        hwcl->sourceCrop.right  = mBufferCrop.right;
+        hwcl->sourceCrop.bottom = mBufferCrop.bottom;
+    } else {
+        hwcl->sourceCrop.left   = 0;
+        hwcl->sourceCrop.top    = 0;
+        hwcl->sourceCrop.right  = buffer->width;
+        hwcl->sourceCrop.bottom = buffer->height;
+    }
 }
 
 void Layer::reloadTexture(const Region& dirty)
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 28b02c9..8a021cb 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -610,21 +610,6 @@
 status_t LayerBaseClient::Surface::onTransact(
         uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
 {
-    switch (code) {
-        case REGISTER_BUFFERS:
-        case UNREGISTER_BUFFERS:
-        case CREATE_OVERLAY:
-        {
-            if (!mFlinger->mAccessSurfaceFlinger.checkCalling()) {
-                IPCThreadState* ipc = IPCThreadState::self();
-                const int pid = ipc->getCallingPid();
-                const int uid = ipc->getCallingUid();
-                LOGE("Permission Denial: "
-                        "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
-                return PERMISSION_DENIED;
-            }
-        }
-    }
     return BnSurface::onTransact(code, data, reply, flags);
 }
 
@@ -639,26 +624,6 @@
     return INVALID_OPERATION;
 }
 
-status_t LayerBaseClient::Surface::registerBuffers(
-        const ISurface::BufferHeap& buffers) 
-{ 
-    return INVALID_OPERATION; 
-}
-
-void LayerBaseClient::Surface::postBuffer(ssize_t offset) 
-{
-}
-
-void LayerBaseClient::Surface::unregisterBuffers() 
-{
-}
-
-sp<OverlayRef> LayerBaseClient::Surface::createOverlay(
-        uint32_t w, uint32_t h, int32_t format, int32_t orientation)
-{
-    return NULL;
-};
-
 // ---------------------------------------------------------------------------
 
 }; // namespace android
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 135b3a6..f6c49fc 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -27,7 +27,6 @@
 #include <utils/RefBase.h>
 
 #include <ui/Region.h>
-#include <ui/Overlay.h>
 
 #include <surfaceflinger/ISurfaceComposerClient.h>
 #include <private/surfaceflinger/SharedBufferStack.h>
@@ -314,12 +313,6 @@
                 uint32_t w, uint32_t h, uint32_t format, uint32_t usage);
         virtual status_t setBufferCount(int bufferCount);
 
-        virtual status_t registerBuffers(const ISurface::BufferHeap& buffers); 
-        virtual void postBuffer(ssize_t offset);
-        virtual void unregisterBuffers();
-        virtual sp<OverlayRef> createOverlay(uint32_t w, uint32_t h,
-                int32_t format, int32_t orientation);
-
     protected:
         friend class LayerBaseClient;
         sp<SurfaceFlinger>  mFlinger;
diff --git a/services/surfaceflinger/LayerBlur.cpp b/services/surfaceflinger/LayerBlur.cpp
deleted file mode 100644
index 4cfcfe3..0000000
--- a/services/surfaceflinger/LayerBlur.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-#include "clz.h"
-#include "BlurFilter.h"
-#include "LayerBlur.h"
-#include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display,
-        const sp<Client>& client)
-    : LayerBaseClient(flinger, display, client), mCacheDirty(true),
-          mRefreshCache(true), mCacheAge(0), mTextureName(-1U),
-          mWidthScale(1.0f), mHeightScale(1.0f),
-          mBlurFormat(GGL_PIXEL_FORMAT_RGB_565)
-{
-}
-
-LayerBlur::~LayerBlur()
-{
-    if (mTextureName != -1U) {
-        glDeleteTextures(1, &mTextureName);
-    }
-}
-
-void LayerBlur::setVisibleRegion(const Region& visibleRegion)
-{
-    LayerBaseClient::setVisibleRegion(visibleRegion);
-    if (visibleRegionScreen.isEmpty()) {
-        if (mTextureName != -1U) {
-            // We're not visible, free the texture up.
-            glBindTexture(GL_TEXTURE_2D, 0);
-            glDeleteTextures(1, &mTextureName);
-            mTextureName = -1U;
-        }
-    }
-}
-
-uint32_t LayerBlur::doTransaction(uint32_t flags)
-{
-    // we're doing a transaction, refresh the cache!
-    if (!mFlinger->isFrozen()) {
-        mRefreshCache = true;
-        mCacheDirty = true;
-        flags |= eVisibleRegion;
-        this->contentDirty = true;
-    }
-    return LayerBase::doTransaction(flags);    
-}
-
-void LayerBlur::unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion)
-{
-    // this code-path must be as tight as possible, it's called each time
-    // the screen is composited.
-    if (UNLIKELY(!visibleRegionScreen.isEmpty())) {
-        // if anything visible below us is invalidated, the cache becomes dirty
-        if (!mCacheDirty && 
-                !visibleRegionScreen.intersect(outDirtyRegion).isEmpty()) {
-            mCacheDirty = true;
-        }
-        if (mCacheDirty) {
-            if (!mFlinger->isFrozen()) {
-                // update everything below us that is visible
-                outDirtyRegion.orSelf(visibleRegionScreen);
-                nsecs_t now = systemTime();
-                if ((now - mCacheAge) >= ms2ns(500)) {
-                    mCacheAge = now;
-                    mRefreshCache = true;
-                    mCacheDirty = false;
-                } else {
-                    if (!mAutoRefreshPending) {
-                        mFlinger->postMessageAsync(
-                                new MessageBase(MessageQueue::INVALIDATE),
-                                ms2ns(500));
-                        mAutoRefreshPending = true;
-                    }
-                }
-            }
-        }
-    }
-    LayerBase::unlockPageFlip(planeTransform, outDirtyRegion);
-}
-
-void LayerBlur::onDraw(const Region& clip) const
-{
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
-    const uint32_t fbHeight = hw.getHeight();
-    int x = mTransformedBounds.left;
-    int y = mTransformedBounds.top;
-    int w = mTransformedBounds.width();
-    int h = mTransformedBounds.height();
-    GLint X = x;
-    GLint Y = fbHeight - (y + h);
-    if (X < 0) {
-        w += X;
-        X = 0;
-    }
-    if (Y < 0) {
-        h += Y;
-        Y = 0;
-    }
-    if (w<0 || h<0) {
-        // we're outside of the framebuffer
-        return;
-    }
-
-    if (mTextureName == -1U) {
-        // create the texture name the first time
-        // can't do that in the ctor, because it runs in another thread.
-        glGenTextures(1, &mTextureName);
-        glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, &mReadFormat);
-        glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, &mReadType);
-        if (mReadFormat != GL_RGB || mReadType != GL_UNSIGNED_SHORT_5_6_5) {
-            mReadFormat = GL_RGBA;
-            mReadType = GL_UNSIGNED_BYTE;
-            mBlurFormat = GGL_PIXEL_FORMAT_RGBX_8888;
-        }
-    }
-
-    Region::const_iterator it = clip.begin();
-    Region::const_iterator const end = clip.end();
-    if (it != end) {
-#if defined(GL_OES_EGL_image_external)
-        if (GLExtensions::getInstance().haveTextureExternal()) {
-            glDisable(GL_TEXTURE_EXTERNAL_OES);
-        }
-#endif
-        glEnable(GL_TEXTURE_2D);
-        glBindTexture(GL_TEXTURE_2D, mTextureName);
-
-        if (mRefreshCache) {
-            mRefreshCache = false;
-            mAutoRefreshPending = false;
-
-            int32_t pixelSize = 4;
-            int32_t s = w;
-            if (mReadType == GL_UNSIGNED_SHORT_5_6_5) {
-                // allocate enough memory for 4-bytes (2 pixels) aligned data
-                s = (w + 1) & ~1;
-                pixelSize = 2;
-            }
-
-            uint16_t* const pixels = (uint16_t*)malloc(s*h*pixelSize);
-
-            // This reads the frame-buffer, so a h/w GL would have to
-            // finish() its rendering first. we don't want to do that
-            // too often. Read data is 4-bytes aligned.
-            glReadPixels(X, Y, w, h, mReadFormat, mReadType, pixels);
-
-            // blur that texture.
-            GGLSurface bl;
-            bl.version = sizeof(GGLSurface);
-            bl.width = w;
-            bl.height = h;
-            bl.stride = s;
-            bl.format = mBlurFormat;
-            bl.data = (GGLubyte*)pixels;            
-            blurFilter(&bl, 8, 2);
-
-            if (GLExtensions::getInstance().haveNpot()) {
-                glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, w, h, 0,
-                        mReadFormat, mReadType, pixels);
-                mWidthScale  = 1.0f / w;
-                mHeightScale =-1.0f / h;
-                mYOffset = 0;
-            } else {
-                GLuint tw = 1 << (31 - clz(w));
-                GLuint th = 1 << (31 - clz(h));
-                if (tw < GLuint(w)) tw <<= 1;
-                if (th < GLuint(h)) th <<= 1;
-                glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, tw, th, 0,
-                        mReadFormat, mReadType, NULL);
-                glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, 
-                        mReadFormat, mReadType, pixels);
-                mWidthScale  = 1.0f / tw;
-                mHeightScale =-1.0f / th;
-                mYOffset = th-h;
-            }
-
-            free((void*)pixels);
-        }
-
-        const State& s = drawingState();
-        if (UNLIKELY(s.alpha < 0xFF)) {
-            const GLfloat alpha = s.alpha * (1.0f/255.0f);
-            glColor4f(0, 0, 0, alpha);
-            glEnable(GL_BLEND);
-            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-            glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-        } else {
-            glDisable(GL_BLEND);
-        }
-
-        if (mFlags & DisplayHardware::SLOW_CONFIG) {
-            glDisable(GL_DITHER);
-        } else {
-            glEnable(GL_DITHER);
-        }
-
-        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-        glMatrixMode(GL_TEXTURE);
-        glLoadIdentity();
-        glScalef(mWidthScale, mHeightScale, 1);
-        glTranslatef(-x, mYOffset - y, 0);
-        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-        glVertexPointer(2, GL_FLOAT, 0, mVertices);
-        glTexCoordPointer(2, GL_FLOAT, 0, mVertices);
-        while (it != end) {
-            const Rect& r = *it++;
-            const GLint sy = fbHeight - (r.top + r.height());
-            glScissor(r.left, sy, r.width(), r.height());
-            glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-        }
-        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-        glLoadIdentity();
-        glMatrixMode(GL_MODELVIEW);
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/services/surfaceflinger/LayerBlur.h b/services/surfaceflinger/LayerBlur.h
deleted file mode 100644
index 4c9ec64..0000000
--- a/services/surfaceflinger/LayerBlur.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_LAYER_BLUR_H
-#define ANDROID_LAYER_BLUR_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <ui/Region.h>
-
-#include "LayerBase.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class LayerBlur : public LayerBaseClient
-{
-public:    
-                LayerBlur(SurfaceFlinger* flinger, DisplayID display,
-                        const sp<Client>& client);
-        virtual ~LayerBlur();
-
-    virtual void onDraw(const Region& clip) const;
-    virtual bool needsBlending() const  { return true; }
-    virtual bool isSecure() const       { return false; }
-    virtual const char* getTypeId() const { return "LayerBlur"; }
-
-    virtual uint32_t doTransaction(uint32_t flags);
-    virtual void setVisibleRegion(const Region& visibleRegion);
-    virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
-
-private:
-            bool    mCacheDirty;
-    mutable bool    mRefreshCache;
-    mutable bool    mAutoRefreshPending;
-            nsecs_t mCacheAge;
-    mutable GLuint  mTextureName;
-    mutable GLfloat mWidthScale;
-    mutable GLfloat mHeightScale;
-    mutable GLfloat mYOffset;
-    mutable GLint   mReadFormat;
-    mutable GLint   mReadType;
-    mutable uint32_t mBlurFormat;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_BLUR_H
diff --git a/services/surfaceflinger/LayerBuffer.cpp b/services/surfaceflinger/LayerBuffer.cpp
deleted file mode 100644
index 23506cf..0000000
--- a/services/surfaceflinger/LayerBuffer.cpp
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <math.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/StopWatch.h>
-
-#include <ui/GraphicBuffer.h>
-#include <ui/PixelFormat.h>
-#include <ui/FramebufferNativeWindow.h>
-#include <ui/Rect.h>
-#include <ui/Region.h>
-
-#include <hardware/copybit.h>
-
-#include "LayerBuffer.h"
-#include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-gralloc_module_t const* LayerBuffer::sGrallocModule = 0;
-
-// ---------------------------------------------------------------------------
-
-LayerBuffer::LayerBuffer(SurfaceFlinger* flinger, DisplayID display,
-        const sp<Client>& client)
-    : LayerBaseClient(flinger, display, client),
-      mNeedsBlending(false), mBlitEngine(0)
-{
-}
-
-LayerBuffer::~LayerBuffer()
-{
-    if (mBlitEngine) {
-        copybit_close(mBlitEngine);
-    }
-}
-
-void LayerBuffer::onFirstRef()
-{
-    LayerBaseClient::onFirstRef();
-    mSurface = new SurfaceLayerBuffer(mFlinger, this);
-
-    hw_module_t const* module = (hw_module_t const*)sGrallocModule;
-    if (!module) {
-        // NOTE: technically there is a race here, but it shouldn't
-        // cause any problem since hw_get_module() always returns
-        // the same value.
-        if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
-            sGrallocModule = (gralloc_module_t const *)module;
-        }
-    }
-
-    if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) {
-        copybit_open(module, &mBlitEngine);
-    }
-}
-
-sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const
-{
-    return mSurface;
-}
-
-status_t LayerBuffer::ditch()
-{
-    mSurface.clear();
-    return NO_ERROR;
-}
-
-bool LayerBuffer::needsBlending() const {
-    return mNeedsBlending;
-}
-
-void LayerBuffer::setNeedsBlending(bool blending) {
-    mNeedsBlending = blending;
-}
-
-void LayerBuffer::postBuffer(ssize_t offset)
-{
-    sp<Source> source(getSource());
-    if (source != 0)
-        source->postBuffer(offset);
-}
-
-void LayerBuffer::unregisterBuffers()
-{
-    sp<Source> source(clearSource());
-    if (source != 0)
-        source->unregisterBuffers();
-}
-
-uint32_t LayerBuffer::doTransaction(uint32_t flags)
-{
-    sp<Source> source(getSource());
-    if (source != 0)
-        source->onTransaction(flags);
-    uint32_t res = LayerBase::doTransaction(flags);
-    // we always want filtering for these surfaces
-    mNeedsFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG);
-    return res;
-}
-
-void LayerBuffer::unlockPageFlip(const Transform& planeTransform,
-        Region& outDirtyRegion)
-{
-    // this code-path must be as tight as possible, it's called each time
-    // the screen is composited.
-    sp<Source> source(getSource());
-    if (source != 0)
-        source->onVisibilityResolved(planeTransform);
-    LayerBase::unlockPageFlip(planeTransform, outDirtyRegion);    
-}
-
-void LayerBuffer::validateVisibility(const Transform& globalTransform)
-{
-    sp<Source> source(getSource());
-    if (source != 0)
-        source->onvalidateVisibility(globalTransform);
-    LayerBase::validateVisibility(globalTransform);
-}
-
-void LayerBuffer::drawForSreenShot() const
-{
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
-    clearWithOpenGL( Region(hw.bounds()) );
-}
-
-void LayerBuffer::onDraw(const Region& clip) const
-{
-    sp<Source> source(getSource());
-    if (LIKELY(source != 0)) {
-        source->onDraw(clip);
-    } else {
-        clearWithOpenGL(clip);
-    }
-}
-
-void LayerBuffer::serverDestroy()
-{
-    sp<Source> source(clearSource());
-    if (source != 0) {
-        source->destroy();
-    }
-}
-
-/**
- * This creates a "buffer" source for this surface
- */
-status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers)
-{
-    Mutex::Autolock _l(mLock);
-    if (mSource != 0)
-        return INVALID_OPERATION;
-
-    sp<BufferSource> source = new BufferSource(*this, buffers);
-
-    status_t result = source->getStatus();
-    if (result == NO_ERROR) {
-        mSource = source;
-    }
-    return result;
-}    
-
-/**
- * This creates an "overlay" source for this surface
- */
-sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f,
-        int32_t orientation)
-{
-    sp<OverlayRef> result;
-    Mutex::Autolock _l(mLock);
-    if (mSource != 0)
-        return result;
-
-    sp<OverlaySource> source = new OverlaySource(*this, &result, w, h, f, orientation);
-    if (result != 0) {
-        mSource = source;
-    }
-    return result;
-}
-
-sp<LayerBuffer::Source> LayerBuffer::getSource() const {
-    Mutex::Autolock _l(mLock);
-    return mSource;
-}
-
-sp<LayerBuffer::Source> LayerBuffer::clearSource() {
-    sp<Source> source;
-    Mutex::Autolock _l(mLock);
-    source = mSource;
-    mSource.clear();
-    return source;
-}
-
-// ============================================================================
-// LayerBuffer::SurfaceLayerBuffer
-// ============================================================================
-
-LayerBuffer::SurfaceLayerBuffer::SurfaceLayerBuffer(
-        const sp<SurfaceFlinger>& flinger, const sp<LayerBuffer>& owner)
-    : LayerBaseClient::Surface(flinger, owner->getIdentity(), owner)
-{
-}
-
-LayerBuffer::SurfaceLayerBuffer::~SurfaceLayerBuffer()
-{
-    unregisterBuffers();
-}
-
-status_t LayerBuffer::SurfaceLayerBuffer::registerBuffers(
-        const ISurface::BufferHeap& buffers)
-{
-    sp<LayerBuffer> owner(getOwner());
-    if (owner != 0)
-        return owner->registerBuffers(buffers);
-    return NO_INIT;
-}
-
-void LayerBuffer::SurfaceLayerBuffer::postBuffer(ssize_t offset)
-{
-    sp<LayerBuffer> owner(getOwner());
-    if (owner != 0)
-        owner->postBuffer(offset);
-}
-
-void LayerBuffer::SurfaceLayerBuffer::unregisterBuffers()
-{
-    sp<LayerBuffer> owner(getOwner());
-    if (owner != 0)
-        owner->unregisterBuffers();
-}
-
-sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay(
-        uint32_t w, uint32_t h, int32_t format, int32_t orientation) {
-    sp<OverlayRef> result;
-    sp<LayerBuffer> owner(getOwner());
-    if (owner != 0)
-        result = owner->createOverlay(w, h, format, orientation);
-    return result;
-}
-
-// ============================================================================
-// LayerBuffer::Buffer
-// ============================================================================
-
-LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers,
-        ssize_t offset, size_t bufferSize)
-    : mBufferHeap(buffers), mSupportsCopybit(false)
-{
-    NativeBuffer& src(mNativeBuffer);
-    src.crop.l = 0;
-    src.crop.t = 0;
-    src.crop.r = buffers.w;
-    src.crop.b = buffers.h;
-
-    src.img.w       = buffers.hor_stride ?: buffers.w;
-    src.img.h       = buffers.ver_stride ?: buffers.h;
-    src.img.format  = buffers.format;
-    src.img.base    = (void*)(intptr_t(buffers.heap->base()) + offset);
-    src.img.handle  = 0;
-
-    gralloc_module_t const * module = LayerBuffer::getGrallocModule();
-    if (module && module->perform) {
-        int err = module->perform(module,
-                GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER,
-                buffers.heap->heapID(), bufferSize,
-                offset, buffers.heap->base(),
-                &src.img.handle);
-
-        // we can fail here is the passed buffer is purely software
-        mSupportsCopybit = (err == NO_ERROR);
-    }
- }
-
-LayerBuffer::Buffer::~Buffer()
-{
-    NativeBuffer& src(mNativeBuffer);
-    if (src.img.handle) {
-        native_handle_delete(src.img.handle);
-    }
-}
-
-// ============================================================================
-// LayerBuffer::Source
-// LayerBuffer::BufferSource
-// LayerBuffer::OverlaySource
-// ============================================================================
-
-LayerBuffer::Source::Source(LayerBuffer& layer)
-    : mLayer(layer)
-{    
-}
-LayerBuffer::Source::~Source() {    
-}
-void LayerBuffer::Source::onDraw(const Region& clip) const {
-}
-void LayerBuffer::Source::onTransaction(uint32_t flags) {
-}
-void LayerBuffer::Source::onVisibilityResolved(
-        const Transform& planeTransform) {
-}
-void LayerBuffer::Source::postBuffer(ssize_t offset) {
-}
-void LayerBuffer::Source::unregisterBuffers() {
-}
-
-// ---------------------------------------------------------------------------
-
-LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
-        const ISurface::BufferHeap& buffers)
-    : Source(layer), mStatus(NO_ERROR), mBufferSize(0)
-{
-    if (buffers.heap == NULL) {
-        // this is allowed, but in this case, it is illegal to receive
-        // postBuffer(). The surface just erases the framebuffer with
-        // fully transparent pixels.
-        mBufferHeap = buffers;
-        mLayer.setNeedsBlending(false);
-        return;
-    }
-
-    status_t err = (buffers.heap->heapID() >= 0) ? NO_ERROR : NO_INIT;
-    if (err != NO_ERROR) {
-        LOGE("LayerBuffer::BufferSource: invalid heap (%s)", strerror(err));
-        mStatus = err;
-        return;
-    }
-    
-    PixelFormatInfo info;
-    err = getPixelFormatInfo(buffers.format, &info);
-    if (err != NO_ERROR) {
-        LOGE("LayerBuffer::BufferSource: invalid format %d (%s)",
-                buffers.format, strerror(err));
-        mStatus = err;
-        return;
-    }
-
-    if (buffers.hor_stride<0 || buffers.ver_stride<0) {
-        LOGE("LayerBuffer::BufferSource: invalid parameters "
-             "(w=%d, h=%d, xs=%d, ys=%d)", 
-             buffers.w, buffers.h, buffers.hor_stride, buffers.ver_stride);
-        mStatus = BAD_VALUE;
-        return;
-    }
-
-    mBufferHeap = buffers;
-    mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0);    
-    mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride;
-    mLayer.forceVisibilityTransaction();
-}
-
-LayerBuffer::BufferSource::~BufferSource()
-{    
-    class MessageDestroyTexture : public MessageBase {
-        SurfaceFlinger* flinger;
-        GLuint name;
-    public:
-        MessageDestroyTexture(
-                SurfaceFlinger* flinger, GLuint name)
-            : flinger(flinger), name(name) { }
-        virtual bool handler() {
-            glDeleteTextures(1, &name);
-            return true;
-        }
-    };
-
-    if (mTexture.name != -1U) {
-        // GL textures can only be destroyed from the GL thread
-        getFlinger()->mEventQueue.postMessage(
-                new MessageDestroyTexture(getFlinger(), mTexture.name) );
-    }
-    if (mTexture.image != EGL_NO_IMAGE_KHR) {
-        EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
-        eglDestroyImageKHR(dpy, mTexture.image);
-    }
-}
-
-void LayerBuffer::BufferSource::postBuffer(ssize_t offset)
-{    
-    ISurface::BufferHeap buffers;
-    { // scope for the lock
-        Mutex::Autolock _l(mBufferSourceLock);
-        buffers = mBufferHeap;
-        if (buffers.heap != 0) {
-            const size_t memorySize = buffers.heap->getSize();
-            if ((size_t(offset) + mBufferSize) > memorySize) {
-                LOGE("LayerBuffer::BufferSource::postBuffer() "
-                     "invalid buffer (offset=%d, size=%d, heap-size=%d",
-                     int(offset), int(mBufferSize), int(memorySize));
-                return;
-            }
-        }
-    }
-
-    sp<Buffer> buffer;
-    if (buffers.heap != 0) {
-        buffer = new LayerBuffer::Buffer(buffers, offset, mBufferSize);
-        if (buffer->getStatus() != NO_ERROR)
-            buffer.clear();
-        setBuffer(buffer);
-        mLayer.invalidate();
-    }
-}
-
-void LayerBuffer::BufferSource::unregisterBuffers()
-{
-    Mutex::Autolock _l(mBufferSourceLock);
-    mBufferHeap.heap.clear();
-    mBuffer.clear();
-    mLayer.invalidate();
-}
-
-sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const
-{
-    Mutex::Autolock _l(mBufferSourceLock);
-    return mBuffer;
-}
-
-void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer)
-{
-    Mutex::Autolock _l(mBufferSourceLock);
-    mBuffer = buffer;
-}
-
-void LayerBuffer::BufferSource::onDraw(const Region& clip) const 
-{
-    sp<Buffer> ourBuffer(getBuffer());
-    if (UNLIKELY(ourBuffer == 0))  {
-        // nothing to do, we don't have a buffer
-        mLayer.clearWithOpenGL(clip);
-        return;
-    }
-
-    status_t err = NO_ERROR;
-    NativeBuffer src(ourBuffer->getBuffer());
-    const Rect transformedBounds(mLayer.getTransformedBounds());
-
-#if defined(EGL_ANDROID_image_native_buffer)
-    if (GLExtensions::getInstance().haveDirectTexture()) {
-        err = INVALID_OPERATION;
-        if (ourBuffer->supportsCopybit()) {
-            copybit_device_t* copybit = mLayer.mBlitEngine;
-            if (copybit && err != NO_ERROR) {
-                // create our EGLImageKHR the first time
-                err = initTempBuffer();
-                if (err == NO_ERROR) {
-                    // NOTE: Assume the buffer is allocated with the proper USAGE flags
-                    const NativeBuffer& dst(mTempBuffer);
-                    region_iterator clip(Region(Rect(dst.crop.r, dst.crop.b)));
-                    copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
-                    copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
-                    copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
-                    err = copybit->stretch(copybit, &dst.img, &src.img,
-                            &dst.crop, &src.crop, &clip);
-                    if (err != NO_ERROR) {
-                        clearTempBufferImage();
-                    }
-                }
-            }
-        }
-    }
-#endif
-    else {
-        err = INVALID_OPERATION;
-    }
-
-    if (err != NO_ERROR) {
-        // slower fallback
-        GGLSurface t;
-        t.version = sizeof(GGLSurface);
-        t.width  = src.crop.r;
-        t.height = src.crop.b;
-        t.stride = src.img.w;
-        t.vstride= src.img.h;
-        t.format = src.img.format;
-        t.data = (GGLubyte*)src.img.base;
-        const Region dirty(Rect(t.width, t.height));
-        mTextureManager.loadTexture(&mTexture, dirty, t);
-    }
-
-    mLayer.setBufferTransform(mBufferHeap.transform);
-    mLayer.drawWithOpenGL(clip, mTexture);
-}
-
-status_t LayerBuffer::BufferSource::initTempBuffer() const
-{
-    // figure out the size we need now
-    const ISurface::BufferHeap& buffers(mBufferHeap);
-    uint32_t w = mLayer.mTransformedBounds.width();
-    uint32_t h = mLayer.mTransformedBounds.height();
-    if (mLayer.getOrientation() & (Transform::ROT_90 | Transform::ROT_270)) {
-        int t = w; w = h; h = t;
-    }
-
-    // we're in the copybit case, so make sure we can handle this blit
-    // we don't have to keep the aspect ratio here
-    copybit_device_t* copybit = mLayer.mBlitEngine;
-    const int down = copybit->get(copybit, COPYBIT_MINIFICATION_LIMIT);
-    const int up = copybit->get(copybit, COPYBIT_MAGNIFICATION_LIMIT);
-    if (buffers.w > w*down)     w = buffers.w / down;
-    else if (w > buffers.w*up)  w = buffers.w*up;
-    if (buffers.h > h*down)     h = buffers.h / down;
-    else if (h > buffers.h*up)  h = buffers.h*up;
-
-    if (mTexture.image != EGL_NO_IMAGE_KHR) {
-        // we have an EGLImage, make sure the needed size didn't change
-        if (w!=mTexture.width || h!= mTexture.height) {
-            // delete the EGLImage and texture
-            clearTempBufferImage();
-        } else {
-            // we're good, we have an EGLImageKHR and it's (still) the
-            // right size
-            return NO_ERROR;
-        }
-    }
-
-    // figure out if we need linear filtering
-    if (buffers.w * h == buffers.h * w) {
-        // same pixel area, don't use filtering
-        mLayer.mNeedsFiltering = false;
-    }
-
-    // Allocate a temporary buffer and create the corresponding EGLImageKHR
-    // once the EGLImage has been created we don't need the
-    // graphic buffer reference anymore.
-    sp<GraphicBuffer> buffer = new GraphicBuffer(
-            w, h, HAL_PIXEL_FORMAT_RGB_565,
-            GraphicBuffer::USAGE_HW_TEXTURE |
-            GraphicBuffer::USAGE_HW_2D);
-
-    status_t err = buffer->initCheck();
-    if (err == NO_ERROR) {
-        NativeBuffer& dst(mTempBuffer);
-        dst.img.w = buffer->getStride();
-        dst.img.h = h;
-        dst.img.format = buffer->getPixelFormat();
-        dst.img.handle = (native_handle_t *)buffer->handle;
-        dst.img.base = 0;
-        dst.crop.l = 0;
-        dst.crop.t = 0;
-        dst.crop.r = w;
-        dst.crop.b = h;
-
-        EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
-        err = mTextureManager.initEglImage(&mTexture, dpy, buffer);
-    }
-
-    return err;
-}
-
-void LayerBuffer::BufferSource::clearTempBufferImage() const
-{
-    // delete the image
-    EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay());
-    eglDestroyImageKHR(dpy, mTexture.image);
-
-    // and the associated texture (recreate a name)
-    glDeleteTextures(1, &mTexture.name);
-    Texture defaultTexture;
-    mTexture = defaultTexture;
-}
-
-// ---------------------------------------------------------------------------
-
-LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
-        sp<OverlayRef>* overlayRef, 
-        uint32_t w, uint32_t h, int32_t format, int32_t orientation)
-    : Source(layer), mVisibilityChanged(false),
-    mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation)
-{
-    overlay_control_device_t* overlay_dev = getFlinger()->getOverlayEngine();
-    if (overlay_dev == NULL) {
-        // overlays not supported
-        return;
-    }
-
-    mOverlayDevice = overlay_dev;
-    overlay_t* overlay = overlay_dev->createOverlay(overlay_dev, w, h, format);
-    if (overlay == NULL) {
-        // couldn't create the overlay (no memory? no more overlays?)
-        return;
-    }
-
-    // enable dithering...
-    overlay_dev->setParameter(overlay_dev, overlay, 
-            OVERLAY_DITHER, OVERLAY_ENABLE);
-
-    mOverlay = overlay;
-    mWidth = overlay->w;
-    mHeight = overlay->h;
-    mFormat = overlay->format; 
-    mWidthStride = overlay->w_stride;
-    mHeightStride = overlay->h_stride;
-    mInitialized = false;
-
-    mOverlayHandle = overlay->getHandleRef(overlay);
-    
-    sp<OverlayChannel> channel = new OverlayChannel( &layer );
-
-    *overlayRef = new OverlayRef(mOverlayHandle, channel,
-            mWidth, mHeight, mFormat, mWidthStride, mHeightStride);
-    getFlinger()->signalEvent();
-}
-
-LayerBuffer::OverlaySource::~OverlaySource()
-{
-    if (mOverlay && mOverlayDevice) {
-        overlay_control_device_t* overlay_dev = mOverlayDevice;
-        overlay_dev->destroyOverlay(overlay_dev, mOverlay);
-    }
-}
-
-void LayerBuffer::OverlaySource::onDraw(const Region& clip) const
-{
-    // this would be where the color-key would be set, should we need it.
-    GLclampf red = 0;
-    GLclampf green = 0;
-    GLclampf blue = 0;
-    mLayer.clearWithOpenGL(clip, red, green, blue, 0);
-}
-
-void LayerBuffer::OverlaySource::onTransaction(uint32_t flags)
-{
-    const Layer::State& front(mLayer.drawingState());
-    const Layer::State& temp(mLayer.currentState());
-    if (temp.sequence != front.sequence) {
-        mVisibilityChanged = true;
-    }
-}
-
-void LayerBuffer::OverlaySource::onvalidateVisibility(const Transform&)
-{
-    mVisibilityChanged = true;
-}
-
-void LayerBuffer::OverlaySource::onVisibilityResolved(
-        const Transform& planeTransform)
-{
-    // this code-path must be as tight as possible, it's called each time
-    // the screen is composited.
-    if (UNLIKELY(mOverlay != 0)) {
-        if (mVisibilityChanged || !mInitialized) {
-            mVisibilityChanged = false;
-            mInitialized = true;
-            const Rect bounds(mLayer.getTransformedBounds());
-            int x = bounds.left;
-            int y = bounds.top;
-            int w = bounds.width();
-            int h = bounds.height();
-            
-            // we need a lock here to protect "destroy"
-            Mutex::Autolock _l(mOverlaySourceLock);
-            if (mOverlay) {
-                overlay_control_device_t* overlay_dev = mOverlayDevice;
-                overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h);
-                // we need to combine the layer orientation and the
-                // user-requested orientation.
-                Transform finalTransform(Transform(mLayer.getOrientation()) *
-                        Transform(mOrientation));
-                overlay_dev->setParameter(overlay_dev, mOverlay,
-                        OVERLAY_TRANSFORM, finalTransform.getOrientation());
-                overlay_dev->commit(overlay_dev, mOverlay);
-            }
-        }
-    }
-}
-
-void LayerBuffer::OverlaySource::destroy()
-{
-    // we need a lock here to protect "onVisibilityResolved"
-    Mutex::Autolock _l(mOverlaySourceLock);
-    if (mOverlay && mOverlayDevice) {
-        overlay_control_device_t* overlay_dev = mOverlayDevice;
-        overlay_dev->destroyOverlay(overlay_dev, mOverlay);
-        mOverlay = 0;
-    }
-}
-
-// ---------------------------------------------------------------------------
-}; // namespace android
diff --git a/services/surfaceflinger/LayerBuffer.h b/services/surfaceflinger/LayerBuffer.h
deleted file mode 100644
index a89d8fe..0000000
--- a/services/surfaceflinger/LayerBuffer.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_LAYER_BUFFER_H
-#define ANDROID_LAYER_BUFFER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "LayerBase.h"
-#include "TextureManager.h"
-
-struct copybit_device_t;
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class Buffer;
-class Region;
-class OverlayRef;
-
-// ---------------------------------------------------------------------------
-
-class LayerBuffer : public LayerBaseClient
-{
-    class Source : public LightRefBase<Source> {
-    public:
-        Source(LayerBuffer& layer);
-        virtual ~Source();
-        virtual void onDraw(const Region& clip) const;
-        virtual void onTransaction(uint32_t flags);
-        virtual void onVisibilityResolved(const Transform& planeTransform);
-        virtual void onvalidateVisibility(const Transform& globalTransform) { }
-        virtual void postBuffer(ssize_t offset);
-        virtual void unregisterBuffers();
-        virtual void destroy() { }
-        SurfaceFlinger* getFlinger() const { return mLayer.mFlinger.get(); }
-    protected:
-        LayerBuffer& mLayer;
-    };
-
-public:
-            LayerBuffer(SurfaceFlinger* flinger, DisplayID display,
-                    const sp<Client>& client);
-        virtual ~LayerBuffer();
-
-    virtual void onFirstRef();
-    virtual bool needsBlending() const;
-    virtual const char* getTypeId() const { return "LayerBuffer"; }
-
-    virtual sp<LayerBaseClient::Surface> createSurface() const;
-    virtual status_t ditch();
-    virtual void onDraw(const Region& clip) const;
-    virtual void drawForSreenShot() const;
-    virtual uint32_t doTransaction(uint32_t flags);
-    virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
-    virtual void validateVisibility(const Transform& globalTransform);
-
-    status_t registerBuffers(const ISurface::BufferHeap& buffers);
-    void postBuffer(ssize_t offset);
-    void unregisterBuffers();
-    sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format,
-            int32_t orientation);
-    
-    sp<Source> getSource() const;
-    sp<Source> clearSource();
-    void setNeedsBlending(bool blending);
-    Rect getTransformedBounds() const {
-        return mTransformedBounds;
-    }
-
-    void serverDestroy();
-
-private:
-    struct NativeBuffer {
-        copybit_image_t   img;
-        copybit_rect_t    crop;
-    };
-
-    static gralloc_module_t const* sGrallocModule;
-    static gralloc_module_t const* getGrallocModule() {
-        return sGrallocModule;
-    }
-
-    class Buffer : public LightRefBase<Buffer> {
-    public:
-        Buffer(const ISurface::BufferHeap& buffers,
-                ssize_t offset, size_t bufferSize);
-        inline bool supportsCopybit() const {
-            return mSupportsCopybit;
-        }
-        inline status_t getStatus() const {
-            return mBufferHeap.heap!=0 ? NO_ERROR : NO_INIT;
-        }
-        inline const NativeBuffer& getBuffer() const {
-            return mNativeBuffer;
-        }
-    protected:
-        friend class LightRefBase<Buffer>;
-        Buffer& operator = (const Buffer& rhs);
-        Buffer(const Buffer& rhs);
-        ~Buffer();
-    private:
-        ISurface::BufferHeap    mBufferHeap;
-        NativeBuffer            mNativeBuffer;
-        bool                    mSupportsCopybit;
-    };
-
-    class BufferSource : public Source {
-    public:
-        BufferSource(LayerBuffer& layer, const ISurface::BufferHeap& buffers);
-        virtual ~BufferSource();
-
-        status_t getStatus() const { return mStatus; }
-        sp<Buffer> getBuffer() const;
-        void setBuffer(const sp<Buffer>& buffer);
-
-        virtual void onDraw(const Region& clip) const;
-        virtual void postBuffer(ssize_t offset);
-        virtual void unregisterBuffers();
-        virtual void destroy() { }
-    private:
-        status_t initTempBuffer() const;
-        void clearTempBufferImage() const;
-        mutable Mutex                   mBufferSourceLock;
-        sp<Buffer>                      mBuffer;
-        status_t                        mStatus;
-        ISurface::BufferHeap            mBufferHeap;
-        size_t                          mBufferSize;
-        mutable Texture                 mTexture;
-        mutable NativeBuffer            mTempBuffer;
-        mutable TextureManager          mTextureManager;
-    };
-    
-    class OverlaySource : public Source {
-    public:
-        OverlaySource(LayerBuffer& layer,
-                sp<OverlayRef>* overlayRef, 
-                uint32_t w, uint32_t h, int32_t format, int32_t orientation);
-        virtual ~OverlaySource();
-        virtual void onDraw(const Region& clip) const;
-        virtual void onTransaction(uint32_t flags);
-        virtual void onVisibilityResolved(const Transform& planeTransform);
-        virtual void onvalidateVisibility(const Transform& globalTransform);
-        virtual void destroy();
-    private:
-
-        class OverlayChannel : public BnOverlay {
-            wp<LayerBuffer> mLayer;
-            virtual void destroy() {
-                sp<LayerBuffer> layer(mLayer.promote());
-                if (layer != 0) {
-                    layer->serverDestroy();
-                }
-            }
-        public:
-            OverlayChannel(const sp<LayerBuffer>& layer)
-                : mLayer(layer) {
-            }
-        };
-        
-        friend class OverlayChannel;
-        bool mVisibilityChanged;
-
-        overlay_t* mOverlay;        
-        overlay_handle_t mOverlayHandle;
-        overlay_control_device_t* mOverlayDevice;
-        uint32_t mWidth;
-        uint32_t mHeight;
-        int32_t mFormat;
-        int32_t mWidthStride;
-        int32_t mHeightStride;
-        int32_t mOrientation;
-        mutable Mutex mOverlaySourceLock;
-        bool mInitialized;
-    };
-
-
-    class SurfaceLayerBuffer : public LayerBaseClient::Surface
-    {
-    public:
-        SurfaceLayerBuffer(const sp<SurfaceFlinger>& flinger,
-                        const sp<LayerBuffer>& owner);
-        virtual ~SurfaceLayerBuffer();
-
-        virtual status_t registerBuffers(const ISurface::BufferHeap& buffers);
-        virtual void postBuffer(ssize_t offset);
-        virtual void unregisterBuffers();
-        
-        virtual sp<OverlayRef> createOverlay(
-                uint32_t w, uint32_t h, int32_t format, int32_t orientation);
-    private:
-        sp<LayerBuffer> getOwner() const {
-            return static_cast<LayerBuffer*>(Surface::getOwner().get());
-        }
-    };
-
-    mutable Mutex   mLock;
-    sp<Source>      mSource;
-    sp<Surface>     mSurface;
-    bool            mInvalidate;
-    bool            mNeedsBlending;
-    copybit_device_t* mBlitEngine;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_BUFFER_H
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2e785aa..7980dfa 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -47,8 +47,6 @@
 #include "clz.h"
 #include "GLExtensions.h"
 #include "Layer.h"
-#include "LayerBlur.h"
-#include "LayerBuffer.h"
 #include "LayerDim.h"
 #include "SurfaceFlinger.h"
 
@@ -119,11 +117,6 @@
     glDeleteTextures(1, &mWormholeTexName);
 }
 
-overlay_control_device_t* SurfaceFlinger::getOverlayEngine() const
-{
-    return graphicPlane(0).displayHardware().getOverlayEngine();
-}
-
 sp<IMemoryHeap> SurfaceFlinger::getCblk() const
 {
     return mServerHeap;
@@ -1228,19 +1221,12 @@
     sp<Layer> normalLayer;
     switch (flags & eFXSurfaceMask) {
         case eFXSurfaceNormal:
-#if HAS_PUSH_BUFFERS
-            if (UNLIKELY(flags & ePushBuffers)) {
-                layer = createPushBuffersSurface(client, d, w, h, flags);
-            } else
-#endif
-            {
-                normalLayer = createNormalSurface(client, d, w, h, flags, format);
-                layer = normalLayer;
-            }
+            normalLayer = createNormalSurface(client, d, w, h, flags, format);
+            layer = normalLayer;
             break;
         case eFXSurfaceBlur:
-            layer = createBlurSurface(client, d, w, h, flags);
-            break;
+            // for now we treat Blur as Dim, until we can implement it
+            // efficiently.
         case eFXSurfaceDim:
             layer = createDimSurface(client, d, w, h, flags);
             break;
@@ -1304,15 +1290,6 @@
     return layer;
 }
 
-sp<LayerBlur> SurfaceFlinger::createBlurSurface(
-        const sp<Client>& client, DisplayID display,
-        uint32_t w, uint32_t h, uint32_t flags)
-{
-    sp<LayerBlur> layer = new LayerBlur(this, display, client);
-    layer->initStates(w, h, flags);
-    return layer;
-}
-
 sp<LayerDim> SurfaceFlinger::createDimSurface(
         const sp<Client>& client, DisplayID display,
         uint32_t w, uint32_t h, uint32_t flags)
@@ -1322,15 +1299,6 @@
     return layer;
 }
 
-sp<LayerBuffer> SurfaceFlinger::createPushBuffersSurface(
-        const sp<Client>& client, DisplayID display,
-        uint32_t w, uint32_t h, uint32_t flags)
-{
-    sp<LayerBuffer> layer = new LayerBuffer(this, display, client);
-    layer->initStates(w, h, flags);
-    return layer;
-}
-
 status_t SurfaceFlinger::removeSurface(const sp<Client>& client, SurfaceID sid)
 {
     /*
@@ -1460,7 +1428,7 @@
 
 status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
 {
-    const size_t SIZE = 1024;
+    const size_t SIZE = 4096;
     char buffer[SIZE];
     String8 result;
     if (!mDump.checkCalling()) {
@@ -1538,6 +1506,7 @@
 
         const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get());
         alloc.dump(result);
+        hw.dump(result);
 
         if (locked) {
             mStateLock.unlock();
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index dda25e8..c0e5acd 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -48,9 +48,7 @@
 class DisplayHardware;
 class FreezeLock;
 class Layer;
-class LayerBlur;
 class LayerDim;
-class LayerBuffer;
 
 #define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
 #define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
@@ -207,8 +205,6 @@
             void                        screenReleased(DisplayID dpy);
             void                        screenAcquired(DisplayID dpy);
 
-            overlay_control_device_t* getOverlayEngine() const;
-
     status_t removeLayer(const sp<LayerBase>& layer);
     status_t addLayer(const sp<LayerBase>& layer);
     status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
@@ -218,11 +214,9 @@
 private:
     friend class Client;
     friend class LayerBase;
-    friend class LayerBuffer;
     friend class LayerBaseClient;
     friend class LayerBaseClient::Surface;
     friend class Layer;
-    friend class LayerBlur;
     friend class LayerDim;
 
     sp<ISurface> createSurface(const sp<Client>& client,
@@ -236,18 +230,10 @@
             uint32_t w, uint32_t h, uint32_t flags,
             PixelFormat& format);
 
-    sp<LayerBlur> createBlurSurface(
-            const sp<Client>& client, DisplayID display,
-            uint32_t w, uint32_t h, uint32_t flags);
-
     sp<LayerDim> createDimSurface(
             const sp<Client>& client, DisplayID display,
             uint32_t w, uint32_t h, uint32_t flags);
 
-    sp<LayerBuffer> createPushBuffersSurface(
-            const sp<Client>& client, DisplayID display,
-            uint32_t w, uint32_t h, uint32_t flags);
-
     status_t removeSurface(const sp<Client>& client, SurfaceID sid);
     status_t destroySurface(const sp<LayerBaseClient>& layer);
     status_t setClientState(const sp<Client>& client,
diff --git a/services/surfaceflinger/tests/overlays/Android.mk b/services/surfaceflinger/tests/overlays/Android.mk
deleted file mode 100644
index 592b601..0000000
--- a/services/surfaceflinger/tests/overlays/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
-	overlays.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-	libcutils \
-	libutils \
-    libui \
-    libsurfaceflinger_client
-
-LOCAL_MODULE:= test-overlays
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/services/surfaceflinger/tests/overlays/overlays.cpp b/services/surfaceflinger/tests/overlays/overlays.cpp
deleted file mode 100644
index c248a61..0000000
--- a/services/surfaceflinger/tests/overlays/overlays.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
-
-#include <ui/Overlay.h>
-
-#include <surfaceflinger/Surface.h>
-#include <surfaceflinger/ISurface.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-
-using namespace android;
-
-namespace android {
-class Test {
-public:
-    static const sp<ISurface>& getISurface(const sp<Surface>& s) {
-        return s->getISurface();
-    }
-};
-};
-
-int main(int argc, char** argv)
-{
-    // set up the thread-pool
-    sp<ProcessState> proc(ProcessState::self());
-    ProcessState::self()->startThreadPool();
-
-    // create a client to surfaceflinger
-    sp<SurfaceComposerClient> client = new SurfaceComposerClient();
-    
-    // create pushbuffer surface
-    sp<Surface> surface = client->createSurface(getpid(), 0, 320, 240, 
-            PIXEL_FORMAT_UNKNOWN, ISurfaceComposer::ePushBuffers);
-
-    // get to the isurface
-    sp<ISurface> isurface = Test::getISurface(surface);
-    printf("isurface = %p\n", isurface.get());
-    
-    // now request an overlay
-    sp<OverlayRef> ref = isurface->createOverlay(320, 240, PIXEL_FORMAT_RGB_565);
-    sp<Overlay> overlay = new Overlay(ref);
-    
-
-    /*
-     * here we can use the overlay API 
-     */
-    
-    overlay_buffer_t buffer; 
-    overlay->dequeueBuffer(&buffer);
-    printf("buffer = %p\n", buffer);
-    
-    void* address = overlay->getBufferAddress(buffer);
-    printf("address = %p\n", address);
-
-    overlay->queueBuffer(buffer);
-
-    return 0;
-}
diff --git a/services/surfaceflinger/tests/resize/resize.cpp b/services/surfaceflinger/tests/resize/resize.cpp
index 127cca3..99f4b4f 100644
--- a/services/surfaceflinger/tests/resize/resize.cpp
+++ b/services/surfaceflinger/tests/resize/resize.cpp
@@ -10,8 +10,6 @@
 #include <surfaceflinger/ISurface.h>
 #include <surfaceflinger/SurfaceComposerClient.h>
 
-#include <ui/Overlay.h>
-
 using namespace android;
 
 namespace android {
@@ -32,7 +30,6 @@
     // create a client to surfaceflinger
     sp<SurfaceComposerClient> client = new SurfaceComposerClient();
     
-    // create pushbuffer surface
     sp<Surface> surface = client->createSurface(getpid(), 0, 160, 240, 
             PIXEL_FORMAT_RGB_565);
 
diff --git a/services/surfaceflinger/tests/surface/surface.cpp b/services/surfaceflinger/tests/surface/surface.cpp
index b4de4b4..194fbb6 100644
--- a/services/surfaceflinger/tests/surface/surface.cpp
+++ b/services/surfaceflinger/tests/surface/surface.cpp
@@ -10,8 +10,6 @@
 #include <surfaceflinger/ISurface.h>
 #include <surfaceflinger/SurfaceComposerClient.h>
 
-#include <ui/Overlay.h>
-
 using namespace android;
 
 int main(int argc, char** argv)
@@ -23,7 +21,6 @@
     // create a client to surfaceflinger
     sp<SurfaceComposerClient> client = new SurfaceComposerClient();
     
-    // create pushbuffer surface
     sp<SurfaceControl> surfaceControl = client->createSurface(
             getpid(), 0, 160, 240, PIXEL_FORMAT_RGB_565);
     client->openTransaction();
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index 916602f..c97ba6e 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -359,6 +359,11 @@
                             rr.onError(GENERIC_FAILURE, null);
                             rr.release();
                         }
+                    } finally {
+                        // Note: We are "Done" only if there are no outstanding
+                        // requests or replies. Thus this code path will only release
+                        // the wake lock on errors.
+                        releaseWakeLockIfDone();
                     }
 
                     if (!alreadySubtracted) {
@@ -2026,6 +2031,12 @@
     send(RILRequest rr) {
         Message msg;
 
+        if (mSocket == null) {
+            rr.onError(RADIO_NOT_AVAILABLE, null);
+            rr.release();
+            return;
+        }
+
         msg = mSender.obtainMessage(EVENT_SEND, rr);
 
         acquireWakeLock();
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 7f3a968..7fa71a9 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -261,8 +261,7 @@
 
         <activity
                 android:name="LinesActivity"
-                android:label="_Lines"
-                android:hardwareAccelerated="true">
+                android:label="_Lines">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java
index 0dc836d..6afbb01 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java
@@ -36,6 +36,8 @@
     }
 
     static class LinesView extends View {
+        private static final boolean LINE_AA = false;
+
         private final Bitmap mBitmap1;
         private final Paint mSmallPaint;
         private final Paint mMediumPaint;
@@ -43,6 +45,7 @@
         private final BitmapShader mShader;
         private final float[] mPoints;
         private final Paint mAlphaPaint;
+        private final Paint mHairLinePaint;
 
         LinesView(Context c) {
             super(c);
@@ -50,25 +53,30 @@
             mBitmap1 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1);
 
             mSmallPaint = new Paint();
-            mSmallPaint.setAntiAlias(true);
+            mSmallPaint.setAntiAlias(LINE_AA);
             mSmallPaint.setColor(0xffff0000);
             mSmallPaint.setStrokeWidth(1.0f);
 
             mMediumPaint = new Paint();
-            mMediumPaint.setAntiAlias(true);
+            mMediumPaint.setAntiAlias(LINE_AA);
             mMediumPaint.setColor(0xff0000ff);
             mMediumPaint.setStrokeWidth(4.0f);
 
             mLargePaint = new Paint();
-            mLargePaint.setAntiAlias(true);
+            mLargePaint.setAntiAlias(LINE_AA);
             mLargePaint.setColor(0xff00ff00);
             mLargePaint.setStrokeWidth(15.0f);
 
             mAlphaPaint = new Paint();
-            mAlphaPaint.setAntiAlias(true);
+            mAlphaPaint.setAntiAlias(LINE_AA);
             mAlphaPaint.setColor(0x7fff0050);
             mAlphaPaint.setStrokeWidth(10.0f);
             
+            mHairLinePaint = new Paint();
+            mHairLinePaint.setAntiAlias(LINE_AA);
+            mHairLinePaint.setColor(0xff0000ff);
+            mHairLinePaint.setStrokeWidth(0.0f);
+
             mShader = new BitmapShader(mBitmap1, BitmapShader.TileMode.MIRROR,
                     BitmapShader.TileMode.MIRROR);
 
@@ -100,7 +108,7 @@
 
             mSmallPaint.setAntiAlias(false);
             canvas.drawLine(0.0f, 0.0f, 400.0f, 0.0f, mSmallPaint);
-            mSmallPaint.setAntiAlias(true);
+            mSmallPaint.setAntiAlias(LINE_AA);
             canvas.drawLine(0.0f, 0.0f, 0.0f, 400.0f, mSmallPaint);
             canvas.drawLine(0.0f, 400.0f, 400.0f, 400.0f, mSmallPaint);
             
@@ -110,6 +118,12 @@
             mAlphaPaint.setShader(null);
 
             canvas.restore();
+            
+            canvas.scale(10.0f, 10.0f);
+            canvas.drawLine(50.0f, 40.0f, 10.0f, 40.0f, mSmallPaint);
+            canvas.drawLine(10.0f, 50.0f, 50.0f, 50.0f, mSmallPaint);
+            canvas.drawLine(10.0f, 60.0f, 50.0f, 60.0f, mHairLinePaint);
+            canvas.restore();
         }
     }
 }
diff --git a/tools/aapt/Package.cpp b/tools/aapt/Package.cpp
index faae89b..ab71f34 100644
--- a/tools/aapt/Package.cpp
+++ b/tools/aapt/Package.cpp
@@ -461,7 +461,7 @@
         ZipFile jar;
         err = jar.open(jars[i], ZipFile::kOpenReadOnly);
         if (err != 0) {
-            fprintf(stderr, "ERROR: unable to open '%s' as a zip file: %zd\n",
+            fprintf(stderr, "ERROR: unable to open '%s' as a zip file: %d\n",
                 jars[i], err);
             return err;
         }
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 7b74506..4614d6f 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -542,11 +542,11 @@
                         DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> > baseFiles =
                                 baseGroup->getFiles();
                         for (size_t i=0; i < baseFiles.size(); i++) {
-                            printf("baseFile %d has flavor %s\n", i,
+                            printf("baseFile %zd has flavor %s\n", i,
                                     baseFiles.keyAt(i).toString().string());
                         }
                         for (size_t i=0; i < overlayFiles.size(); i++) {
-                            printf("overlayFile %d has flavor %s\n", i,
+                            printf("overlayFile %zd has flavor %s\n", i,
                                     overlayFiles.keyAt(i).toString().string());
                         }
                     }
@@ -560,7 +560,7 @@
                                 keyAt(overlayGroupIndex));
                         if(baseFileIndex < UNKNOWN_ERROR) {
                             if (bundle->getVerbose()) {
-                                printf("found a match (%d) for overlay file %s, for flavor %s\n",
+                                printf("found a match (%zd) for overlay file %s, for flavor %s\n",
                                         baseFileIndex,
                                         overlayGroup->getLeaf().string(),
                                         overlayFiles.keyAt(overlayGroupIndex).toString().string());
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index e28bdff..d067d59 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -30,7 +30,7 @@
             str = String8(pool->stringAt(s, &len)).string();
         }
 
-        printf("String #%d: %s\n", s, str);
+        printf("String #%zd: %s\n", s, str);
     }
 }