Merge "Fix issue #5187844: Query is misrouted to wrong content provider"
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index d3dbb8d..879c441 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -2406,13 +2406,16 @@
         }
 
         /**
-         * Sets the white balance.
+         * Sets the white balance. Changing the setting will release the
+         * auto-white balance lock.
          *
          * @param value new white balance.
          * @see #getWhiteBalance()
+         * @see #setAutoWhiteBalanceLock()
          */
         public void setWhiteBalance(String value) {
             set(KEY_WHITE_BALANCE, value);
+            set(KEY_AUTO_WHITEBALANCE_LOCK, FALSE);
         }
 
         /**
@@ -2823,6 +2826,9 @@
          * set the lock to false. However, the lock can be re-enabled before
          * preview is re-started to keep the same white balance parameters.</p>
          *
+         * <p> Changing the white balance mode with {@link #setWhiteBalance}
+         * will release the auto-white balance lock if it is set.</p>
+         *
          * <p>Exposure compensation, in conjunction with re-enabling the AE and
          * AWB locks after each still capture, can be used to capture an
          * exposure-bracketed burst of images, for example. Auto-white balance
@@ -2845,6 +2851,7 @@
          *        auto-white balance routine is free to run normally.
          *
          * @see #getAutoWhiteBalanceLock()
+         * @see #setWhiteBalance(String)
          */
         public void setAutoWhiteBalanceLock(boolean toggle) {
             set(KEY_AUTO_WHITEBALANCE_LOCK, toggle ? TRUE : FALSE);
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index cb85e5f..e1aa9a4 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -101,6 +101,8 @@
     /** Dialog's content view */
     private final View mView;
 
+    /** The visible portion of the volume overlay */
+    private final ViewGroup mPanel;
     /** Contains the sliders and their touchable icons */
     private final ViewGroup mSliderGroup;
     /** The button that expands the dialog to show all sliders */
@@ -173,10 +175,23 @@
         View view = mView = inflater.inflate(R.layout.volume_adjust, null);
         mView.setOnTouchListener(new View.OnTouchListener() {
             public boolean onTouch(View v, MotionEvent event) {
+                // Dismiss the dialog if the user touches outside the visible area. This is not
+                // handled by the usual dialog dismissing code because there is a region above
+                // the panel (marginTop) that is still within the dialog.
+                if (event.getAction() == MotionEvent.ACTION_DOWN) {
+                    int x = (int) event.getX();
+                    int y = (int) event.getY();
+                    if (x < mPanel.getLeft() || x > mPanel.getRight() || y < mPanel.getTop()
+                            || y > mPanel.getBottom()) {
+                        forceTimeout();
+                        return true;
+                    }
+                }
                 resetTimeout();
                 return true;
             }
         });
+        mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel);
         mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group);
         mMoreButton = (ImageView) mView.findViewById(R.id.expand_button);
         mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider);
@@ -639,6 +654,11 @@
         sendMessageDelayed(obtainMessage(MSG_TIMEOUT), TIMEOUT_DELAY);
     }
 
+    private void forceTimeout() {
+        removeMessages(MSG_TIMEOUT);
+        sendMessage(obtainMessage(MSG_TIMEOUT));
+    }
+
     public void onProgressChanged(SeekBar seekBar, int progress,
             boolean fromUser) {
         final Object tag = seekBar.getTag();
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 99f2765..f230031 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -745,7 +745,7 @@
     }
 
     @Override
-    public void onDetachedFromWindow() {
+    protected void onDetachedFromWindow() {
         removeCallbacks(mUpdateDrawableStateRunnable);
         super.onDetachedFromWindow();
     }
diff --git a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
index dd75925..df4243a 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
@@ -19,6 +19,7 @@
 import com.android.internal.view.menu.ActionMenuView.ActionMenuChildView;
 
 import android.content.Context;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -109,6 +110,16 @@
         mScrapActionButtonView = null;
     }
 
+    public void onConfigurationChanged(Configuration newConfig) {
+        if (!mMaxItemsSet) {
+            mMaxItems = mContext.getResources().getInteger(
+                    com.android.internal.R.integer.max_action_buttons);
+            if (mMenu != null) {
+                mMenu.onItemsChanged(true);
+            }
+        }
+    }
+
     public void setWidthLimit(int width, boolean strict) {
         mWidthLimit = width;
         mStrictWidthLimit = strict;
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index 5645a6f..45d38ae 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -25,6 +25,7 @@
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
 import android.text.TextUtils;
@@ -92,6 +93,14 @@
         a.recycle();
     }
 
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        if (mActionMenuPresenter != null) {
+            mActionMenuPresenter.onConfigurationChanged(newConfig);
+        }
+    }
+
     public void setHeight(int height) {
         mContentHeight = height;
     }
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 078e08a..28181ba 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -259,6 +259,9 @@
                 com.android.internal.R.attr.actionBarStyle, 0);
         setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
         a.recycle();
+        if (mActionMenuPresenter != null) {
+            mActionMenuPresenter.onConfigurationChanged(newConfig);
+        }
     }
 
     @Override
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index f8be136..b01dcd8 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -770,11 +770,7 @@
         value->computeValues(paint, textArray, start, count, end, flags);
 #endif
 
-#if DEBUG_GLYPHS
-        logGlyphs(value);
-#endif
-
-    doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
+        doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
             x, y, flags, paint);
     }
 
@@ -794,10 +790,6 @@
         value->computeValues(paint, textArray, start, count, contextCount, flags);
 #endif
 
-#if DEBUG_GLYPHS
-        logGlyphs(value);
-#endif
-
         doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
                 x, y, flags, paint);
     }
