Merge "egl: fix GetProcAddress for EGLimage extensions" into honeycomb
diff --git a/api/current.xml b/api/current.xml
index 4989eba..f7172f4 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -61561,6 +61561,36 @@
  visibility="public"
 >
 </field>
+<field name="externalCacheSize"
+ type="long"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="externalDataSize"
+ type="long"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="externalMediaSize"
+ type="long"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="packageName"
  type="java.lang.String"
  transient="false"
@@ -167355,6 +167385,38 @@
 <parameter name="dimX" type="int">
 </parameter>
 </method>
+<method name="setFromFieldPacker"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="xoff" type="int">
+</parameter>
+<parameter name="fp" type="android.renderscript.FieldPacker">
+</parameter>
+</method>
+<method name="setFromFieldPacker"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="xoff" type="int">
+</parameter>
+<parameter name="component_number" type="int">
+</parameter>
+<parameter name="fp" type="android.renderscript.FieldPacker">
+</parameter>
+</method>
 <method name="syncAll"
  return="void"
  abstract="false"
@@ -173115,6 +173177,49 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<method name="bindAllocation"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="va" type="android.renderscript.Allocation">
+</parameter>
+<parameter name="slot" type="int">
+</parameter>
+</method>
+<method name="invoke"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="slot" type="int">
+</parameter>
+</method>
+<method name="invoke"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="slot" type="int">
+</parameter>
+<parameter name="v" type="android.renderscript.FieldPacker">
+</parameter>
+</method>
 <method name="setTimeZone"
  return="void"
  abstract="false"
@@ -173128,6 +173233,111 @@
 <parameter name="timeZone" type="java.lang.String">
 </parameter>
 </method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="v" type="float">
+</parameter>
+</method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="v" type="double">
+</parameter>
+</method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="v" type="int">
+</parameter>
+</method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="v" type="long">
+</parameter>
+</method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="v" type="boolean">
+</parameter>
+</method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="o" type="android.renderscript.BaseObj">
+</parameter>
+</method>
+<method name="setVar"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="index" type="int">
+</parameter>
+<parameter name="v" type="android.renderscript.FieldPacker">
+</parameter>
+</method>
 </class>
 <class name="Script.Builder"
  extends="java.lang.Object"
@@ -173259,6 +173469,32 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<constructor name="ScriptC"
+ type="android.renderscript.ScriptC"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="id" type="int">
+</parameter>
+<parameter name="rs" type="android.renderscript.RenderScript">
+</parameter>
+</constructor>
+<constructor name="ScriptC"
+ type="android.renderscript.ScriptC"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="rs" type="android.renderscript.RenderScript">
+</parameter>
+<parameter name="resources" type="android.content.res.Resources">
+</parameter>
+<parameter name="resourceID" type="int">
+</parameter>
+</constructor>
 </class>
 <class name="Short2"
  extends="java.lang.Object"
@@ -260288,7 +260524,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="t" type="T">
+<parameter name="arg0" type="T">
 </parameter>
 </method>
 </interface>
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 1590bf4..5705057 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -1192,4 +1192,16 @@
     public static int getCurrentAnimationsCount() {
         return sAnimations.get().size();
     }
+
+    /**
+     * Clear all animations on this thread, without canceling or ending them.
+     * This should be used with caution.
+     *
+     * @hide
+     */
+    public static void clearAllAnimations() {
+        sAnimations.get().clear();
+        sPendingAnimations.get().clear();
+        sDelayedAnims.get().clear();
+    }
 }
diff --git a/core/java/android/content/pm/PackageStats.java b/core/java/android/content/pm/PackageStats.java
index 9464321..28a2886 100755
--- a/core/java/android/content/pm/PackageStats.java
+++ b/core/java/android/content/pm/PackageStats.java
@@ -19,20 +19,44 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 
-import java.util.Arrays;
-
 /**
  * implementation of PackageStats associated with a
  * application package.
  */
 public class PackageStats implements Parcelable {
+    /** Name of the package to which this stats applies. */
     public String packageName;
+
+    /** Size of the code (e.g., APK) */
     public long codeSize;
+
+    /**
+     * Size of the internal data size for the application. (e.g.,
+     * /data/data/<app>)
+     */
     public long dataSize;
+
+    /** Size of cache used by the application. (e.g., /data/data/<app>/cache) */
     public long cacheSize;
-    
+
+    /**
+     * Size of the external data used by the application (e.g.,
+     * <sdcard>/Android/data/<app>)
+     */
+    public long externalDataSize;
+
+    /**
+     * Size of the external cache used by the application (i.e., on the SD
+     * card). If this is a subdirectory of the data directory, this size will be
+     * subtracted out of the external data size.
+     */
+    public long externalCacheSize;
+
+    /** Size of the external media size used by the application. */
+    public long externalMediaSize;
+
     public static final Parcelable.Creator<PackageStats> CREATOR
-    = new Parcelable.Creator<PackageStats>() {
+            = new Parcelable.Creator<PackageStats>() {
         public PackageStats createFromParcel(Parcel in) {
             return new PackageStats(in);
         }
@@ -41,29 +65,49 @@
             return new PackageStats[size];
         }
     };
-    
+
     public String toString() {
-        return "PackageStats{"
-        + Integer.toHexString(System.identityHashCode(this))
-        + " " + packageName + "}";
+        final StringBuilder sb = new StringBuilder("PackageStats{");
+        sb.append(Integer.toHexString(System.identityHashCode(this)));
+        sb.append(" packageName=");
+        sb.append(packageName);
+        sb.append(",codeSize=");
+        sb.append(codeSize);
+        sb.append(",dataSize=");
+        sb.append(dataSize);
+        sb.append(",cacheSize=");
+        sb.append(cacheSize);
+        sb.append(",externalDataSize=");
+        sb.append(externalDataSize);
+        sb.append(",externalCacheSize=");
+        sb.append(externalCacheSize);
+        sb.append(",externalMediaSize=");
+        sb.append(externalMediaSize);
+        return sb.toString();
     }
-    
+
     public PackageStats(String pkgName) {
         packageName = pkgName;
     }
-    
+
     public PackageStats(Parcel source) {
         packageName = source.readString();
         codeSize = source.readLong();
         dataSize = source.readLong();
         cacheSize = source.readLong();
+        externalDataSize = source.readLong();
+        externalCacheSize = source.readLong();
+        externalMediaSize = source.readLong();
     }
-    
+
     public PackageStats(PackageStats pStats) {
         packageName = pStats.packageName;
         codeSize = pStats.codeSize;
         dataSize = pStats.dataSize;
         cacheSize = pStats.cacheSize;
+        externalDataSize = pStats.externalDataSize;
+        externalCacheSize = pStats.externalCacheSize;
+        externalMediaSize = pStats.externalMediaSize;
     }
 
     public int describeContents() {
@@ -75,5 +119,8 @@
         dest.writeLong(codeSize);
         dest.writeLong(dataSize);
         dest.writeLong(cacheSize);
+        dest.writeLong(externalDataSize);
+        dest.writeLong(externalCacheSize);
+        dest.writeLong(externalMediaSize);
     }
 }
diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java
index 3d21048..472a335 100644
--- a/core/java/android/widget/ExpandableListView.java
+++ b/core/java/android/widget/ExpandableListView.java
@@ -22,7 +22,6 @@
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
 import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -212,6 +211,9 @@
                 .getDimensionPixelSize(com.android.internal.R.styleable.ExpandableListView_indicatorLeft, 0);
         mIndicatorRight = a
                 .getDimensionPixelSize(com.android.internal.R.styleable.ExpandableListView_indicatorRight, 0);
