Merge "Longpressing in landscape correctly starts selection mode."
diff --git a/api/current.txt b/api/current.txt
index 91002f2..dfd8a33 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -2452,6 +2452,8 @@
     method public abstract void setLogo(android.graphics.drawable.Drawable);
     method public abstract void setNavigationMode(int);
     method public abstract void setSelectedNavigationItem(int);
+    method public void setSplitBackgroundDrawable(android.graphics.drawable.Drawable);
+    method public void setStackedBackgroundDrawable(android.graphics.drawable.Drawable);
     method public abstract void setSubtitle(java.lang.CharSequence);
     method public abstract void setSubtitle(int);
     method public abstract void setTitle(java.lang.CharSequence);
@@ -8897,7 +8899,6 @@
     method public int getMinimumWidth();
     method public abstract int getOpacity();
     method public boolean getPadding(android.graphics.Rect);
-    method public int getResolvedLayoutDirectionSelf();
     method public int[] getState();
     method public android.graphics.Region getTransparentRegion();
     method public void inflate(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
@@ -8932,10 +8933,6 @@
     method public abstract void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable);
   }
 
-  public static abstract interface Drawable.Callback2 implements android.graphics.drawable.Drawable.Callback {
-    method public abstract int getResolvedLayoutDirection(android.graphics.drawable.Drawable);
-  }
-
   public static abstract class Drawable.ConstantState {
     ctor public Drawable.ConstantState();
     method public abstract int getChangingConfigurations();
@@ -22667,7 +22664,7 @@
     method public void recycle();
   }
 
-  public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback2 android.view.KeyEvent.Callback {
+  public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
     ctor public View(android.content.Context);
     ctor public View(android.content.Context, android.util.AttributeSet);
     ctor public View(android.content.Context, android.util.AttributeSet, int);
@@ -22684,7 +22681,6 @@
     method public void buildDrawingCache();
     method public void buildDrawingCache(boolean);
     method public void buildLayer();
-    method protected boolean canResolveLayoutDirection();
     method public boolean canScrollHorizontally(int);
     method public boolean canScrollVertically(int);
     method public void cancelLongPress();
@@ -22796,7 +22792,6 @@
     method public final android.view.ViewParent getParent();
     method public float getPivotX();
     method public float getPivotY();
-    method public int getResolvedLayoutDirection(android.graphics.drawable.Drawable);
     method public android.content.res.Resources getResources();
     method public final int getRight();
     method protected float getRightFadingEdgeStrength();
@@ -22861,7 +22856,6 @@
     method public boolean isHovered();
     method public boolean isInEditMode();
     method public boolean isInTouchMode();
-    method protected static boolean isLayoutDirectionRtl(java.util.Locale);
     method public boolean isLayoutRequested();
     method public boolean isLongClickable();
     method public boolean isOpaque();
@@ -22947,10 +22941,8 @@
     method public void requestLayout();
     method public boolean requestRectangleOnScreen(android.graphics.Rect);
     method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
-    method protected void resetResolvedTextDirection();
     method public static int resolveSize(int, int);
     method public static int resolveSizeAndState(int, int, int);
-    method protected void resolveTextDirection();
     method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>);
     method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>);
     method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long);
@@ -23051,7 +23043,6 @@
     method public boolean willNotCacheDrawing();
     method public boolean willNotDraw();
     field public static android.util.Property ALPHA;
-    field protected static int DEFAULT_TEXT_DIRECTION;
     field public static final int DRAWING_CACHE_QUALITY_AUTO = 0; // 0x0
     field public static final int DRAWING_CACHE_QUALITY_HIGH = 1048576; // 0x100000
     field public static final int DRAWING_CACHE_QUALITY_LOW = 524288; // 0x80000
@@ -23380,6 +23371,7 @@
     method public boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
     method public void requestTransparentRegion(android.view.View);
     method protected void resetResolvedLayoutDirection();
+    method protected void resetResolvedTextDirection();
     method public void scheduleLayoutAnimation();
     method public void setAddStatesFromChildren(boolean);
     method public void setAlwaysDrawnWithCacheEnabled(boolean);
@@ -25925,8 +25917,9 @@
     ctor public FrameLayout(android.content.Context);
     ctor public FrameLayout(android.content.Context, android.util.AttributeSet);
     ctor public FrameLayout(android.content.Context, android.util.AttributeSet, int);
-    method public boolean getConsiderGoneChildrenWhenMeasuring();
+    method public deprecated boolean getConsiderGoneChildrenWhenMeasuring();
     method public android.graphics.drawable.Drawable getForeground();
+    method public boolean getMeasureAllChildren();
     method protected void onLayout(boolean, int, int, int, int);
     method public void setForeground(android.graphics.drawable.Drawable);
     method public void setForegroundGravity(int);
@@ -27177,6 +27170,7 @@
     method protected void resetResolvedDrawables();
     method protected void resetResolvedLayoutDirection();
     method protected void resolveDrawables();