diff --git a/core/jni/android/graphics/TextLayout.h b/core/jni/android/graphics/TextLayout.h
index d197d04..9bb1b92 100644
--- a/core/jni/android/graphics/TextLayout.h
+++ b/core/jni/android/graphics/TextLayout.h
@@ -64,14 +64,6 @@
     kDirection_Mask = 0x1
 };
 
-static void logGlyphs(sp<TextLayoutCacheValue> value) {
-    if (value == NULL) return;
-    LOGD("Got glyphs - count=%d", value->getGlyphsCount());
-    for (size_t i = 0; i < value->getGlyphsCount(); i++) {
-        LOGD("      glyphs[%d]=%d", i, value->getGlyphs()[i]);
-    }
-}
-
 class TextLayout {
 public:
 
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 89440c9..f04c5eb5 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -554,6 +554,15 @@
 #endif
 }
 
+static void logGlyphs(HB_ShaperItem shaperItem) {
+    LOGD("Got glyphs - count=%d", shaperItem.num_glyphs);
+    for (size_t i = 0; i < shaperItem.num_glyphs; i++) {
+        LOGD("      glyphs[%d]=%d - offset.x=%f offset.y=%f", i, shaperItem.glyphs[i],
+                HBFixedToFloat(shaperItem.offsets[i].x),
+                HBFixedToFloat(shaperItem.offsets[i].y));
+    }
+}
+
 void TextLayoutCacheValue::computeRunValuesWithHarfbuzz(SkPaint* paint, const UChar* chars,
         size_t start, size_t count, size_t contextCount, bool isRTL,
         jfloat* outAdvances, jfloat* outTotalAdvance,
@@ -570,6 +579,8 @@
             shaperItem.kerning_applied);
     LOGD("         -- string= '%s'", String8(chars + start, count).string());
     LOGD("         -- isDevKernText=%d", paint->isDevKernText());
