Merge changes Iaa7bc042,Icc312fc9,I50ba06ed into honeycomb

* changes:
  Make keyguard also ask to turn the back button off, now that it is controlled separately.
  Allow independent control of the back and the other navigation buttons.
  Allow the status bar disable flags to be used as View's system ui visibility fields.
diff --git a/api/current.xml b/api/current.xml
index 64e5626c..2ebf2ed 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -11809,6 +11809,28 @@
  visibility="public"
 >
 </field>
+<field name="dialog_holo_dark_frame"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17301682"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="dialog_holo_light_frame"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17301683"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="divider_horizontal_bright"
  type="int"
  transient="false"
@@ -26585,6 +26607,39 @@
 <parameter name="viewSpacingBottom" type="int">
 </parameter>
 </method>
+<field name="THEME_HOLO_DARK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="THEME_HOLO_LIGHT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="THEME_TRADITIONAL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="AlertDialog.Builder"
  extends="java.lang.Object"
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 055984f..3c45080 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4268,7 +4268,7 @@
         
         mWindow = PolicyManager.makeNewWindow(this);
         mWindow.setCallback(this);
-        mWindow.getLayoutInflater().setFactory2(this);
+        mWindow.getLayoutInflater().setPrivateFactory(this);
         if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
             mWindow.setSoftInputMode(info.softInputMode);
         }
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java
index 428f4e3..e83d104 100644
--- a/core/java/android/app/AlertDialog.java
+++ b/core/java/android/app/AlertDialog.java
@@ -58,29 +58,69 @@
 public class AlertDialog extends Dialog implements DialogInterface {
     private AlertController mAlert;
 
+    /**
+     * Special theme constant for {@link #AlertDialog(Context, int)}: use
+     * the traditional (pre-Holo) alert dialog theme.
+     */
+    public static final int THEME_TRADITIONAL = 1;
+    
+    /**
+     * Special theme constant for {@link #AlertDialog(Context, int)}: use
+     * the holographic alert theme with a dark background.
+     */
+    public static final int THEME_HOLO_DARK = 2;
+    
+    /**
+     * Special theme constant for {@link #AlertDialog(Context, int)}: use
+     * the holographic alert theme with a light background.
+     */
+    public static final int THEME_HOLO_LIGHT = 3;
+    
     protected AlertDialog(Context context) {
-        this(context, getDefaultDialogTheme(context));
+        this(context, resolveDialogTheme(context, 0), true);
     }
 
+    /**
+     * Construct an AlertDialog that uses an explicit theme.  The actual style
+     * that an AlertDialog uses is a private implementation, however you can
+     * here supply either the name of an attribute in the theme from which
+     * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme}
+     * or one of the constants {@link #THEME_TRADITIONAL},
+     * {@link #THEME_HOLO_DARK}, or {@link #THEME_HOLO_LIGHT}.
+     */
     protected AlertDialog(Context context, int theme) {
-        super(context, theme == 0 ? getDefaultDialogTheme(context) : theme);
+        this(context, theme, true);
+    }
+
+    AlertDialog(Context context, int theme, boolean createContextWrapper) {
+        super(context, resolveDialogTheme(context, theme), createContextWrapper);
         mWindow.alwaysReadCloseOnTouchAttr();
-        mAlert = new AlertController(context, this, getWindow());
+        mAlert = new AlertController(getContext(), this, getWindow());
     }
 
     protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
-        super(context, getDefaultDialogTheme(context));
+        super(context, resolveDialogTheme(context, 0));
         mWindow.alwaysReadCloseOnTouchAttr();
         setCancelable(cancelable);
         setOnCancelListener(cancelListener);
         mAlert = new AlertController(context, this, getWindow());
     }
 
-    private static int getDefaultDialogTheme(Context context) {
-        TypedValue outValue = new TypedValue();
-        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
-                outValue, true);
-        return outValue.resourceId;
+    static int resolveDialogTheme(Context context, int resid) {
+        if (resid == THEME_TRADITIONAL) {
+            return com.android.internal.R.style.Theme_Dialog_Alert;
+        } else if (resid == THEME_HOLO_DARK) {
+            return com.android.internal.R.style.Theme_Holo_Dialog_Alert;
+        } else if (resid == THEME_HOLO_LIGHT) {
+            return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert;
+        } else if (resid >= 0x01000000) {   // start of real resource IDs.
+            return resid;
+        } else {
+            TypedValue outValue = new TypedValue();
+            context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
+                    outValue, true);
+            return outValue.resourceId;
+        }
     }
 
     /**
@@ -294,15 +334,23 @@
          * Constructor using a context for this builder and the {@link AlertDialog} it creates.
          */
         public Builder(Context context) {
-            this(context, getDefaultDialogTheme(context));
+            this(context, resolveDialogTheme(context, 0));
         }
 
         /**
          * Constructor using a context and theme for this builder and
-         * the {@link AlertDialog} it creates.
+         * the {@link AlertDialog} it creates.  The actual theme
+         * that an AlertDialog uses is a private implementation, however you can
+         * here supply either the name of an attribute in the theme from which
+         * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme}
+         * or one of the constants
+         * {@link AlertDialog#THEME_TRADITIONAL AlertDialog.THEME_TRADITIONAL},
+         * {@link AlertDialog#THEME_HOLO_DARK AlertDialog.THEME_HOLO_DARK}, or
+         * {@link AlertDialog#THEME_HOLO_LIGHT AlertDialog.THEME_HOLO_LIGHT}.
          */
         public Builder(Context context, int theme) {
-            P = new AlertController.AlertParams(new ContextThemeWrapper(context, theme));
+            P = new AlertController.AlertParams(new ContextThemeWrapper(
+                    context, resolveDialogTheme(context, theme)));
             mTheme = theme;
         }
         