+    method protected void resolveTextDirection();
     method public void setAllCaps(boolean);
     method public final void setAutoLinkMask(int);
     method public void setCompoundDrawablePadding(int);
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index 46dc5ff..0d4a067 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -402,13 +402,33 @@
     public abstract void setDisplayShowCustomEnabled(boolean showCustom);
 
     /**
-     * Set the ActionBar's background.
+     * Set the ActionBar's background. This will be used for the primary
+     * action bar.
      * 
      * @param d Background drawable
+     * @see #setStackedBackgroundDrawable(Drawable)
+     * @see #setSplitBackgroundDrawable(Drawable)
      */
     public abstract void setBackgroundDrawable(Drawable d);
 
     /**
+     * Set the ActionBar's stacked background. This will appear
+     * in the second row/stacked bar on some devices and configurations.
+     *
+     * @param d Background drawable for the stacked row
+     */
+    public void setStackedBackgroundDrawable(Drawable d) { }
+
+    /**
+     * Set the ActionBar's split background. This will appear in
+     * the split action bar containing menu-provided action buttons
+     * on some devices and configurations.
+     *
+     * @param d Background drawable for the split bar
+     */
+    public void setSplitBackgroundDrawable(Drawable d) { }
+
+    /**
      * @return The current custom view.
      */
     public abstract View getCustomView();
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 41e3fdf..034e3c7 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1638,6 +1638,12 @@
      * or later, consider instead using {@link LoaderManager} instead, available
      * via {@link #getLoaderManager()}.</em>
      *
+     * <p><strong>Warning:</strong> Do not call {@link Cursor#close()} on a cursor obtained using
+     * this method, because the activity will do that for you at the appropriate time. However, if
+     * you call {@link #stopManagingCursor} on a cursor from a managed query, the system <em>will
+     * not</em> automatically close the cursor and, in that case, you must call
+     * {@link Cursor#close()}.</p>
+     * 
      * @param uri The URI of the content provider to query.
      * @param projection List of columns to return.
      * @param selection SQL WHERE clause.
@@ -1672,6 +1678,12 @@
      * or later, consider instead using {@link LoaderManager} instead, available
      * via {@link #getLoaderManager()}.</em>
      *
+     * <p><strong>Warning:</strong> Do not call {@link Cursor#close()} on a cursor obtained using
+     * this method, because the activity will do that for you at the appropriate time. However, if
+     * you call {@link #stopManagingCursor} on a cursor from a managed query, the system <em>will
+     * not</em> automatically close the cursor and, in that case, you must call
+     * {@link Cursor#close()}.</p>
+     * 
      * @param uri The URI of the content provider to query.
      * @param projection List of columns to return.
      * @param selection SQL WHERE clause.
@@ -1707,6 +1719,12 @@
      * or later, consider instead using {@link LoaderManager} instead, available
      * via {@link #getLoaderManager()}.</em>
      *
+     * <p><strong>Warning:</strong> Do not call {@link Cursor#close()} on cursor obtained from
+     * {@link #managedQuery}, because the activity will do that for you at the appropriate time.
+     * However, if you call {@link #stopManagingCursor} on a cursor from a managed query, the system
+     * <em>will not</em> automatically close the cursor and, in that case, you must call
+     * {@link Cursor#close()}.</p>
+     * 
      * @param c The Cursor to be managed.
      * 
      * @see #managedQuery(android.net.Uri , String[], String, String[], String)
@@ -1728,6 +1746,10 @@
      * {@link #startManagingCursor}, stop the activity's management of that
      * cursor.
      * 
+     * <p><strong>Warning:</strong> After calling this method on a cursor from a managed query,
+     * the system <em>will not</em> automatically close the cursor and you must call 
+     * {@link Cursor#close()}.</p>
+     * 
      * @param c The Cursor that was being managed.
      * 
      * @see #startManagingCursor
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 102fac1..4fe9cef 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -1254,6 +1254,12 @@
          */
         public ComponentName importanceReasonComponent;
         
+        /**
+         * When {@link importanceReasonPid} is non-0, this is the importance
+         * of the other pid. @hide
+         */
+        public int importanceReasonImportance;
+
         public RunningAppProcessInfo() {
             importance = IMPORTANCE_FOREGROUND;
             importanceReasonCode = REASON_UNKNOWN;
@@ -1280,6 +1286,7 @@
             dest.writeInt(importanceReasonCode);
             dest.writeInt(importanceReasonPid);
             ComponentName.writeToParcel(importanceReasonComponent, dest);
+            dest.writeInt(importanceReasonImportance);
         }
 
         public void readFromParcel(Parcel source) {
@@ -1293,6 +1300,7 @@
             importanceReasonCode = source.readInt();
             importanceReasonPid = source.readInt();
             importanceReasonComponent = ComponentName.readFromParcel(source);
+            importanceReasonImportance = source.readInt();
         }
 
         public static final Creator<RunningAppProcessInfo> CREATOR = 
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 46712a9..48f94d0 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -239,6 +239,9 @@
      * methods of activities and other components are called.  Note that you
      * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when
      * appropriate in the future; this will not be removed for you.
+     *
+     * @param callback The interface to call.  This can be either a
+     * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface.
      */
     public void registerComponentCallbacks(ComponentCallbacks callback) {
         getApplicationContext().registerComponentCallbacks(callback);
diff --git a/core/java/android/hardware/SensorEvent.java b/core/java/android/hardware/SensorEvent.java
index 0411b5c..784bcc5 100644
--- a/core/java/android/hardware/SensorEvent.java
+++ b/core/java/android/hardware/SensorEvent.java
@@ -154,16 +154,16 @@
      * All values are in micro-Tesla (uT) and measure the ambient magnetic field
      * in the X, Y and Z axis.
      * 
-     * <h4>{@link android.hardware.Sensor#TYPE_GYROSCOPE Sensor.TYPE_GYROSCOPE}:</h4>
-     *  All values are in radians/second and measure the rate of rotation
-     *  around the X, Y and Z axis. The coordinate system is the same as is
-     *  used for the acceleration sensor.  Rotation is positive in the counter-clockwise
-     *  direction.  That is, an observer looking from some positive location on the x, y.
-     *  or z axis at a device positioned on the origin would report positive rotation
-     *  if the device appeared to be rotating counter clockwise.  Note that this is the
-     *  standard mathematical definition of positive rotation and does not agree with the
-     *  definition of roll given earlier.
-     *
+     * <h4>{@link android.hardware.Sensor#TYPE_GYROSCOPE Sensor.TYPE_GYROSCOPE}:
+     * </h4> All values are in radians/second and measure the rate of rotation
+     * around the device's local X, Y and Z axis. The coordinate system is the
+     * same as is used for the acceleration sensor. Rotation is positive in the
+     * counter-clockwise direction. That is, an observer looking from some
+     * positive location on the x, y or z axis at a device positioned on the
+     * origin would report positive rotation if the device appeared to be
+     * rotating counter clockwise. Note that this is the standard mathematical
+     * definition of positive rotation and does not agree with the definition of
+     * roll given earlier.
      * <ul>
      * <p>
      * values[0]: Angular speed around the x-axis
@@ -176,28 +176,61 @@
      * </p>
      * </ul>
      * <p>
-     * Typically the output of the gyroscope is integrated over time to calculate
-     * an angle, for example:
+     * Typically the output of the gyroscope is integrated over time to
+     * calculate a rotation describing the change of angles over the timestep,
+     * for example:
      * </p>
+     *
      * <pre class="prettyprint">
      *     private static final float NS2S = 1.0f / 1000000000.0f;
+     *     private final float[] deltaRotationVector = new float[4]();
      *     private float timestamp;
-     *     public void onSensorChanged(SensorEvent event)
-     *     {
+     *
+     *     public void onSensorChanged(SensorEvent event) {
+     *          // This timestep's delta rotation to be multiplied by the current rotation
+     *          // after computing it from the gyro sample data.
      *          if (timestamp != 0) {
      *              final float dT = (event.timestamp - timestamp) * NS2S;
-     *              angle[0] += event.values[0] * dT;
-     *              angle[1] += event.values[1] * dT;
-     *              angle[2] += event.values[2] * dT;
+     *              // Axis of the rotation sample, not normalized yet.
+     *              float axisX = event.values[0];
+     *              float axisY = event.values[1];
+     *              float axisZ = event.values[2];
+     *
+     *              // Calculate the angular speed of the sample
+     *              float omegaMagnitude = sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
+     *
+     *              // Normalize the rotation vector if it's big enough to get the axis
+     *              if (omegaMagnitude > EPSILON) {
+     *                  axisX /= omegaMagnitude;
+     *                  axisY /= omegaMagnitude;
+     *                  axisZ /= omegaMagnitude;
+     *              }
+     *
+     *              // Integrate around this axis with the angular speed by the timestep
+     *              // in order to get a delta rotation from this sample over the timestep
+     *              // We will convert this axis-angle representation of the delta rotation
+     *              // into a quaternion before turning it into the rotation matrix.
+     *              float thetaOverTwo = omegaMagnitude * dT / 2.0f;
+     *              float sinThetaOverTwo = sin(thetaOverTwo);
+     *              float cosThetaOverTwo = cos(thetaOverTwo);
+     *              deltaRotationVector[0] = sinThetaOverTwo * axisX;
+     *              deltaRotationVector[1] = sinThetaOverTwo * axisY;
+     *              deltaRotationVector[2] = sinThetaOverTwo * axisZ;
+     *              deltaRotationVector[3] = cosThetaOverTwo;
      *          }
      *          timestamp = event.timestamp;
+     *          float[] deltaRotationMatrix = new float[9];
+     *          SensorManager.getRotationMatrixFromVector(deltaRotationMatrix, deltaRotationVector);
+     *          // User code should concatenate the delta rotation we computed with the current rotation
+     *          // in order to get the updated rotation.
+     *          // rotationCurrent = rotationCurrent * deltaRotationMatrix;
      *     }
      * </pre>
-     *
-     * <p>In practice, the gyroscope noise and offset will introduce some errors which need
-     * to be compensated for. This is usually done using the information from other
-     * sensors, but is beyond the scope of this document.</p>
-     *
+     * <p>
+     * In practice, the gyroscope noise and offset will introduce some errors
+     * which need to be compensated for. This is usually done using the
+     * information from other sensors, but is beyond the scope of this document.
+     * </p>
      * <h4>{@link android.hardware.Sensor#TYPE_LIGHT Sensor.TYPE_LIGHT}:</h4>
      * <ul>
      * <p>
diff --git a/core/java/android/inputmethodservice/ExtractEditText.java b/core/java/android/inputmethodservice/ExtractEditText.java
index 44e7e52..4fc63ed 100644
--- a/core/java/android/inputmethodservice/ExtractEditText.java
+++ b/core/java/android/inputmethodservice/ExtractEditText.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.inputmethod.ExtractedText;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
 
 /***
@@ -142,4 +143,17 @@
     @Override public boolean hasFocus() {
         return this.isEnabled();
     }
+
+    /**
+     * @hide
+     */
+    @Override protected void viewClicked(InputMethodManager imm) {
+        // As an instance of this class is supposed to be owned by IMS,
+        // and it has a reference to the IMS (the current IME),
+        // we just need to call back its onViewClicked() here.
+        // It should be good to avoid unnecessary IPCs by doing this as well.
+        if (mIME != null) {
+            mIME.onViewClicked(false);
+        }
+    }
 }
diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java
index 3918cfd..f3be39c 100644
--- a/core/java/android/net/NetworkStats.java
+++ b/core/java/android/net/NetworkStats.java
@@ -102,6 +102,21 @@
             this.txPackets = txPackets;
             this.operations = operations;
         }
+
+        @Override
+        public String toString() {
+            final StringBuilder builder = new StringBuilder();
+            builder.append("iface=").append(iface);
+            builder.append(" uid=").append(uid);
+            builder.append(" set=").append(setToString(set));
+            builder.append(" tag=").append(tagToString(tag));
+            builder.append(" rxBytes=").append(rxBytes);
+            builder.append(" rxPackets=").append(rxPackets);
+            builder.append(" txBytes=").append(txBytes);
+            builder.append(" txPackets=").append(txPackets);
+            builder.append(" operations=").append(operations);
+            return builder.toString();
+        }
     }
 
     public NetworkStats(long elapsedRealtime, int initialSize) {
diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java
index 625d869..afd9892 100644
--- a/core/java/android/text/TextPaint.java
+++ b/core/java/android/text/TextPaint.java
@@ -72,8 +72,15 @@
         linkColor = tp.linkColor;
         drawableState = tp.drawableState;
         density = tp.density;
-        underlineColors = tp.underlineColors;
-        underlineThicknesses = tp.underlineThicknesses;
+
+        if (tp.underlineColors != null) {
+            if (underlineColors == null || underlineColors.length < tp.underlineCount) {
+                underlineColors = new int[tp.underlineCount];
+                underlineThicknesses = new float[tp.underlineCount];
+            }
+            System.arraycopy(tp.underlineColors, 0, underlineColors, 0, tp.underlineCount);
+            System.arraycopy(tp.underlineThicknesses, 0, underlineThicknesses, 0, tp.underlineCount);
+        }
         underlineCount = tp.underlineCount;
     }
 
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index ba23218..fd60813f 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -636,7 +636,8 @@
  *
  * @see android.view.ViewGroup
  */
-public class View implements Drawable.Callback2, KeyEvent.Callback, AccessibilityEventSource {
+public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Callback,
+        AccessibilityEventSource {
     private static final boolean DBG = false;
 
     /**
@@ -2583,6 +2584,8 @@
 
     /**
      * Default text direction is inherited
+     *
+     * @hide
      */
     protected static int DEFAULT_TEXT_DIRECTION = TEXT_DIRECTION_INHERIT;
 
@@ -9294,6 +9297,11 @@
         recomputePadding();
     }
 
+    /**
+     * Return true if layout direction resolution can be done
+     *
+     * @hide
+     */
     protected boolean canResolveLayoutDirection() {
         switch (getLayoutDirection()) {
             case LAYOUT_DIRECTION_INHERIT:
@@ -9322,6 +9330,8 @@
      *
      * @param locale Locale to check
      * @return true if a Locale is corresponding to a RTL script.
+     *
+     * @hide
      */
     protected static boolean isLayoutDirectionRtl(Locale locale) {
         return (LocaleUtil.TEXT_LAYOUT_DIRECTION_RTL_DO_NOT_USE ==
@@ -13240,7 +13250,6 @@
      * {@link #TEXT_DIRECTION_INHERIT},
      * {@link #TEXT_DIRECTION_FIRST_STRONG}
      * {@link #TEXT_DIRECTION_ANY_RTL},
-     * {@link #TEXT_DIRECTION_CHAR_COUNT},
      * {@link #TEXT_DIRECTION_LTR},
      * {@link #TEXT_DIRECTION_RTL},
      *
@@ -13258,7 +13267,6 @@
      * {@link #TEXT_DIRECTION_INHERIT},
      * {@link #TEXT_DIRECTION_FIRST_STRONG}
      * {@link #TEXT_DIRECTION_ANY_RTL},
-     * {@link #TEXT_DIRECTION_CHAR_COUNT},
      * {@link #TEXT_DIRECTION_LTR},
      * {@link #TEXT_DIRECTION_RTL},
      *
@@ -13279,7 +13287,6 @@
      *
      * {@link #TEXT_DIRECTION_FIRST_STRONG}
      * {@link #TEXT_DIRECTION_ANY_RTL},
-     * {@link #TEXT_DIRECTION_CHAR_COUNT},
      * {@link #TEXT_DIRECTION_LTR},
      * {@link #TEXT_DIRECTION_RTL},
      *
@@ -13294,6 +13301,8 @@
 
     /**
      * Resolve the text direction.
+     *
+     * @hide
      */
     protected void resolveTextDirection() {
         if (mTextDirection != TEXT_DIRECTION_INHERIT) {
@@ -13309,6 +13318,8 @@
 
     /**
      * Reset resolved text direction. Will be resolved during a call to getResolvedTextDirection().
+     *
+     * @hide
      */
     protected void resetResolvedTextDirection() {
         mResolvedTextDirection = TEXT_DIRECTION_INHERIT;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index b3dd071..fb3f6e8 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -4543,7 +4543,7 @@
                 predicate.init(accessibilityId);
                 View root = ViewRootImpl.this.mView;
                 View target = root.findViewByPredicate(predicate);
-                if (target != null && target.isShown()) {
+                if (target != null && target.getVisibility() == View.VISIBLE) {
                     info = target.createAccessibilityNodeInfo();
                 }
             } finally {
@@ -4586,7 +4586,7 @@
             try {
                 View root = ViewRootImpl.this.mView;
                 View target = root.findViewById(viewId);
-                if (target != null && target.isShown()) {
+                if (target != null && target.getVisibility() == View.VISIBLE) {
                     info = target.createAccessibilityNodeInfo();
                 }
             } finally {
@@ -4637,14 +4637,14 @@
                 ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
                 foundViews.clear();
 
-                View root;
+                View root = null;
                 if (accessibilityViewId != View.NO_ID) {
                     root = findViewByAccessibilityId(accessibilityViewId);
                 } else {
                     root = ViewRootImpl.this.mView;
                 }
 
-                if (root == null || !root.isShown()) {
+                if (root == null || root.getVisibility() != View.VISIBLE) {
                     return;
                 }
 
@@ -4659,7 +4659,7 @@
                 final int viewCount = foundViews.size();
                 for (int i = 0; i < viewCount; i++) {
                     View foundView = foundViews.get(i);
-                    if (foundView.isShown()) {
+                    if (foundView.getVisibility() == View.VISIBLE) {
                         infos.add(foundView.createAccessibilityNodeInfo());
                     }
                  }
@@ -4732,7 +4732,7 @@
 
         private boolean performActionFocus(int accessibilityId) {
             View target = findViewByAccessibilityId(accessibilityId);
-            if (target == null) {
+            if (target == null || target.getVisibility() != View.VISIBLE) {
                 return false;
             }
             // Get out of touch mode since accessibility wants to move focus around.
@@ -4742,7 +4742,7 @@
 
         private boolean performActionClearFocus(int accessibilityId) {
             View target = findViewByAccessibilityId(accessibilityId);
-            if (target == null) {
+            if (target == null || target.getVisibility() != View.VISIBLE) {
                 return false;
             }
             if (!target.isFocused()) {
@@ -4754,7 +4754,7 @@
 
         private boolean performActionSelect(int accessibilityId) {
             View target = findViewByAccessibilityId(accessibilityId);
-            if (target == null) {
+            if (target == null || target.getVisibility() != View.VISIBLE) {
                 return false;
             }
             if (target.isSelected()) {
@@ -4766,7 +4766,7 @@
 
         private boolean performActionClearSelection(int accessibilityId) {
             View target = findViewByAccessibilityId(accessibilityId);
-            if (target == null) {
+            if (target == null || target.getVisibility() != View.VISIBLE) {
                 return false;
             }
             if (!target.isSelected()) {
@@ -4783,18 +4783,21 @@
             }
             mFindByAccessibilityIdPredicate.init(accessibilityId);
             View foundView = root.findViewByPredicate(mFindByAccessibilityIdPredicate);
-            return (foundView != null && foundView.isShown()) ? foundView : null;
+            if (foundView == null || foundView.getVisibility() != View.VISIBLE) {
+                return null;
+            }
+            return foundView;
         }
 
         private final class FindByAccessibilitytIdPredicate implements Predicate<View> {
-            public int mSerchedId;
+            public int mSearchedId;
 
             public void init(int searchedId) {
-                mSerchedId = searchedId;
+                mSearchedId = searchedId;
             }
 
             public boolean apply(View view) {
-                return (view.getAccessibilityViewId() == mSerchedId);
+                return (view.getAccessibilityViewId() == mSearchedId);
             }
         }
     }
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index ef4bcc1..7ba93da0 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -383,6 +383,39 @@
         }
     }
 
+    private static class OnTrimMemoryListener implements ComponentCallbacks2 {
+        private static OnTrimMemoryListener sInstance = null;
+
+        static void init(Context c) {
+            if (sInstance == null) {
+                sInstance = new OnTrimMemoryListener(c.getApplicationContext());
+            }
+        }
+
+        private OnTrimMemoryListener(Context c) {
+            c.registerComponentCallbacks(this);
+        }
+
+        @Override
+        public void onConfigurationChanged(Configuration newConfig) {
+            // Ignore
+        }
+
+        @Override
+        public void onLowMemory() {
+            // Ignore
+        }
+
+        @Override
+        public void onTrimMemory(int level) {
+            if (DebugFlags.WEB_VIEW) {
+                Log.d("WebView", "onTrimMemory: " + level);
+            }
+            WebView.nativeOnTrimMemory(level);
+        }
+
+    }
+
     // A final CallbackProxy shared by WebViewCore and BrowserFrame.
     private final CallbackProxy mCallbackProxy;
 
@@ -1195,6 +1228,8 @@
     }
 
     private void init() {
+        OnTrimMemoryListener.init(getContext());
+
         setWillNotDraw(false);
         setFocusable(true);
         setFocusableInTouchMode(true);
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index b945038..2d10bbe 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -886,9 +886,11 @@
             event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
         }
 
-        // We first get a chance to populate the event.
-        onPopulateAccessibilityEvent(event);
-
+        View selectedView = getSelectedView();
+        if (selectedView != null && selectedView.getVisibility() == VISIBLE) {
+            // We first get a chance to populate the event.
+            onPopulateAccessibilityEvent(event);
+        }
         return false;
     }
 
@@ -896,10 +898,7 @@
     public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
         // We send selection events only from AdapterView to avoid
         // generation of such event for each child.
-        View selectedView = getSelectedView();
-        if (selectedView != null) {
-            selectedView.dispatchPopulateAccessibilityEvent(event);
-        }
+        getSelectedView().dispatchPopulateAccessibilityEvent(event);
     }
 
     @Override
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index 0b0b812..398a7eb 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -465,23 +465,42 @@
     }
 
     /**
-     * Determines whether to measure all children or just those in 
-     * the VISIBLE or INVISIBLE state when measuring. Defaults to false.
+     * Sets whether to consider all children, or just those in
+     * the VISIBLE or INVISIBLE state, when measuring. Defaults to false.
+     *
      * @param measureAll true to consider children marked GONE, false otherwise.
      * Default value is false.
-     * 
+     *
      * @attr ref android.R.styleable#FrameLayout_measureAllChildren
      */
     @android.view.RemotableViewMethod
     public void setMeasureAllChildren(boolean measureAll) {
         mMeasureAllChildren = measureAll;
     }
-    
+
     /**
-     * Determines whether to measure all children or just those in 
-     * the VISIBLE or INVISIBLE state when measuring. 
+     * Determines whether all children, or just those in the VISIBLE or
+     * INVISIBLE state, are considered when measuring.
+     *
+     * @return Whether all children are considered when measuring.
+     *
+     * @deprecated This method is deprecated in favor of
+     * {@link #getMeasureAllChildren() getMeasureAllChildren()}, which was
+     * renamed for consistency with
+     * {@link #setMeasureAllChildren(boolean) setMeasureAllChildren()}.
      */
+    @Deprecated
     public boolean getConsiderGoneChildrenWhenMeasuring() {
+        return getMeasureAllChildren();
+    }
+
+    /**
+     * Determines whether all children, or just those in the VISIBLE or
+     * INVISIBLE state, are considered when measuring.
+     *
+     * @return Whether all children are considered when measuring.
+     */
+    public boolean getMeasureAllChildren() {
         return mMeasureAllChildren;
     }
 
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index a5cf62e..6edfd59 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -961,7 +961,8 @@
         }
 
         for (View view : mTopToBottomLeftToRightSet) {
-            if (view.dispatchPopulateAccessibilityEvent(event)) {
+            if (view.getVisibility() == View.VISIBLE
+                    && view.dispatchPopulateAccessibilityEvent(event)) {
                 mTopToBottomLeftToRightSet.clear();
                 return true;
             }
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 9afb625..191c4ca 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -405,7 +405,10 @@
         onPopulateAccessibilityEvent(event);
         // Dispatch only to the selected tab.
         if (mSelectedTab != -1) {
-            return getChildTabViewAt(mSelectedTab).dispatchPopulateAccessibilityEvent(event);
+            View tabView = getChildTabViewAt(mSelectedTab);
+            if (tabView != null && tabView.getVisibility() == VISIBLE) {
+                return tabView.dispatchPopulateAccessibilityEvent(event);
+            }
         }
         return false;
     }
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d890ba5..39f6e27 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5432,8 +5432,8 @@
                         if (mMovement != null && mText instanceof Editable
                                 && mLayout != null && onCheckIsTextEditor()) {
                             InputMethodManager imm = InputMethodManager.peekInstance();
+                            viewClicked(imm);
                             if (imm != null) {
-                                imm.viewClicked(this);
                                 imm.showSoftInput(this, 0);
                             }
                         }
@@ -8348,9 +8348,7 @@
             if (touchIsFinished && (isTextEditable() || mTextIsSelectable)) {
                 // Show the IME, except when selecting in read-only text.
                 final InputMethodManager imm = InputMethodManager.peekInstance();
-                if (imm != null) {
-                    imm.viewClicked(this);
-                }
+                viewClicked(imm);
                 if (!mTextIsSelectable) {
                     handled |= imm != null && imm.showSoftInput(this, 0);
                 }
@@ -11320,6 +11318,15 @@
         mResolvedDrawables = false;
     }
 
+    /**
+     * @hide
+     */
+    protected void viewClicked(InputMethodManager imm) {
+        if (imm != null) {
+            imm.viewClicked(this);
+        }
+    }
+
     @ViewDebug.ExportedProperty(category = "text")
     private CharSequence            mText;
     private CharSequence            mTransformed;
@@ -11342,7 +11349,7 @@
     private final TextPaint         mTextPaint;
     private boolean                 mUserSetTextScaleX;
     private final Paint             mHighlightPaint;
-    private int                     mHighlightColor = 0x4C33B5E5;
+    private int                     mHighlightColor = 0x6633B5E5;
     /**
      * This is temporarily visible to fix bug 3085564 in webView. Do not rely on
      * this field being protected. Will be restored as private when lineHeight
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 90d19fd..ccca22e 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -346,7 +346,17 @@
     }
 
     public void setBackgroundDrawable(Drawable d) {
-        mContainerView.setBackgroundDrawable(d);
+        mContainerView.setPrimaryBackground(d);
+    }
+
+    public void setStackedBackgroundDrawable(Drawable d) {
+        mContainerView.setStackedBackground(d);
+    }
+
+    public void setSplitBackgroundDrawable(Drawable d) {
+        if (mSplitView != null) {
+            mSplitView.setSplitBackground(d);
+        }
     }
 
     public View getCustomView() {
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index ba2f5d4..3fba1be 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -58,9 +58,20 @@
     private TextView mClearDefaultHint;
     private PackageManager mPm;
 
+    private Intent makeMyIntent() {
+        Intent intent = new Intent(getIntent());
+        // The resolver activity is set to be hidden from recent tasks.
+        // we don't want this attribute to be propagated to the next activity
+        // being launched.  Note that if the original Intent also had this
+        // flag set, we are now losing it.  That should be a very rare case
+        // and we can live with this.
+        intent.setFlags(intent.getFlags()&~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+        return intent;
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        onCreate(savedInstanceState, new Intent(getIntent()),
+        onCreate(savedInstanceState, makeMyIntent(),
                 getResources().getText(com.android.internal.R.string.whichApplication),
                 null, null, true);
     }
diff --git a/core/java/com/android/internal/view/menu/ListMenuPresenter.java b/core/java/com/android/internal/view/menu/ListMenuPresenter.java
index 146c7ac..e6538b0 100644
--- a/core/java/com/android/internal/view/menu/ListMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/ListMenuPresenter.java
@@ -34,6 +34,8 @@
  * MenuPresenter for list-style menus.
  */
 public class ListMenuPresenter implements MenuPresenter, AdapterView.OnItemClickListener {
+    private static final String TAG = "ListMenuPresenter";
+
     Context mContext;
     LayoutInflater mInflater;
     MenuBuilder mMenu;
@@ -76,7 +78,7 @@
     public void initForMenu(Context context, MenuBuilder menu) {
         if (mThemeRes != 0) {
             mContext = new ContextThemeWrapper(context, mThemeRes);
-        } else if (mContext == null) {
+        } else if (mContext != null) {
             mContext = context;
         }
         mInflater = LayoutInflater.from(mContext);
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
index fd9ee08..f95de62 100644
--- a/core/java/com/android/internal/widget/ActionBarContainer.java
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -76,6 +76,21 @@
         mActionBarView = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
     }
 
+    public void setPrimaryBackground(Drawable bg) {
+        mBackground = bg;
+        invalidate();
+    }
+
+    public void setStackedBackground(Drawable bg) {
+        mStackedBackground = bg;
+        invalidate();
+    }
+
+    public void setSplitBackground(Drawable bg) {
+        mSplitBackground = bg;
+        invalidate();
+    }
+
     /**
      * Set the action bar into a "transitioning" state. While transitioning
      * the bar will block focus and touch from all of its descendants. This
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index b01dcd8..9313d0a 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -760,7 +760,8 @@
         jint count = end - start;
         sp<TextLayoutCacheValue> value;
 #if USE_TEXT_LAYOUT_CACHE
-        value = gTextLayoutCache.getValue(paint, textArray, start, count, end, flags);
+        value = TextLayoutCache::getInstance().getValue(paint, textArray, start, count,
+                        end, flags);
         if (value == NULL) {
             LOGE("Cannot get TextLayoutCache value");
             return ;
@@ -780,7 +781,8 @@
 
         sp<TextLayoutCacheValue> value;
 #if USE_TEXT_LAYOUT_CACHE
-        value = gTextLayoutCache.getValue(paint, textArray, start, count, contextCount, flags);
+        value = TextLayoutCache::getInstance().getValue(paint, textArray, start, count,
+                        contextCount, flags);
         if (value == NULL) {
             LOGE("Cannot get TextLayoutCache value");
             return ;
diff --git a/core/jni/android/graphics/TextLayout.cpp b/core/jni/android/graphics/TextLayout.cpp
index 7e89a37..fa9a7b7 100644
--- a/core/jni/android/graphics/TextLayout.cpp
+++ b/core/jni/android/graphics/TextLayout.cpp
@@ -257,7 +257,7 @@
     sp<TextLayoutCacheValue> value;
 #if USE_TEXT_LAYOUT_CACHE
     // Return advances from the cache. Compute them if needed
-    value = gTextLayoutCache.getValue(
+    value = TextLayoutCache::getInstance().getValue(
             paint, chars, start, count, contextCount, dirFlags);
 #else
     value = new TextLayoutCacheValue();
diff --git a/core/jni/android/graphics/TextLayout.h b/core/jni/android/graphics/TextLayout.h
index 9bb1b92..0a29d78 100644
--- a/core/jni/android/graphics/TextLayout.h
+++ b/core/jni/android/graphics/TextLayout.h
@@ -41,11 +41,6 @@
  */
 #define USE_TEXT_LAYOUT_CACHE 1
 
-
-#if USE_TEXT_LAYOUT_CACHE
-    static TextLayoutCache gTextLayoutCache;
-#endif
-
 enum {
     kBidi_LTR = 0,
     kBidi_RTL = 1,
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index f04c5eb5..7f79277 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "TextLayoutCache"
+
 #include "TextLayoutCache.h"
 #include "TextLayout.h"
 
@@ -23,6 +25,12 @@
 
 namespace android {
 
+//--------------------------------------------------------------------------------------------------
+#if USE_TEXT_LAYOUT_CACHE
+    ANDROID_SINGLETON_STATIC_INSTANCE(TextLayoutCache);
+#endif
+//--------------------------------------------------------------------------------------------------
+
 TextLayoutCache::TextLayoutCache() :
         mCache(GenerationCache<TextLayoutCacheKey, sp<TextLayoutCacheValue> >::kUnlimitedCapacity),
         mSize(0), mMaxSize(MB(DEFAULT_TEXT_LAYOUT_CACHE_SIZE_IN_MB)),
@@ -30,13 +38,6 @@
     init();
 }
 
-TextLayoutCache::TextLayoutCache(uint32_t max):
-        mCache(GenerationCache<TextLayoutCacheKey, sp<TextLayoutCacheValue> >::kUnlimitedCapacity),
-        mSize(0), mMaxSize(max),
-        mCacheHitCount(0), mNanosecondsSaved(0) {
-    init();
-}
-
 TextLayoutCache::~TextLayoutCache() {
     mCache.clear();
 }
@@ -46,25 +47,21 @@
 
     mDebugLevel = readRtlDebugLevel();
     mDebugEnabled = mDebugLevel & kRtlDebugCaches;
-    LOGD("Using TextLayoutCache debug level: %d - Debug Enabled: %d", mDebugLevel, mDebugEnabled);
+    LOGD("Using debug level: %d - Debug Enabled: %d", mDebugLevel, mDebugEnabled);
 
     mCacheStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    if (mDebugEnabled) {
-        LOGD("TextLayoutCache start time: %lld", mCacheStartTime);
-    }
-    mInitialized = true;
 
     if (mDebugEnabled) {
+        LOGD("Start time: %lld", mCacheStartTime);
 #if RTL_USE_HARFBUZZ
-        LOGD("TextLayoutCache is using HARFBUZZ");
+        LOGD("Using HARFBUZZ");
 #else
-        LOGD("TextLayoutCache is using ICU");
+        LOGD("Using ICU");
 #endif
+        LOGD("Initialization is done");
     }
 
-    if (mDebugEnabled) {
-        LOGD("TextLayoutCache initialization is done");
-    }
+    mInitialized = true;
 }
 
 /*
@@ -147,8 +144,7 @@
             // Cleanup to make some room if needed
             if (mSize + size > mMaxSize) {
                 if (mDebugEnabled) {
-                    LOGD("TextLayoutCache: need to clean some entries "
-                            "for making some room for a new entry");
+                    LOGD("Need to clean some entries for making some room for a new entry");
                 }
                 while (mSize + size > mMaxSize) {
                     // This will call the callback
@@ -213,7 +209,7 @@
     float remainingPercent = 100 * ((mMaxSize - mSize) / ((float)mMaxSize));
     float timeRunningInSec = (systemTime(SYSTEM_TIME_MONOTONIC) - mCacheStartTime) / 1000000000;
     LOGD("------------------------------------------------");
-    LOGD("TextLayoutCache stats");
+    LOGD("Cache stats");
     LOGD("------------------------------------------------");
     LOGD("pid       : %d", getpid());
     LOGD("running   : %.0f seconds", timeRunningInSec);
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h
index 10dee87..0d8d71f 100644
--- a/core/jni/android/graphics/TextLayoutCache.h
+++ b/core/jni/android/graphics/TextLayoutCache.h
@@ -25,6 +25,7 @@
 #include <utils/GenerationCache.h>
 #include <utils/Compare.h>
 #include <utils/RefBase.h>
+#include <utils/Singleton.h>
 
 #include <SkPaint.h>
 #include <SkTemplates.h>
@@ -187,11 +188,11 @@
 /**
  * Cache of text layout information.
  */
-class TextLayoutCache : public OnEntryRemoved<TextLayoutCacheKey, sp<TextLayoutCacheValue> >
+class TextLayoutCache : public OnEntryRemoved<TextLayoutCacheKey, sp<TextLayoutCacheValue> >,
+        public Singleton<TextLayoutCache>
 {
 public:
     TextLayoutCache();
-    TextLayoutCache(uint32_t maxByteSize);
 
     virtual ~TextLayoutCache();
 
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index bcf8e71..395e417 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -477,7 +477,7 @@
 #if RTL_USE_HARFBUZZ
     sp<TextLayoutCacheValue> value;
 #if USE_TEXT_LAYOUT_CACHE
-    value = gTextLayoutCache.getValue(paint, text, 0, count, count, flags);
+    value = TextLayoutCache::getInstance().getValue(paint, text, 0, count, count, flags);
     if (value == NULL) {
         LOGE("Cannot get TextLayoutCache value");
         return ;
@@ -507,7 +507,7 @@
 #if RTL_USE_HARFBUZZ
     sp<TextLayoutCacheValue> value;
 #if USE_TEXT_LAYOUT_CACHE
-    value = gTextLayoutCache.getValue(paint, text, start, count, contextCount, flags);
+    value = TextLayoutCache::getInstance().getValue(paint, text, start, count, contextCount, flags);
     if (value == NULL) {
         LOGE("Cannot get TextLayoutCache value");
         return ;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 3fa4d48..72863a2 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -87,9 +87,7 @@
     <protected-broadcast android:name="android.bluetooth.device.action.NAME_FAILED" />
     <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
     <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
-    <protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REQUEST" />
     <protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REPLY" />
-    <protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL" />
     <protected-broadcast
         android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />
     <protected-broadcast
@@ -1501,19 +1499,23 @@
                 android:theme="@style/Theme.Holo.Dialog"
                 android:label="@string/heavy_weight_switcher_title"
                 android:finishOnCloseSystemDialogs="true"
-                android:excludeFromRecents="true">
+                android:excludeFromRecents="true"
+                android:process=":ui">
         </activity>
         <activity android:name="com.android.internal.app.PlatLogoActivity"
-                android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen">
+                android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen"
+                android:process=":ui">
         </activity>
         <activity android:name="com.android.internal.app.DisableCarModeActivity"
                 android:theme="@style/Theme.NoDisplay"
-                android:excludeFromRecents="true">
+                android:excludeFromRecents="true"
+                android:process=":ui">
         </activity>
         <activity android:name="com.android.internal.app.RingtonePickerActivity"
                 android:theme="@style/Theme.Holo.Dialog.Alert"
                 android:excludeFromRecents="true"
-                android:multiprocess="true">
+                android:multiprocess="true"
+                android:process=":ui">
             <intent-filter>
                 <action android:name="android.intent.action.RINGTONE_PICKER" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1524,18 +1526,21 @@
                 android:excludeFromRecents="true"
                 android:exported="true"
                 android:theme="@android:style/Theme.Holo.Dialog"
-                android:label="@string/choose_account_label">
+                android:label="@string/choose_account_label"
+                android:process=":ui">
         </activity>
 
         <activity android:name="android.accounts.GrantCredentialsPermissionActivity"
                 android:excludeFromRecents="true"
                 android:exported="true"
-                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge"
+                android:process=":ui">
         </activity>
 
         <activity android:name="android.content.SyncActivityTooManyDeletes"
                android:theme="@android:style/Theme.Holo.Dialog"
-               android:label="@string/sync_too_many_deletes">
+               android:label="@string/sync_too_many_deletes"
+               android:process=":ui">
         </activity>
 
         <activity android:name="com.android.server.ShutdownActivity"
@@ -1553,7 +1558,8 @@
 
         <activity android:name="com.android.internal.app.NetInitiatedActivity"
                 android:theme="@style/Theme.Holo.Dialog.Alert"
-                android:excludeFromRecents="true">
+                android:excludeFromRecents="true"
+                android:process=":ui">
         </activity>
 
         <receiver android:name="com.android.server.BootReceiver" >
diff --git a/core/res/res/drawable-hdpi/list_divider_holo_dark.9.png b/core/res/res/drawable-hdpi/list_divider_holo_dark.9.png
deleted file mode 100644
index 7264a7a..0000000
--- a/core/res/res/drawable-hdpi/list_divider_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_divider_holo_light.9.png b/core/res/res/drawable-hdpi/list_divider_holo_light.9.png
deleted file mode 100644
index 74f48f5..0000000
--- a/core/res/res/drawable-hdpi/list_divider_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_divider_holo_dark.9.png b/core/res/res/drawable-mdpi/list_divider_holo_dark.9.png
deleted file mode 100644
index aa8015d..0000000
--- a/core/res/res/drawable-mdpi/list_divider_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_divider_holo_light.9.png b/core/res/res/drawable-mdpi/list_divider_holo_light.9.png
deleted file mode 100644
index c25c256..0000000
--- a/core/res/res/drawable-mdpi/list_divider_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-nodpi/indicator_code_lock_drag_direction_green_up.png b/core/res/res/drawable-nodpi/indicator_code_lock_drag_direction_green_up.png
deleted file mode 100644
index cc46f19..0000000
--- a/core/res/res/drawable-nodpi/indicator_code_lock_drag_direction_green_up.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-nodpi/indicator_code_lock_drag_direction_red_up.png b/core/res/res/drawable-nodpi/indicator_code_lock_drag_direction_red_up.png
deleted file mode 100644
index cc46f19..0000000
--- a/core/res/res/drawable-nodpi/indicator_code_lock_drag_direction_red_up.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/list_divider_horizontal_holo_dark.9.png b/core/res/res/drawable-xhdpi/list_divider_horizontal_holo_dark.9.png
index a8ad54d..0c901de 100644
--- a/core/res/res/drawable-xhdpi/list_divider_horizontal_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/list_divider_horizontal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/values-bg-rBG/donottranslate-cldr.xml b/core/res/res/values-bg-rBG/donottranslate-cldr.xml
deleted file mode 100644
index 4c38ad2..0000000
--- a/core/res/res/values-bg-rBG/donottranslate-cldr.xml
+++ /dev/null
@@ -1,149 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="month_long_standalone_january">януари</string>
-    <string name="month_long_standalone_february">февруари</string>
-    <string name="month_long_standalone_march">март</string>
-    <string name="month_long_standalone_april">април</string>
-    <string name="month_long_standalone_may">май</string>
-    <string name="month_long_standalone_june">юни</string>
-    <string name="month_long_standalone_july">юли</string>
-    <string name="month_long_standalone_august">август</string>
-    <string name="month_long_standalone_september">септември</string>
-    <string name="month_long_standalone_october">октомври</string>
-    <string name="month_long_standalone_november">ноември</string>
-    <string name="month_long_standalone_december">декември</string>
-
-    <string name="month_long_january">януари</string>
-    <string name="month_long_february">февруари</string>
-    <string name="month_long_march">март</string>
-    <string name="month_long_april">април</string>
-    <string name="month_long_may">май</string>
-    <string name="month_long_june">юни</string>
-    <string name="month_long_july">юли</string>
-    <string name="month_long_august">август</string>
-    <string name="month_long_september">септември</string>
-    <string name="month_long_october">октомври</string>
-    <string name="month_long_november">ноември</string>
-    <string name="month_long_december">декември</string>
-
-    <string name="month_medium_january">ян.</string>
-    <string name="month_medium_february">февр.</string>
-    <string name="month_medium_march">март</string>
-    <string name="month_medium_april">апр.</string>
-    <string name="month_medium_may">май</string>
-    <string name="month_medium_june">юни</string>
-    <string name="month_medium_july">юли</string>
-    <string name="month_medium_august">авг.</string>
-    <string name="month_medium_september">септ.</string>
-    <string name="month_medium_october">окт.</string>
-    <string name="month_medium_november">ноем.</string>
-    <string name="month_medium_december">дек.</string>
-
-    <string name="month_shortest_january">я</string>
-    <string name="month_shortest_february">ф</string>
-    <string name="month_shortest_march">м</string>
-    <string name="month_shortest_april">а</string>
-    <string name="month_shortest_may">м</string>
-    <string name="month_shortest_june">ю</string>
-    <string name="month_shortest_july">ю</string>
-    <string name="month_shortest_august">а</string>
-    <string name="month_shortest_september">с</string>
-    <string name="month_shortest_october">о</string>
-    <string name="month_shortest_november">н</string>
-    <string name="month_shortest_december">д</string>
-
-    <string name="day_of_week_long_sunday">неделя</string>
-    <string name="day_of_week_long_monday">понеделник</string>
-    <string name="day_of_week_long_tuesday">вторник</string>
-    <string name="day_of_week_long_wednesday">сряда</string>
-    <string name="day_of_week_long_thursday">четвъртък</string>
-    <string name="day_of_week_long_friday">петък</string>
-    <string name="day_of_week_long_saturday">събота</string>
-
-    <string name="day_of_week_medium_sunday">нд</string>
-    <string name="day_of_week_medium_monday">пн</string>
-    <string name="day_of_week_medium_tuesday">вт</string>
-    <string name="day_of_week_medium_wednesday">ср</string>
-    <string name="day_of_week_medium_thursday">чт</string>
-    <string name="day_of_week_medium_friday">пт</string>
-    <string name="day_of_week_medium_saturday">сб</string>
-
-    <string name="day_of_week_short_sunday">нд</string>
-    <string name="day_of_week_short_monday">пн</string>
-    <string name="day_of_week_short_tuesday">вт</string>
-    <string name="day_of_week_short_wednesday">ср</string>
-    <string name="day_of_week_short_thursday">чт</string>
-    <string name="day_of_week_short_friday">пт</string>
-    <string name="day_of_week_short_saturday">сб</string>
-
-    <string name="day_of_week_shortest_sunday">н</string>
-    <string name="day_of_week_shortest_monday">п</string>
-    <string name="day_of_week_shortest_tuesday">в</string>
-    <string name="day_of_week_shortest_wednesday">с</string>
-    <string name="day_of_week_shortest_thursday">ч</string>
-    <string name="day_of_week_shortest_friday">п</string>
-    <string name="day_of_week_shortest_saturday">с</string>
-
-    <string name="am">пр. об.</string>
-    <string name="pm">сл. об.</string>
-    <string name="yesterday">Вчера</string>
-    <string name="today">Днес</string>
-    <string name="tomorrow">Утре</string>
-
-    <string name="hour_minute_24">%-k:%M</string>
-    <string name="hour_minute_ampm">%-l:%M %p</string>
-    <string name="hour_minute_cap_ampm">%-l:%M %p</string>
-    <string name="twelve_hour_time_format">h:mm a</string>
-    <string name="twenty_four_hour_time_format">H:mm</string>
-    <string name="numeric_date">%d.%m.%Y</string>
-    <string name="numeric_date_format">dd.MM.yyyy</string>
-    <string name="numeric_date_template">"%s.%s.%s"</string>
-    <string name="month_day_year">%d %B %Y</string>
-    <string name="time_of_day">%H:%M:%S</string>
-    <string name="date_and_time">%H:%M:%S %d.%m.%Y</string>
-    <string name="date_time">%2$s %1$s</string>
-    <string name="time_date">%1$s %3$s</string>
-    <string name="abbrev_month_day_year">%d.%m.%Y</string>
-    <string name="month_day">%-e %B</string>
-    <string name="month">%-B</string>
-    <string name="month_year">%B %Y</string>
-    <string name="abbrev_month_day">%-e %b</string>
-    <string name="abbrev_month">%b</string>
-    <string name="abbrev_month_year">%b %Y</string>
-    <string name="time1_time2">%1$s-%2$s</string>
-    <string name="date1_date2">%2$s - %5$s</string>
-    <string name="numeric_md1_md2">%3$s.%2$s - %8$s.%7$s</string>
-    <string name="numeric_wday1_md1_wday2_md2">%3$s.%2$s, %1$s - %8$s.%7$s, %6$s</string>
-    <string name="numeric_mdy1_mdy2">%3$s.%2$s.%4$s - %8$s.%7$s.%9$s</string>
-    <string name="numeric_wday1_mdy1_wday2_mdy2">%3$s.%2$s.%4$s, %1$s - %8$s.%7$s.%9$s, %6$s</string>
-    <string name="numeric_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %3$s.%2$s.%4$s, %1$s - %10$s %8$s.%7$s.%9$s, %6$s</string>
-    <string name="numeric_md1_time1_md2_time2">%5$s %3$s.%2$s - %10$s %8$s.%7$s</string>
-    <string name="numeric_wday1_md1_time1_wday2_md2_time2">%5$s %3$s.%2$s, %1$s - %10$s %8$s.%7$s, %6$s</string>
-    <string name="numeric_mdy1_time1_mdy2_time2">%5$s %3$s.%2$s.%4$s - %10$s %8$s.%7$s.%9$s</string>
-    <string name="wday1_date1_time1_wday2_date2_time2">%3$s %2$s, %1$s - %6$s %5$s, %4$s</string>
-    <string name="wday1_date1_wday2_date2">%2$s, %1$s - %5$s, %4$s</string>
-    <string name="date1_time1_date2_time2">%3$s %2$s - %6$s %5$s</string>
-    <string name="time_wday_date">%1$s %3$s, %2$s</string>
-    <string name="wday_date">%3$s, %2$s</string>
-    <string name="time_wday">%1$s %2$s</string>
-    <string name="same_year_md1_md2">%3$s %2$s - %8$s %7$s</string>
-    <string name="same_year_wday1_md1_wday2_md2">%3$s %2$s, %1$s - %8$s %7$s, %6$s</string>
-    <string name="same_year_md1_time1_md2_time2">%5$s %3$s %2$s - %10$s %8$s %7$s</string>
-    <string name="same_month_md1_time1_md2_time2">%5$s %3$s %2$s - %10$s %8$s %7$s</string>
-    <string name="same_year_wday1_md1_time1_wday2_md2_time2">%5$s %3$s %2$s, %1$s - %10$s %8$s %7$s, %6$s</string>
-    <string name="same_month_wday1_md1_time1_wday2_md2_time2">%5$s %3$s %2$s, %1$s - %10$s %8$s %7$s, %6$s</string>
-    <string name="same_year_mdy1_time1_mdy2_time2">%5$s %3$s %2$s %4$s - %10$s %8$s %7$s %9$s</string>
-    <string name="same_month_mdy1_time1_mdy2_time2">%5$s %3$s %2$s %4$s - %10$s %8$s %7$s %9$s</string>
-    <string name="same_year_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %3$s %2$s %4$s, %1$s - %10$s %8$s %7$s %9$s, %6$s</string>
-    <string name="same_month_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %3$s %2$s %4$s, %1$s - %10$s %8$s %7$s %9$s, %6$s</string>
-    <string name="same_month_wday1_mdy1_wday2_mdy2">%3$s %2$s %4$s, %1$s - %8$s %7$s %9$s, %6$s</string>
-    <string name="same_month_md1_md2">%3$s-%8$s %2$s</string>
-    <string name="same_month_wday1_md1_wday2_md2">%3$s %2$s, %1$s - %8$s %7$s, %6$s</string>
-    <string name="same_year_mdy1_mdy2">%3$s %2$s - %8$s %7$s %9$s</string>
-    <string name="same_month_mdy1_mdy2">%3$s-%8$s %2$s %9$s</string>
-    <string name="same_year_wday1_mdy1_wday2_mdy2">%3$s %2$s %9$s, %1$s - %8$s %7$s y, %6$s</string>
-    <string name="short_format_month">%b</string>
-    <string name="full_wday_month_day_no_year">EEEE MMMM d</string>
-    <string name="abbrev_wday_month_day_year">d MMM yyyy, E</string>
-</resources>
diff --git a/core/res/res/values-bg/donottranslate-cldr.xml b/core/res/res/values-bg/donottranslate-cldr.xml
index 62f550a..dc8b3ad 100644
--- a/core/res/res/values-bg/donottranslate-cldr.xml
+++ b/core/res/res/values-bg/donottranslate-cldr.xml
@@ -128,22 +128,22 @@
     <string name="wday_date">%3$s, %2$s</string>
     <string name="time_wday">%1$s %2$s</string>
     <string name="same_year_md1_md2">%3$s %2$s - %8$s %7$s</string>
-    <string name="same_year_wday1_md1_wday2_md2">%1$s %2$s %3$s - %6$s %7$s %8$s</string>
+    <string name="same_year_wday1_md1_wday2_md2">%3$s %2$s, %1$s - %8$s %7$s, %6$s</string>
     <string name="same_year_md1_time1_md2_time2">%5$s %3$s %2$s - %10$s %8$s %7$s</string>
     <string name="same_month_md1_time1_md2_time2">%5$s %3$s %2$s - %10$s %8$s %7$s</string>
-    <string name="same_year_wday1_md1_time1_wday2_md2_time2">%5$s %1$s %2$s %3$s - %10$s %6$s %7$s %8$s</string>
-    <string name="same_month_wday1_md1_time1_wday2_md2_time2">%5$s %1$s %2$s %3$s - %10$s %6$s %7$s %8$s</string>
+    <string name="same_year_wday1_md1_time1_wday2_md2_time2">%5$s %3$s %2$s, %1$s - %10$s %8$s %7$s, %6$s</string>
+    <string name="same_month_wday1_md1_time1_wday2_md2_time2">%5$s %3$s %2$s, %1$s - %10$s %8$s %7$s, %6$s</string>
     <string name="same_year_mdy1_time1_mdy2_time2">%5$s %3$s %2$s %4$s - %10$s %8$s %7$s %9$s</string>
     <string name="same_month_mdy1_time1_mdy2_time2">%5$s %3$s %2$s %4$s - %10$s %8$s %7$s %9$s</string>
     <string name="same_year_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %3$s %2$s %4$s, %1$s - %10$s %8$s %7$s %9$s, %6$s</string>
     <string name="same_month_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %3$s %2$s %4$s, %1$s - %10$s %8$s %7$s %9$s, %6$s</string>
     <string name="same_month_wday1_mdy1_wday2_mdy2">%3$s %2$s %4$s, %1$s - %8$s %7$s %9$s, %6$s</string>
     <string name="same_month_md1_md2">%3$s-%8$s %2$s</string>
-    <string name="same_month_wday1_md1_wday2_md2">%1$s %2$s %3$s - %6$s %7$s %8$s</string>
+    <string name="same_month_wday1_md1_wday2_md2">%3$s %2$s, %1$s - %8$s %7$s, %6$s</string>
     <string name="same_year_mdy1_mdy2">%3$s %2$s - %8$s %7$s %9$s</string>
     <string name="same_month_mdy1_mdy2">%3$s-%8$s %2$s %9$s</string>
     <string name="same_year_wday1_mdy1_wday2_mdy2">%3$s %2$s %9$s, %1$s - %8$s %7$s y, %6$s</string>
     <string name="short_format_month">%b</string>
-    <string name="full_wday_month_day_no_year">E, d MMMM</string>
-    <string name="abbrev_wday_month_day_year">d MMM y, E</string>
+    <string name="full_wday_month_day_no_year">d MMMM, EEEE</string>
+    <string name="abbrev_wday_month_day_year">d MMM yyyy, E</string>
 </resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index f434ce8..6f98e02 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -878,8 +878,8 @@
         <item name="textColorSearchUrl">@android:color/search_url_text_holo</item>
         <item name="textColorHighlight">@android:color/highlighted_text_holo_dark</item>
         <item name="textColorHighlightInverse">@android:color/highlighted_text_holo_light</item>
-        <item name="textColorLink">@android:color/link_text_holo_dark</item>
-        <item name="textColorLinkInverse">@android:color/link_text_holo_light</item>
+        <item name="textColorLink">@android:color/holo_blue_light</item>
+        <item name="textColorLinkInverse">@android:color/holo_blue_light</item>
         <item name="textColorAlertDialogListItem">@android:color/primary_text_holo_dark</item>
 
         <item name="textAppearanceLarge">@android:style/TextAppearance.Holo.Large</item>
@@ -1182,8 +1182,8 @@
         <item name="textColorSearchUrl">@android:color/search_url_text_holo</item>
         <item name="textColorHighlight">@android:color/highlighted_text_holo_light</item>
         <item name="textColorHighlightInverse">@android:color/highlighted_text_holo_dark</item>
-        <item name="textColorLink">@android:color/link_text_holo_light</item>
-        <item name="textColorLinkInverse">@android:color/link_text_holo_dark</item>
+        <item name="textColorLink">@android:color/holo_blue_light</item>
+        <item name="textColorLinkInverse">@android:color/holo_blue_light</item>
         <item name="textColorAlertDialogListItem">@android:color/primary_text_holo_light</item>
 
         <item name="textAppearanceLarge">@android:style/TextAppearance.Holo.Light.Large</item>
diff --git a/data/fonts/DroidSansFallback.ttf b/data/fonts/DroidSansFallback.ttf
index ba9d76f..ff97670 100644
--- a/data/fonts/DroidSansFallback.ttf
+++ b/data/fonts/DroidSansFallback.ttf
Binary files differ
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 72d233a3..0a3deb1 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -290,6 +290,8 @@
 
     /**
      * Implement this interface if you want to create an drawable that is RTL aware
+     *
+     * @hide
      */
     public static interface Callback2 extends Callback {
         /**
@@ -379,6 +381,8 @@
     /**
      * Use the current {@link android.graphics.drawable.Drawable.Callback2} implementation to get
      * the resolved layout direction of this Drawable.
+     *
+     * @hide
      */
     public int getResolvedLayoutDirectionSelf() {
         final Callback callback = getCallback();
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 392193b..5ccf87f 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -78,12 +78,8 @@
 // conditionals don't get stripped...  but that is probably what we want.
 #if !LOG_NDEBUG
 static const char *kReturnStrings[] = {
-#if 1 /* TODO: error update strings */
-    "unknown",
-#else
+    "BR_ERROR",
     "BR_OK",
-    "BR_TIMEOUT",
-    "BR_WAKEUP",
     "BR_TRANSACTION",
     "BR_REPLY",
     "BR_ACQUIRE_RESULT",
@@ -94,25 +90,19 @@
     "BR_RELEASE",
     "BR_DECREFS",
     "BR_ATTEMPT_ACQUIRE",
-    "BR_EVENT_OCCURRED",
     "BR_NOOP",
     "BR_SPAWN_LOOPER",
     "BR_FINISHED",
     "BR_DEAD_BINDER",
-    "BR_CLEAR_DEATH_NOTIFICATION_DONE"
-#endif
+    "BR_CLEAR_DEATH_NOTIFICATION_DONE",
+    "BR_FAILED_REPLY"
 };
 
 static const char *kCommandStrings[] = {
-#if 1 /* TODO: error update strings */
-    "unknown",
-#else
-    "BC_NOOP",
     "BC_TRANSACTION",
     "BC_REPLY",
     "BC_ACQUIRE_RESULT",
     "BC_FREE_BUFFER",
-    "BC_TRANSACTION_COMPLETE",
     "BC_INCREFS",
     "BC_ACQUIRE",
     "BC_RELEASE",
@@ -120,18 +110,12 @@
     "BC_INCREFS_DONE",
     "BC_ACQUIRE_DONE",
     "BC_ATTEMPT_ACQUIRE",
-    "BC_RETRIEVE_ROOT_OBJECT",
-    "BC_SET_THREAD_ENTRY",
     "BC_REGISTER_LOOPER",
     "BC_ENTER_LOOPER",
     "BC_EXIT_LOOPER",
-    "BC_SYNC",
-    "BC_STOP_PROCESS",
-    "BC_STOP_SELF",
     "BC_REQUEST_DEATH_NOTIFICATION",
     "BC_CLEAR_DEATH_NOTIFICATION",
     "BC_DEAD_BINDER_DONE"
-#endif
 };
 
 static const char* getReturnString(size_t idx)
@@ -154,30 +138,36 @@
 {
     const binder_transaction_data* btd =
         (const binder_transaction_data*)data;
-    out << "target=" << btd->target.ptr << " (cookie " << btd->cookie << ")" << endl
+    if (btd->target.handle < 1024) {
+        /* want to print descriptors in decimal; guess based on value */
+        out << "target.desc=" << btd->target.handle;
+    } else {
+        out << "target.ptr=" << btd->target.ptr;
+    }
+    out << " (cookie " << btd->cookie << ")" << endl
         << "code=" << TypeCode(btd->code) << ", flags=" << (void*)btd->flags << endl
         << "data=" << btd->data.ptr.buffer << " (" << (void*)btd->data_size
         << " bytes)" << endl
         << "offsets=" << btd->data.ptr.offsets << " (" << (void*)btd->offsets_size
-        << " bytes)" << endl;
+        << " bytes)";
     return btd+1;
 }
 
 static const void* printReturnCommand(TextOutput& out, const void* _cmd)
 {
-    static const int32_t N = sizeof(kReturnStrings)/sizeof(kReturnStrings[0]);
-    
+    static const size_t N = sizeof(kReturnStrings)/sizeof(kReturnStrings[0]);
     const int32_t* cmd = (const int32_t*)_cmd;
     int32_t code = *cmd++;
-    if (code == BR_ERROR) {
+    size_t cmdIndex = code & 0xff;
+    if (code == (int32_t) BR_ERROR) {
         out << "BR_ERROR: " << (void*)(*cmd++) << endl;
         return cmd;
-    } else if (code < 0 || code >= N) {
+    } else if (cmdIndex >= N) {
         out << "Unknown reply: " << code << endl;
         return cmd;
     }
+    out << kReturnStrings[cmdIndex];
     
-    out << kReturnStrings[code];
     switch (code) {
         case BR_TRANSACTION:
         case BR_REPLY: {
@@ -213,6 +203,11 @@
             const int32_t c = *cmd++;
             out << ": death cookie " << (void*)c;
         } break;
+
+        default:
+            // no details to show for: BR_OK, BR_DEAD_REPLY,
+            // BR_TRANSACTION_COMPLETE, BR_FINISHED
+            break;
     }
     
     out << endl;
@@ -221,16 +216,17 @@
 
 static const void* printCommand(TextOutput& out, const void* _cmd)
 {
-    static const int32_t N = sizeof(kCommandStrings)/sizeof(kCommandStrings[0]);
-    
+    static const size_t N = sizeof(kCommandStrings)/sizeof(kCommandStrings[0]);
     const int32_t* cmd = (const int32_t*)_cmd;
     int32_t code = *cmd++;
-    if (code < 0 || code >= N) {
+    size_t cmdIndex = code & 0xff;
+
+    if (cmdIndex >= N) {
         out << "Unknown command: " << code << endl;
         return cmd;
     }
-    
-    out << kCommandStrings[code];
+    out << kCommandStrings[cmdIndex];
+
     switch (code) {
         case BC_TRANSACTION:
         case BC_REPLY: {
@@ -254,7 +250,7 @@
         case BC_RELEASE:
         case BC_DECREFS: {
             const int32_t d = *cmd++;
-            out << ": descriptor=" << (void*)d;
+            out << ": desc=" << d;
         } break;
     
         case BC_INCREFS_DONE:
@@ -267,7 +263,7 @@
         case BC_ATTEMPT_ACQUIRE: {
             const int32_t p = *cmd++;
             const int32_t d = *cmd++;
-            out << ": decriptor=" << (void*)d << ", pri=" << p;
+            out << ": desc=" << d << ", pri=" << p;
         } break;
         
         case BC_REQUEST_DEATH_NOTIFICATION:
@@ -281,6 +277,11 @@
             const int32_t c = *cmd++;
             out << ": death cookie " << (void*)c;
         } break;
+
+        default:
+            // no details to show for: BC_REGISTER_LOOPER, BC_ENTER_LOOPER,
+            // BC_EXIT_LOOPER
+            break;
     }
     
     out << endl;
@@ -592,6 +593,7 @@
 
 status_t IPCThreadState::attemptIncStrongHandle(int32_t handle)
 {
+    LOG_REMOTEREFS("IPCThreadState::attemptIncStrongHandle(%d)\n", handle);
     mOut.writeInt32(BC_ATTEMPT_ACQUIRE);
     mOut.writeInt32(0); // xxx was thread priority
     mOut.writeInt32(handle);
@@ -772,7 +774,7 @@
     } else {
         bwr.read_size = 0;
     }
-    
+
     IF_LOG_COMMANDS() {
         TextOutput::Bundle _b(alog);
         if (outAvail != 0) {
@@ -789,7 +791,7 @@
     
     // Return immediately if there is nothing to do.
     if ((bwr.write_size == 0) && (bwr.read_size == 0)) return NO_ERROR;
-    
+
     bwr.write_consumed = 0;
     bwr.read_consumed = 0;
     status_t err;
@@ -809,7 +811,7 @@
             alog << "Finished read/write, write size = " << mOut.dataSize() << endl;
         }
     } while (err == -EINTR);
-    
+
     IF_LOG_COMMANDS() {
         alog << "Our err: " << (void*)err << ", write consumed: "
             << bwr.write_consumed << " (of " << mOut.dataSize()
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index 7e8c7fd..349b9e3 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -91,6 +91,13 @@
 #endif
 }
 
+// TODO: This implementation is flawed and can generate T-junctions
+//       in the mesh, which will in turn produce cracks when the
+//       mesh is rotated/skewed. The easiest way to fix this would
+//       be, for each row, to add new vertices shared with the previous
+//       row when the two rows share an edge.
+//       In practice, T-junctions do not appear often so this has yet
+//       to be fixed.
 void LayerRenderer::generateMesh() {
 #if RENDER_LAYERS_AS_REGIONS
     if (mLayer->region.isRect() || mLayer->region.isEmpty()) {
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index a20a88e..24784af 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -724,6 +724,8 @@
         return;
     }
 
+    // TODO: See LayerRenderer.cpp::generateMesh() for important
+    //       information about this implementation
     if (!layer->region.isEmpty()) {
         size_t count;
         const android::Rect* rects = layer->region.getArray(&count);
diff --git a/libs/utils/Static.cpp b/libs/utils/Static.cpp
index 4dfa578..ceca435 100644
--- a/libs/utils/Static.cpp
+++ b/libs/utils/Static.cpp
@@ -56,7 +56,9 @@
 protected:
     virtual status_t writeLines(const struct iovec& vec, size_t N)
     {
-        android_writevLog(&vec, N);
+        //android_writevLog(&vec, N);       <-- this is now a no-op
+        if (N != 1) LOGI("WARNING: writeLines N=%d\n", N);
+        LOGI("%.*s", vec.iov_len, (const char*) vec.iov_base);
         return NO_ERROR;
     }
 };
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index aa0a2e9..d7b8eaa 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -3758,65 +3758,33 @@
 
     /**
      * This method extracts a frame from the input file
-     * and returns the frame as a bitmap
-     *
-     * @param inputFile The inputFile
-     * @param width The width of the output frame
-     * @param height The height of the output frame
-     * @param timeMS The time in ms at which the frame has to be extracted
+     * and returns the frame as a bitmap. See getPixelsList() for more information.
      */
-    Bitmap getPixels(String inputFile, int width, int height, long timeMS) {
-        if (inputFile == null) {
-            throw new IllegalArgumentException("Invalid input file");
-        }
-
-        /* Make width and height as even */
-        final int newWidth = (width + 1) & 0xFFFFFFFE;
-        final int newHeight = (height + 1) & 0xFFFFFFFE;
-
-        /* Create a temp bitmap for resized thumbnails */
-        Bitmap tempBitmap = null;
-        if ((newWidth != width) || (newHeight != height)) {
-             tempBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);
-        }
-
-        IntBuffer rgb888 = IntBuffer.allocate(newWidth * newHeight * 4);
-        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
-        nativeGetPixels(inputFile, rgb888.array(), newWidth, newHeight, timeMS);
-
-        if ((newWidth == width) && (newHeight == height)) {
-            bitmap.copyPixelsFromBuffer(rgb888);
-        } else {
-            /* Create a temp bitmap to be used for resize */
-            tempBitmap.copyPixelsFromBuffer(rgb888);
-
-            /* Create a canvas to resize */
-            final Canvas canvas = new Canvas(bitmap);
-            canvas.drawBitmap(tempBitmap, new Rect(0, 0, newWidth, newHeight),
-                                          new Rect(0, 0, width, height), sResizePaint);
-            canvas.setBitmap(null);
-        }
-
-        if (tempBitmap != null) {
-            tempBitmap.recycle();
-        }
-
-        return bitmap;
+    Bitmap getPixels(String filename, int width, int height, long timeMs,
+            int videoRotation) {
+        final Bitmap result[] = new Bitmap[1];
+        getPixelsList(filename, width, height, timeMs, timeMs, 1, new int[] {0},
+                new MediaItem.GetThumbnailListCallback() {
+            public void onThumbnail(Bitmap bitmap, int index) {
+                result[0] = bitmap;
+            }
+        }, videoRotation);
+        return result[0];
     }
 
     /**
      * This method extracts a list of frame from the
      * input file and returns the frame in bitmap array
      *
-     * @param filename The inputFile
-     * @param width The width of the output frame
-     * @param height The height of the output frame
+     * @param filename The input file name
+     * @param width The width of the output frame, before rotation
+     * @param height The height of the output frame, before rotation
      * @param startMs The starting time in ms
      * @param endMs The end time in ms
      * @param thumbnailCount The number of frames to be extracted
      * @param indices The indices of thumbnails wanted
      * @param callback The callback used to pass back the bitmaps
-     * from startMs to endMs
+     * @param videoRotation The rotation degree need to be done for the bitmap
      *
      * @return The frames as bitmaps in bitmap array
      **/
@@ -3824,62 +3792,69 @@
             long startMs, long endMs, int thumbnailCount, int[] indices,
             final MediaItem.GetThumbnailListCallback callback,
             final int videoRotation) {
-        /* Make width and height as even */
-        final int newWidth = (width + 1) & 0xFFFFFFFE;
-        final int newHeight = (height + 1) & 0xFFFFFFFE;
-        final int thumbnailSize = newWidth * newHeight;
 
-        /* Create a temp bitmap for resized thumbnails */
-        final Bitmap tempBitmap =
-                (newWidth != width || newHeight != height)
-                ? Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888)
+        // The decoder needs output width and height as even
+        final int decWidth = (width + 1) & 0xFFFFFFFE;
+        final int decHeight = (height + 1) & 0xFFFFFFFE;
+        final int thumbnailSize = decWidth * decHeight;
+
+        // We convert the decoder output (in int[]) to a bitmap by first
+        // copy it into an IntBuffer, then use Bitmap.copyPixelsFromBuffer to
+        // copy it to the bitmap.
+        final int[] decArray = new int[thumbnailSize];
+        final IntBuffer decBuffer = IntBuffer.allocate(thumbnailSize);
+
+        // If we need to resize and/or rotate the decoder output, we need a
+        // temporary bitmap to hold the decoded output.
+        final boolean needToMassage =
+                (decWidth != width || decHeight != height || videoRotation != 0);
+        final Bitmap tmpBitmap = needToMassage
+                ? Bitmap.createBitmap(decWidth, decHeight, Bitmap.Config.ARGB_8888)
                 : null;
 
-        final int[] rgb888 = new int[thumbnailSize];
-        final IntBuffer tmpBuffer = IntBuffer.allocate(thumbnailSize);
-        nativeGetPixelsList(filename, rgb888, newWidth, newHeight,
-                thumbnailCount, videoRotation, startMs, endMs, indices,
+        // The final output bitmap width/height may swap because of rotation.
+        final boolean needToSwapWH = (videoRotation == 90 || videoRotation == 270);
+        final int outWidth = needToSwapWH ? height : width;
+        final int outHeight = needToSwapWH ? width : height;
+
+        nativeGetPixelsList(filename, decArray, decWidth, decHeight,
+                thumbnailCount, startMs, endMs, indices,
                 new NativeGetPixelsListCallback() {
             public void onThumbnail(int index) {
-                Bitmap bitmap = Bitmap.createBitmap(
-                        width, height, Bitmap.Config.ARGB_8888);
-                tmpBuffer.put(rgb888, 0, thumbnailSize);
-                tmpBuffer.rewind();
+                // This is the bitmap we will output to the client
+                Bitmap outBitmap = Bitmap.createBitmap(
+                        outWidth, outHeight, Bitmap.Config.ARGB_8888);
 
-                if ((newWidth == width) && (newHeight == height)) {
-                    bitmap.copyPixelsFromBuffer(tmpBuffer);
+                // Copy int[] to IntBuffer
+                decBuffer.put(decArray, 0, thumbnailSize);
+                decBuffer.rewind();
+
+                if (!needToMassage) {
+                    // We can directly read the decoded result to output bitmap
+                    outBitmap.copyPixelsFromBuffer(decBuffer);
                 } else {
-                    /* Copy the out rgb buffer to temp bitmap */
-                    tempBitmap.copyPixelsFromBuffer(tmpBuffer);
+                    // Copy the decoded result to an intermediate bitmap first
+                    tmpBitmap.copyPixelsFromBuffer(decBuffer);
 
-                    /* Create a canvas to resize */
-                    final Canvas canvas = new Canvas(bitmap);
-                    canvas.drawBitmap(tempBitmap,
-                            new Rect(0, 0, newWidth, newHeight),
-                            new Rect(0, 0, width, height), sResizePaint);
-
-                    canvas.setBitmap(null);
+                    // Create a canvas to resize/rotate the bitmap
+                    // First scale the decoded bitmap to (0,0)-(1,1), rotate it
+                    // with (0.5, 0.5) as center, then scale it to
+                    // (outWidth, outHeight).
+                    final Canvas canvas = new Canvas(outBitmap);
+                    Matrix m = new Matrix();
+                    float sx = 1f / decWidth;
+                    float sy = 1f / decHeight;
+                    m.postScale(sx, sy);
+                    m.postRotate(videoRotation, 0.5f, 0.5f);
+                    m.postScale(outWidth, outHeight);
+                    canvas.drawBitmap(tmpBitmap, m, sResizePaint);
                 }
-
-                if (videoRotation == 0) {
-                    callback.onThumbnail(bitmap, index);
-                } else {
-                    Matrix mtx = new Matrix();
-                    mtx.postRotate(videoRotation);
-                    Bitmap rotatedBmp =
-                        Bitmap.createBitmap(bitmap, 0, 0, width, height, mtx, false);
-                    callback.onThumbnail(rotatedBmp, index);
-
-                    if (bitmap != null) {
-                        bitmap.recycle();
-                    }
-                }
-
+                callback.onThumbnail(outBitmap, index);
             }
         });
 
-        if (tempBitmap != null) {
-            tempBitmap.recycle();
+        if (tmpBitmap != null) {
+            tmpBitmap.recycle();
         }
     }
 
@@ -3996,7 +3971,7 @@
             long timeMS);
 
     private native int nativeGetPixelsList(String fileName, int[] pixelArray,
-            int width, int height, int nosofTN, int videoRotation, long startTimeMs,
+            int width, int height, int nosofTN, long startTimeMs,
             long endTimeMs, int[] indices, NativeGetPixelsListCallback callback);
 
     /**
diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java
index 65a9e19..a862d00 100755
--- a/media/java/android/media/videoeditor/MediaImageItem.java
+++ b/media/java/android/media/videoeditor/MediaImageItem.java
@@ -606,7 +606,7 @@
     public Bitmap getThumbnail(int width, int height, long timeMs) throws IOException {
         if (getGeneratedImageClip() != null) {
             return mMANativeHelper.getPixels(getGeneratedImageClip(),
-                width, height,timeMs);
+                width, height, timeMs, 0);
         } else {
             return scaleImage(mFilename, width, height);
         }
diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index 2ce857c..bbcdf57 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -293,7 +293,14 @@
             throw new IllegalArgumentException("Invalid Dimensions");
         }
 
-        return mMANativeHelper.getPixels(super.getFilename(), width, height,timeMs);
+        if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270) {
+            int temp = width;
+            width = height;
+            height = temp;
+        }
+
+        return mMANativeHelper.getPixels(
+                getFilename(), width, height, timeMs, mVideoRotationDegree);
     }
 
     /*
@@ -318,8 +325,14 @@
             throw new IllegalArgumentException("Invalid dimension");
         }
 
-        mMANativeHelper.getPixelsList(super.getFilename(), width,
-                height, startMs, endMs, thumbnailCount, indices, callback,
+        if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270) {
+            int temp = width;
+            width = height;
+            height = temp;
+        }
+
+        mMANativeHelper.getPixelsList(getFilename(), width, height,
+                startMs, endMs, thumbnailCount, indices, callback,
                 mVideoRotationDegree);
     }
 
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index f18dd88..2446c2f 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -1825,27 +1825,10 @@
         if (mMediaItems.size() > 0) {
             MediaItem mI = mMediaItems.get(0);
             /*
-             * Lets initialize the width for default aspect ratio i.e 16:9
+             * Keep aspect ratio of the image
              */
             int height = 480;
-            int width = 854;
-            switch (mI.getAspectRatio()) {
-                case MediaProperties.ASPECT_RATIO_3_2:
-                    width = 720;
-                    break;
-                case MediaProperties.ASPECT_RATIO_4_3:
-                    width = 640;
-                    break;
-                case MediaProperties.ASPECT_RATIO_5_3:
-                    width = 800;
-                    break;
-                case MediaProperties.ASPECT_RATIO_11_9:
-                    width = 586;
-                    break;
-                case MediaProperties.ASPECT_RATIO_16_9:
-                case MediaProperties.ASPECT_RATIO_UNDEFINED:
-                    break;
-            }
+            int width = mI.getWidth() * height / mI.getHeight();
 
             Bitmap projectBitmap = null;
             String filename = mI.getFilename();
diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp
index 4e73581..4e954fc 100755
--- a/media/jni/mediaeditor/VideoEditorMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorMain.cpp
@@ -185,7 +185,6 @@
                                      M4OSA_UInt32             width,
                                      M4OSA_UInt32             height,
                                      M4OSA_UInt32             noOfThumbnails,
-                                     M4OSA_UInt32             videoRotation,
                                      jlong                    startTime,
                                      jlong                    endTime,
                                      jintArray                indexArray,
@@ -292,7 +291,7 @@
                                 (void *)videoEditor_release            },
     {"nativeGetPixels",         "(Ljava/lang/String;[IIIJ)I",
                                 (void*)videoEditor_getPixels               },
-    {"nativeGetPixelsList",     "(Ljava/lang/String;[IIIIIJJ[ILandroid/media/videoeditor/MediaArtistNativeHelper$NativeGetPixelsListCallback;)I",
+    {"nativeGetPixelsList",     "(Ljava/lang/String;[IIIIJJ[ILandroid/media/videoeditor/MediaArtistNativeHelper$NativeGetPixelsListCallback;)I",
                                 (void*)videoEditor_getPixelsList           },
     {"getMediaProperties",
     "(Ljava/lang/String;)Landroid/media/videoeditor/MediaArtistNativeHelper$Properties;",
@@ -2286,7 +2285,6 @@
                 M4OSA_UInt32            width,
                 M4OSA_UInt32            height,
                 M4OSA_UInt32            noOfThumbnails,
-                M4OSA_UInt32            videoRotation,
                 jlong                   startTime,
                 jlong                   endTime,
                 jintArray               indexArray,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
index e287b7a..06798c6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -20,7 +20,7 @@
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
-import android.animation.TimeAnimator;
+import android.animation.ValueAnimator;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
@@ -37,12 +37,12 @@
 import com.android.systemui.R;
 import com.android.systemui.SwipeHelper;
 
-import java.util.HashSet;
+import java.util.HashMap;
 
 public class NotificationRowLayout extends ViewGroup implements SwipeHelper.Callback {
     private static final String TAG = "NotificationRowLayout";
     private static final boolean DEBUG = false;
-    private static final boolean SLOW_ANIMATIONS = false; // DEBUG;
+    private static final boolean SLOW_ANIMATIONS = DEBUG;
 
     private static final boolean ANIMATE_LAYOUT = true;
 
@@ -54,8 +54,8 @@
     int mRowHeight = 0;
     int mHeight = 0;
 
-    HashSet<View> mAppearingViews = new HashSet<View>();
-    HashSet<View> mDisappearingViews = new HashSet<View>();
+    HashMap<View, ValueAnimator> mAppearingViews = new HashMap<View, ValueAnimator>();
+    HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>();
 
     private SwipeHelper mSwipeHelper;
 
@@ -166,8 +166,6 @@
         final View childF = child;
 
         if (ANIMATE_LAYOUT) {
-            mAppearingViews.add(child);
-
             child.setPivotY(0);
             final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f, 1f);
             alphaFade.setDuration(APPEAR_ANIM_LEN);
@@ -178,7 +176,11 @@
                     requestLayout(); // pick up any final changes in position
                 }
             });
+
             alphaFade.start();
+
+            mAppearingViews.put(child, alphaFade);
+
             requestLayout(); // start the container animation
         }
     }
@@ -187,27 +189,27 @@
     public void removeView(View child) {
         final View childF = child;
         if (ANIMATE_LAYOUT) {
-            if (mAppearingViews.contains(child)) {
+            if (mAppearingViews.containsKey(child)) {
                 mAppearingViews.remove(child);
             }
-            mDisappearingViews.add(child);
-
             child.setPivotY(0);
 
             final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f);
+            alphaFade.setDuration(DISAPPEAR_ANIM_LEN);
             alphaFade.addListener(new AnimatorListenerAdapter() {
                 @Override
                 public void onAnimationEnd(Animator animation) {
                     if (DEBUG) Slog.d(TAG, "actually removing child: " + childF);
                     NotificationRowLayout.super.removeView(childF);
-                    childF.setAlpha(1f);
                     mDisappearingViews.remove(childF);
                     requestLayout(); // pick up any final changes in position
                 }
             });
 
-            alphaFade.setDuration(DISAPPEAR_ANIM_LEN);
             alphaFade.start();
+
+            mDisappearingViews.put(child, alphaFade);
+
             requestLayout(); // start the container animation
         } else {
             super.removeView(child);
@@ -246,7 +248,7 @@
             if (child.getVisibility() == GONE) {
                 continue;
             }
-            if (mDisappearingViews.contains(child)) {
+            if (mDisappearingViews.containsKey(child)) {
                 continue;
             }
             numRows++;
@@ -304,14 +306,19 @@
             if (child.getVisibility() == GONE) {
                 continue;
             }
-            float alpha = child.getAlpha();
-            if (alpha > 1.0f) {
-                if (DEBUG) {
-                    Slog.w(TAG, "alpha=" + alpha + " > 1!!! " + child);
-                }
-                alpha = 1f;
+            float progress = 1.0f;
+            if (mDisappearingViews.containsKey(child)) {
+                progress = 1.0f - mDisappearingViews.get(child).getAnimatedFraction();
+            } else if (mAppearingViews.containsKey(child)) {
+                progress = 1.0f - mAppearingViews.get(child).getAnimatedFraction();
             }
-            final int thisRowHeight = (int)(alpha * mRowHeight);
+            if (progress > 1.0f) {
+                if (DEBUG) {
+                    Slog.w(TAG, "progress=" + progress + " > 1!!! " + child);
+                }
+                progress = 1f;
+            }
+            final int thisRowHeight = (int)(progress * mRowHeight);
             if (DEBUG) {
                 Slog.d(TAG, String.format(
                             "laying out child #%d: (0, %d, %d, %d) h=%d",
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index b69a7c2..f5e3a45 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -384,7 +384,7 @@
                 st.menu.stopDispatchingItemsChanged();
                 if ((cb == null) || !cb.onCreatePanelMenu(st.featureId, st.menu)) {
                     // Ditch the menu created above
-                    st.menu = null;
+                    st.setMenu(null);
 
                     if (mActionBar != null) {
                         // Don't show it in the action bar either
@@ -3207,7 +3207,17 @@
         }
 
         void setMenu(MenuBuilder menu) {
+            if (menu == this.menu) return;
+
+            if (this.menu != null) {
+                this.menu.removeMenuPresenter(iconMenuPresenter);
+                this.menu.removeMenuPresenter(listMenuPresenter);
+            }
             this.menu = menu;
+            if (menu != null) {
+                if (iconMenuPresenter != null) menu.addMenuPresenter(iconMenuPresenter);
+                if (listMenuPresenter != null) menu.addMenuPresenter(listMenuPresenter);
+            }
         }
 
         MenuView getListMenuView(MenuPresenter.Callback cb) {
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 1497511..f774dea 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -98,6 +98,7 @@
     public static final String LIMIT_GLOBAL_ALERT = "globalAlert";
 
     /** {@link #mStatsXtUid} headers. */
+    private static final String KEY_IDX = "idx";
     private static final String KEY_IFACE = "iface";
     private static final String KEY_UID = "uid_tag_int";
     private static final String KEY_COUNTER_SET = "cnt_set";
@@ -1323,17 +1324,20 @@
 
         // TODO: remove knownLines check once 5087722 verified
         final HashSet<String> knownLines = Sets.newHashSet();
+        // TODO: remove lastIdx check once 5270106 verified
+        int lastIdx = 0;
 
         final ArrayList<String> keys = Lists.newArrayList();
         final ArrayList<String> values = Lists.newArrayList();
         final HashMap<String, String> parsed = Maps.newHashMap();
 
         BufferedReader reader = null;
+        String line = null;
         try {
             reader = new BufferedReader(new FileReader(mStatsXtUid));
 
             // parse first line as header
-            String line = reader.readLine();
+            line = reader.readLine();
             splitLine(line, keys);
 
             // parse remaining lines
@@ -1342,32 +1346,35 @@
                 parseLine(keys, values, parsed);
 
                 if (!knownLines.add(line)) {
-                    throw new IllegalStateException("encountered duplicate proc entry");
+                    throw new IllegalStateException("duplicate proc entry: " + line);
                 }
 
-                try {
-                    entry.iface = parsed.get(KEY_IFACE);
-                    entry.uid = getParsedInt(parsed, KEY_UID);
-                    entry.set = getParsedInt(parsed, KEY_COUNTER_SET);
-                    entry.tag = kernelToTag(parsed.get(KEY_TAG_HEX));
-                    entry.rxBytes = getParsedLong(parsed, KEY_RX_BYTES);
-                    entry.rxPackets = getParsedLong(parsed, KEY_RX_PACKETS);
-                    entry.txBytes = getParsedLong(parsed, KEY_TX_BYTES);
-                    entry.txPackets = getParsedLong(parsed, KEY_TX_PACKETS);
+                final int idx = getParsedInt(parsed, KEY_IDX);
+                if (idx > lastIdx + 1) {
+                    throw new IllegalStateException(
+                            "inconsistent idx=" + idx + " after lastIdx=" + lastIdx);
+                }
+                lastIdx = idx;
 
-                    if (limitUid == UID_ALL || limitUid == entry.uid) {
-                        stats.addValues(entry);
-                    }
-                } catch (NumberFormatException e) {
-                    Slog.w(TAG, "problem parsing stats row '" + line + "': " + e);
+                entry.iface = parsed.get(KEY_IFACE);
+                entry.uid = getParsedInt(parsed, KEY_UID);
+                entry.set = getParsedInt(parsed, KEY_COUNTER_SET);
+                entry.tag = kernelToTag(parsed.get(KEY_TAG_HEX));
+                entry.rxBytes = getParsedLong(parsed, KEY_RX_BYTES);
+                entry.rxPackets = getParsedLong(parsed, KEY_RX_PACKETS);
+                entry.txBytes = getParsedLong(parsed, KEY_TX_BYTES);
+                entry.txPackets = getParsedLong(parsed, KEY_TX_PACKETS);
+
+                if (limitUid == UID_ALL || limitUid == entry.uid) {
+                    stats.addValues(entry);
                 }
             }
         } catch (NullPointerException e) {
-            throw new IllegalStateException("problem parsing stats: " + e);
+            throw new IllegalStateException("problem parsing line: " + line, e);
         } catch (NumberFormatException e) {
-            throw new IllegalStateException("problem parsing stats: " + e);
+            throw new IllegalStateException("problem parsing line: " + line, e);
         } catch (IOException e) {
-            throw new IllegalStateException("problem parsing stats: " + e);
+            throw new IllegalStateException("problem parsing line: " + line, e);
         } finally {
             IoUtils.closeQuietly(reader);
         }
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9db56ce..57bfaed 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -106,6 +106,7 @@
 import android.os.SystemProperties;
 import android.provider.Settings;
 import android.util.EventLog;
+import android.util.Pair;
 import android.util.Slog;
 import android.util.Log;
 import android.util.PrintWriterPrinter;
@@ -5004,7 +5005,13 @@
                             maxNum < N ? maxNum : N);
             for (int i=0; i<N && maxNum > 0; i++) {
                 TaskRecord tr = mRecentTasks.get(i);
-                if (((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0)
+                // Return the entry if desired by the caller.  We always return
+                // the first entry, because callers always expect this to be the
+                // forground app.  We may filter others if the caller has
+                // not supplied RECENT_WITH_EXCLUDED and there is some reason
+                // we should exclude the entry.
+                if (i == 0
+                        || ((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0)
                         || (tr.intent == null)
                         || ((tr.intent.getFlags()
                                 &Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
@@ -7546,7 +7553,33 @@
 
         return errList;
     }
-    
+
+    static int oomAdjToImportance(int adj, ActivityManager.RunningAppProcessInfo currApp) {
+        if (adj >= ProcessList.EMPTY_APP_ADJ) {
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY;
+        } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) {
+            if (currApp != null) {
+                currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1;
+            }
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
+        } else if (adj >= ProcessList.HOME_APP_ADJ) {
+            if (currApp != null) {
+                currApp.lru = 0;
+            }
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
+        } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) {
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
+        } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) {
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE;
+        } else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) {
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
+        } else if (adj >= ProcessList.VISIBLE_APP_ADJ) {
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
+        } else {
+            return ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
+        }
+    }
+
     public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() {
         // Lazy instantiation of list
         List<ActivityManager.RunningAppProcessInfo> runList = null;
@@ -7567,28 +7600,12 @@
                         currApp.flags |= ActivityManager.RunningAppProcessInfo.FLAG_PERSISTENT;
                     }
                     int adj = app.curAdj;
-                    if (adj >= ProcessList.EMPTY_APP_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY;
-                    } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
-                        currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1;
-                    } else if (adj >= ProcessList.HOME_APP_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
-                        currApp.lru = 0;
-                    } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
-                    } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE;
-                    } else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
-                    } else if (adj >= ProcessList.VISIBLE_APP_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
-                    } else {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
-                    }
+                    currApp.importance = oomAdjToImportance(adj, currApp);
                     currApp.importanceReasonCode = app.adjTypeCode;
                     if (app.adjSource instanceof ProcessRecord) {
                         currApp.importanceReasonPid = ((ProcessRecord)app.adjSource).pid;
+                        currApp.importanceReasonImportance = oomAdjToImportance(
+                                app.adjSourceOom, null);
                     } else if (app.adjSource instanceof ActivityRecord) {
                         ActivityRecord r = (ActivityRecord)app.adjSource;
                         if (r.app != null) currApp.importanceReasonPid = r.app.pid;
@@ -7891,7 +7908,7 @@
         if (mLruProcesses.size() > 0) {
             if (needSep) pw.println(" ");
             needSep = true;
-            pw.println("  Process LRU list (most recent first):");
+            pw.println("  Process LRU list (sorted by oom_adj):");
             dumpProcessOomList(pw, this, mLruProcesses, "    ",
                     "Proc", "PERS", false);
             needSep = true;
@@ -8069,29 +8086,6 @@
         boolean needSep = false;
 
         if (mLruProcesses.size() > 0) {
-            ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mLruProcesses);
-
-            Comparator<ProcessRecord> comparator = new Comparator<ProcessRecord>() {
-                @Override
-                public int compare(ProcessRecord object1, ProcessRecord object2) {
-                    if (object1.setAdj != object2.setAdj) {
-                        return object1.setAdj > object2.setAdj ? -1 : 1;
-                    }
-                    if (object1.setSchedGroup != object2.setSchedGroup) {
-                        return object1.setSchedGroup > object2.setSchedGroup ? -1 : 1;
-                    }
-                    if (object1.keeping != object2.keeping) {
-                        return object1.keeping ? -1 : 1;
-                    }
-                    if (object1.pid != object2.pid) {
-                        return object1.pid > object2.pid ? -1 : 1;
-                    }
-                    return 0;
-                }
-            };
-
-            Collections.sort(procs, comparator);
-
             if (needSep) pw.println(" ");
             needSep = true;
             pw.println("  OOM levels:");
@@ -8110,7 +8104,7 @@
             if (needSep) pw.println(" ");
             needSep = true;
             pw.println("  Process OOM control:");
-            dumpProcessOomList(pw, this, procs, "    ",
+            dumpProcessOomList(pw, this, mLruProcesses, "    ",
                     "Proc", "PERS", true);
             needSep = true;
         }
@@ -8859,10 +8853,33 @@
     }
 
     private static final void dumpProcessOomList(PrintWriter pw,
-            ActivityManagerService service, List<ProcessRecord> list,
+            ActivityManagerService service, List<ProcessRecord> origList,
             String prefix, String normalLabel, String persistentLabel,
             boolean inclDetails) {
 
+        ArrayList<Pair<ProcessRecord, Integer>> list
+                = new ArrayList<Pair<ProcessRecord, Integer>>(origList.size());
+        for (int i=0; i<origList.size(); i++) {
+            list.add(new Pair<ProcessRecord, Integer>(origList.get(i), i));
+        }
+
+        Comparator<Pair<ProcessRecord, Integer>> comparator
+                = new Comparator<Pair<ProcessRecord, Integer>>() {
+            @Override
+            public int compare(Pair<ProcessRecord, Integer> object1,
+                    Pair<ProcessRecord, Integer> object2) {
+                if (object1.first.setAdj != object2.first.setAdj) {
+                    return object1.first.setAdj > object2.first.setAdj ? -1 : 1;
+                }
+                if (object1.second.intValue() != object2.second.intValue()) {
+                    return object1.second.intValue() > object2.second.intValue() ? -1 : 1;
+                }
+                return 0;
+            }
+        };
+
+        Collections.sort(list, comparator);
+
         final long curRealtime = SystemClock.elapsedRealtime();
         final long realtimeSince = curRealtime - service.mLastPowerCheckRealtime;
         final long curUptime = SystemClock.uptimeMillis();
@@ -8870,7 +8887,7 @@
 
         final int N = list.size()-1;
         for (int i=N; i>=0; i--) {
-            ProcessRecord r = list.get(i);
+            ProcessRecord r = list.get(i).first;
             String oomAdj;
             if (r.setAdj >= ProcessList.EMPTY_APP_ADJ) {
                 oomAdj = buildOomTag("empty", null, r.setAdj, ProcessList.EMPTY_APP_ADJ);
@@ -8919,7 +8936,7 @@
             }
             pw.println(String.format("%s%s #%2d: adj=%s/%s%s trm=%2d %s (%s)",
                     prefix, (r.persistent ? persistentLabel : normalLabel),
-                    N-i, oomAdj, schedGroup, foreground, r.trimMemoryLevel,
+                    N-list.get(i).second, oomAdj, schedGroup, foreground, r.trimMemoryLevel,
                     r.toShortString(), r.adjType));
             if (r.adjSource != null || r.adjTarget != null) {
                 pw.print(prefix);
@@ -13118,6 +13135,7 @@
                                     app.adjTypeCode = ActivityManager.RunningAppProcessInfo
                                             .REASON_SERVICE_IN_USE;
                                     app.adjSource = cr.binding.client;
+                                    app.adjSourceOom = clientAdj;
                                     app.adjTarget = s.name;
                                 }
                                 if ((cr.flags&Context.BIND_NOT_FOREGROUND) == 0) {
@@ -13140,6 +13158,7 @@
                                     app.adjTypeCode = ActivityManager.RunningAppProcessInfo
                                             .REASON_SERVICE_IN_USE;
                                     app.adjSource = a;
+                                    app.adjSourceOom = adj;
                                     app.adjTarget = s.name;
                                 }
                             }
@@ -13201,6 +13220,7 @@
                             app.adjTypeCode = ActivityManager.RunningAppProcessInfo
                                     .REASON_PROVIDER_IN_USE;
                             app.adjSource = client;
+                            app.adjSourceOom = clientAdj;
                             app.adjTarget = cpr.name;
                         }
                         if (client.curSchedGroup == Process.THREAD_GROUP_DEFAULT) {
@@ -13511,16 +13531,21 @@
         computeOomAdjLocked(app, hiddenAdj, TOP_APP, false);
 
         if (app.curRawAdj != app.setRawAdj) {
-            if (app.curRawAdj > ProcessList.FOREGROUND_APP_ADJ
-                    && app.setRawAdj <= ProcessList.FOREGROUND_APP_ADJ) {
-                // If this app is transitioning from foreground to
-                // non-foreground, have it do a gc.
-                scheduleAppGcLocked(app);
-            } else if (app.curRawAdj >= ProcessList.HIDDEN_APP_MIN_ADJ
-                    && app.setRawAdj < ProcessList.HIDDEN_APP_MIN_ADJ) {
-                // Likewise do a gc when an app is moving in to the
-                // background (such as a service stopping).
-                scheduleAppGcLocked(app);
+            if (false) {
+                // Removing for now.  Forcing GCs is not so useful anymore
+                // with Dalvik, and the new memory level hint facility is
+                // better for what we need to do these days.
+                if (app.curRawAdj > ProcessList.FOREGROUND_APP_ADJ
+                        && app.setRawAdj <= ProcessList.FOREGROUND_APP_ADJ) {
+                    // If this app is transitioning from foreground to
+                    // non-foreground, have it do a gc.
+                    scheduleAppGcLocked(app);
+                } else if (app.curRawAdj >= ProcessList.HIDDEN_APP_MIN_ADJ
+                        && app.setRawAdj < ProcessList.HIDDEN_APP_MIN_ADJ) {
+                    // Likewise do a gc when an app is moving in to the
+                    // background (such as a service stopping).
+                    scheduleAppGcLocked(app);
+                }
             }
 
             if (wasKeeping && !app.keeping) {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 4ad0f45..a0aedf9 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1151,6 +1151,7 @@
                     try {
                         mService.mWindowManager.setAppVisibility(r, true);
                         r.sleeping = false;
+                        r.app.pendingUiClean = true;
                         r.app.thread.scheduleWindowVisibility(r, true);
                         r.stopFreezingScreenLocked(false);
                     } catch (Exception e) {
@@ -1497,6 +1498,7 @@
                 
                 next.sleeping = false;
                 showAskCompatModeDialogLocked(next);
+                next.app.pendingUiClean = true;
                 next.app.thread.scheduleResumeActivity(next,
                         mService.isNextTransitionForward());
                 
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index 24d92cf..9392bb4 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -99,6 +99,7 @@
     String adjType;             // Debugging: primary thing impacting oom_adj.
     int adjTypeCode;            // Debugging: adj code to report to app.
     Object adjSource;           // Debugging: option dependent object.
+    int adjSourceOom;           // Debugging: oom_adj of adjSource's process.
     Object adjTarget;           // Debugging: target component impacting oom_adj.
     
     // contains HistoryRecord objects
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 8af90ff..9067fae 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -100,6 +100,7 @@
 import android.telephony.TelephonyManager;
 import android.text.format.Formatter;
 import android.text.format.Time;
+import android.util.Log;
 import android.util.NtpTrustedTime;
 import android.util.Slog;
 import android.util.SparseArray;
@@ -298,18 +299,9 @@
 
         try {
             mActivityManager.registerProcessObserver(mProcessObserver);
-        } catch (RemoteException e) {
-            // ouch, no foregroundActivities updates means some processes may
-            // never get network access.
-            Slog.e(TAG, "unable to register IProcessObserver", e);
-        }
-
-        try {
             mNetworkManager.registerObserver(mAlertObserver);
         } catch (RemoteException e) {
-            // ouch, no alert updates means we fall back to
-            // ACTION_NETWORK_STATS_UPDATED broadcasts.
-            Slog.e(TAG, "unable to register INetworkManagementEventObserver", e);
+            // ignored; both services live in system_server
         }
 
         // TODO: traverse existing processes to know foreground state, or have
@@ -462,7 +454,7 @@
                         // caused alert to trigger.
                         mNetworkStats.forceUpdate();
                     } catch (RemoteException e) {
-                        Slog.w(TAG, "problem updating network stats");
+                        // ignored; service lives in system_server
                     }
 
                     updateNetworkEnabledLocked();
@@ -495,9 +487,7 @@
 
             final long start = computeLastCycleBoundary(currentTime, policy);
             final long end = currentTime;
-
             final long totalBytes = getTotalBytes(policy.template, start, end);
-            if (totalBytes == UNKNOWN_BYTES) continue;
 
             if (policy.limitBytes != LIMIT_DISABLED && totalBytes >= policy.limitBytes) {
                 if (policy.lastSnooze >= start) {
@@ -671,7 +661,7 @@
                     packageName, tag, 0x0, builder.getNotification(), idReceived);
             mActiveNotifs.add(tag);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem during enqueueNotification: " + e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -705,7 +695,7 @@
                     0x0, builder.getNotification(), idReceived);
             mActiveNotifs.add(tag);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem during enqueueNotification: " + e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -716,7 +706,7 @@
             mNotifManager.cancelNotificationWithTag(
                     packageName, tag, 0x0);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem during enqueueNotification: " + e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -758,9 +748,7 @@
 
             final long start = computeLastCycleBoundary(currentTime, policy);
             final long end = currentTime;
-
             final long totalBytes = getTotalBytes(policy.template, start, end);
-            if (totalBytes == UNKNOWN_BYTES) continue;
 
             // disable data connection when over limit and not snoozed
             final boolean overLimit = policy.limitBytes != LIMIT_DISABLED
@@ -810,7 +798,7 @@
         try {
             states = mConnManager.getAllNetworkState();
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem reading network state");
+            // ignored; service lives in system_server
             return;
         }
 
@@ -857,9 +845,7 @@
 
             final long start = computeLastCycleBoundary(currentTime, policy);
             final long end = currentTime;
-
             final long totalBytes = getTotalBytes(policy.template, start, end);
-            if (totalBytes == UNKNOWN_BYTES) continue;
 
             if (LOGD) {
                 Slog.d(TAG, "applying policy " + policy.toString() + " to ifaces "
@@ -1006,9 +992,9 @@
             // missing policy is okay, probably first boot
             upgradeLegacyBackgroundData();
         } catch (IOException e) {
-            Slog.e(TAG, "problem reading network stats", e);
+            Log.wtf(TAG, "problem reading network policy", e);
         } catch (XmlPullParserException e) {
-            Slog.e(TAG, "problem reading network stats", e);
+            Log.wtf(TAG, "problem reading network policy", e);
         } finally {
             IoUtils.closeQuietly(fis);
         }
@@ -1246,12 +1232,10 @@
 
         final long currentTime = currentTimeMillis(false);
 
+        // find total bytes used under policy
         final long start = computeLastCycleBoundary(currentTime, policy);
         final long end = currentTime;
-
-        // find total bytes used under policy
         final long totalBytes = getTotalBytes(policy.template, start, end);
-        if (totalBytes == UNKNOWN_BYTES) return null;
 
         // report soft and hard limits under policy
         final long softLimitBytes = policy.warningBytes != WARNING_DISABLED ? policy.warningBytes
@@ -1369,6 +1353,7 @@
             try {
                 mScreenOn = mPowerManager.isScreenOn();
             } catch (RemoteException e) {
+                // ignored; service lives in system_server
             }
             updateRulesForScreenLocked();
         }
@@ -1448,7 +1433,7 @@
             // adjust stats accounting based on foreground status
             mNetworkStats.setUidForeground(uid, uidForeground);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem dispatching foreground change");
+            // ignored; service lives in system_server
         }
     }
 
@@ -1498,9 +1483,9 @@
         try {
             mNetworkManager.setInterfaceQuota(iface, quotaBytes);
         } catch (IllegalStateException e) {
-            Slog.e(TAG, "problem setting interface quota", e);
+            Log.wtf(TAG, "problem setting interface quota", e);
         } catch (RemoteException e) {
-            Slog.e(TAG, "problem setting interface quota", e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -1508,29 +1493,9 @@
         try {
             mNetworkManager.removeInterfaceQuota(iface);
         } catch (IllegalStateException e) {
-            Slog.e(TAG, "problem removing interface quota", e);
+            Log.wtf(TAG, "problem removing interface quota", e);
         } catch (RemoteException e) {
-            Slog.e(TAG, "problem removing interface quota", e);
-        }
-    }
-
-    private void setInterfaceAlert(String iface, long alertBytes) {
-        try {
-            mNetworkManager.setInterfaceAlert(iface, alertBytes);
-        } catch (IllegalStateException e) {
-            Slog.e(TAG, "problem setting interface alert", e);
-        } catch (RemoteException e) {
-            Slog.e(TAG, "problem setting interface alert", e);
-        }
-    }
-
-    private void removeInterfaceAlert(String iface) {
-        try {
-            mNetworkManager.removeInterfaceAlert(iface);
-        } catch (IllegalStateException e) {
-            Slog.e(TAG, "problem removing interface alert", e);
-        } catch (RemoteException e) {
-            Slog.e(TAG, "problem removing interface alert", e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -1538,9 +1503,9 @@
         try {
             mNetworkManager.setUidNetworkRules(uid, rejectOnQuotaInterfaces);
         } catch (IllegalStateException e) {
-            Slog.e(TAG, "problem setting uid rules", e);
+            Log.wtf(TAG, "problem setting uid rules", e);
         } catch (RemoteException e) {
-            Slog.e(TAG, "problem setting uid rules", e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -1556,7 +1521,7 @@
             try {
                 mConnManager.setPolicyDataEnable(networkType, enabled);
             } catch (RemoteException e) {
-                Slog.e(TAG, "problem setting network enabled", e);
+                // ignored; service lives in system_server
             }
 
             mActiveNetworkEnabled.put(networkType, enabled);
@@ -1569,8 +1534,6 @@
         return telephony.getSubscriberId();
     }
 
-    private static final long UNKNOWN_BYTES = -1;
-
     private long getTotalBytes(NetworkTemplate template, long start, long end) {
         try {
             final NetworkStats stats = mNetworkStats.getSummaryForNetwork(
@@ -1578,8 +1541,8 @@
             final NetworkStats.Entry entry = stats.getValues(0, null);
             return entry.rxBytes + entry.txBytes;
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem reading summary for template " + template);
-            return UNKNOWN_BYTES;
+            // ignored; service lives in system_server
+            return 0;
         }
     }
 
diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java
index 4d54fd4..af29d85 100644
--- a/services/java/com/android/server/net/NetworkStatsService.java
+++ b/services/java/com/android/server/net/NetworkStatsService.java
@@ -79,6 +79,7 @@
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.util.EventLog;
+import android.util.Log;
 import android.util.NtpTrustedTime;
 import android.util.Slog;
 import android.util.SparseIntArray;
@@ -128,7 +129,16 @@
     private static final int VERSION_UID_WITH_SET = 4;
 
     private static final int MSG_PERFORM_POLL = 0x1;
-    private static final int MSG_PERFORM_POLL_DETAILED = 0x2;
+
+    /** Flags to control detail level of poll event. */
+    private static final int FLAG_POLL_NETWORK = 0x1;
+    private static final int FLAG_POLL_UID = 0x2;
+    private static final int FLAG_PERSIST_NETWORK = 0x10;
+    private static final int FLAG_PERSIST_UID = 0x20;
+    private static final int FLAG_FORCE_PERSIST = 0x100;
+
+    private static final int FLAG_POLL_ALL = FLAG_POLL_NETWORK | FLAG_POLL_UID;
+    private static final int FLAG_PERSIST_ALL = FLAG_PERSIST_NETWORK | FLAG_PERSIST_UID;
 
     private final Context mContext;
     private final INetworkManagementService mNetworkManager;
@@ -261,9 +271,7 @@
         try {
             mNetworkManager.registerObserver(mAlertObserver);
         } catch (RemoteException e) {
-            // ouch, no push updates means we fall back to
-            // ACTION_NETWORK_STATS_POLL intervals.
-            Slog.e(TAG, "unable to register INetworkManagementEventObserver", e);
+            // ignored; service lives in system_server
         }
 
         registerPollAlarmLocked();
@@ -305,7 +313,7 @@
             mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, currentRealtime,
                     mSettings.getPollInterval(), mPollIntent);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem registering for poll alarm: " + e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -321,7 +329,7 @@
         } catch (IllegalStateException e) {
             Slog.w(TAG, "problem registering for global alert: " + e);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem registering for global alert: " + e);
+            // ignored; service lives in system_server
         }
     }
 
@@ -509,7 +517,7 @@
     @Override
     public void forceUpdate() {
         mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
-        performPoll(true, false);
+        performPoll(FLAG_POLL_ALL | FLAG_PERSIST_ALL);
     }
 
     /**
@@ -538,7 +546,7 @@
         public void onReceive(Context context, Intent intent) {
             // on background handler thread, and verified UPDATE_DEVICE_STATS
             // permission above.
-            performPoll(true, false);
+            performPoll(FLAG_POLL_ALL | FLAG_PERSIST_ALL);
 
             // verify that we're watching global alert
             registerGlobalAlert();
@@ -585,7 +593,8 @@
             if (LIMIT_GLOBAL_ALERT.equals(limitName)) {
                 // kick off background poll to collect network stats; UID stats
                 // are handled during normal polling interval.
-                mHandler.obtainMessage(MSG_PERFORM_POLL).sendToTarget();
+                final int flags = FLAG_POLL_NETWORK | FLAG_PERSIST_NETWORK;
+                mHandler.obtainMessage(MSG_PERFORM_POLL, flags, 0).sendToTarget();
 
                 // re-arm global alert for next update
                 registerGlobalAlert();
@@ -605,13 +614,17 @@
         // take one last stats snapshot before updating iface mapping. this
         // isn't perfect, since the kernel may already be counting traffic from
         // the updated network.
-        performPollLocked(false, false);
+
+        // poll both network and UID stats, but only persist network stats,
+        // since this codepath should stay fast. UID stats will be persisted
+        // during next alarm poll event.
+        performPollLocked(FLAG_POLL_ALL | FLAG_PERSIST_NETWORK);
 
         final NetworkState[] states;
         try {
             states = mConnManager.getAllNetworkState();
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem reading network state");
+            // ignored; service lives in system_server
             return;
         }
 
@@ -646,15 +659,15 @@
         } catch (IllegalStateException e) {
             Slog.w(TAG, "problem reading network stats: " + e);
         } catch (RemoteException e) {
-            Slog.w(TAG, "problem reading network stats: " + e);
+            // ignored; service lives in system_server
         }
     }
 
-    private void performPoll(boolean detailedPoll, boolean forcePersist) {
+    private void performPoll(int flags) {
         synchronized (mStatsLock) {
             mWakeLock.acquire();
             try {
-                performPollLocked(detailedPoll, forcePersist);
+                performPollLocked(flags);
             } finally {
                 mWakeLock.release();
             }
@@ -664,14 +677,17 @@
     /**
      * Periodic poll operation, reading current statistics and recording into
      * {@link NetworkStatsHistory}.
-     *
-     * @param detailedPoll Indicate if detailed UID stats should be collected
-     *            during this poll operation.
      */
-    private void performPollLocked(boolean detailedPoll, boolean forcePersist) {
-        if (LOGV) Slog.v(TAG, "performPollLocked()");
+    private void performPollLocked(int flags) {
+        if (LOGV) Slog.v(TAG, "performPollLocked(flags=0x" + Integer.toHexString(flags) + ")");
         final long startRealtime = SystemClock.elapsedRealtime();
 
+        final boolean pollNetwork = (flags & FLAG_POLL_NETWORK) != 0;
+        final boolean pollUid = (flags & FLAG_POLL_UID) != 0;
+        final boolean persistNetwork = (flags & FLAG_PERSIST_NETWORK) != 0;
+        final boolean persistUid = (flags & FLAG_PERSIST_UID) != 0;
+        final boolean forcePersist = (flags & FLAG_FORCE_PERSIST) != 0;
+
         // try refreshing time source when stale
         if (mTime.getCacheAge() > mSettings.getTimeCacheMaxAge()) {
             mTime.forceRefresh();
@@ -680,41 +696,40 @@
         // TODO: consider marking "untrusted" times in historical stats
         final long currentTime = mTime.hasCache() ? mTime.currentTimeMillis()
                 : System.currentTimeMillis();
-        final long persistThreshold = mSettings.getPersistThreshold();
+        final long threshold = mSettings.getPersistThreshold();
 
-        final NetworkStats networkSnapshot;
-        final NetworkStats uidSnapshot;
         try {
-            networkSnapshot = mNetworkManager.getNetworkStatsSummary();
-            uidSnapshot = detailedPoll ? mNetworkManager.getNetworkStatsUidDetail(UID_ALL) : null;
-        } catch (IllegalStateException e) {
-            Slog.w(TAG, "problem reading network stats: " + e);
-            return;
-        } catch (RemoteException e) {
-            Slog.w(TAG, "problem reading network stats: " + e);
-            return;
-        }
+            if (pollNetwork) {
+                final NetworkStats networkSnapshot = mNetworkManager.getNetworkStatsSummary();
+                performNetworkPollLocked(networkSnapshot, currentTime);
 
-        performNetworkPollLocked(networkSnapshot, currentTime);
-
-        // persist when enough network data has occurred
-        final NetworkStats persistNetworkDelta = computeStatsDelta(
-                mLastPersistNetworkSnapshot, networkSnapshot, true);
-        if (forcePersist || persistNetworkDelta.getTotalBytes() > persistThreshold) {
-            writeNetworkStatsLocked();
-            mLastPersistNetworkSnapshot = networkSnapshot;
-        }
-
-        if (detailedPoll) {
-            performUidPollLocked(uidSnapshot, currentTime);
-
-            // persist when enough network data has occurred
-            final NetworkStats persistUidDelta = computeStatsDelta(
-                    mLastPersistUidSnapshot, uidSnapshot, true);
-            if (forcePersist || persistUidDelta.getTotalBytes() > persistThreshold) {
-                writeUidStatsLocked();
-                mLastPersistUidSnapshot = networkSnapshot;
+                // persist when enough network data has occurred
+                final NetworkStats persistNetworkDelta = computeStatsDelta(
+                        mLastPersistNetworkSnapshot, networkSnapshot, true);
+                final boolean pastThreshold = persistNetworkDelta.getTotalBytes() > threshold;
+                if (forcePersist || (persistNetwork && pastThreshold)) {
+                    writeNetworkStatsLocked();
+                    mLastPersistNetworkSnapshot = networkSnapshot;
+                }
             }
+
+            if (pollUid) {
+                final NetworkStats uidSnapshot = mNetworkManager.getNetworkStatsUidDetail(UID_ALL);
+                performUidPollLocked(uidSnapshot, currentTime);
+
+                // persist when enough network data has occurred
+                final NetworkStats persistUidDelta = computeStatsDelta(
+                        mLastPersistUidSnapshot, uidSnapshot, true);
+                final boolean pastThreshold = persistUidDelta.getTotalBytes() > threshold;
+                if (forcePersist || (persistUid && pastThreshold)) {
+                    writeUidStatsLocked();
+                    mLastPersistUidSnapshot = uidSnapshot;
+                }
+            }
+        } catch (IllegalStateException e) {
+            Log.wtf(TAG, "problem reading network stats", e);
+        } catch (RemoteException e) {
+            // ignored; service lives in system_server
         }
 
         if (LOGV) {
@@ -722,8 +737,8 @@
             Slog.v(TAG, "performPollLocked() took " + duration + "ms");
         }
 
-        // sample stats after detailed poll
-        if (detailedPoll) {
+        // sample stats after each full poll
+        if (pollNetwork && pollUid) {
             performSample();
         }
 
@@ -785,6 +800,10 @@
             entry = delta.getValues(i, entry);
             final NetworkIdentitySet ident = mActiveIfaces.get(entry.iface);
             if (ident == null) {
+                if (entry.rxBytes > 0 || entry.rxPackets > 0 || entry.txBytes > 0
+                        || entry.txPackets > 0) {
+                    Log.w(TAG, "dropping UID delta from unknown iface: " + entry);
+                }
                 continue;
             }
 
@@ -959,7 +978,7 @@
         } catch (FileNotFoundException e) {
             // missing stats is okay, probably first boot
         } catch (IOException e) {
-            Slog.e(TAG, "problem reading network stats", e);
+            Log.wtf(TAG, "problem reading network stats", e);
         } finally {
             IoUtils.closeQuietly(in);
         }
@@ -1032,7 +1051,7 @@
         } catch (FileNotFoundException e) {
             // missing stats is okay, probably first boot
         } catch (IOException e) {
-            Slog.e(TAG, "problem reading uid stats", e);
+            Log.wtf(TAG, "problem reading uid stats", e);
         } finally {
             IoUtils.closeQuietly(in);
         }
@@ -1061,7 +1080,7 @@
             out.flush();
             mNetworkFile.finishWrite(fos);
         } catch (IOException e) {
-            Slog.w(TAG, "problem writing stats: ", e);
+            Log.wtf(TAG, "problem writing stats", e);
             if (fos != null) {
                 mNetworkFile.failWrite(fos);
             }
@@ -1115,7 +1134,7 @@
             out.flush();
             mUidFile.finishWrite(fos);
         } catch (IOException e) {
-            Slog.w(TAG, "problem writing stats: ", e);
+            Log.wtf(TAG, "problem writing stats", e);
             if (fos != null) {
                 mUidFile.failWrite(fos);
             }
@@ -1142,7 +1161,7 @@
             }
 
             if (argSet.contains("poll")) {
-                performPollLocked(true, true);
+                performPollLocked(FLAG_POLL_ALL | FLAG_PERSIST_ALL | FLAG_FORCE_PERSIST);
                 pw.println("Forced poll");
                 return;
             }
@@ -1273,11 +1292,8 @@
         public boolean handleMessage(Message msg) {
             switch (msg.what) {
                 case MSG_PERFORM_POLL: {
-                    performPoll(false, false);
-                    return true;
-                }
-                case MSG_PERFORM_POLL_DETAILED: {
-                    performPoll(true, false);
+                    final int flags = msg.arg1;
+                    performPoll(flags);
                     return true;
                 }
                 default: {
@@ -1349,7 +1365,7 @@
             return getSecureLong(NETSTATS_POLL_INTERVAL, 30 * MINUTE_IN_MILLIS);
         }
         public long getPersistThreshold() {
-            return getSecureLong(NETSTATS_PERSIST_THRESHOLD, 512 * KB_IN_BYTES);
+            return getSecureLong(NETSTATS_PERSIST_THRESHOLD, 2 * MB_IN_BYTES);
         }
         public long getNetworkBucketDuration() {
             return getSecureLong(NETSTATS_NETWORK_BUCKET_DURATION, HOUR_IN_MILLIS);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 755a268..211c4da 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5824,27 +5824,6 @@
         config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale);
         config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dm, dw, dh);
 
-        // We need to determine the smallest width that will occur under normal
-        // operation.  To this, start with the base screen size and compute the
-        // width under the different possible rotations.  We need to un-rotate
-        // the current screen dimensions before doing this.
-        int unrotDw, unrotDh;
-        if (rotated) {
-            unrotDw = dh;
-            unrotDh = dw;
-        } else {
-            unrotDw = dw;
-            unrotDh = dh;
-        }
-        config.smallestScreenWidthDp = reduceConfigWidthSize(unrotDw,
-                Surface.ROTATION_0, dm.density, unrotDw);
-        config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
-                Surface.ROTATION_90, dm.density, unrotDh);
-        config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
-                Surface.ROTATION_180, dm.density, unrotDw);
-        config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
-                Surface.ROTATION_270, dm.density, unrotDh);
-
         // Compute the screen layout size class.
         int screenLayout;
         int longSize = dw;
diff --git a/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java
index 54f3bb0..e7f1d9a 100644
--- a/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java
@@ -178,6 +178,7 @@
         expectDefaultSettings();
         expectNetworkState(buildWifiState());
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -230,6 +231,7 @@
         expectDefaultSettings();
         expectNetworkState(buildWifiState());
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -320,6 +322,7 @@
         expectSettings(0L, HOUR_IN_MILLIS, WEEK_IN_MILLIS);
         expectNetworkState(buildWifiState());
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -370,6 +373,7 @@
         expectDefaultSettings();
         expectNetworkState(buildMobile3gState(IMSI_1));
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -450,6 +454,7 @@
         expectDefaultSettings();
         expectNetworkState(buildWifiState());
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -507,6 +512,7 @@
         expectDefaultSettings();
         expectNetworkState(buildMobile3gState(IMSI_1));
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -573,6 +579,7 @@
         expectDefaultSettings();
         expectNetworkState(buildWifiState());
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
@@ -635,6 +642,7 @@
         expectDefaultSettings();
         expectNetworkState(buildWifiState());
         expectNetworkStatsSummary(buildEmptyStats());
+        expectNetworkStatsUidDetail(buildEmptyStats());
 
         replay();
         mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION_IMMEDIATE));
diff --git a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl
index a0c7dd1..381a450 100644
--- a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl
+++ b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl
@@ -26,6 +26,5 @@
 interface IWifiP2pManager
 {
     Messenger getMessenger();
-    boolean isP2pSupported();
 }
 
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 10a316e..5715186 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -400,15 +400,6 @@
         }
     }
 
-    /** @hide */
-    public boolean isP2pSupported() {
-        try {
-            return mService.isP2pSupported();
-        } catch (RemoteException e) {
-            return false;
-        }
-    }
-
     /**
      * Sends in a request to the system to enable p2p. This will pop up a dialog
      * to the user and upon authorization will enable p2p.
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 361cac5..e2b2249 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -155,8 +155,9 @@
         mInterface = SystemProperties.get("wifi.interface", "wlan0");
         mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI_P2P, 0, NETWORKTYPE, "");
 
-        mP2pSupported = mContext.getResources().getBoolean(
-                com.android.internal.R.bool.config_wifi_p2p_support);
+        mP2pSupported = mContext.getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_WIFI_DIRECT);
+
         mDeviceType = mContext.getResources().getString(
                 com.android.internal.R.string.config_wifi_p2p_device_type);
         mDeviceName = getDefaultDeviceName();
@@ -218,14 +219,6 @@
         return new Messenger(mP2pStateMachine.getHandler());
     }
 
-    /**
-     * Return if p2p is supported
-     */
-    public boolean isP2pSupported() {
-        enforceAccessPermission();
-        return mP2pSupported;
-    }
-
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -1218,6 +1211,11 @@
         mReplyChannel.replyToMessage(msg, what);
     }
 
+    private void replyToMessage(Message msg, int what, int arg1) {
+        if (msg.replyTo == null) return;
+        mReplyChannel.replyToMessage(msg, what, arg1);
+    }
+
     private void replyToMessage(Message msg, int what, Object obj) {
         if (msg.replyTo == null) return;
         mReplyChannel.replyToMessage(msg, what, obj);