+
+    logGlyphs(shaperItem);
 #endif
 
     if (shaperItem.advances == NULL || shaperItem.num_glyphs == 0) {
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 80c79fd..fb5e5fe 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -472,9 +472,6 @@
     value = new TextLayoutCacheValue();
     value->computeValues(paint, text, 0, count, count, flags);
 #endif
-#if DEBUG_GLYPHS
-    logGlyphs(value);
-#endif
     const jchar* glyphArray = value->getGlyphs();
     int glyphCount = value->getGlyphsCount();
     int bytesCount = glyphCount * sizeof(jchar);
@@ -505,9 +502,6 @@
     value = new TextLayoutCacheValue();
     value->computeValues(paint, text, start, count, contextCount, flags);
 #endif
-#if DEBUG_GLYPHS
-    logGlyphs(value);
-#endif
     const jchar* glyphArray = value->getGlyphs();
     int glyphCount = value->getGlyphsCount();
     int bytesCount = glyphCount * sizeof(jchar);
diff --git a/core/res/res/drawable-hdpi/overscroll_glow.png b/core/res/res/drawable-hdpi/overscroll_glow.png
index 5963c00..8f0c2cb 100644
--- a/core/res/res/drawable-hdpi/overscroll_glow.png
+++ b/core/res/res/drawable-hdpi/overscroll_glow.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/overscroll_glow.png b/core/res/res/drawable-mdpi/overscroll_glow.png
index e63e465..8389ef4 100644
--- a/core/res/res/drawable-mdpi/overscroll_glow.png
+++ b/core/res/res/drawable-mdpi/overscroll_glow.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/overscroll_glow.png b/core/res/res/drawable-xhdpi/overscroll_glow.png
index 227565e..75c3eb4 100644
--- a/core/res/res/drawable-xhdpi/overscroll_glow.png
+++ b/core/res/res/drawable-xhdpi/overscroll_glow.png
Binary files differ
diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml
index 7303003..ea4e1f9 100644
--- a/core/res/res/layout/volume_adjust.xml
+++ b/core/res/res/layout/volume_adjust.xml
@@ -18,6 +18,7 @@
     android:layout_width="480dp"
     android:layout_height="wrap_content">
     <LinearLayout
+        android:id="@+id/visible_panel"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="80dp"
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w360dp/dimens.xml
similarity index 94%
copy from core/res/res/values-port/dimens.xml
copy to core/res/res/values-w360dp/dimens.xml
index bf0a342..0f5d656 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w360dp/dimens.xml
@@ -20,5 +20,5 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">2</integer>
+    <integer name="max_action_buttons">3</integer>
 </resources>
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w500dp/dimens.xml
similarity index 94%
rename from core/res/res/values-port/dimens.xml
rename to core/res/res/values-w500dp/dimens.xml
index bf0a342..68841ca 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w500dp/dimens.xml
@@ -20,5 +20,5 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">2</integer>
+    <integer name="max_action_buttons">4</integer>
 </resources>
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w600dp/dimens.xml
similarity index 94%
copy from core/res/res/values-port/dimens.xml
copy to core/res/res/values-w600dp/dimens.xml
index bf0a342..83c45b5 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w600dp/dimens.xml
@@ -20,5 +20,5 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">2</integer>
+    <integer name="max_action_buttons">5</integer>
 </resources>
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index fe5ace8..04e510b 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -236,11 +236,8 @@
        <item>@drawable/spinner_dropdown_background_up</item>
        <item>@drawable/spinner_focused_holo_dark</item>
        <item>@drawable/spinner_focused_holo_light</item>
-       <item>@drawable/spinner_normal</item>
-       <item>@drawable/spinner_press</item>
        <item>@drawable/spinner_pressed_holo_dark</item>
        <item>@drawable/spinner_pressed_holo_light</item>
-       <item>@drawable/spinner_select</item>
        <item>@drawable/cab_background_bottom_holo_dark</item>
        <item>@drawable/cab_background_top_holo_light</item>
        <item>@drawable/cab_background_bottom_holo_light</item>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 83e86939..c522c1e 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -28,7 +28,7 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">3</integer>
+    <integer name="max_action_buttons">2</integer>
     <dimen name="toast_y_offset">64dip</dimen>
     <!-- Height of the status bar -->
     <dimen name="status_bar_height">25dip</dimen>
diff --git a/docs/html/guide/topics/graphics/opengl.jd b/docs/html/guide/topics/graphics/opengl.jd
index 2edc63d..b750858 100644
--- a/docs/html/guide/topics/graphics/opengl.jd
+++ b/docs/html/guide/topics/graphics/opengl.jd
@@ -14,7 +14,7 @@
         </ol>
       <li><a href="#manifest">Declaring OpenGL Requirements</a></li>
       </li>
-      <li><a href="#coordinate-mapping">Coordinate Mapping for Drawn Objects</a>  
+      <li><a href="#coordinate-mapping">Mapping Coordinates for Drawn Objects</a>  
         <ol>
           <li><a href="#proj-es1">Projection and camera in ES 1.0</a></li>
           <li><a href="#proj-es1">Projection and camera in ES 2.0</a></li>
@@ -197,9 +197,9 @@
   installed on devices that do not support OpenGL ES 2.0.</p>
   </li>
   <li><strong>Texture compression requirements</strong> - If your application uses texture
-compression formats that are not supported by all devices, you must declare them in your manifest
-file using <a href="{@docRoot}guide/topics/manifest/supports-gl-texture-element.html">
-{@code &lt;supports-gl-texture&gt;}</a>. For more information about available texture compression
+compression formats, you must declare the formats your application supports in your manifest file
+using <a href="{@docRoot}guide/topics/manifest/supports-gl-texture-element.html">{@code
+&lt;supports-gl-texture&gt;}</a>. For more information about available texture compression
 formats, see <a href="#textures">Texture compression support</a>. 
 
 <p>Declaring texture compression requirements in your manifest hides your application from users
@@ -212,7 +212,7 @@
 </ul>
 
 
-<h2 id="coordinate-mapping">Coordinate Mapping for Drawn Objects</h2>
+<h2 id="coordinate-mapping">Mapping Coordinates for Drawn Objects</h2>
 
 <p>One of the basic problems in displaying graphics on Android devices is that their screens can
 vary in size and shape. OpenGL assumes a square, uniform coordinate system and, by default, happily
@@ -241,9 +241,11 @@
 <ol>
 <li><strong>Projection matrix</strong> - Create a projection matrix using the geometry of the
 device screen in order to recalculate object coordinates so they are drawn with correct proportions.
-The following example code demonstrates how to modify the {@code onSurfaceChanged()} method of a
-{@link android.opengl.GLSurfaceView.Renderer} implementation to create a projection matrix based on
-the screen's aspect ratio and apply it to the OpenGL rendering environment.
+The following example code demonstrates how to modify the {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition.khronos.opengles.GL10,
+int, int) onSurfaceChanged()} method of a {@link android.opengl.GLSurfaceView.Renderer}
+implementation to create a projection matrix based on the screen's aspect ratio and apply it to the
+OpenGL rendering environment.
 
 <pre>
   public void onSurfaceChanged(GL10 gl, int width, int height) {
@@ -260,11 +262,13 @@
 
 <li><strong>Camera transformation matrix</strong> - Once you have adjusted the coordinate system
 using a projection matrix, you must also apply a camera view. The following example code shows how
-to modify the {@code onDrawFrame()} method of a {@link android.opengl.GLSurfaceView.Renderer}
-implementation to apply a model view and use the {@link
-android.opengl.GLU#gluLookAt(javax.microedition.khronos.opengles.GL10, float, float, float, float,
-float, float, float, float, float) GLU.gluLookAt()} utility to create a viewing tranformation which
-simulates a camera position.
+to modify the {@link        
+android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.microedition.khronos.opengles.GL10)
+onDrawFrame()} method of a {@link android.opengl.GLSurfaceView.Renderer}
+implementation to apply a model view and use the
+{@link android.opengl.GLU#gluLookAt(javax.microedition.khronos.opengles.GL10, float, float, float,
+float, float, float, float, float, float) GLU.gluLookAt()} utility to create a viewing tranformation
+which simulates a camera position.
 
 <pre>
     public void onDrawFrame(GL10 gl) {
@@ -320,8 +324,10 @@
 </li>
 <li><strong>Access the shader matrix</strong> - After creating a hook in your vertex shaders to
 apply projection and camera view, you can then access that variable to apply projection and
-camera viewing matrices. The following code shows how to modify the {@code onSurfaceCreated()}
-method of a {@link android.opengl.GLSurfaceView.Renderer} implementation to access the matrix
+camera viewing matrices. The following code shows how to modify the {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.microedition.khronos.opengles.GL10,
+javax.microedition.khronos.egl.EGLConfig) onSurfaceCreated()} method of a {@link
+android.opengl.GLSurfaceView.Renderer} implementation to access the matrix
 variable defined in the vertex shader above.
 
 <pre>
@@ -334,9 +340,13 @@
 </li>
 <li><strong>Create projection and camera viewing matrices</strong> - Generate the projection and
 viewing matrices to be applied the graphic objects. The following example code shows how to modify