@@ -840,7 +888,7 @@
          * to do and want this to be created and displayed.
          */
         public AlertDialog create() {
-            final AlertDialog dialog = new AlertDialog(P.mContext, mTheme);
+            final AlertDialog dialog = new AlertDialog(P.mContext, mTheme, false);
             P.apply(dialog.mAlert);
             dialog.setCancelable(P.mCancelable);
             dialog.setOnCancelListener(P.mOnCancelListener);
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index f4fa567..23d4065 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -119,7 +119,7 @@
      *                present its UI.
      */
     public Dialog(Context context) {
-        this(context, 0);
+        this(context, 0, true);
     }
 
     /**
@@ -135,6 +135,10 @@
      * <var>context</var>.  If 0, the default dialog theme will be used.
      */
     public Dialog(Context context, int theme) {
+        this(context, theme, true);
+    }
+
+    Dialog(Context context, int theme, boolean createContextWrapper) {
         if (theme == 0) {
             TypedValue outValue = new TypedValue();
             context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme,
@@ -142,7 +146,7 @@
             theme = outValue.resourceId;
         }
 
-        mContext = new ContextThemeWrapper(context, theme);
+        mContext = createContextWrapper ? new ContextThemeWrapper(context, theme) : context;
         mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
         Window w = PolicyManager.makeNewWindow(mContext);
         mWindow = w;
@@ -152,7 +156,7 @@
         mUiThread = Thread.currentThread();
         mListenersHandler = new ListenersHandler(this);
     }
-
+    
     /**
      * @deprecated
      * @hide
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index d24af52..a17ed9d 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -68,6 +68,7 @@
     private boolean mFactorySet;
     private Factory mFactory;
     private Factory2 mFactory2;
+    private Factory2 mPrivateFactory;
     private Filter mFilter;
 
     private final Object[] mConstructorArgs = new Object[2];
@@ -193,6 +194,7 @@
         mContext = newContext;
         mFactory = original.mFactory;
         mFactory2 = original.mFactory2;
+        mPrivateFactory = original.mPrivateFactory;
         mFilter = original.mFilter;
     }
     
@@ -300,6 +302,13 @@
     }
 
     /**
+     * @hide for use by framework
+     */
+    public void setPrivateFactory(Factory2 factory) {
+        mPrivateFactory = factory;
+    }
+
+    /**
      * @return The {@link Filter} currently used by this LayoutInflater to restrict the set of Views
      * that are allowed to be inflated.
      */
@@ -651,6 +660,10 @@
             else if (mFactory != null) view = mFactory.onCreateView(name, mContext, attrs);
             else view = null;
 
+            if (view == null && mPrivateFactory != null) {
+                view = mPrivateFactory.onCreateView(parent, name, mContext, attrs);
+            }
+            
             if (view == null) {
                 if (-1 == name.indexOf('.')) {
                     view = onCreateView(parent, name, attrs);
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index b21af41..b1d509a 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1551,11 +1551,13 @@
                 Log.e(TAG, "OutOfResourcesException locking surface", e);
                 // TODO: we should ask the window manager to do something!
                 // for now we just do nothing
+                mLayoutRequested = true;    // ask wm for a new surface next time.
                 return;
             } catch (IllegalArgumentException e) {
                 Log.e(TAG, "IllegalArgumentException locking surface", e);
                 // TODO: we should ask the window manager to do something!
                 // for now we just do nothing
+                mLayoutRequested = true;    // ask wm for a new surface next time.
                 return;
             }
 
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6363299..790a040 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -350,6 +350,7 @@
     private ZoomManager mZoomManager;
 
     private Rect mGLRectViewport = new Rect();
+    private boolean mGLViewportEmpty = false;
 
     /**
      *  Transportation object for returning WebView across thread boundaries.
@@ -3734,6 +3735,10 @@
             return;
         }
 
+        if (canvas.isHardwareAccelerated()) {
+            mZoomManager.setHardwareAccelerated();
+        }
+
         int saveCount = canvas.save();
         if (mInOverScrollMode && !getSettings()
                 .getUseWebViewBackgroundForOverscrollBackground()) {
@@ -4071,7 +4076,8 @@
         }
 
         if (canvas.isHardwareAccelerated()) {
-            int functor = nativeGetDrawGLFunction(mGLRectViewport, getScale(), extras);
+            int functor = nativeGetDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport,
+                    getScale(), extras);
             ((HardwareCanvas) canvas).callDrawGLFunction(functor);
         } else {
             DrawFilter df = null;
@@ -5155,16 +5161,21 @@
 
     void setGLRectViewport() {
         // Use the getGlobalVisibleRect() to get the intersection among the parents
-        getGlobalVisibleRect(mGLRectViewport);
-
-        // Then need to invert the Y axis, just for GL
-        View rootView = getRootView();
-        int rootViewHeight = rootView.getHeight();
-        int savedWebViewBottom = mGLRectViewport.bottom;
-        mGLRectViewport.bottom = rootViewHeight - mGLRectViewport.top - getVisibleTitleHeight();
-        mGLRectViewport.top = rootViewHeight - savedWebViewBottom;
-
-        nativeUpdateDrawGLFunction(mGLRectViewport);
+        // visible == false means we're clipped - send a null rect down to indicate that
+        // we should not draw
+        boolean visible = getGlobalVisibleRect(mGLRectViewport);
+        if (visible) {
+            // Then need to invert the Y axis, just for GL
+            View rootView = getRootView();
+            int rootViewHeight = rootView.getHeight();
+            int savedWebViewBottom = mGLRectViewport.bottom;
+            mGLRectViewport.bottom = rootViewHeight - mGLRectViewport.top - getVisibleTitleHeight();
+            mGLRectViewport.top = rootViewHeight - savedWebViewBottom;
+            mGLViewportEmpty = false;
+        } else {
+            mGLViewportEmpty = true;
+        }
+        nativeUpdateDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport);
     }
 
     /**
@@ -6824,7 +6835,7 @@
                     previouslyFocusedRect);
         } else {
             result = super.requestFocus(direction, previouslyFocusedRect);
-            if (mWebViewCore.getSettings().getNeedInitialFocus()) {
+            if (mWebViewCore.getSettings().getNeedInitialFocus() && !isInTouchMode()) {
                 // For cases such as GMail, where we gain focus from a direction,
                 // we want to move to the first available link.
                 // FIXME: If there are no visible links, we may not want to
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index b47fe86..efbcd58 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -183,6 +183,9 @@
     private ScaleGestureDetector mScaleDetector;
     private boolean mPinchToZoomAnimating = false;
 
+    private boolean mHardwareAccelerated = false;
+    private boolean mInHWAcceleratedZoom = false;
+
     public ZoomManager(WebView webView, CallbackProxy callbackProxy) {
         mWebView = webView;
         mCallbackProxy = callbackProxy;
@@ -384,6 +387,10 @@
             scale = getReadingLevelScale();
         }
 
+        if (mHardwareAccelerated) {
+            mInHWAcceleratedZoom = true;
+        }
+
         setZoomScale(scale, reflowText);
 
         if (oldScale != mActualScale) {
@@ -447,8 +454,18 @@
                 - titleHeight, mWebView.getViewHeight(), Math.round(mWebView.getContentHeight()
                 * zoomScale)) + titleHeight) + mWebView.getScrollY();
 
-        canvas.translate(tx, ty);
-        canvas.scale(zoomScale, zoomScale);
+        if (mHardwareAccelerated) {
+            mWebView.updateScrollCoordinates(mWebView.getScrollX() - tx, mWebView.getScrollY() - ty);
+            setZoomScale(zoomScale, false);
+
+            if (mZoomScale == 0) {
+                // We've reached the end of the zoom animation.
+                mInHWAcceleratedZoom = false;
+            }
+        } else {
+            canvas.translate(tx, ty);
+            canvas.scale(zoomScale, zoomScale);
+        }
     }
 
     public boolean isZoomAnimating() {
@@ -493,12 +510,14 @@
             mActualScale = scale;
             mInvActualScale = 1 / scale;
 
-            if (!mWebView.drawHistory()) {
+            if (!mWebView.drawHistory() && !mInHWAcceleratedZoom) {
 
                 // If history Picture is drawn, don't update scroll. They will
                 // be updated when we get out of that mode.
                 // update our scroll so we don't appear to jump
                 // i.e. keep the center of the doc in the center of the view
+                // If this is part of a zoom on a HW accelerated canvas, we
+                // have already updated the scroll so don't do it again.
                 int oldX = mWebView.getScrollX();
                 int oldY = mWebView.getScrollY();
                 float ratio = scale * oldInvScale;
@@ -1020,4 +1039,8 @@
             return null;
         }
     }
+
+    public void setHardwareAccelerated() {
+        mHardwareAccelerated = true;
+    }
 }
diff --git a/core/res/res/drawable-hdpi/stat_notify_chat.png b/core/res/res/drawable-hdpi/stat_notify_chat.png
index b2e65c6..9c713c8 100644
--- a/core/res/res/drawable-hdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-hdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_chat.png b/core/res/res/drawable-mdpi/stat_notify_chat.png
index f98b032..91b4290 100644
--- a/core/res/res/drawable-mdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-mdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png
index e936fac..8cc5535 100644
--- a/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png
index eb626df..4441ba2 100644
--- a/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png
index d6bc7d3..73891a3 100644
--- a/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png
index 8c8f25d..db68eea 100644
--- a/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png
index 661cc2f..7af6921 100644
--- a/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png
index b2d7186..22adc67 100644
--- a/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png
index 36ab1ff..c434d12 100644
--- a/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png
index a14b3c7..daf3b84 100644
--- a/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png
index 81a66c1..7b097b1 100644
--- a/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png
index a286ac6..8daef7c 100644
--- a/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml b/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml
index e9b106d..fcbdf6d 100644
--- a/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml
+++ b/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml
@@ -30,27 +30,21 @@
             android:fadingEdge="horizontal"
             />
     </LinearLayout>
-    <RelativeLayout
+    <TextView android:id="@+id/info"
+        android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
-        >
-        <TextView android:id="@+id/info"
-            android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:singleLine="true"
-            android:gravity="center_vertical"
-            android:layout_alignParentLeft="true"
-            android:paddingLeft="8dp"
-            />
-        <ImageView android:id="@+id/icon"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            android:layout_alignRight="@id/info"
-            android:layout_marginBottom="8dip"
-            android:scaleType="center"
-            />
-    </RelativeLayout>
+        android:singleLine="true"
+        android:gravity="center_vertical"
+        android:paddingLeft="4dp"
+        android:paddingRight="4dp"
+        />
+    <ImageView android:id="@+id/icon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom"
+        android:layout_marginBottom="13dip"
+        android:scaleType="center"
+        />
 </LinearLayout>
 
diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml b/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml
index b382c55..ff0f7d4 100644
--- a/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml
+++ b/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml
@@ -37,11 +37,13 @@
         android:layout_marginTop="-10dp"
         />
     <ImageView android:id="@+id/icon"
-        android:layout_width="48dp"
-        android:layout_height="32dp"
-        android:layout_gravity="top"
-        android:layout_marginTop="6dp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom"
+        android:layout_marginBottom="13dip"
         android:scaleType="center"
+        android:layout_marginRight="4dip"
+        android:layout_marginLeft="16dip"
         />
 </LinearLayout>
 
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index ff9ef59..9c59cb6 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -72,6 +72,9 @@
     <drawable name="editbox_dropdown_dark_frame">@drawable/editbox_dropdown_background_dark</drawable>
     <drawable name="editbox_dropdown_light_frame">@drawable/editbox_dropdown_background</drawable>
 
+    <drawable name="dialog_holo_dark_frame">@drawable/dialog_full_holo_dark</drawable>
+    <drawable name="dialog_holo_light_frame">@drawable/dialog_full_holo_light</drawable>
+    
     <drawable name="input_method_fullscreen_background">#fff9f9f9</drawable>
 
     <!-- For date picker widget -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index ae269df..957707d 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1496,6 +1496,9 @@
        a ListView). -->
   <public type="layout" name="simple_list_item_activated_2" />
 
+  <public type="drawable" name="dialog_holo_dark_frame" />
+  <public type="drawable" name="dialog_holo_light_frame" />
+
   <public type="style" name="Theme.WithActionBar" />
   <public type="style" name="Theme.NoTitleBar.OverlayActionModes" />
 
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index b739d83..d8a7f9d 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1690,7 +1690,7 @@
         int contextLen = contextEnd - contextStart;
         char[] buf = TemporaryBuffer.obtain(contextLen);
         TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
-        int result = getTextRunCursor(buf, 0, contextLen, flags, offset, cursorOpt);
+        int result = getTextRunCursor(buf, 0, contextLen, flags, offset - contextStart, cursorOpt);
         TemporaryBuffer.recycle(buf);
         return result;
     }
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java
index 64c209a..4c659d4 100644
--- a/graphics/java/android/graphics/SurfaceTexture.java
+++ b/graphics/java/android/graphics/SurfaceTexture.java
@@ -24,9 +24,9 @@
 /**
  * Captures frames from an image stream as an OpenGL ES texture.
  *
- * <p>The image stream may come from either video playback or camera preview.  A SurfaceTexture may
- * be used in place of a SurfaceHolder when specifying the output destination of a MediaPlayer or
- * Camera object.  This will cause all the frames from that image stream to be sent to the
+ * <p>The image stream may come from either camera preview.  A SurfaceTexture may be used in place
+ * of a SurfaceHolder when specifying the output destination of a {@link android.hardware.Camera}
+ * object.  Doing so will cause all the frames from the image stream to be sent to the
  * SurfaceTexture object rather than to the device's display.  When {@link #updateTexImage} is
  * called, the contents of the texture object specified when the SurfaceTexture was created is
  * updated to contain the most recent image from the image stream.  This may cause some frames of
@@ -34,6 +34,11 @@
  *
  * <p>The texture object uses the GL_TEXTURE_EXTERNAL_OES texture target, which is defined by the
  * OES_EGL_image_external OpenGL ES extension.  This limits how the texture may be used.
+ *
+ * <p>SurfaceTexture objects may be created on any thread.  {@link #updateTexImage} may only be
+ * called on the thread with the OpenGL ES context that contains the texture object.  The
+ * frame-available callback is called on an arbitrary thread, so unless special care is taken {@link
+ * #updateTexImage} should not be called directly from the callback.
  */
 public class SurfaceTexture {
 
diff --git a/libs/hwui/OpenGLDebugRenderer.cpp b/libs/hwui/OpenGLDebugRenderer.cpp
index 58d6c26..05870bb 100644
--- a/libs/hwui/OpenGLDebugRenderer.cpp
+++ b/libs/hwui/OpenGLDebugRenderer.cpp
@@ -23,10 +23,11 @@
 namespace android {
 namespace uirenderer {
 
-void OpenGLDebugRenderer::prepare(bool opaque) {
+void OpenGLDebugRenderer::prepareDirty(float left, float top,
+        float right, float bottom, bool opaque) {
     mPrimitivesCount = 0;
     LOGD("========= Frame start =========");
-    OpenGLRenderer::prepare(opaque);
+    OpenGLRenderer::prepareDirty(left, top, right, bottom, opaque);
 }
 
 void OpenGLDebugRenderer::finish() {
@@ -105,6 +106,33 @@
     OpenGLRenderer::drawRect(left, top, right, bottom, paint);
 }
 
+void OpenGLDebugRenderer::drawRoundRect(float left, float top, float right, float bottom,
+        float rx, float ry, SkPaint* paint) {
+    mPrimitivesCount++;
+    StopWatch w("drawRoundRect");
+    OpenGLRenderer::drawRoundRect(left, top, right, bottom, rx, ry, paint);
+}
+
+void OpenGLDebugRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
+    mPrimitivesCount++;
+    StopWatch w("drawCircle");
+    OpenGLRenderer::drawCircle(x, y, radius, paint);
+}
+
+void OpenGLDebugRenderer::drawOval(float left, float top, float right, float bottom,
+        SkPaint* paint) {
+    mPrimitivesCount++;
+    StopWatch w("drawOval");
+    OpenGLRenderer::drawOval(left, top, right, bottom, paint);
+}
+
+void OpenGLDebugRenderer::drawArc(float left, float top, float right, float bottom,
+        float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
+    mPrimitivesCount++;
+    StopWatch w("drawArc");
+    OpenGLRenderer::drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
+}
+
 void OpenGLDebugRenderer::drawPath(SkPath* path, SkPaint* paint) {
     mPrimitivesCount++;
     StopWatch w("drawPath");
diff --git a/libs/hwui/OpenGLDebugRenderer.h b/libs/hwui/OpenGLDebugRenderer.h
index 76e6a2e..1a18a67 100644
--- a/libs/hwui/OpenGLDebugRenderer.h
+++ b/libs/hwui/OpenGLDebugRenderer.h
@@ -34,7 +34,7 @@
     ~OpenGLDebugRenderer() {
     }
 
-    void prepare(bool opaque);
+    void prepareDirty(float left, float top, float right, float bottom, bool opaque);
     void finish();
 
     int saveLayer(float left, float top, float right, float bottom,
@@ -52,6 +52,12 @@
             float left, float top, float right, float bottom, SkPaint* paint);
     void drawColor(int color, SkXfermode::Mode mode);
     void drawRect(float left, float top, float right, float bottom, SkPaint* paint);
+    void drawRoundRect(float left, float top, float right, float bottom,
+            float rx, float ry, SkPaint* paint);
+    void drawCircle(float x, float y, float radius, SkPaint* paint);
+    void drawOval(float left, float top, float right, float bottom, SkPaint* paint);
+    void drawArc(float left, float top, float right, float bottom,
+            float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
     void drawPath(SkPath* path, SkPaint* paint);
     void drawLines(float* points, int count, SkPaint* paint);
     void drawText(const char* text, int bytesCount, int count, float x, float y,
diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp
index 3f88543..70b7278 100644
--- a/libs/rs/rsLocklessFifo.cpp
+++ b/libs/rs/rsLocklessFifo.cpp
@@ -100,7 +100,9 @@
     //dumpState("commit 1");
     reinterpret_cast<uint16_t *>(mPut)[0] = command;
     reinterpret_cast<uint16_t *>(mPut)[1] = sizeInBytes;
-    mPut += ((sizeInBytes + 3) & ~3) + 4;
+
+    int32_t s = ((sizeInBytes + 3) & ~3) + 4;
+    android_atomic_add(s, (int32_t *)&mPut);
     //dumpState("commit 2");
     mSignalToWorker.set();
 }
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index bbf5093..73ff230 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -3703,9 +3703,9 @@
 void ResTable::getLocales(Vector<String8>* locales) const
 {
     Vector<ResTable_config> configs;
-    LOGD("calling getConfigurations");
+    LOGV("calling getConfigurations");
     getConfigurations(&configs);
-    LOGD("called getConfigurations size=%d", (int)configs.size());
+    LOGV("called getConfigurations size=%d", (int)configs.size());
     const size_t I = configs.size();
     for (size_t i=0; i<I; i++) {
         char locale[6];
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 11ac56c..89b3dab 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -378,14 +378,11 @@
 }
 
 void AwesomePlayer::reset() {
-    LOGI("reset");
-
     Mutex::Autolock autoLock(mLock);
     reset_l();
 }
 
 void AwesomePlayer::reset_l() {
-    LOGI("reset_l");
     mDisplayWidth = 0;
     mDisplayHeight = 0;
 
@@ -411,10 +408,6 @@
         }
     }
 
-    if (mFlags & PREPARING) {
-        LOGI("waiting until preparation is completes.");
-    }
-
     while (mFlags & PREPARING) {
         mPreparedCondition.wait(mLock);
     }
@@ -438,8 +431,6 @@
     }
     mAudioSource.clear();
 
-    LOGI("audio source cleared");
-
     mTimeSource = NULL;
 
     delete mAudioPlayer;
@@ -480,8 +471,6 @@
         IPCThreadState::self()->flushCommands();
     }
 
-    LOGI("video source cleared");
-
     mDurationUs = -1;
     mFlags = 0;
     mExtractorFlags = 0;
@@ -498,8 +487,6 @@
     mFileSource.clear();
 
     mBitrate = -1;
-
-    LOGI("reset_l completed");
 }
 
 void AwesomePlayer::notifyListener_l(int msg, int ext1, int ext2) {
diff --git a/media/libstagefright/rtsp/ASessionDescription.cpp b/media/libstagefright/rtsp/ASessionDescription.cpp
index 77917b3..3e710dc 100644
--- a/media/libstagefright/rtsp/ASessionDescription.cpp
+++ b/media/libstagefright/rtsp/ASessionDescription.cpp
@@ -254,26 +254,12 @@
         return false;
     }
 
-    if (value == "npt=now-" || value == "npt=0-") {
-        return false;
-    }
-
     if (strncmp(value.c_str(), "npt=", 4)) {
         return false;
     }
 
-    const char *s = value.c_str() + 4;
-    char *end;
-    double from = strtod(s, &end);
-
-    if (end == s || *end != '-') {
-        return false;
-    }
-
-    s = end + 1;
-    double to = strtod(s, &end);
-
-    if (end == s || *end != '\0' || to < from) {
+    float from, to;
+    if (!parseNTPRange(value.c_str() + 4, &from, &to)) {
         return false;
     }
 
@@ -307,5 +293,39 @@
     }
 }
 
+// static
+bool ASessionDescription::parseNTPRange(
+        const char *s, float *npt1, float *npt2) {
+    if (s[0] == '-') {
+        return false;  // no start time available.
+    }
+
+    if (!strncmp("now", s, 3)) {
+        return false;  // no absolute start time available
+    }
+
+    char *end;
+    *npt1 = strtof(s, &end);
+
+    if (end == s || *end != '-') {
+        // Failed to parse float or trailing "dash".
+        return false;
+    }
+
+    s = end + 1;  // skip the dash.
+
+    if (!strncmp("now", s, 3)) {
+        return false;  // no absolute end time available
+    }
+
+    *npt2 = strtof(s, &end);
+
+    if (end == s || *end != '\0') {
+        return false;
+    }
+
+    return *npt2 > *npt1;
+}
+
 }  // namespace android
 
diff --git a/media/libstagefright/rtsp/ASessionDescription.h b/media/libstagefright/rtsp/ASessionDescription.h
index a3fa79e..b462983 100644
--- a/media/libstagefright/rtsp/ASessionDescription.h
+++ b/media/libstagefright/rtsp/ASessionDescription.h
@@ -55,6 +55,14 @@
 
     bool findAttribute(size_t index, const char *key, AString *value) const;
 
+    // parses strings of the form
+    //   npt      := npt-time "-" npt-time? | "-" npt-time
+    //   npt-time := "now" | [0-9]+("." [0-9]*)?
+    //
+    // Returns true iff both "npt1" and "npt2" times were available,
+    // i.e. we have a fixed duration, otherwise this is live streaming.
+    static bool parseNTPRange(const char *s, float *npt1, float *npt2);
+
 protected:
     virtual ~ASessionDescription();
 
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index 9bb8c46..306a9c1 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -938,13 +938,11 @@
 
         AString val;
         CHECK(GetAttribute(range.c_str(), "npt", &val));
-        float npt1, npt2;
 
-        if (val == "now-" || val == "0-") {
+        float npt1, npt2;
+        if (!ASessionDescription::parseNTPRange(val.c_str(), &npt1, &npt2)) {
             // This is a live stream and therefore not seekable.
             return;
-        } else {
-            CHECK_EQ(sscanf(val.c_str(), "%f-%f", &npt1, &npt2), 2);
         }
 
         i = response->mHeaders.indexOfKey("rtp-info");
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml b/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml
index 0f3f5f0..8e456b2 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml
@@ -27,7 +27,7 @@
 
     <com.android.systemui.statusbar.LatestItemView android:id="@+id/content"
         android:layout_width="match_parent"
-        android:layout_height="64sp"
+        android:layout_height="64dp"
         android:layout_alignParentTop="true"
         android:layout_toRightOf="@id/large_icon"
         android:layout_toLeftOf="@id/veto"
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 fd04418..6c8a20d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -98,8 +98,6 @@
     // Fitts' Law assistance for LatinIME; TODO: replace with a more general approach
     private static final boolean FAKE_SPACE_BAR = true;
 
-    public static final int LIGHTS_ON_DELAY = 5000;
-
     // The height of the bar, as definied by the build.  It may be taller if we're plugged
     // into hdmi.
     int mNaturalBarHeight = -1;
@@ -392,6 +390,12 @@
             new View.OnTouchListener() {
                 public boolean onTouch(View v, MotionEvent ev) {
                     if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+                        // even though setting the systemUI visibility below will turn these views
+                        // on, we need them to come up faster so that they can catch this motion
+                        // event
+                        mShadow.setVisibility(View.GONE);
+                        mBarContents.setVisibility(View.VISIBLE);
+
                         try {
                             mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
                         } catch (RemoteException ex) {
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 30a9432..faaa28d7 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1315,7 +1315,20 @@
     static boolean canBeImeTarget(WindowState w) {
         final int fl = w.mAttrs.flags
                 & (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM);
-        if (fl == 0 || fl == (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
+        if (fl == 0 || fl == (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)
+                || w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
+            if (DEBUG_INPUT_METHOD) {
+                Slog.i(TAG, "isVisibleOrAdding " + w + ": " + w.isVisibleOrAdding());
+                if (!w.isVisibleOrAdding()) {
+                    Slog.i(TAG, "  mSurface=" + w.mSurface + " reportDestroy=" + w.mReportDestroySurface
+                            + " relayoutCalled=" + w.mRelayoutCalled + " viewVis=" + w.mViewVisibility
+                            + " policyVis=" + w.mPolicyVisibility + " attachHid=" + w.mAttachedHidden
+                            + " exiting=" + w.mExiting + " destroying=" + w.mDestroying);
+                    if (w.mAppToken != null) {
+                        Slog.i(TAG, "  mAppToken.hiddenRequested=" + w.mAppToken.hiddenRequested);
+                    }
+                }
+            }
             return w.isVisibleOrAdding();
         }
         return false;
@@ -1330,8 +1343,8 @@
             i--;
             w = localmWindows.get(i);
 
-            //Slog.i(TAG, "Checking window @" + i + " " + w + " fl=0x"
-            //        + Integer.toHexString(w.mAttrs.flags));
+            if (DEBUG_INPUT_METHOD && willMove) Slog.i(TAG, "Checking window @" + i
+                    + " " + w + " fl=0x" + Integer.toHexString(w.mAttrs.flags));
             if (canBeImeTarget(w)) {
                 //Slog.i(TAG, "Putting input method here!");
 
@@ -1353,6 +1366,8 @@
             }
         }
 
+        if (DEBUG_INPUT_METHOD && willMove) Slog.v(TAG, "Proposed new IME target: " + w);
+        
         // Now, a special case -- if the last target's window is in the
         // process of exiting, and is above the new target, keep on the
         // last target to avoid flicker.  Consider for example a Dialog with
@@ -1365,6 +1380,7 @@
             if (mInputMethodTarget.mAnimLayer > w.mAnimLayer) {
                 w = mInputMethodTarget;
                 i = localmWindows.indexOf(w);
+                if (DEBUG_INPUT_METHOD) Slog.v(TAG, "Current target higher, switching to: " + w);
             }
         }
 
@@ -1420,6 +1436,7 @@
                         // with an animation, and it is on top of the next target
                         // we will be over, then hold off on moving until
                         // that is done.
+                        mInputMethodTargetWaitingAnim = true;
                         mInputMethodTarget = highestTarget;
                         return highestPos + 1;
                     }
@@ -1440,6 +1457,7 @@
                             + mInputMethodTarget + " to " + w, e);
                 }
                 mInputMethodTarget = w;
+                mInputMethodTargetWaitingAnim = false;
                 if (w.mAppToken != null) {
                     setInputMethodAnimLayerAdjustment(w.mAppToken.animLayerAdjustment);
                 } else {
@@ -8539,7 +8557,7 @@
                 w.mAnimLayer = w.mLayer + adj;
                 if (DEBUG_LAYERS) Slog.v(TAG, "Updating layer " + w + ": "
                         + w.mAnimLayer);
-                if (w == mInputMethodTarget) {
+                if (w == mInputMethodTarget && !mInputMethodTargetWaitingAnim) {
                     setInputMethodAnimLayerAdjustment(adj);
                 }
                 if (w == mWallpaperTarget && mLowerWallpaperTarget == null) {
@@ -8630,6 +8648,10 @@
 
             clearAnimation();
             animating = false;
+            if (animLayerAdjustment != 0) {
+                animLayerAdjustment = 0;
+                updateLayers();
+            }
             if (mInputMethodTarget != null && mInputMethodTarget.mAppToken == this) {
                 moveInputMethodWindowsIfNeededLocked(true);
             }
@@ -8639,10 +8661,6 @@
                     + ": reportedVisible=" + reportedVisible);
 
             transformation.clear();
-            if (animLayerAdjustment != 0) {
-                animLayerAdjustment = 0;
-                updateLayers();
-            }
 
             final int N = windows.size();
             for (int i=0; i<N; i++) {
@@ -9248,11 +9266,47 @@
             WindowState imFocus;
             if (idx > 0) {
                 imFocus = mWindows.get(idx-1);
+                //Log.i(TAG, "Desired input method target: " + imFocus);
+                //Log.i(TAG, "Current focus: " + this.mCurrentFocus);
+                //Log.i(TAG, "Last focus: " + this.mLastFocus);
                 if (imFocus != null) {
+                    // This may be a starting window, in which case we still want
+                    // to count it as okay.
+                    if (imFocus.mAttrs.type == LayoutParams.TYPE_APPLICATION_STARTING
+                            && imFocus.mAppToken != null) {
+                        // The client has definitely started, so it really should
+                        // have a window in this app token.  Let's look for it.
+                        for (int i=0; i<imFocus.mAppToken.windows.size(); i++) {
+                            WindowState w = imFocus.mAppToken.windows.get(i);
+                            if (w != imFocus) {
+                                //Log.i(TAG, "Switching to real app window: " + w);
+                                imFocus = w;
+                                break;
+                            }
+                        }
+                    }
+                    //Log.i(TAG, "IM target client: " + imFocus.mSession.mClient);
+                    //if (imFocus.mSession.mClient != null) {
+                    //    Log.i(TAG, "IM target client binder: " + imFocus.mSession.mClient.asBinder());
+                    //    Log.i(TAG, "Requesting client binder: " + client.asBinder());
+                    //}
                     if (imFocus.mSession.mClient != null &&
                             imFocus.mSession.mClient.asBinder() == client.asBinder()) {
                         return true;
                     }
+                    
+                    // Okay, how about this...  what is the current focus?
+                    // It seems in some cases we may not have moved the IM
+                    // target window, such as when it was in a pop-up window,
+                    // so let's also look at the current focus.  (An example:
+                    // go to Gmail, start searching so the keyboard goes up,
+                    // press home.  Sometimes the IME won't go down.)
+                    // Would be nice to fix this more correctly, but it's
+                    // way at the end of a release, and this should be good enough.
+                    if (mCurrentFocus != null && mCurrentFocus.mSession.mClient != null &&
+                            mCurrentFocus.mSession.mClient.asBinder() == client.asBinder()) {
+                        return true;
+                    }
                 }
             }
         }
@@ -11261,13 +11315,13 @@
 
         mInputMonitor.thawInputDispatchingLw();
 
+        boolean configChanged;
+        
         // While the display is frozen we don't re-compute the orientation
         // to avoid inconsistent states.  However, something interesting
         // could have actually changed during that time so re-evaluate it
         // now to catch that.
-        if (updateOrientationFromAppTokensLocked(false)) {
-            mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
-        }
+        configChanged = updateOrientationFromAppTokensLocked(false);
 
         // A little kludge: a lot could have happened while the
         // display was frozen, so now that we are coming back we
@@ -11282,11 +11336,12 @@
         
         if (updateRotation) {
             if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
-            boolean changed = setRotationUncheckedLocked(
+            configChanged |= setRotationUncheckedLocked(
                     WindowManagerPolicy.USE_LAST_ROTATION, 0, false);
-            if (changed) {
-                sendNewConfiguration();
-            }
+        }
+        
+        if (configChanged) {
+            mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
         }
     }
 
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 6bb19b0..254a19b 100755
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -11944,28 +11944,6 @@
             adj = FOREGROUND_APP_ADJ;
             schedGroup = Process.THREAD_GROUP_DEFAULT;
             app.adjType = "exec-service";
-        } else if (app.foregroundServices) {
-            // The user is aware of this app, so make it visible.
-            adj = PERCEPTIBLE_APP_ADJ;
-            schedGroup = Process.THREAD_GROUP_DEFAULT;
-            app.adjType = "foreground-service";
-        } else if (app.forcingToForeground != null) {
-            // The user is aware of this app, so make it visible.
-            adj = PERCEPTIBLE_APP_ADJ;
-            schedGroup = Process.THREAD_GROUP_DEFAULT;
-            app.adjType = "force-foreground";
-            app.adjSource = app.forcingToForeground;
-        } else if (app == mHeavyWeightProcess) {
-            // We don't want to kill the current heavy-weight process.
-            adj = HEAVY_WEIGHT_APP_ADJ;
-            schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE;
-            app.adjType = "heavy";
-        } else if (app == mHomeProcess) {
-            // This process is hosting what we currently consider to be the
-            // home app, so we don't want to let it go into the background.
-            adj = HOME_APP_ADJ;
-            schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE;
-            app.adjType = "home";
         } else if ((N=app.activities.size()) != 0) {
             // This app is in the background with paused activities.
             app.hidden = true;
@@ -11998,7 +11976,37 @@
             adj = hiddenAdj;
             app.adjType = "bg-empty";
         }
+        
+        if (adj > PERCEPTIBLE_APP_ADJ) {
+            if (app.foregroundServices) {
+                // The user is aware of this app, so make it visible.
+                adj = PERCEPTIBLE_APP_ADJ;
+                schedGroup = Process.THREAD_GROUP_DEFAULT;
+                app.adjType = "foreground-service";
+            } else if (app.forcingToForeground != null) {
+                // The user is aware of this app, so make it visible.
+                adj = PERCEPTIBLE_APP_ADJ;
+                schedGroup = Process.THREAD_GROUP_DEFAULT;
+                app.adjType = "force-foreground";
+                app.adjSource = app.forcingToForeground;
+            }
+        }
+        
+        if (adj > HEAVY_WEIGHT_APP_ADJ && app == mHeavyWeightProcess) {
+            // We don't want to kill the current heavy-weight process.
+            adj = HEAVY_WEIGHT_APP_ADJ;
+            schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE;
+            app.adjType = "heavy";
+        }
 
+        if (adj > HOME_APP_ADJ && app == mHomeProcess) {
+            // This process is hosting what we currently consider to be the
+            // home app, so we don't want to let it go into the background.
+            adj = HOME_APP_ADJ;
+            schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE;
+            app.adjType = "home";
+        }
+        
         //Slog.i(TAG, "OOM " + app + ": initial adj=" + adj);
         
         // By default, we use the computed adjustment.  It may be changed if
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 19e7fae..a7f7866 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -1069,6 +1069,8 @@
 
         cdmaDataConnectionState = newCdmaDataConnectionState;
         networkType = newNetworkType;
+        // this new state has been applied - forget it until we get a new new state
+        newNetworkType = 0;
 
         newSS.setStateOutOfService(); // clean slate for next time
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index c107d17..bb99e45 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -957,6 +957,9 @@
 
         gprsState = newGPRSState;
         networkType = newNetworkType;
+        // this new state has been applied - forget it until we get a new new state
+        newNetworkType = 0;
+
 
         newSS.setStateOutOfService(); // clean slate for next time
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
index 7a0c2f7..38c092d 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
@@ -95,7 +95,7 @@
          * Pre-computes the colors for the gradient. This must be called once before any call
          * to {@link #getGradientColor(float)}
          */
-        protected synchronized void precomputeGradientColors() {
+        protected void precomputeGradientColors() {
             if (mGradient == null) {
                 // actually create an array with an extra size, so that we can really go
                 // from 0 to SIZE (100%), or currentPos in the loop below will never equal 1.0
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index bd52dc2..0ed4305 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -28,6 +28,7 @@
 import com.android.layoutlib.bridge.impl.FontLoader;
 import com.android.layoutlib.bridge.impl.RenderSessionImpl;
 import com.android.ninepatch.NinePatchChunk;
+import com.android.resources.ResourceType;
 import com.android.tools.layoutlib.create.MethodAdapter;
 import com.android.tools.layoutlib.create.OverrideMethod;
 
@@ -410,8 +411,9 @@
      * @param name the name of the resource.
      * @return an {@link Integer} containing the resource id, or null if no resource were found.
      */
-    public static Integer getResourceValue(String type, String name) {
-        Map<String, Integer> map = sRFullMap.get(type);
+    public static Integer getResourceValue(ResourceType type, String name) {
+        String typeString = type.getName();
+        Map<String, Integer> map = sRFullMap.get(typeString);
         if (map != null) {
             return map.get(name);
         }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 79264d0..abea8c70 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -24,6 +24,7 @@
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.BridgeConstants;
 import com.android.layoutlib.bridge.impl.Stack;
+import com.android.resources.ResourceType;
 
 import android.app.Activity;
 import android.app.Fragment;
@@ -614,7 +615,7 @@
         return null;
     }
 
-    int getFrameworkResourceValue(String resType, String resName, int defValue) {
+    int getFrameworkResourceValue(ResourceType resType, String resName, int defValue) {
         Integer value = Bridge.getResourceValue(resType, resName);
         if (value != null) {
             return value.intValue();
@@ -623,7 +624,7 @@
         return defValue;
     }
 
-    int getProjectResourceValue(String resType, String resName, int defValue) {
+    int getProjectResourceValue(ResourceType resType, String resName, int defValue) {
         if (mProjectCallback != null) {
             Integer value = mProjectCallback.getResourceValue(resType, resName);
             if (value != null) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
index 465bf1d..edc92c2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
@@ -19,9 +19,9 @@
 import com.android.ide.common.rendering.api.IProjectCallback;
 import com.android.ide.common.rendering.api.LayoutLog;
 import com.android.ide.common.rendering.api.MergeCookie;
-import com.android.ide.common.rendering.api.RenderResources;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.layoutlib.bridge.Bridge;
+import com.android.resources.ResourceType;
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
@@ -158,13 +158,13 @@
             String[] layoutInfo = Bridge.resolveResourceValue(resource);
             if (layoutInfo != null) {
                 value = bridgeContext.getRenderResources().getFrameworkResource(
-                        RenderResources.RES_LAYOUT, layoutInfo[0]);
+                        ResourceType.LAYOUT, layoutInfo[0]);
             } else {
                 layoutInfo = mProjectCallback.resolveResourceValue(resource);
 
                 if (layoutInfo != null) {
                     value = bridgeContext.getRenderResources().getProjectResource(
-                            RenderResources.RES_LAYOUT, layoutInfo[0]);
+                            ResourceType.LAYOUT, layoutInfo[0]);
                 }
             }
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
index 7b66809..e71bbb2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
@@ -22,6 +22,7 @@
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.BridgeConstants;
 import com.android.layoutlib.bridge.impl.ResourceHelper;
+import com.android.resources.ResourceType;
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
@@ -103,9 +104,14 @@
         String[] resourceInfo = Bridge.resolveResourceValue(id);
 
         if (resourceInfo != null) {
+            ResourceType resType = ResourceType.getEnum(resourceInfo[1]);
+            if (resType == null) {
+                return null;
+            }
+
             platformResFlag_out[0] = true;
             return mContext.getRenderResources().getFrameworkResource(
-                    resourceInfo[1], resourceInfo[0]);
+                    resType, resourceInfo[0]);
         }
 
         // didn't find a match in the framework? look in the project.
@@ -113,9 +119,14 @@
             resourceInfo = mProjectCallback.resolveResourceValue(id);
 
             if (resourceInfo != null) {
+                ResourceType resType = ResourceType.getEnum(resourceInfo[1]);
+                if (resType == null) {
+                    return null;
+                }
+
                 platformResFlag_out[0] = false;
                 return mContext.getRenderResources().getProjectResource(
-                        resourceInfo[1], resourceInfo[0]);
+                        resType, resourceInfo[0]);
             }
         }
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
index 8d3c929..2b48539 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
@@ -24,6 +24,7 @@
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.BridgeConstants;
 import com.android.layoutlib.bridge.impl.ResourceHelper;
+import com.android.resources.ResourceType;
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
@@ -39,6 +40,7 @@
 
 import java.io.File;
 import java.io.FileReader;
+import java.util.Arrays;
 import java.util.Map;
 
 /**
@@ -587,17 +589,17 @@
         // then the xml attribute value was "resolved" which leads us to a ResourceValue with a
         // valid getType() and getName() returning a resource name.
         // (and getValue() returning null!). We need to handle this!
-        if (resValue.getType() != null && resValue.getType().startsWith("@+") == false) {
+        if (resValue.getResourceType() != null && resValue.getType().startsWith("@+") == false) {
             // if this is a framework id
             if (mPlatformFile || resValue.isFramework()) {
                 // look for idName in the android R classes
                 return mContext.getFrameworkResourceValue(
-                        resValue.getType(), resValue.getName(), defValue);
+                        resValue.getResourceType(), resValue.getName(), defValue);
             }
 
             // look for idName in the project R class.
             return mContext.getProjectResourceValue(
-                    resValue.getType(), resValue.getName(), defValue);
+                    resValue.getResourceType(), resValue.getName(), defValue);
         }
 
         // else, try to get the value, and resolve it somehow.
@@ -634,21 +636,22 @@
             // if this is a framework id
             if (mPlatformFile || value.startsWith("@android") || value.startsWith("@+android")) {
                 // look for idName in the android R classes
-                return mContext.getFrameworkResourceValue(RenderResources.RES_ID, idName, defValue);
+                return mContext.getFrameworkResourceValue(ResourceType.ID, idName, defValue);
             }
 
             // look for idName in the project R class.
-            return mContext.getProjectResourceValue(RenderResources.RES_ID, idName, defValue);
+            return mContext.getProjectResourceValue(ResourceType.ID, idName, defValue);
         }
 
         // not a direct id valid reference? resolve it
         Integer idValue = null;
 
         if (resValue.isFramework()) {
-            idValue = Bridge.getResourceValue(resValue.getType(), resValue.getName());
+            idValue = Bridge.getResourceValue(resValue.getResourceType(),
+                    resValue.getName());
         } else {
             idValue = mContext.getProjectCallback().getResourceValue(
-                    resValue.getType(), resValue.getName());
+                    resValue.getResourceType(), resValue.getName());
         }
 
         if (idValue != null) {
@@ -796,6 +799,6 @@
 
     @Override
     public String toString() {
-        return mResourceData.toString();
+        return Arrays.toString(mResourceData);
     }
  }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
index 4a6880b..f39961e 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
@@ -20,6 +20,7 @@
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.layoutlib.bridge.Bridge;
 import com.android.layoutlib.bridge.BridgeConstants;
+import com.android.resources.ResourceType;
 
 import org.xmlpull.v1.XmlPullParser;
 
@@ -58,7 +59,7 @@
         String ns = mParser.getAttributeNamespace(index);
 
         if (BridgeConstants.NS_RESOURCES.equals(ns)) {
-            Integer v = Bridge.getResourceValue(RenderResources.RES_ATTR, name);
+            Integer v = Bridge.getResourceValue(ResourceType.ATTR, name);
             if (v != null) {
                 return v.intValue();
             }
@@ -69,7 +70,7 @@
         // this is not an attribute in the android namespace, we query the customviewloader, if
         // the namespaces match.
         if (mContext.getProjectCallback().getNamespace().equals(ns)) {
-            Integer v = mContext.getProjectCallback().getResourceValue(RenderResources.RES_ATTR,
+            Integer v = mContext.getProjectCallback().getResourceValue(ResourceType.ATTR,
                     name);
             if (v != null) {
                 return v.intValue();
@@ -110,10 +111,10 @@
         if (resource != null) {
             Integer id = null;
             if (mPlatformFile || resource.isFramework()) {
-                id = Bridge.getResourceValue(resource.getType(), resource.getName());
+                id = Bridge.getResourceValue(resource.getResourceType(), resource.getName());
             } else {
                 id = mContext.getProjectCallback().getResourceValue(
-                        resource.getType(), resource.getName());
+                        resource.getResourceType(), resource.getName());
             }
 
             if (id != null) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java
index 5d56370..f62fad2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java
@@ -163,7 +163,7 @@
             mTtfToFontMap.put(ttf, styleMap);
         }
 
-        Font f = styleMap.get(style);
+        Font f = styleMap.get(style[0]);
 
         if (f != null) {
             return f;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index 978832f..19251f9 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -48,6 +48,7 @@
 import com.android.layoutlib.bridge.android.BridgeWindowSession;
 import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
 import com.android.resources.Density;
+import com.android.resources.ResourceType;
 import com.android.resources.ScreenSize;
 
 import android.animation.Animator;
@@ -566,17 +567,16 @@
         int animationId = 0;
         if (isFrameworkAnimation) {
             animationResource = mContext.getRenderResources().getFrameworkResource(
-                    RenderResources.RES_ANIMATOR, animationName);
+                    ResourceType.ANIMATOR, animationName);
             if (animationResource != null) {
-                animationId = Bridge.getResourceValue(RenderResources.RES_ANIMATOR,
-                        animationName);
+                animationId = Bridge.getResourceValue(ResourceType.ANIMATOR, animationName);
             }
         } else {
             animationResource = mContext.getRenderResources().getProjectResource(
-                    RenderResources.RES_ANIMATOR, animationName);
+                    ResourceType.ANIMATOR, animationName);
             if (animationResource != null) {
                 animationId = mContext.getProjectCallback().getResourceValue(
-                        RenderResources.RES_ANIMATOR, animationName);
+                        ResourceType.ANIMATOR, animationName);
             }
         }
 
@@ -1022,7 +1022,7 @@
                 mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT;
 
                 // get the real value
-                ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN,
+                ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
                         "status_bar_height");
 
                 if (value != null) {
@@ -1110,7 +1110,7 @@
             mSystemBarSize = 56; // ??
 
             // get the real value
-            ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN,
+            ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
                     "status_bar_height");
 
             if (value != null) {
@@ -1309,7 +1309,7 @@
     // --- FrameworkResourceIdProvider methods
 
     @Override
-    public Integer getId(String resType, String resName) {
+    public Integer getId(ResourceType resType, String resName) {
         return Bridge.getResourceValue(resType, resName);
     }
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 119dfb1..ae7a77f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -298,7 +298,7 @@
      */
     public static boolean stringToFloat(String s, TypedValue outValue) {
         // remove the space before and after
-        s.trim();
+        s = s.trim();
         int len = s.length();
 
         if (len <= 0) {