+        if (mIndicatorRight == 0) {
+            mIndicatorRight = mIndicatorLeft + mGroupIndicator.getIntrinsicWidth();
+        }
         mChildIndicatorLeft = a.getDimensionPixelSize(
                 com.android.internal.R.styleable.ExpandableListView_childIndicatorLeft, CHILD_INDICATOR_INHERIT);
         mChildIndicatorRight = a.getDimensionPixelSize(
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index 264af71..2c10077 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -1,5 +1,4 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
+/* 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.
@@ -209,22 +208,19 @@
             }
         }
 
-        if (fromIndex == -1 && toIndex == NUM_ACTIVE_VIEWS -1) {
+        if (fromIndex == -1 && toIndex == getNumActiveViews() -1) {
             // Fade item in
             if (view.getAlpha() == 1) {
                 view.setAlpha(0);
             }
-            view.setScaleX(1 - PERSPECTIVE_SCALE_FACTOR);
-            view.setScaleY(1 - PERSPECTIVE_SCALE_FACTOR);
-            view.setTranslationX(mPerspectiveShiftX);
-            view.setTranslationY(0);
+            transformViewAtIndex(toIndex, view, false);
             view.setVisibility(VISIBLE);
 
             alphaOa = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 1.0f);
             alphaOa.setDuration(FADE_IN_ANIMATION_DURATION);
             if (oldAlphaOa != null) oldAlphaOa.cancel();
             alphaOa.start();
-            view.setTagInternal(com.android.internal.R.id.viewAlphaAnimation, 
+            view.setTagInternal(com.android.internal.R.id.viewAlphaAnimation,
                     new WeakReference<ObjectAnimator>(alphaOa));
         } else if (fromIndex == 0 && toIndex == 1) {
             // Slide item in
@@ -270,7 +266,7 @@
             alphaOa.setDuration(STACK_RELAYOUT_DURATION);
             if (oldAlphaOa != null) oldAlphaOa.cancel();
             alphaOa.start();
-            view.setTagInternal(com.android.internal.R.id.viewAlphaAnimation, 
+            view.setTagInternal(com.android.internal.R.id.viewAlphaAnimation,
                     new WeakReference<ObjectAnimator>(alphaOa));
         }
 
@@ -284,16 +280,20 @@
         final float maxPerspectiveShiftY = mPerspectiveShiftY;
         final float maxPerspectiveShiftX = mPerspectiveShiftX;
 
-        index = mMaxNumActiveViews - index - 1;
-        if (index == mMaxNumActiveViews - 1) index--;
+        if (mStackMode == ITEMS_SLIDE_DOWN) {
+            index = mMaxNumActiveViews - index - 1;
+            if (index == mMaxNumActiveViews - 1) index--;
+        } else {
+            index--;
+            if (index < 0) index++;
+        }
 
         float r = (index * 1.0f) / (mMaxNumActiveViews - 2);
 
         final float scale = 1 - PERSPECTIVE_SCALE_FACTOR * (1 - r);
 
-        int stackDirection = (mStackMode == ITEMS_SLIDE_UP) ? 1 : -1;
-        float perspectiveTranslationY = -stackDirection * r * maxPerspectiveShiftY;
-        float scaleShiftCorrectionY = stackDirection * (1 - scale) *
+        float perspectiveTranslationY = r * maxPerspectiveShiftY;
+        float scaleShiftCorrectionY = (scale - 1) *
                 (getMeasuredHeight() * (1 - PERSPECTIVE_SHIFT_FACTOR_Y) / 2.0f);
         final float transY = perspectiveTranslationY + scaleShiftCorrectionY;
 
@@ -302,7 +302,7 @@
                 (getMeasuredWidth() * (1 - PERSPECTIVE_SHIFT_FACTOR_X) / 2.0f);
         final float transX = perspectiveTranslationX + scaleShiftCorrectionX;
 
-        // If this view is currently being animated for a certain position, we need to cancel 
+        // If this view is currently being animated for a certain position, we need to cancel
         // this animation so as not to interfere with the new transformation.
         Object tag = view.getTag(com.android.internal.R.id.viewAnimation);
         if (tag instanceof WeakReference<?>) {
@@ -515,11 +515,12 @@
 
     private void beginGestureIfNeeded(float deltaY) {
         if ((int) Math.abs(deltaY) > mTouchSlop && mSwipeGestureType == GESTURE_NONE) {
-            int swipeGestureType = deltaY < 0 ? GESTURE_SLIDE_UP : GESTURE_SLIDE_DOWN;
+            final int swipeGestureType = deltaY < 0 ? GESTURE_SLIDE_UP : GESTURE_SLIDE_DOWN;
             cancelLongPress();
             requestDisallowInterceptTouchEvent(true);
 
             if (mAdapter == null) return;
+            final int adapterCount = mAdapter.getCount();
 
             int activeIndex;
             if (mStackMode == ITEMS_SLIDE_UP) {
@@ -528,13 +529,20 @@
                 activeIndex = (swipeGestureType == GESTURE_SLIDE_DOWN) ? 1 : 0;
             }
 
+            boolean endOfStack = mLoopViews && adapterCount == 1 && 
+                ((mStackMode == ITEMS_SLIDE_UP && swipeGestureType == GESTURE_SLIDE_UP) ||
+                 (mStackMode == ITEMS_SLIDE_DOWN && swipeGestureType == GESTURE_SLIDE_DOWN));
+            boolean beginningOfStack = mLoopViews && adapterCount == 1 && 
+                ((mStackMode == ITEMS_SLIDE_DOWN && swipeGestureType == GESTURE_SLIDE_UP) ||
+                 (mStackMode == ITEMS_SLIDE_UP && swipeGestureType == GESTURE_SLIDE_DOWN));
+
             int stackMode;
-            if (mLoopViews) {
+            if (mLoopViews && !beginningOfStack && !endOfStack) {
                 stackMode = StackSlider.NORMAL_MODE;
-            } else if (mCurrentWindowStartUnbounded + activeIndex == -1) {
+            } else if (mCurrentWindowStartUnbounded + activeIndex == -1 || beginningOfStack) {
                 activeIndex++;
                 stackMode = StackSlider.BEGINNING_OF_STACK_MODE;
-            } else if (mCurrentWindowStartUnbounded + activeIndex == mAdapter.getCount() - 1) {
+            } else if (mCurrentWindowStartUnbounded + activeIndex == adapterCount - 1 || endOfStack) {
                 stackMode = StackSlider.END_OF_STACK_MODE;
             } else {
                 stackMode = StackSlider.NORMAL_MODE;
@@ -989,6 +997,11 @@
     @Override
     public void advance() {
         long timeSinceLastInteraction = System.currentTimeMillis() - mLastInteractionTime;
+
+        if (mAdapter == null) return;
+        final int adapterCount = mAdapter.getCount();
+        if (adapterCount == 1 && mLoopViews) return;
+
         if (mSwipeGestureType == GESTURE_NONE &&
                 timeSinceLastInteraction > MIN_TIME_BETWEEN_INTERACTION_AND_AUTOADVANCE) {
             showNext();
@@ -1266,4 +1279,4 @@
             mask.recycle();
         }
     }
-}
+}
\ No newline at end of file
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index 8e491e9..8825c02 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -20,7 +20,6 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.Gravity;
 import android.view.View;
@@ -44,6 +43,7 @@
     private MenuBuilder mMenu;
 
     private int mMaxItems;
+    private int mWidthLimit;
     private boolean mReserveOverflow;
     private OverflowMenuButton mOverflowButton;
     private MenuPopupHelper mOverflowPopup;
@@ -91,6 +91,7 @@
         final int screen = res.getConfiguration().screenLayout;
         mReserveOverflow = (screen & Configuration.SCREENLAYOUT_SIZE_MASK) ==
                 Configuration.SCREENLAYOUT_SIZE_XLARGE;
+        mWidthLimit = res.getDisplayMetrics().widthPixels / 2;
         
         TypedArray a = context.obtainStyledAttributes(com.android.internal.R.styleable.Theme);
         mDivider = a.getDrawable(com.android.internal.R.styleable.Theme_dividerVertical);
@@ -108,6 +109,7 @@
         mReserveOverflow = (screen & Configuration.SCREENLAYOUT_SIZE_MASK) ==
                 Configuration.SCREENLAYOUT_SIZE_XLARGE;
         mMaxItems = getMaxActionButtons();
+        mWidthLimit = getResources().getDisplayMetrics().widthPixels / 2;
         if (mMenu != null) {
             mMenu.setMaxActionItems(mMaxItems);
             updateChildren(false);
@@ -172,6 +174,19 @@
     }
 
     public void initialize(MenuBuilder menu, int menuType) {
+        int width = mWidthLimit;
+        if (mReserveOverflow) {
+            if (mOverflowButton == null) {
+                OverflowMenuButton button = new OverflowMenuButton(mContext);
+                mOverflowButton = button;
+            }
+            final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+            mOverflowButton.measure(spec, spec);
+            width -= mOverflowButton.getMeasuredWidth();
+        }
+
+        menu.setActionWidthLimit(width);
+
         menu.setMaxActionItems(mMaxItems);
         mMenu = menu;
         updateChildren(true);
@@ -219,9 +234,11 @@
                 if (itemCount > 0) {
                     addView(makeDividerView(), makeDividerLayoutParams());
                 }
-                OverflowMenuButton button = new OverflowMenuButton(mContext);
-                addView(button);
-                mOverflowButton = button;
+                if (mOverflowButton == null) {
+                    OverflowMenuButton button = new OverflowMenuButton(mContext);
+                    mOverflowButton = button;
+                }
+                addView(mOverflowButton);
             } else {
                 mOverflowButton = null;
             }
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index 830c2c1..588b10c 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -27,9 +27,10 @@
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Parcelable;
-import android.util.Log;
 import android.util.SparseArray;
+import android.util.SparseBooleanArray;
 import android.util.TypedValue;
+import android.view.ContextMenu.ContextMenuInfo;
 import android.view.ContextThemeWrapper;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
@@ -38,8 +39,8 @@
 import android.view.MenuItem;
 import android.view.SubMenu;
 import android.view.View;
+import android.view.View.MeasureSpec;
 import android.view.ViewGroup;
-import android.view.ContextMenu.ContextMenuInfo;
 import android.widget.AdapterView;
 import android.widget.BaseAdapter;
 
@@ -164,6 +165,10 @@
      */
     private int mMaxActionItems;
     /**
+     * The total width limit in pixels for all action items within a menu
+     */
+    private int mActionWidthLimit;
+    /**
      * Whether or not the items (or any one item's action state) has changed since it was
      * last fetched.
      */
@@ -208,6 +213,11 @@
     
     private boolean mOptionalIconsVisible = false;
 
+    private ViewGroup mMeasureActionButtonParent;
+
+    // Group IDs that have been added as actions - used temporarily, allocated here for reuse.
+    private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray();
+
     private static int getAlertDialogTheme(Context context) {
         TypedValue outValue = new TypedValue();
         context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
@@ -1035,6 +1045,44 @@
         return mVisibleItems;
     }
     
+    /**
+     * @return A fake action button parent view for obtaining child views.
+     */
+    private ViewGroup getMeasureActionButtonParent() {
+        if (mMeasureActionButtonParent == null) {
+            mMeasureActionButtonParent = (ViewGroup) mMenuTypes[TYPE_ACTION_BUTTON].getInflater()
+                    .inflate(LAYOUT_RES_FOR_TYPE[TYPE_ACTION_BUTTON], null, false);
+        }
+        return mMeasureActionButtonParent;
+    }
+
+    /**
+     * This method determines which menu items get to be 'action items' that will appear
+     * in an action bar and which items should be 'overflow items' in a secondary menu.
+     * The rules are as follows:
+     *
+     * <p>Items are considered for inclusion in the order specified within the menu.
+     * There is a limit of mMaxActionItems as a total count, optionally including the overflow
+     * menu button itself. This is a soft limit; if an item shares a group ID with an item
+     * previously included as an action item, the new item will stay with its group and become
+     * an action item itself even if it breaks the max item count limit. This is done to
+     * limit the conceptual complexity of the items presented within an action bar. Only a few
+     * unrelated concepts should be presented to the user in this space, and groups are treated
+     * as a single concept.
+     *
+     * <p>There is also a hard limit of consumed measurable space: mActionWidthLimit. This
+     * limit may be broken by a single item that exceeds the remaining space, but no further
+     * items may be added. If an item that is part of a group cannot fit within the remaining
+     * measured width, the entire group will be demoted to overflow. This is done to ensure room
+     * for navigation and other affordances in the action bar as well as reduce general UI clutter.
+     *
+     * <p>The space freed by demoting a full group cannot be consumed by future menu items.
+     * Once items begin to overflow, all future items become overflow items as well. This is
+     * to avoid inadvertent reordering that may break the app's intended design.
+     *
+     * @param reserveActionOverflow true if an overflow button should consume one space
+     *                              in the available item count
+     */
     private void flagActionItems(boolean reserveActionOverflow) {
         if (reserveActionOverflow != mReserveActionOverflow) {
             mReserveActionOverflow = reserveActionOverflow;
@@ -1048,9 +1096,13 @@
         final ArrayList<MenuItemImpl> visibleItems = getVisibleItems();
         final int itemsSize = visibleItems.size();
         int maxActions = mMaxActionItems;
+        int widthLimit = mActionWidthLimit;
+        final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+        final ViewGroup parent = getMeasureActionButtonParent();
 
         int requiredItems = 0;
         int requestedItems = 0;
+        int firstActionWidth = 0;
         boolean hasOverflow = false;
         for (int i = 0; i < itemsSize; i++) {
             MenuItemImpl item = visibleItems.get(i);
@@ -1070,12 +1122,68 @@
         }
         maxActions -= requiredItems;
 
+        final SparseBooleanArray seenGroups = mActionButtonGroups;
+        seenGroups.clear();
+
         // Flag as many more requested items as will fit.
         for (int i = 0; i < itemsSize; i++) {
             MenuItemImpl item = visibleItems.get(i);
-            if (item.requestsActionButton()) {
-                item.setIsActionButton(maxActions > 0);
+
+            if (item.requiresActionButton()) {
+                View v = item.getActionView();
+                if (v == null) {
+                    v = item.getItemView(TYPE_ACTION_BUTTON, parent);
+                }
+                v.measure(querySpec, querySpec);
+                final int measuredWidth = v.getMeasuredWidth();
+                widthLimit -= measuredWidth;
+                if (firstActionWidth == 0) {
+                    firstActionWidth = measuredWidth;
+                }
+                final int groupId = item.getGroupId();
+                if (groupId != 0) {
+                    seenGroups.put(groupId, true);
+                }
+            } else if (item.requestsActionButton()) {
+                // Items in a group with other items that already have an action slot
+                // can break the max actions rule, but not the width limit.
+                final int groupId = item.getGroupId();
+                final boolean inGroup = seenGroups.get(groupId);
+                boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0;
                 maxActions--;
+
+                if (isAction) {
+                    View v = item.getActionView();
+                    if (v == null) {
+                        v = item.getItemView(TYPE_ACTION_BUTTON, parent);
+                    }
+                    v.measure(querySpec, querySpec);
+                    final int measuredWidth = v.getMeasuredWidth();
+                    widthLimit -= measuredWidth;
+                    if (firstActionWidth == 0) {
+                        firstActionWidth = measuredWidth;
+                    }
+
+                    // Did this push the entire first item past halfway?
+                    if (widthLimit + firstActionWidth <= 0) {
+                        isAction = false;
+                    }
+                }
+
+                if (isAction && groupId != 0) {
+                    seenGroups.put(groupId, true);
+                } else if (inGroup) {
+                    // We broke the width limit. Demote the whole group, they all overflow now.
+                    seenGroups.put(groupId, false);
+                    for (int j = 0; j < i; j++) {
+                        MenuItemImpl areYouMyGroupie = visibleItems.get(j);
+                        if (areYouMyGroupie.getGroupId() == groupId) {
+                            areYouMyGroupie.setIsActionButton(false);
+                        }
+                    }
+                }
+
+                item.setIsActionButton(isAction);
             }
         }
 
@@ -1108,6 +1216,11 @@
         mIsActionItemsStale = true;
     }
 
+    void setActionWidthLimit(int widthLimit) {
+        mActionWidthLimit = widthLimit;
+        mIsActionItemsStale = true;
+    }
+
     public void clearHeader() {
         mHeaderIcon = null;
         mHeaderTitle = null;
diff --git a/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml b/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml
index 8a46546..4f5beff 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml
@@ -27,12 +27,11 @@
         android:layout_height="0px"
         android:layout_weight="1"
         android:layout_above="@+id/emergencyCall">
-        <RelativeLayout 
+        <RelativeLayout
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-                >
-        
-            <TextView 
+            android:layout_height="match_parent">
+
+            <TextView
                 android:id="@+id/topHeader"
                 android:layout_width="match_parent"
                 android:layout_height="64dip"
@@ -43,7 +42,7 @@
                 android:drawableLeft="@drawable/ic_lock_idle_lock"
                 android:drawablePadding="5dip"
                 />
-        
+
             <!-- spacer below header -->
             <View
                 android:id="@+id/spacerTop"
@@ -51,7 +50,7 @@
                 android:layout_height="1dip"
                 android:layout_below="@id/topHeader"
                 android:background="@drawable/divider_horizontal_dark"/>
-        
+
             <TextView
                 android:id="@+id/instructions"
                 android:layout_width="match_parent"
@@ -62,7 +61,7 @@
                 android:textAppearance="?android:attr/textAppearanceSmall"
                 android:text="@android:string/lockscreen_glogin_instructions"
                 />
-        
+
             <EditText
                 android:id="@+id/login"
                 android:layout_width="match_parent"
@@ -74,7 +73,7 @@
                 android:hint="@android:string/lockscreen_glogin_username_hint"
                 android:inputType="textEmailAddress"
                 />
-        
+
             <EditText
                 android:id="@+id/password"
                 android:layout_width="match_parent"
@@ -88,11 +87,11 @@
                 android:nextFocusRight="@+id/ok"
                 android:nextFocusDown="@+id/ok"
                 />
-        
+
             <!-- ok below password, aligned to right of screen -->
             <Button
                 android:id="@+id/ok"
-                android:layout_width="85dip"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_below="@id/password"
                 android:layout_marginTop="7dip"
@@ -100,10 +99,10 @@
                 android:layout_alignParentRight="true"
                 android:text="@android:string/lockscreen_glogin_submit_button"
                 />
-        
+
         </RelativeLayout>
     </ScrollView>
-    
+
     <!-- spacer above emergency call -->
     <View
         android:layout_width="match_parent"
@@ -121,6 +120,7 @@
         android:drawableLeft="@drawable/ic_emergency"
         android:drawablePadding="8dip"
         android:text="@android:string/lockscreen_emergency_call"
+        android:visibility="gone"
         />
 
 </LinearLayout>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index f65b1f2..744d0d8 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -114,7 +114,7 @@
                 ?android:attr/expandableListPreferredItemPaddingLeft</item>
 
         <item name="expandableListPreferredItemIndicatorLeft">3dip</item>
-        <item name="expandableListPreferredItemIndicatorRight">33dip</item>
+        <item name="expandableListPreferredItemIndicatorRight">0dip</item>
         <item name="expandableListPreferredChildIndicatorLeft">
                 ?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="expandableListPreferredChildIndicatorRight">
@@ -816,7 +816,7 @@
                 ?android:attr/expandableListPreferredItemPaddingLeft</item>
 
         <item name="expandableListPreferredItemIndicatorLeft">3dip</item>
-        <item name="expandableListPreferredItemIndicatorRight">33dip</item>
+        <item name="expandableListPreferredItemIndicatorRight">0dip</item>
         <item name="expandableListPreferredChildIndicatorLeft">
                 ?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="expandableListPreferredChildIndicatorRight">
@@ -1075,7 +1075,7 @@
                 ?android:attr/expandableListPreferredItemPaddingLeft</item>
 
         <item name="expandableListPreferredItemIndicatorLeft">3dip</item>
-        <item name="expandableListPreferredItemIndicatorRight">33dip</item>
+        <item name="expandableListPreferredItemIndicatorRight">0dip</item>
         <item name="expandableListPreferredChildIndicatorLeft">
                 ?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="expandableListPreferredChildIndicatorRight">
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 579f314..852aabf 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -239,15 +239,13 @@
     }
 
     /**
-     * @hide
-     *
      * This is only intended to be used by auto-generate code reflected from the
      * renderscript script files.
      *
      * @param xoff
      * @param fp
      */
-    public void setOneElement(int xoff, FieldPacker fp) {
+    public void setFromFieldPacker(int xoff, FieldPacker fp) {
         int eSize = mType.mElement.getSizeBytes();
         final byte[] data = fp.getData();
 
@@ -262,8 +260,6 @@
 
 
     /**
-     * @hide
-     *
      * This is only intended to be used by auto-generate code reflected from the
      * renderscript script files.
      *
@@ -271,7 +267,7 @@
      * @param component_number
      * @param fp
      */
-    public void setOneComponent(int xoff, int component_number, FieldPacker fp) {
+    public void setFromFieldPacker(int xoff, int component_number, FieldPacker fp) {
         if (component_number >= mType.mElement.mElements.length) {
             throw new RSIllegalArgumentException("Component_number " + component_number + " out of range.");
         }
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index b3ad20a..56abba5 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -21,8 +21,6 @@
  **/
 public class Script extends BaseObj {
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param slot
@@ -32,8 +30,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param slot
@@ -54,8 +50,6 @@
 
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param va
@@ -71,8 +65,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
@@ -83,8 +75,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
@@ -95,8 +85,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
@@ -107,8 +95,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
@@ -119,8 +105,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
@@ -131,8 +115,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
@@ -143,8 +125,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by generated reflected code.
      *
      * @param index
diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java
index 14e4ab5..ff8f093 100644
--- a/graphics/java/android/renderscript/ScriptC.java
+++ b/graphics/java/android/renderscript/ScriptC.java
@@ -36,8 +36,6 @@
     private static final String TAG = "ScriptC";
 
     /**
-     * @hide
-     *
      * Only intended for use by the generated derived classes.
      *
      * @param id
@@ -48,8 +46,6 @@
     }
 
     /**
-     * @hide
-     *
      * Only intended for use by the generated derived classes.
      *
      *
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h
index bdd8e73..71ec760 100644
--- a/libs/hwui/Debug.h
+++ b/libs/hwui/Debug.h
@@ -37,6 +37,10 @@
 // Turn on to display vertex and tex coords data about 9patch objects
 // This flag requires DEBUG_PATCHES to be turned on
 #define DEBUG_PATCHES_VERTICES 0
+// Turn on to display vertex and tex coords data used by empty quads
+// in 9patch objects
+// This flag requires DEBUG_PATCHES to be turned on
+#define DEBUG_PATCHES_EMPTY_VERTICES 0
 
 // Turn on to display debug info about paths
 #define DEBUG_PATHS 0
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index cd2554e..e6bea78 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -29,10 +29,6 @@
 void LayerRenderer::prepare(bool opaque) {
     LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->fbo);
 
-#if RENDER_LAYERS_AS_REGIONS
-    mLayer->region.clear();
-#endif
-
     glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &mPreviousFbo);
     glBindFramebuffer(GL_FRAMEBUFFER, mLayer->fbo);
 
@@ -78,6 +74,7 @@
             mLayer->meshIndices = NULL;
             mLayer->meshElementCount = 0;
         }
+        mLayer->region.clear();
         return;
     }
 
@@ -129,6 +126,8 @@
         indices[index + 4] = quad + 1;   // top-right
         indices[index + 5] = quad + 3;   // bottom-right
     }
+
+    mLayer->region.clear();
 #endif
 }
 
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index e5cb67b..77cbb80 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -212,7 +212,7 @@
         }
         float u2 = fmax(0.0f, stepX - 0.5f) / bitmapWidth;
 
-        generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
+        bool valid = generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
 
         x1 = x2;
         u1 = (stepX + 0.5f) / bitmapWidth;
@@ -223,17 +223,22 @@
     generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount);
 }
 
-void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
+bool Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
             float u1, float v1, float u2, float v2, uint32_t& quadCount) {
     const uint32_t oldQuadCount = quadCount;
-    const bool valid = x2 - x1 > 0.9999f && y2 - y1 > 0.9999f;
+    const bool valid = x2 >= x1 && y2 >= y1;
     if (valid) {
         quadCount++;
     }
 
     // Skip degenerate and transparent (empty) quads
     if (!valid || ((mColorKey >> oldQuadCount) & 0x1) == 1) {
-        return;
+#if DEBUG_PATCHES_EMPTY_VERTICES
+        PATCH_LOGD("    quad %d (empty)", oldQuadCount);
+        PATCH_LOGD("        left,  top    = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
+        PATCH_LOGD("        right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
+#endif
+        return false;
     }
 
 #if RENDER_LAYERS_AS_REGIONS
@@ -262,6 +267,8 @@
     PATCH_LOGD("        left,  top    = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
     PATCH_LOGD("        right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
 #endif
+
+    return true;
 }
 
 }; // namespace uirenderer
diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h
index 0f0ffa2..45ce998 100644
--- a/libs/hwui/Patch.h
+++ b/libs/hwui/Patch.h
@@ -71,7 +71,7 @@
     void generateRow(TextureVertex*& vertex, float y1, float y2,
             float v1, float v2, float stretchX, float width, float bitmapWidth,
             uint32_t& quadCount);
-    void generateQuad(TextureVertex*& vertex,
+    bool generateQuad(TextureVertex*& vertex,
             float x1, float y1, float x2, float y2,
             float u1, float v1, float u2, float v2,
             uint32_t& quadCount);
diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
index aa4cf2d..4615e1f 100644
--- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
+++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
@@ -56,7 +56,7 @@
 }
 
 //sliao
-uchar3 convert2uchar3(float3 xyz);
+extern uchar3 __attribute__((overloadable)) convert2uchar3(float3 xyz);
 
 void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
     uchar4 *output = (uchar4 *)v_out;
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 6e4c22e..41c9fe2 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -212,6 +212,7 @@
     GLenum type = mType->getElement()->getComponent().getGLType();
     GLenum format = mType->getElement()->getComponent().getGLFormat();
     GLenum target = (GLenum)getGLTarget();
+    rsAssert(mTextureID);
     glBindTexture(target, mTextureID);
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
     GLenum t = GL_TEXTURE_2D;
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 0ecb18a..1ab2109 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -490,7 +490,8 @@
         if (bccLinkBC(s->mBccScript,
                       resName,
                       NULL /*rs_runtime_lib_bc*/,
-                      0 /*rs_runtime_lib_bc_size*/,
+                      1 /*rs_runtime_lib_bc_size*/
+                        /*"1" means skip buffer here, and let libbcc decide*/,
                       0) != 0) {
             LOGE("bcc: FAILS to link bitcode");
             // Handle Fatal Error
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
index 1c6c5ac..001ac55 100644
--- a/libs/rs/rsThreadIO.cpp
+++ b/libs/rs/rsThreadIO.cpp
@@ -53,6 +53,10 @@
         waitForCommand = false;
         //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize);
 
+        if (cmdID >= (sizeof(gPlaybackFuncs) / sizeof(void *))) {
+            rsAssert(cmdID < (sizeof(gPlaybackFuncs) / sizeof(void *)));
+            LOGE("playCoreCommands error con %p, cmd %i", con, cmdID);
+        }
         gPlaybackFuncs[cmdID](con, data);
         mToCore.next();
     }
diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c
index 1e468bb..4ac5b7f 100644
--- a/libs/rs/rsg_generator.c
+++ b/libs/rs/rsg_generator.c
@@ -219,7 +219,7 @@
         fprintf(f, "};\n\n");
     }
 
-    fprintf(f, "RsPlaybackFunc gPlaybackFuncs[] = {\n");
+    fprintf(f, "RsPlaybackFunc gPlaybackFuncs[%i] = {\n", apiCount + 1);
     fprintf(f, "    NULL,\n");
     for (ct=0; ct < apiCount; ct++) {
         fprintf(f, "    %s%s,\n", "rsp_", apis[ct].name);
@@ -265,7 +265,7 @@
             printFuncDecls(f, "rsi_", 1);
             printPlaybackFuncs(f, "rsp_");
             fprintf(f, "\n\ntypedef void (*RsPlaybackFunc)(Context *, const void *);\n");
-            fprintf(f, "extern RsPlaybackFunc gPlaybackFuncs[];\n");
+            fprintf(f, "extern RsPlaybackFunc gPlaybackFuncs[%i];\n", apiCount + 1);
 
             fprintf(f, "}\n");
             fprintf(f, "}\n");
diff --git a/native/android/looper.cpp b/native/android/looper.cpp
index 9f5cda9..615493f 100644
--- a/native/android/looper.cpp
+++ b/native/android/looper.cpp
@@ -19,9 +19,11 @@
 
 #include <android/looper.h>
 #include <utils/Looper.h>
+#include <binder/IPCThreadState.h>
 
 using android::Looper;
 using android::sp;
+using android::IPCThreadState;
 
 ALooper* ALooper_forThread() {
     return Looper::getForThread().get();
@@ -46,6 +48,7 @@
         return ALOOPER_POLL_ERROR;
     }
 
+    IPCThreadState::self()->flushCommands();
     return looper->pollOnce(timeoutMillis, outFd, outEvents, outData);
 }
 
@@ -55,7 +58,8 @@
         LOGE("ALooper_pollAll: No looper for this thread!");
         return ALOOPER_POLL_ERROR;
     }
-    
+
+    IPCThreadState::self()->flushCommands();
     return looper->pollAll(timeoutMillis, outFd, outEvents, outData);
 }
 
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index 0c85af8..2ec2226 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -165,8 +165,13 @@
         }
 
         @Override
-        public long calculateDirectorySize(String directory) throws RemoteException {
-            return MeasurementUtils.measureDirectory(directory);
+        public long calculateDirectorySize(String path) throws RemoteException {
+            final File directory = new File(path);
+            if (directory.exists() && directory.isDirectory()) {
+                return MeasurementUtils.measureDirectory(path);
+            } else {
+                return 0L;
+            }
         }
     };
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 73b6723..dfe0262 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -668,7 +668,8 @@
             if ((mPhoneState == TelephonyManager.CALL_STATE_IDLE) && isEvdo()){
                 iconLevel = getEvdoLevel();
                 if (false) {
-                    Slog.d(TAG, "use Evdo level=" + iconLevel + " to replace Cdma Level=" + getCdmaLevel());
+                    Slog.d(TAG, "use Evdo level=" + iconLevel + " to replace Cdma Level="
+                            + getCdmaLevel());
                 }
             } else {
                 iconLevel = getCdmaLevel();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AirplaneModeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AirplaneModeController.java
index 1b2fcad..0d2538d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AirplaneModeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AirplaneModeController.java
@@ -55,7 +55,6 @@
     }
 
     public void onCheckedChanged(CompoundButton view, boolean checked) {
-        Slog.d(TAG, "onCheckedChanged checked=" + checked + " mAirplaneMode=" + mAirplaneMode);
         if (checked != mAirplaneMode) {
             mAirplaneMode = checked;
             unsafe(checked);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 3a7bd90..e80e37d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -47,7 +47,6 @@
     int mRepeat;
     Runnable mCheckLongPress = new Runnable() {
         public void run() {
-            Slog.d("KeyButtonView", "longpress");
             if (isPressed()) {
                 mLongPressed = true;
                 mRepeat++;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java
index 5616159..90c9568 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java
@@ -73,12 +73,10 @@
     private void setPlugged(boolean plugged) {
         final Resources res = mContext.getResources();
 
-        Slog.d(TAG, "plugged=" + plugged);
         int height = -1;
         if (plugged) {
             final DisplayMetrics metrics = new DisplayMetrics();
             mWindowManager.getDefaultDisplay().getMetrics(metrics);
-            Slog.d(TAG, "metrics=" + metrics);
             height = metrics.heightPixels - 720;
         }
 
@@ -87,7 +85,8 @@
         if (height < minHeight) {
             height = minHeight;
         }
-        Slog.d(TAG, "using height=" + height + " old=" + mHeight);
+        Slog.i(TAG, "Resizing status bar plugged=" + plugged + " height="
+                + height + " old=" + mHeight);
         mHeight = height;
 
         final int N = mListeners.size();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
index a2f6e3a..45a22b6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
@@ -269,7 +269,8 @@
                 // fully closed, no animation necessary
             } else if (mVisible) {
                 if (DEBUG) {
-                    Slog.d(TAG, "panelHeight not zero but trying to open; scheduling an anim to open fully");
+                    Slog.d(TAG, "panelHeight not zero but trying to open; scheduling an anim"
+                            + " to open fully");
                 }
                 startAnimation(true);
             }
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 07af466..9ca83e6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java
@@ -95,7 +95,6 @@
     // Network
     // ----------------------------
     private void onClickNetwork() {
-        Slog.d(TAG, "onClickNetwork");
         getContext().startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)
                 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
         getStatusBarManager().collapse();
@@ -104,7 +103,6 @@
     // Settings
     // ----------------------------
     private void onClickSettings() {
-        Slog.d(TAG, "onClickSettings");
         getContext().startActivity(new Intent(Settings.ACTION_SETTINGS)
                 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
         getStatusBarManager().collapse();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
index 2ebd067..e864577 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
@@ -143,7 +143,6 @@
                 hideWindow();
                 return true;
             } else if (action == MotionEvent.ACTION_DOWN) {
-                Slog.d(TAG, "ACTION_DOWN");
                 final ClipData clip = mClipping;
                 if (clip != null) {
                     final Bitmap icon = clip.getIcon();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index d8e3053..825877a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -596,7 +596,7 @@
             // TODO: immersive mode popups for tablet
         } else if (notification.notification.fullScreenIntent != null) {
             // not immersive & a full-screen alert should be shown
-            Slog.d(TAG, "Notification has fullScreenIntent and activity is not immersive;"
+            Slog.w(TAG, "Notification has fullScreenIntent and activity is not immersive;"
                     + " sending fullScreenIntent");
             try {
                 notification.notification.fullScreenIntent.send();
@@ -732,28 +732,28 @@
         // act accordingly
         if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) {
             boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0;
-            Slog.d(TAG, "DISABLE_CLOCK: " + (show ? "no" : "yes"));
+            Slog.i(TAG, "DISABLE_CLOCK: " + (show ? "no" : "yes"));
             showClock(show);
         }
         if ((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) {
             boolean show = (state & StatusBarManager.DISABLE_SYSTEM_INFO) == 0;
-            Slog.d(TAG, "DISABLE_SYSTEM_INFO: " + (show ? "no" : "yes"));
+            Slog.i(TAG, "DISABLE_SYSTEM_INFO: " + (show ? "no" : "yes"));
             mNotificationTrigger.setVisibility(show ? View.VISIBLE : View.GONE);
         }
         if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
             if ((state & StatusBarManager.DISABLE_EXPAND) != 0) {
-                Slog.d(TAG, "DISABLE_EXPAND: yes");
+                Slog.i(TAG, "DISABLE_EXPAND: yes");
                 animateCollapse();
             }
         }
         if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
             if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
-                Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
+                Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
                 // synchronize with current shadow state
                 mNotificationIconArea.setVisibility(View.GONE);
                 mTicker.halt();
             } else {
-                Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no");
+                Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: no");
                 // synchronize with current shadow state
                 mNotificationIconArea.setVisibility(View.VISIBLE);
             }
@@ -764,11 +764,11 @@
         }
         if ((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) {
             if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) {
-                Slog.d(TAG, "DISABLE_NAVIGATION: yes");
+                Slog.i(TAG, "DISABLE_NAVIGATION: yes");
                 mNavigationArea.setVisibility(View.GONE);
                 mInputMethodSwitchButton.setScreenLocked(true);
             } else {
-                Slog.d(TAG, "DISABLE_NAVIGATION: no");
+                Slog.i(TAG, "DISABLE_NAVIGATION: no");
                 mNavigationArea.setVisibility(View.VISIBLE);
                 mInputMethodSwitchButton.setScreenLocked(false);
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarView.java
index 4ee985d..98f718b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarView.java
@@ -65,7 +65,9 @@
                 }
             }
         }
-        Slog.d(TabletStatusBar.TAG, "TabletStatusBarView not intercepting event");
+        if (TabletStatusBar.DEBUG) {
+            Slog.d(TabletStatusBar.TAG, "TabletStatusBarView not intercepting event");
+        }
         return super.onInterceptTouchEvent(ev);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
index fa732c3..440d680 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletTicker.java
@@ -111,7 +111,6 @@
 
     public void remove(IBinder key, boolean advance) {
         if (mCurrentKey == key) {
-            Slog.d(TAG, "removed current");
             // Showing now
             if (advance) {
                 removeMessages(MSG_ADVANCE);
@@ -121,7 +120,6 @@
             // In the queue
             for (int i=0; i<QUEUE_LENGTH; i++) {
                 if (mKeys[i] == key) {
-                    Slog.d(TAG, "removed from queue: " + i);
                     for (; i<QUEUE_LENGTH-1; i++) {
                         mKeys[i] = mKeys[i+1];
                         mQueue[i] = mQueue[i+1];
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 79fbe0e..1b810d5 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -311,8 +311,8 @@
         setFocusableInTouchMode(true);
         setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
 
-        updateMonitor.registerInfoCallback(this);
-        updateMonitor.registerSimStateCallback(this);
+        mUpdateMonitor.registerInfoCallback(this);
+        mUpdateMonitor.registerSimStateCallback(this);
 
         mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
         mSilentMode = isSilentMode();
@@ -414,6 +414,9 @@
     public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn,
             int batteryLevel) {
         if (DBG) Log.d(TAG, "onRefreshBatteryInfo(" + showBatteryInfo + ", " + pluggedIn + ")");
+
+        mStatusView.onRefreshBatteryInfo(showBatteryInfo, pluggedIn, batteryLevel);
+
         mShowingBatteryInfo = showBatteryInfo;
         mPluggedIn = pluggedIn;
         mBatteryLevel = batteryLevel;
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index 9db86aa..b789288 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -109,22 +109,21 @@
         mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
 
         mKeyboardHelper = new PasswordEntryKeyboardHelper(context, mKeyboardView, this, false);
+        // TODO: re-enable on phones with keyboards
+        boolean isPhysicalKbShowing = false;
+        //mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
         if (mKeyboardViewAlpha == null || !mIsAlpha) {
             mKeyboardHelper.setKeyboardMode(mIsAlpha ?
                     PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
                     : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
-            mKeyboardView.setVisibility(
-                    mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO
-                    ? View.INVISIBLE : View.VISIBLE);
+            mKeyboardView.setVisibility(isPhysicalKbShowing ? View.INVISIBLE : View.VISIBLE);
         } else {
             mKeyboardHelperAlpha = new PasswordEntryKeyboardHelper(context, mKeyboardViewAlpha,
                     this, false);
             mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
             mKeyboardHelperAlpha.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA);
             mKeyboardView.setVisibility(View.GONE);
-            mKeyboardViewAlpha.setVisibility(
-                    mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO
-                    ? View.INVISIBLE : View.VISIBLE);
+            mKeyboardViewAlpha.setVisibility(isPhysicalKbShowing ? View.INVISIBLE : View.VISIBLE);
             mPasswordEntry.setWidth(mKeyboardViewAlpha.getLayoutParams().width);
         }
 
diff --git a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
index 5d1455e..6815d50 100644
--- a/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
@@ -169,6 +169,9 @@
         }
 
         mStatusView = new StatusView(this, mUpdateMonitor, mLockPatternUtils);
+        // This shows up when no other information is required on status1
+        mStatusView.setHelpMessage(R.string.lockscreen_pattern_instructions,
+                StatusView.LOCK_ICON);
 
         mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern);
 
@@ -216,8 +219,8 @@
         // assume normal footer mode for now
         updateFooter(FooterMode.Normal);
 
-        updateMonitor.registerInfoCallback(this);
-        updateMonitor.registerSimStateCallback(this);
+        mUpdateMonitor.registerInfoCallback(this);
+        mUpdateMonitor.registerSimStateCallback(this);
         setFocusableInTouchMode(true);
 
         // until we get an update...
diff --git a/policy/src/com/android/internal/policy/impl/StatusView.java b/policy/src/com/android/internal/policy/impl/StatusView.java
index 1caf0b7..5d32cf4 100644
--- a/policy/src/com/android/internal/policy/impl/StatusView.java
+++ b/policy/src/com/android/internal/policy/impl/StatusView.java
@@ -19,10 +19,10 @@
 import android.widget.TextView;
 
 class StatusView {
-    private static final int LOCK_ICON = R.drawable.ic_lock_idle_lock;
-    private static final int ALARM_ICON = R.drawable.ic_lock_idle_alarm;
-    private static final int CHARGING_ICON = R.drawable.ic_lock_idle_charging;
-    private static final int BATTERY_LOW_ICON = R.drawable.ic_lock_idle_low_battery;
+    public static final int LOCK_ICON = R.drawable.ic_lock_idle_lock;
+    public static final int ALARM_ICON = R.drawable.ic_lock_idle_alarm;
+    public static final int CHARGING_ICON = R.drawable.ic_lock_idle_charging;
+    public static final int BATTERY_LOW_ICON = R.drawable.ic_lock_idle_low_battery;
 
     private String mDateFormatString;
 
@@ -49,6 +49,8 @@
 
     private TextView mAlarmStatus;
     private LockPatternUtils mLockPatternUtils;
+    private int mHelpMessageId;
+    private int mHelpIconId;
 
     private View findViewById(int id) {
         return mView.findViewById(id);
@@ -148,8 +150,8 @@
      */
     void updateStatusLines(boolean showStatusLines) {
         if (!showStatusLines) {
-            mStatus1.setVisibility(showStatusLines ? View.VISIBLE : View.GONE);
-            mAlarmStatus.setVisibility(showStatusLines ? View.VISIBLE : View.GONE);
+            mStatus1.setVisibility(showStatusLines ? View.VISIBLE : View.INVISIBLE);
+            mAlarmStatus.setVisibility(showStatusLines ? View.VISIBLE : View.INVISIBLE);
             return;
         }
 
@@ -171,7 +173,7 @@
             mAlarmStatus.setText(nextAlarm);
             mAlarmStatus.setVisibility(View.VISIBLE);
         } else {
-            mAlarmStatus.setVisibility(View.GONE);
+            mAlarmStatus.setVisibility(View.INVISIBLE);
         }
 
         // Update Status1
@@ -199,13 +201,22 @@
             }
             mStatus1.setVisibility(View.VISIBLE);
         } else {
-            // nothing specific to show; show general instructions
-            mStatus1.setText(R.string.lockscreen_pattern_instructions);
-            mStatus1.setCompoundDrawablesWithIntrinsicBounds(LOCK_ICON, 0,0, 0);
-            mStatus1.setVisibility(View.VISIBLE);
+            // nothing specific to show; show help message and icon, if provided
+            if (mHelpMessageId != 0) {
+                mStatus1.setText(mHelpMessageId);
+                mStatus1.setCompoundDrawablesWithIntrinsicBounds(mHelpIconId, 0,0, 0);
+                mStatus1.setVisibility(View.VISIBLE);
+            } else {
+                mStatus1.setVisibility(View.INVISIBLE);
+            }
         }
     }
 
+    void setHelpMessage(int messageId, int iconId) {
+        mHelpMessageId = messageId;
+        mHelpIconId = iconId;
+    }
+
     void refreshTimeAndDateDisplay() {
         if (mHasDate) {
             mDate.setText(DateFormat.format(mDateFormatString, new Date()));
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 1c3967d..19667d4 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -4806,6 +4806,74 @@
         abstract void handleReturnCode();
     }
 
+    class MeasureParams extends HandlerParams {
+        private final PackageStats mStats;
+        private boolean mSuccess;
+
+        private final IPackageStatsObserver mObserver;
+
+        public MeasureParams(PackageStats stats, boolean success,
+                IPackageStatsObserver observer) {
+            mObserver = observer;
+            mStats = stats;
+            mSuccess = success;
+        }
+
+        @Override
+        void handleStartCopy() throws RemoteException {
+            final boolean mounted;
+
+            if (Environment.isExternalStorageEmulated()) {
+                mounted = true;
+            } else {
+                final String status = Environment.getExternalStorageState();
+
+                mounted = status.equals(Environment.MEDIA_MOUNTED)
+                        || status.equals(Environment.MEDIA_MOUNTED_READ_ONLY);
+            }
+
+            if (mounted) {
+                final File externalCacheDir = Environment
+                        .getExternalStorageAppCacheDirectory(mStats.packageName);
+                final long externalCacheSize = mContainerService
+                        .calculateDirectorySize(externalCacheDir.getPath());
+                mStats.externalCacheSize = externalCacheSize;
+
+                final File externalDataDir = Environment
+                        .getExternalStorageAppDataDirectory(mStats.packageName);
+                long externalDataSize = mContainerService.calculateDirectorySize(externalDataDir
+                        .getPath());
+
+                if (externalCacheDir.getParentFile().equals(externalDataDir)) {
+                    externalDataSize -= externalCacheSize;
+                }
+                mStats.externalDataSize = externalDataSize;
+
+                final File externalMediaDir = Environment
+                        .getExternalStorageAppMediaDirectory(mStats.packageName);
+                mStats.externalMediaSize = mContainerService
+                        .calculateDirectorySize(externalCacheDir.getPath());
+            }
+        }
+
+        @Override
+        void handleReturnCode() {
+            if (mObserver != null) {
+                try {
+                    mObserver.onGetStatsCompleted(mStats, mSuccess);
+                } catch (RemoteException e) {
+                    Slog.i(TAG, "Observer no longer exists.");
+                }
+            }
+        }
+
+        @Override
+        void handleServiceError() {
+            Slog.e(TAG, "Could not measure application " + mStats.packageName
+                            + " external storage");
+        }
+    }
+
     class InstallParams extends HandlerParams {
         final IPackageInstallObserver observer;
         int flags;
@@ -6619,18 +6687,16 @@
         mHandler.post(new Runnable() {
             public void run() {
                 mHandler.removeCallbacks(this);
-                PackageStats lStats = new PackageStats(packageName);
-                final boolean succeded;
+                PackageStats stats = new PackageStats(packageName);
+
+                final boolean success;
                 synchronized (mInstallLock) {
-                    succeded = getPackageSizeInfoLI(packageName, lStats);
+                    success = getPackageSizeInfoLI(packageName, stats);
                 }
-                if(observer != null) {
-                    try {
-                        observer.onGetStatsCompleted(lStats, succeded);
-                    } catch (RemoteException e) {
-                        Log.i(TAG, "Observer no longer exists.");
-                    }
-                } //end if observer
+
+                Message msg = mHandler.obtainMessage(INIT_COPY);
+                msg.obj = new MeasureParams(stats, success, observer);
+                mHandler.sendMessage(msg);
             } //end run
         });
     }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 154b822..65ad956 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2132,6 +2132,9 @@
     sh = (!sh) ? hw_h : sh;
     const size_t size = sw * sh * 4;
 
+    LOGD("screenshot: sw=%d, sh=%d, minZ=%d, maxZ=%d",
+            sw, sh, minLayerZ, maxLayerZ);
+
     // make sure to clear all GL error flags
     while ( glGetError() != GL_NO_ERROR ) ;
 
@@ -2146,6 +2149,9 @@
             GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, tname);
 
     GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
+
+    LOGD("screenshot: FBO created, status=0x%x", status);
+
     if (status == GL_FRAMEBUFFER_COMPLETE_OES) {
 
         // invert everything, b/c glReadPixel() below will invert the FB
@@ -2161,6 +2167,8 @@
         glClearColor(0,0,0,1);
         glClear(GL_COLOR_BUFFER_BIT);
 
+        LOGD("screenshot: glClear() issued");
+
         const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ);
         const size_t count = layers.size();
         for (size_t i=0 ; i<count ; ++i) {
@@ -2171,6 +2179,8 @@
             }
         }
 
+        LOGD("screenshot: All layers rendered");
+
         // XXX: this is needed on tegra
         glScissor(0, 0, sw, sh);
 
@@ -2185,6 +2195,10 @@
                     new MemoryHeapBase(size, 0, "screen-capture") );
             void* const ptr = base->getBase();
             if (ptr) {
+
+                LOGD("screenshot: about to call glReadPixels(0,0,%d,%d,...,%p)",
+                        sw, sh, ptr);
+
                 // capture the screen with glReadPixels()
                 glReadPixels(0, 0, sw, sh, GL_RGBA, GL_UNSIGNED_BYTE, ptr);
                 if (glGetError() == GL_NO_ERROR) {
@@ -2197,25 +2211,32 @@
             } else {
                 result = NO_MEMORY;
             }
+
+            LOGD("screenshot: glReadPixels() returned %s", strerror(result));
+
         }
         glEnable(GL_SCISSOR_TEST);
         glViewport(0, 0, hw_w, hw_h);
         glMatrixMode(GL_PROJECTION);
         glPopMatrix();
         glMatrixMode(GL_MODELVIEW);
-
-
     } else {
         result = BAD_VALUE;
     }
 
+    LOGD("screenshot: about to release FBO resources");
+
     // release FBO resources
     glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
     glDeleteRenderbuffersOES(1, &tname);
     glDeleteFramebuffersOES(1, &name);
 
+    LOGD("screenshot: about to call compositionComplete()");
+
     hw.compositionComplete();
 
+    LOGD("screenshot: result = %s", strerror(result));
+
     return result;
 }
 
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index e73afa0..7099ab5 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -25,6 +25,16 @@
         android:hardwareAccelerated="true">
 
         <activity
+                android:name="SimplePatchActivity"
+                android:label="_SimplePatch"
+                android:theme="@android:style/Theme.Translucent.NoTitleBar">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
                 android:name="ViewLayersActivity"
                 android:label="_ViewLayers">
             <intent-filter>
diff --git a/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_maximized.9.png b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_maximized.9.png
new file mode 100644
index 0000000..d5c3276
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_maximized.9.png
Binary files differ
diff --git a/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_minimized.9.png b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_minimized.9.png
new file mode 100644
index 0000000..4515b42
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_minimized.9.png
Binary files differ
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/SimplePatchActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/SimplePatchActivity.java
new file mode 100644
index 0000000..a9b4d1c
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/SimplePatchActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class SimplePatchActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        
+        setContentView(new PatchView(this));
+    }
+
+    private static class PatchView extends View {
+        private final Drawable mDrawable;
+
+        public PatchView(Context context) {
+            super(context);
+            setBackgroundColor(0xff000000);
+            mDrawable = context.getResources().getDrawable(R.drawable.expander_ic_minimized);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.save();
+            canvas.translate(200, 200);
+            mDrawable.setBounds(3, 0, 33, 64);
+            mDrawable.draw(canvas);
+            mDrawable.setBounds(63, 0, 94, 64);
+            mDrawable.draw(canvas);
+            canvas.restore();
+        }
+    }
+}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 54887d7..d05918f 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -274,6 +274,25 @@
      * @see #ERROR_AUTHENTICATING
      */
     public static final String EXTRA_SUPPLICANT_ERROR = "supplicantError";
+
+    /**
+     * Broadcast intent action for reporting errors
+     * @hide
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ERROR_ACTION = "android.net.wifi.ERROR";
+    /**
+     * The type of error being reported
+     * @hide
+     */
+    public static final String EXTRA_ERROR_CODE = "errorCode";
+
+    /**
+     * Valid error codes
+     * @hide
+     */
+    public static final int WPS_OVERLAP_ERROR = 1;
+
     /**
      * Broadcast intent action indicating that the configured networks changed.
      * This can be as a result of adding/updating/deleting a network
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java
index 934e509..090ad3b 100644
--- a/wifi/java/android/net/wifi/WifiMonitor.java
+++ b/wifi/java/android/net/wifi/WifiMonitor.java
@@ -53,6 +53,9 @@
     private static final String passwordKeyMayBeIncorrectEvent =
        "pre-shared key may be incorrect";
 
+    /* WPS events */
+    private static final String wpsOverlapEvent = "WPS-OVERLAP-DETECTED";
+
     /**
      * Names of events from wpa_supplicant (minus the prefix). In the
      * format descriptions, * &quot;<code>x</code>&quot;
@@ -174,6 +177,8 @@
                     if (eventStr.startsWith(wpaEventPrefix) &&
                             0 < eventStr.indexOf(passwordKeyMayBeIncorrectEvent)) {
                         handlePasswordKeyMayBeIncorrect();
+                    } else if (eventStr.startsWith(wpsOverlapEvent)) {
+                        mWifiStateMachine.notifyWpsOverlap();
                     }
                     continue;
                 }
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index d7d86f0..0548b4d 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -215,6 +215,9 @@
     static final int SUPPLICANT_STATE_CHANGE_EVENT        = 39;
     /* Password may be incorrect */
     static final int PASSWORD_MAY_BE_INCORRECT_EVENT      = 40;
+    /* WPS overlap detected */
+    static final int WPS_OVERLAP_EVENT                    = 41;
+
 
     /* Supplicant commands */
     /* Is supplicant alive ? */
@@ -1287,6 +1290,13 @@
         mContext.sendStickyBroadcast(intent);
     }
 
+    private void sendErrorBroadcast(int errorCode) {
+        Intent intent = new Intent(WifiManager.ERROR_ACTION);
+        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+        intent.putExtra(WifiManager.EXTRA_ERROR_CODE, errorCode);
+        mContext.sendBroadcast(intent);
+    }
+
     private void sendLinkConfigurationChangedBroadcast() {
         Intent intent = new Intent(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
@@ -1382,6 +1392,14 @@
     }
 
     /**
+     * Send a notification that the supplicant has detected overlapped
+     * WPS sessions
+     */
+    void notifyWpsOverlap() {
+        sendMessage(WPS_OVERLAP_EVENT);
+    }
+
+    /**
      * Send the tracker a notification that a connection to the supplicant
      * daemon has been established.
      */
@@ -1499,6 +1517,7 @@
                 case SCAN_RESULTS_EVENT:
                 case SUPPLICANT_STATE_CHANGE_EVENT:
                 case PASSWORD_MAY_BE_INCORRECT_EVENT:
+                case WPS_OVERLAP_EVENT:
                 case CMD_BLACKLIST_NETWORK:
                 case CMD_CLEAR_BLACKLIST:
                 case CMD_SET_SCAN_MODE:
@@ -2042,6 +2061,7 @@
                 case NETWORK_CONNECTION_EVENT:
                 case NETWORK_DISCONNECTION_EVENT:
                 case PASSWORD_MAY_BE_INCORRECT_EVENT:
+                case WPS_OVERLAP_EVENT:
                 case CMD_SET_SCAN_TYPE:
                 case CMD_SET_HIGH_PERF_MODE:
                 case CMD_SET_COUNTRY_CODE:
@@ -2276,6 +2296,10 @@
                 case PASSWORD_MAY_BE_INCORRECT_EVENT:
                     mSupplicantStateTracker.sendMessage(PASSWORD_MAY_BE_INCORRECT_EVENT);
                     break;
+                case WPS_OVERLAP_EVENT:
+                    /* We just need to broadcast the error */
+                    sendErrorBroadcast(WifiManager.WPS_OVERLAP_ERROR);
+                    break;
                 case SUPPLICANT_STATE_CHANGE_EVENT:
                     stateChangeResult = (StateChangeResult) message.obj;
                     SupplicantState state = stateChangeResult.state;