-the {@code onSurfaceCreated()} and {@code onSurfaceChanged()} methods of a {@link
-android.opengl.GLSurfaceView.Renderer} implementation to create camera view matrix and a projection
-matrix based on the screen aspect ratio of the device.
+the {@link    
+android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.microedition.khronos.opengles.GL10,
+javax.microedition.khronos.egl.EGLConfig) onSurfaceCreated()} and {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition.khronos.opengles.GL10,
+int, int) onSurfaceChanged()} methods of a {@link android.opengl.GLSurfaceView.Renderer}
+implementation to create camera view matrix and a projection matrix based on the screen aspect ratio
+of the device.
 
 <pre>
     public void onSurfaceCreated(GL10 unused, EGLConfig config) {
@@ -358,9 +368,11 @@
 
 <li><strong>Apply projection and camera viewing matrices</strong> - To apply the projection and
 camera view transformations, multiply the matrices together and then set them into the vertex
-shader. The following example code shows how modify the {@code onDrawFrame()} method of a {@link
-android.opengl.GLSurfaceView.Renderer} implementation to combine the projection matrix and camera
-view created in the code above and then apply it to the graphic objects to be rendered by OpenGL.
+shader. The following example code shows how modify the {@link
+android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.microedition.khronos.opengles.GL10)
+onDrawFrame()} method of a {@link android.opengl.GLSurfaceView.Renderer} implementation to combine
+the projection matrix and camera view created in the code above and then apply it to the graphic
+objects to be rendered by OpenGL.
   
 <pre>
     public void onDrawFrame(GL10 unused) {
diff --git a/docs/html/resources/tutorials/opengl/opengl-es10.jd b/docs/html/resources/tutorials/opengl/opengl-es10.jd
index 40304fd..3570766 100644
--- a/docs/html/resources/tutorials/opengl/opengl-es10.jd
+++ b/docs/html/resources/tutorials/opengl/opengl-es10.jd
@@ -342,8 +342,8 @@
 system onto your typically non-square screen. To solve this problem, you can apply an OpenGL
 projection mode and camera view (eye point) to transform the coordinates of your graphic objects
 so they have the correct proportions on any display. For more information about OpenGL coordinate
-mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Coordinate
-Mapping for Drawn Objects</a>.</p>
+mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Mapping
+Coordinates for Drawn Objects</a>.</p>
 
 <p>To apply projection and camera view transformations to your triangle:
 </p>
diff --git a/docs/html/resources/tutorials/opengl/opengl-es20.jd b/docs/html/resources/tutorials/opengl/opengl-es20.jd
index 439f7d5..889dd50 100644
--- a/docs/html/resources/tutorials/opengl/opengl-es20.jd
+++ b/docs/html/resources/tutorials/opengl/opengl-es20.jd
@@ -422,8 +422,8 @@
 system onto your typically non-square screen. To solve this problem, you can apply an OpenGL
 projection mode and camera view (eye point) to transform the coordinates of your graphic objects
 so they have the correct proportions on any display. For more information about OpenGL coordinate
-mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Coordinate
-Mapping for Drawn Objects</a>.</p>
+mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Mapping
+Coordinates for Drawn Objects</a>.</p>
 
 <p>To apply projection and camera view transformations to your triangle:
 </p>
diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp
index 176dd18..44ea79c 100644
--- a/libs/rs/driver/rsdBcc.cpp
+++ b/libs/rs/driver/rsdBcc.cpp
@@ -45,6 +45,7 @@
     InvokeFunc_t *mInvokeFunctions;
     void ** mFieldAddress;
     bool * mFieldIsObject;
+    const uint32_t *mExportForEachSignatureList;
 
     const uint8_t * mScriptText;
     uint32_t mScriptTextLength;
@@ -74,6 +75,7 @@
     size_t exportFuncCount = 0;
     size_t exportVarCount = 0;
     size_t objectSlotCount = 0;
+    size_t exportForEachSignatureCount = 0;
 
     DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
     if (drv == NULL) {
@@ -153,6 +155,10 @@
         }
     }
 
+    exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount();
+    rsAssert(exportForEachSignatureCount <= 1);
+    drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList();
+
     // Copy info over to runtime
     script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount();
     script->mHal.info.exportedVariableCount = drv->ME->getExportVarCount();
@@ -179,6 +185,7 @@
 typedef struct {
     Context *rsc;
     Script *script;
+    uint32_t sig;
     const Allocation * ain;
     Allocation * aout;
     const void * usr;
@@ -206,7 +213,7 @@
     uint32_t dimZ;
     uint32_t dimArray;
 } MTLaunchStruct;
-typedef int (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
+typedef void (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
 
 static void wc_xy(void *usr, uint32_t idx) {
     MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
@@ -214,6 +221,8 @@
     memset(&p, 0, sizeof(p));
     p.usr = mtls->usr;
     p.usr_len = mtls->usrLen;
+    RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
+    uint32_t sig = mtls->sig;
 
     while (1) {
         uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
@@ -234,7 +243,7 @@
             for (p.x = mtls->xStart; p.x < mtls->xEnd; p.x++) {
                 p.in = xPtrIn;
                 p.out = xPtrOut;
-                ((rs_t)mtls->script->mHal.info.root) (p.in, p.out, p.usr, p.x, p.y, 0, 0);
+                dc->mForEachLaunch[sig](&mtls->script->mHal.info.root, &p);
                 xPtrIn += mtls->eStrideIn;
                 xPtrOut += mtls->eStrideOut;
             }
@@ -248,6 +257,8 @@
     memset(&p, 0, sizeof(p));
     p.usr = mtls->usr;
     p.usr_len = mtls->usrLen;
+    RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
+    uint32_t sig = mtls->sig;
 
     while (1) {
         uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
@@ -265,7 +276,7 @@
         for (p.x = xStart; p.x < xEnd; p.x++) {
             p.in = xPtrIn;
             p.out = xPtrOut;
-            ((rs_t)mtls->script->mHal.info.root) (p.in, p.out, p.usr, p.x, 0, 0, 0);
+            dc->mForEachLaunch[sig](&mtls->script->mHal.info.root, &p);
             xPtrIn += mtls->eStrideIn;
             xPtrOut += mtls->eStrideOut;
         }
@@ -286,6 +297,10 @@
     MTLaunchStruct mtls;
     memset(&mtls, 0, sizeof(mtls));
 
+    DrvScript *drv = (DrvScript *)s->mHal.drv;
+    // We only support slot 0 (root) at this point in time.
+    rsAssert(slot == 0);
+    mtls.sig = drv->mExportForEachSignatureList[slot];
     if (ain) {
         mtls.dimX = ain->getType()->getDimX();
         mtls.dimY = ain->getType()->getDimY();
@@ -369,6 +384,7 @@
         memset(&p, 0, sizeof(p));
         p.usr = mtls.usr;
         p.usr_len = mtls.usrLen;
+        uint32_t sig = mtls.sig;
 
         //LOGE("launch 3");
         for (p.ar[0] = mtls.arrayStart; p.ar[0] < mtls.arrayEnd; p.ar[0]++) {
@@ -383,7 +399,7 @@
                     for (p.x = mtls.xStart; p.x < mtls.xEnd; p.x++) {
                         p.in = xPtrIn;
                         p.out = xPtrOut;
-                        ((rs_t)s->mHal.info.root) (p.in, p.out, p.usr, p.x, p.y, p.z, p.ar[0]);
+                        dc->mForEachLaunch[sig](&s->mHal.info.root, &p);
                         xPtrIn += mtls.eStrideIn;
                         xPtrOut += mtls.eStrideOut;
                     }
diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp
index 38f6895..171d045 100644
--- a/libs/rs/driver/rsdCore.cpp
+++ b/libs/rs/driver/rsdCore.cpp
@@ -43,6 +43,7 @@
 
 static void Shutdown(Context *rsc);
 static void SetPriority(const Context *rsc, int32_t priority);
+static void initForEach(outer_foreach_t* forEachLaunch);
 
 static RsdHalFunctions FunctionTable = {
     rsdGLInit,
@@ -206,6 +207,8 @@
     rsdgThreadTLSKeyCount++;
     pthread_mutex_unlock(&rsdgInitMutex);
 
+    initForEach(dc->mForEachLaunch);
+
     dc->mTlsStruct.mContext = rsc;
     dc->mTlsStruct.mScript = NULL;
     int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
@@ -287,4 +290,112 @@
 
 }
 
+static void rsdForEach17(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, uint32_t);
+    (*(fe*)vRoot)(p->in, p->y);
+}
+
+static void rsdForEach18(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(void *, uint32_t);
+    (*(fe*)vRoot)(p->out, p->y);
+}
+
+static void rsdForEach19(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, void *, uint32_t);
+    (*(fe*)vRoot)(p->in, p->out, p->y);
+}
+
+static void rsdForEach21(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, const void *, uint32_t);
+    (*(fe*)vRoot)(p->in, p->usr, p->y);
+}
+
+static void rsdForEach22(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(void *, const void *, uint32_t);
+    (*(fe*)vRoot)(p->out, p->usr, p->y);
+}
+
+static void rsdForEach23(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, void *, const void *, uint32_t);
+    (*(fe*)vRoot)(p->in, p->out, p->usr, p->y);
+}
+
+static void rsdForEach25(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, uint32_t, uint32_t);
+    (*(fe*)vRoot)(p->in, p->x, p->y);
+}
+
+static void rsdForEach26(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(void *, uint32_t, uint32_t);
+    (*(fe*)vRoot)(p->out, p->x, p->y);
+}
+
+static void rsdForEach27(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, void *, uint32_t, uint32_t);
+    (*(fe*)vRoot)(p->in, p->out, p->x, p->y);
+}
+
+static void rsdForEach29(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, const void *, uint32_t, uint32_t);
+    (*(fe*)vRoot)(p->in, p->usr, p->x, p->y);
+}
+
+static void rsdForEach30(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(void *, const void *, uint32_t, uint32_t);
+    (*(fe*)vRoot)(p->out, p->usr, p->x, p->y);
+}
+
+static void rsdForEach31(const void *vRoot,
+        const android::renderscript::RsForEachStubParamStruct *p) {
+    typedef void (*fe)(const void *, void *, const void *, uint32_t, uint32_t);
+    (*(fe*)vRoot)(p->in, p->out, p->usr, p->x, p->y);
+}
+
+
+static void initForEach(outer_foreach_t* forEachLaunch) {
+    rsAssert(forEachLaunch);
+    forEachLaunch[0x00] = NULL;
+    forEachLaunch[0x01] = rsdForEach31; // in
+    forEachLaunch[0x02] = rsdForEach30; //     out
+    forEachLaunch[0x03] = rsdForEach31; // in, out
+    forEachLaunch[0x04] = NULL;
+    forEachLaunch[0x05] = rsdForEach29;  // in,      usr
+    forEachLaunch[0x06] = rsdForEach30; //     out, usr
+    forEachLaunch[0x07] = rsdForEach31; // in, out, usr
+    forEachLaunch[0x08] = NULL;
+    forEachLaunch[0x09] = rsdForEach25; // in,           x
+    forEachLaunch[0x0a] = rsdForEach26; //     out,      x
+    forEachLaunch[0x0b] = rsdForEach27; // in, out,      x
+    forEachLaunch[0x0c] = NULL;
+    forEachLaunch[0x0d] = rsdForEach29; // in,      usr, x
+    forEachLaunch[0x0e] = rsdForEach30; //     out, usr, x
+    forEachLaunch[0x0f] = rsdForEach31; // in, out, usr, x
+    forEachLaunch[0x10] = NULL;
+    forEachLaunch[0x11] = rsdForEach17; // in               y
+    forEachLaunch[0x12] = rsdForEach18; //     out,         y
+    forEachLaunch[0x13] = rsdForEach19; // in, out,         y
+    forEachLaunch[0x14] = NULL;
+    forEachLaunch[0x15] = rsdForEach21; // in,      usr,    y
+    forEachLaunch[0x16] = rsdForEach22; //     out, usr,    y
+    forEachLaunch[0x17] = rsdForEach23; // in, out, usr,    y
+    forEachLaunch[0x18] = NULL;
+    forEachLaunch[0x19] = rsdForEach25; // in,           x, y
+    forEachLaunch[0x1a] = rsdForEach26; //     out,      x, y
+    forEachLaunch[0x1b] = rsdForEach27; // in, out,      x, y
+    forEachLaunch[0x1c] = NULL;
+    forEachLaunch[0x1d] = rsdForEach29; // in,      usr, x, y
+    forEachLaunch[0x1e] = rsdForEach30; //     out, usr, x, y
+    forEachLaunch[0x1f] = rsdForEach31; // in, out, usr, x, y
+}
 
diff --git a/libs/rs/driver/rsdCore.h b/libs/rs/driver/rsdCore.h
index f393b60..159b72a 100644
--- a/libs/rs/driver/rsdCore.h
+++ b/libs/rs/driver/rsdCore.h
@@ -27,6 +27,9 @@
 typedef void (* InvokeFunc_t)(void);
 typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
 
+typedef void (*outer_foreach_t)(const void *,
+    const android::renderscript::RsForEachStubParamStruct *);
+
 typedef struct RsdSymbolTableRec {
     const char * mName;
     void * mPtr;
@@ -57,6 +60,8 @@
     Workers mWorkers;
     bool mExit;
 
+    outer_foreach_t mForEachLaunch[32];
+
     ScriptTLSStruct mTlsStruct;
 
     RsdGL gl;
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index a366d49..4359d95 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -58,19 +58,7 @@
 }
 
 Allocation::~Allocation() {
-    if (mHal.state.hasReferences &&
-        (mHal.state.hasFaces || mHal.state.hasMipmaps)) {
-        LOGE("Cube/mip allocation with references unsupported, memory not cleaned up!");
-    }
-
-    uint32_t elemCount = mHal.state.dimensionX;
-    if (mHal.state.dimensionY > 1) {
-        elemCount *= mHal.state.dimensionY;
-    }
-    if (mHal.state.dimensionZ > 1) {
-        elemCount *= mHal.state.dimensionZ;
-    }
-    decRefs(getPtr(), elemCount, 0);
+    freeChildrenUnlocked();
     mRSC->mHal.funcs.allocation.destroy(mRSC, this);
 }
 
@@ -299,6 +287,19 @@
     }
 }
 
+void Allocation::freeChildrenUnlocked () {
+    decRefs(getPtr(), mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0);
+}
+
+bool Allocation::freeChildren() {
+    if (mHal.state.hasReferences) {
+        incSysRef();
+        freeChildrenUnlocked();
+        return decSysRef();
+    }
+    return false;
+}
+
 void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) {
 }
 
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index f2589c0..67fc3b5 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -116,6 +116,7 @@
 
     void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
     void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
+    virtual bool freeChildren();
 
     void sendDirty(const Context *rsc) const;
     bool getHasGraphicsMipmaps() const {
@@ -127,6 +128,7 @@
     Vector<const Program *> mToDirtyList;
 
 private:
+    void freeChildrenUnlocked();
     Allocation(Context *rsc, const Type *, uint32_t usages, RsAllocationMipmapControl mc);
 };
 
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 8996ad1..e3a9cf8 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -312,6 +312,7 @@
          mStateSampler.deinit(this);
          mFBOCache.deinit(this);
     }
+    ObjectBase::freeAllChildren(this);
     //LOGV("destroyWorkerThreadResources 2");
     mExit = true;
 }
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp
index f428f94..f5ced26 100644
--- a/libs/rs/rsObjectBase.cpp
+++ b/libs/rs/rsObjectBase.cpp
@@ -81,6 +81,10 @@
 void ObjectBase::preDestroy() const {
 }
 
+bool ObjectBase::freeChildren() {
+    return false;
+}
+
 bool ObjectBase::checkDelete(const ObjectBase *ref) {
     if (!ref) {
         return false;
@@ -217,6 +221,28 @@
     }
 }
 
+void ObjectBase::freeAllChildren(Context *rsc) {
+    if (rsc->props.mLogObjects) {
+        LOGV("Forcing release of all child objects.");
+    }
+
+    // This operation can be slow, only to be called during context cleanup.
+    ObjectBase * o = (ObjectBase *)rsc->mObjHead;
+    while (o) {
+        if (o->freeChildren()) {
+            // deleted ref to self and possibly others, restart from head.
+            o = (ObjectBase *)rsc->mObjHead;
+        } else {
+            o = (ObjectBase *)o->mNext;
+        }
+    }
+
+    if (rsc->props.mLogObjects) {
+        LOGV("Objects remaining.");
+        dumpAll(rsc);
+    }
+}
+
 void ObjectBase::dumpAll(Context *rsc) {
     asyncLock();
 
diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h
index c7cfb0e..d9f5f3b 100644
--- a/libs/rs/rsObjectBase.h
+++ b/libs/rs/rsObjectBase.h
@@ -50,8 +50,10 @@
     void setName(const char *, uint32_t len);
 
     Context * getContext() const {return mRSC;}
+    virtual bool freeChildren();
 
     static void zeroAllUserRef(Context *rsc);
+    static void freeAllChildren(Context *rsc);
     static void dumpAll(Context *rsc);
 
     virtual void dumpLOGV(const char *prefix) const;
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp
index 33eb422e..4178aa5 100644
--- a/libs/rs/rsProgram.cpp
+++ b/libs/rs/rsProgram.cpp
@@ -70,15 +70,8 @@
 }
 
 Program::~Program() {
+    freeChildren();
 
-    for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) {
-        bindAllocation(NULL, NULL, ct);
-    }
-
-    for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
-        bindTexture(NULL, ct, NULL);
-        bindSampler(NULL, ct, NULL);
-    }
     delete[] mHal.state.textures;
     delete[] mHal.state.samplers;
     delete[] mHal.state.textureTargets;
@@ -90,6 +83,18 @@
     mHal.state.texturesCount = 0;
 }
 
+bool Program::freeChildren() {
+    for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) {
+        bindAllocation(NULL, NULL, ct);
+    }
+
+    for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
+        bindTexture(NULL, ct, NULL);
+        bindSampler(NULL, ct, NULL);
+    }
+    return false;
+}
+
 void Program::initMemberVars() {
     mDirty = true;
 
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h
index 948ba3e..3237a72 100644
--- a/libs/rs/rsProgram.h
+++ b/libs/rs/rsProgram.h
@@ -34,6 +34,7 @@
     Program(Context *, const char * shaderText, uint32_t shaderLength,
                        const uint32_t * params, uint32_t paramLength);
     virtual ~Program();
+    virtual bool freeChildren();
 
     void bindAllocation(Context *, Allocation *, uint32_t slot);
 
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index 12ab941..e615d93 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -419,7 +419,7 @@
     def.nVersion.s.nStep = 0;
     def.nPortIndex = portIndex;
     OMX_ERRORTYPE err = OMX_GetParameter(mHandle, OMX_IndexParamPortDefinition, &def);
-    if (err != OK)
+    if (err != OMX_ErrorNone)
     {
         LOGE("%s::%d:Error getting OMX_IndexParamPortDefinition", __FUNCTION__, __LINE__);
         return err;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 7764e35..ebadb5e 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -2398,10 +2398,11 @@
         }
     }
 
+    final Object mScreenshotLock = new Object();
     ServiceConnection mScreenshotConnection = null;
     Runnable mScreenshotTimeout = null;
 
-    void finishScreenshot(ServiceConnection conn) {
+    void finishScreenshotLSS(ServiceConnection conn) {
         if (mScreenshotConnection == conn) {
             mContext.unbindService(conn);
             mScreenshotConnection = null;
@@ -2416,48 +2417,56 @@
         mHandler.post(new Runnable() {
             @Override
             public void run() {
-                if (mScreenshotConnection != null) {
-                    return;
-                }
-                ComponentName cn = new ComponentName("com.android.systemui",
-                        "com.android.systemui.screenshot.TakeScreenshotService");
-                Intent intent = new Intent();
-                intent.setComponent(cn);
-                ServiceConnection conn = new ServiceConnection() {
-                    @Override
-                    public void onServiceConnected(ComponentName name, IBinder service) {
-                        if (mScreenshotConnection != this) {
-                            return;
-                        }
-                        Messenger messenger = new Messenger(service);
-                        Message msg = Message.obtain(null, 1);
-                        final ServiceConnection myConn = this;
-                        Handler h = new Handler(mHandler.getLooper()) {
-                            @Override
-                            public void handleMessage(Message msg) {
-                                finishScreenshot(myConn);
-                            }
-                        };
-                        msg.replyTo = new Messenger(h);
-                        try {
-                            messenger.send(msg);
-                        } catch (RemoteException e) {
-                        }
+                synchronized (mScreenshotLock) {
+                    if (mScreenshotConnection != null) {
+                        return;
                     }
-                    @Override
-                    public void onServiceDisconnected(ComponentName name) {}
-                };
-                if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
-                    mScreenshotConnection = conn;
-                    mScreenshotTimeout = new Runnable() {
-                        @Override public void run() {
-                            if (mScreenshotConnection != null) {
-                                finishScreenshot(mScreenshotConnection);
+                    ComponentName cn = new ComponentName("com.android.systemui",
+                            "com.android.systemui.screenshot.TakeScreenshotService");
+                    Intent intent = new Intent();
+                    intent.setComponent(cn);
+                    ServiceConnection conn = new ServiceConnection() {
+                        @Override
+                        public void onServiceConnected(ComponentName name, IBinder service) {
+                            synchronized (mScreenshotLock) {
+                                if (mScreenshotConnection != this) {
+                                    return;
+                                }
+                                Messenger messenger = new Messenger(service);
+                                Message msg = Message.obtain(null, 1);
+                                final ServiceConnection myConn = this;
+                                Handler h = new Handler(mHandler.getLooper()) {
+                                    @Override
+                                    public void handleMessage(Message msg) {
+                                        synchronized (mScreenshotLock) {
+                                            finishScreenshotLSS(myConn);
+                                        }
+                                    }
+                                };
+                                msg.replyTo = new Messenger(h);
+                                try {
+                                    messenger.send(msg);
+                                } catch (RemoteException e) {
+                                }
                             }
                         }
-
+                        @Override
+                        public void onServiceDisconnected(ComponentName name) {}
                     };
-                    mHandler.postDelayed(mScreenshotTimeout, 10000);
+                    if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
+                        mScreenshotConnection = conn;
+                        mScreenshotTimeout = new Runnable() {
+                            @Override public void run() {
+                                synchronized (mScreenshotLock) {
+                                    if (mScreenshotConnection != null) {
+                                        finishScreenshotLSS(mScreenshotConnection);
+                                    }
+                                }
+                            }
+    
+                        };
+                        mHandler.postDelayed(mScreenshotTimeout, 10000);
+                    }
                 }
             }
         });
diff --git a/telephony/java/com/android/internal/telephony/IccCard.java b/telephony/java/com/android/internal/telephony/IccCard.java
index 02617c8..bce9991 100644
--- a/telephony/java/com/android/internal/telephony/IccCard.java
+++ b/telephony/java/com/android/internal/telephony/IccCard.java
@@ -268,7 +268,6 @@
     }
 
     public void supplyNetworkDepersonalization (String pin, Message onComplete) {
-        if(mDbg) log("Network Despersonalization: " + pin);
         mPhone.mCM.supplyNetworkDepersonalization(pin,
                 mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
     }
@@ -359,7 +358,6 @@
       */
      public void changeIccLockPassword(String oldPassword, String newPassword,
              Message onComplete) {
-         if(mDbg) log("Change Pin1 old: " + oldPassword + " new: " + newPassword);
          mPhone.mCM.changeIccPin(oldPassword, newPassword,
                  mHandler.obtainMessage(EVENT_CHANGE_ICC_PASSWORD_DONE, onComplete));
 
@@ -378,7 +376,6 @@
       */
      public void changeIccFdnPassword(String oldPassword, String newPassword,
              Message onComplete) {
-         if(mDbg) log("Change Pin2 old: " + oldPassword + " new: " + newPassword);
          mPhone.mCM.changeIccPin2(oldPassword, newPassword,
                  mHandler.obtainMessage(EVENT_CHANGE_ICC_PASSWORD_DONE, onComplete));
 
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
index b7d2c26..5e2a9fd 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
@@ -141,7 +141,7 @@
             } else if (!path.startsWith(HTTP_LOCAL_TESTS_PREFIX)
                     && !path.startsWith(HTTP_MEDIA_TESTS_PREFIX)
                     && !path.startsWith(HTTP_WML_TESTS_PREFIX)) {
-                url = "http://127.0.0.1:8000/" + path.substring(HTTP_TESTS_PREFIX.length());
+                url = "http://127.0.0.1:18000/" + path.substring(HTTP_TESTS_PREFIX.length());
             } else {
                 url = "file://" + path;
             }
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
index 25dd04fd..7a277d7 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
@@ -26,7 +26,7 @@
 
 public class ForwardService {
 
-    private ForwardServer fs8000, fs8080, fs8443;
+    private ForwardServer fs18000, fs8080, fs8443;
 
     private static ForwardService inst;
 
@@ -40,7 +40,7 @@
     private ForwardService() {
         int addr = getForwardHostAddr();
         if (addr != -1) {
-            fs8000 = new ForwardServer(8000, addr, 8000);
+            fs18000 = new ForwardServer(18000, addr, 8000);
             fs8080 = new ForwardServer(8080, addr, 8080);
             fs8443 = new ForwardServer(8443, addr, 8443);
         }
@@ -55,8 +55,8 @@
 
     public void startForwardService() {
         try {
-            if (fs8000 != null)
-                fs8000.start();
+            if (fs18000 != null)
+                fs18000.start();
             if (fs8080 != null)
                 fs8080.start();
             if (fs8443 != null)
@@ -68,9 +68,9 @@
     }
 
     public void stopForwardService() {
-        if (fs8000 != null) {
-            fs8000.stop();
-            fs8000 = null;
+        if (fs18000 != null) {
+            fs18000.stop();
+            fs18000 = null;
         }
         if (fs8080 != null) {
             fs8080.stop();
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
index be012ee..e37e9b5 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
@@ -70,6 +70,7 @@
         unitTests.add(new UT_rstime(this, mRes, mCtx));
         unitTests.add(new UT_rstypes(this, mRes, mCtx));
         unitTests.add(new UT_alloc(this, mRes, mCtx));
+        unitTests.add(new UT_foreach(this, mRes, mCtx));
         unitTests.add(new UT_math(this, mRes, mCtx));
         unitTests.add(new UT_fp_mad(this, mRes, mCtx));
         /*
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java
new file mode 100644
index 0000000..1d2555e
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.rs.test;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.renderscript.*;
+
+public class UT_foreach extends UnitTest {
+    private Resources mRes;
+    private Allocation A;
+
+    protected UT_foreach(RSTestCore rstc, Resources res, Context ctx) {
+        super(rstc, "ForEach", ctx);
+        mRes = res;
+    }
+
+    private void initializeGlobals(RenderScript RS, ScriptC_foreach s) {
+        Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
+        int X = 5;
+        int Y = 7;
+        s.set_dimX(X);
+        s.set_dimY(Y);
+        typeBuilder.setX(X).setY(Y);
+        A = Allocation.createTyped(RS, typeBuilder.create());
+        s.bind_a(A);
+
+        return;
+    }
+
+    public void run() {
+        RenderScript pRS = RenderScript.create(mCtx);
+        ScriptC_foreach s = new ScriptC_foreach(pRS, mRes, R.raw.foreach);
+        pRS.setMessageHandler(mRsMessage);
+        initializeGlobals(pRS, s);
+        s.forEach_root(A);
+        s.invoke_foreach_test();
+        pRS.finish();
+        waitForMessage();
+        pRS.destroy();
+    }
+}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs
new file mode 100644
index 0000000..3ba3eef
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs
@@ -0,0 +1,42 @@
+#include "shared.rsh"
+
+int *a;
+int dimX;
+int dimY;
+
+void root(int *out, uint32_t x, uint32_t y) {
+    *out = x + y * dimX;
+}
+
+static bool test_foreach_output() {
+    bool failed = false;
+    int i, j;
+
+    for (j = 0; j < dimY; j++) {
+        for (i = 0; i < dimX; i++) {
+            _RS_ASSERT(a[i + j * dimX] == (i + j * dimX));
+        }
+    }
+
+    if (failed) {
+        rsDebug("test_foreach_output FAILED", 0);
+    }
+    else {
+        rsDebug("test_foreach_output PASSED", 0);
+    }
+
+    return failed;
+}
+
+void foreach_test() {
+    bool failed = false;
+    failed |= test_foreach_output();
+
+    if (failed) {
+        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+    }
+    else {
+        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+    }
+}
+