Merge "Remove unused keyguard code"
diff --git a/api/current.txt b/api/current.txt
index 1eec50e..111bd65 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19394,6 +19394,7 @@
     enum_constant public static final android.renderscript.Element.DataKind PIXEL_LA;
     enum_constant public static final android.renderscript.Element.DataKind PIXEL_RGB;
     enum_constant public static final android.renderscript.Element.DataKind PIXEL_RGBA;
+    enum_constant public static final android.renderscript.Element.DataKind PIXEL_YUV;
     enum_constant public static final android.renderscript.Element.DataKind USER;
   }
 
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index 23d8f46..c1411b0 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -154,8 +154,8 @@
      *
      * @param abstractInterface The ContentProvider interface that is to be
      *              coerced.
-     * @return If the IContentProvider is non-null and local, returns its actual
-     * ContentProvider instance.  Otherwise returns null.
+     * @return If the IContentProvider is non-{@code null} and local, returns its actual
+     * ContentProvider instance.  Otherwise returns {@code null}.
      * @hide
      */
     public static ContentProvider coerceToLocalContentProvider(
@@ -398,7 +398,7 @@
 
     /**
      * Retrieves the Context this provider is running in.  Only available once
-     * {@link #onCreate} has been called -- this will return null in the
+     * {@link #onCreate} has been called -- this will return {@code null} in the
      * constructor.
      */
     public final Context getContext() {
@@ -570,15 +570,15 @@
      *      that the implementation should parse and add to a WHERE or HAVING clause, specifying
      *      that _id value.
      * @param projection The list of columns to put into the cursor. If
-     *      null all columns are included.
+     *      {@code null} all columns are included.
      * @param selection A selection criteria to apply when filtering rows.
-     *      If null then all rows are included.
+     *      If {@code null} then all rows are included.
      * @param selectionArgs You may include ?s in selection, which will be replaced by
      *      the values from selectionArgs, in order that they appear in the selection.
      *      The values will be bound as Strings.
      * @param sortOrder How the rows in the cursor should be sorted.
-     *      If null then the provider is free to define the sort order.
-     * @return a Cursor or null.
+     *      If {@code null} then the provider is free to define the sort order.
+     * @return a Cursor or {@code null}.
      */
     public abstract Cursor query(Uri uri, String[] projection,
             String selection, String[] selectionArgs, String sortOrder);
@@ -633,18 +633,18 @@
      *      that the implementation should parse and add to a WHERE or HAVING clause, specifying
      *      that _id value.
      * @param projection The list of columns to put into the cursor. If
-     *      null all columns are included.
+     *      {@code null} all columns are included.
      * @param selection A selection criteria to apply when filtering rows.
-     *      If null then all rows are included.
+     *      If {@code null} then all rows are included.
      * @param selectionArgs You may include ?s in selection, which will be replaced by
      *      the values from selectionArgs, in order that they appear in the selection.
      *      The values will be bound as Strings.
      * @param sortOrder How the rows in the cursor should be sorted.
-     *      If null then the provider is free to define the sort order.
-     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.
+     *      If {@code null} then the provider is free to define the sort order.
+     * @param cancellationSignal A signal to cancel the operation in progress, or {@code null} if none.
      * If the operation is canceled, then {@link OperationCanceledException} will be thrown
      * when the query is executed.
-     * @return a Cursor or null.
+     * @return a Cursor or {@code null}.
      */
     public Cursor query(Uri uri, String[] projection,
             String selection, String[] selectionArgs, String sortOrder,
@@ -668,7 +668,7 @@
      * to retrieve the MIME type for a URI when dispatching intents.
      *
      * @param uri the URI to query.
-     * @return a MIME type string, or null if there is no type.
+     * @return a MIME type string, or {@code null} if there is no type.
      */
     public abstract String getType(Uri uri);
 
@@ -679,8 +679,9 @@
      * This method can be called from multiple threads, as described in
      * <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
      * and Threads</a>.
-     * @param uri The content:// URI of the insertion request.
+     * @param uri The content:// URI of the insertion request. This must not be {@code null}.
      * @param values A set of column_name/value pairs to add to the database.
+     *     This must not be {@code null}.
      * @return The URI for the newly inserted item.
      */
     public abstract Uri insert(Uri uri, ContentValues values);
@@ -697,6 +698,7 @@
      *
      * @param uri The content:// URI of the insertion request.
      * @param values An array of sets of column_name/value pairs to add to the database.
+     *    This must not be {@code null}.
      * @return The number of values that were inserted.
      */
     public int bulkInsert(Uri uri, ContentValues[] values) {
@@ -741,8 +743,8 @@
      *
      * @param uri The URI to query. This can potentially have a record ID if this
      * is an update request for a specific record.
-     * @param values A Bundle mapping from column names to new column values (NULL is a
-     *               valid value).
+     * @param values A set of column_name/value pairs to update in the database.
+     *     This must not be {@code null}.
      * @param selection An optional filter to match rows to update.
      * @return the number of rows affected.
      */
@@ -875,7 +877,7 @@
     /**
      * Called by a client to determine the types of data streams that this
      * content provider supports for the given URI.  The default implementation
-     * returns null, meaning no types.  If your content provider stores data
+     * returns {@code null}, meaning no types.  If your content provider stores data
      * of a particular type, return that MIME type if it matches the given
      * mimeTypeFilter.  If it can perform type conversions, return an array
      * of all supported MIME types that match mimeTypeFilter.
@@ -883,7 +885,7 @@
      * @param uri The data in the content provider being queried.
      * @param mimeTypeFilter The type of data the client desires.  May be
      * a pattern, such as *\/* to retrieve all possible data types.
-     * @return Returns null if there are no possible data streams for the
+     * @return Returns {@code null} if there are no possible data streams for the
      * given mimeTypeFilter.  Otherwise returns an array of all available
      * concrete MIME types.
      *
@@ -1091,10 +1093,10 @@
      * interfaces that are cheaper and/or unnatural for a table-like
      * model.
      *
-     * @param method method name to call.  Opaque to framework, but should not be null.
-     * @param arg provider-defined String argument.  May be null.
-     * @param extras provider-defined Bundle argument.  May be null.
-     * @return provider-defined return value.  May be null.  Null is also
+     * @param method method name to call.  Opaque to framework, but should not be {@code null}.
+     * @param arg provider-defined String argument.  May be {@code null}.
+     * @param extras provider-defined Bundle argument.  May be {@code null}.
+     * @return provider-defined return value.  May be {@code null}, which is also
      *   the default for providers which don't implement any call methods.
      */
     public Bundle call(String method, String arg, Bundle extras) {
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java
index 460a5fe..65eefcb 100644
--- a/core/java/android/os/Bundle.java
+++ b/core/java/android/os/Bundle.java
@@ -1061,10 +1061,7 @@
      */
     public String getString(String key) {
         unparcel();
-        Object o = mMap.get(key);
-        if (o == null) {
-            return null;
-        }
+        final Object o = mMap.get(key);
         try {
             return (String) o;
         } catch (ClassCastException e) {
@@ -1079,20 +1076,12 @@
      *
      * @param key a String, or null
      * @param defaultValue Value to return if key does not exist
-     * @return a String value, or null
+     * @return the String value associated with the given key, or defaultValue
+     *     if no valid String object is currently mapped to that key.
      */
     public String getString(String key, String defaultValue) {
-        unparcel();
-        Object o = mMap.get(key);
-        if (o == null) {
-            return defaultValue;
-        }
-        try {
-            return (String) o;
-        } catch (ClassCastException e) {
-            typeWarning(key, o, "String", e);
-            return defaultValue;
-        }
+        final String s = getString(key);
+        return (s == null) ? defaultValue : s;
     }
 
     /**
@@ -1105,10 +1094,7 @@
      */
     public CharSequence getCharSequence(String key) {
         unparcel();
-        Object o = mMap.get(key);
-        if (o == null) {
-            return null;
-        }
+        final Object o = mMap.get(key);
         try {
             return (CharSequence) o;
         } catch (ClassCastException e) {
@@ -1123,20 +1109,12 @@
      *
      * @param key a String, or null
      * @param defaultValue Value to return if key does not exist
-     * @return a CharSequence value, or null
+     * @return the CharSequence value associated with the given key, or defaultValue
+     *     if no valid CharSequence object is currently mapped to that key.
      */
     public CharSequence getCharSequence(String key, CharSequence defaultValue) {
-        unparcel();
-        Object o = mMap.get(key);
-        if (o == null) {
-            return defaultValue;
-        }
-        try {
-            return (CharSequence) o;
-        } catch (ClassCastException e) {
-            typeWarning(key, o, "CharSequence", e);
-            return defaultValue;
-        }
+        final CharSequence cs = getCharSequence(key);
+        return (cs == null) ? defaultValue : cs;
     }
 
     /**
diff --git a/docs/html/about/dashboards/index.jd b/docs/html/about/dashboards/index.jd
index 7282dbb..aa0e010 100644
--- a/docs/html/about/dashboards/index.jd
+++ b/docs/html/about/dashboards/index.jd
@@ -30,33 +30,33 @@
   <th>API</th>
   <th>Distribution</th>
 </tr>
-<tr><td><a href="/about/versions/android-1.5.html">1.5</a></td><td>Cupcake</td>  <td>3</td><td>0.1%</td></tr>
-<tr><td><a href="/about/versions/android-1.6.html">1.6</a></td><td>Donut</td>    <td>4</td><td>0.3%</td></tr>
-<tr><td><a href="/about/versions/android-2.1.html">2.1</a></td><td>Eclair</td>   <td>7</td><td>2.7%</td></tr>
-<tr><td><a href="/about/versions/android-2.2.html">2.2</a></td><td>Froyo</td>    <td>8</td><td>10.3%</td></tr>
+<tr><td><a href="/about/versions/android-1.6.html">1.6</a></td><td>Donut</td>    <td>4</td><td>0.2%</td></tr>
+<tr><td><a href="/about/versions/android-2.1.html">2.1</a></td><td>Eclair</td>   <td>7</td><td>2.4%</td></tr>
+<tr><td><a href="/about/versions/android-2.2.html">2.2</a></td><td>Froyo</td>    <td>8</td><td>9.0%</td></tr>
 <tr><td><a href="/about/versions/android-2.3.html">2.3 - 2.3.2</a>
                                    </td><td rowspan="2">Gingerbread</td>    <td>9</td><td>0.2%</td></tr>
 <tr><td><a href="/about/versions/android-2.3.3.html">2.3.3 - 2.3.7
-        </a></td><!-- Gingerbread -->                                       <td>10</td><td>50.6%</td></tr>
+        </a></td><!-- Gingerbread -->                                       <td>10</td><td>47.4%</td></tr>
 <tr><td><a href="/about/versions/android-3.1.html">3.1</a></td>
                                                    <td rowspan="2">Honeycomb</td>      <td>12</td><td>0.4%</td></tr>
-<tr><td><a href="/about/versions/android-3.2.html">3.2</a></td>      <!-- Honeycomb --><td>13</td><td>1.2%</td></tr>
+<tr><td><a href="/about/versions/android-3.2.html">3.2</a></td>      <!-- Honeycomb --><td>13</td><td>1.1%</td></tr>
 <tr><td><a href="/about/versions/android-4.0.3.html">4.0.3 - 4.0.4</a></td>
-                                                            <td>Ice Cream Sandwich</td><td>15</td><td>27.5%</td></tr> 
+                                                            <td>Ice Cream Sandwich</td><td>15</td><td>29.1%</td></tr> 
 <tr><td><a href="/about/versions/android-4.1.html">4.1</a></td>
-                                                   <td rowspan="2">Jelly Bean</td><td>16</td><td>5.9%</td></tr>
-<tr><td><a href="/about/versions/android-4.2.html">4.2</a></td><!--Jelly Bean-->  <td>17</td><td>0.8%</td></tr>  
+                                                   <td rowspan="2">Jelly Bean</td><td>16</td><td>9.0%</td></tr>
+<tr><td><a href="/about/versions/android-4.2.html">4.2</a></td><!--Jelly Bean-->  <td>17</td><td>1.2%</td></tr>  
 </table>
 
 </div>
 
 <div class="col-8" style="margin-right:0">
 <img alt=""
-src="http://chart.apis.google.com/chart?&cht=p&chs=460x245&chf=bg,s,00000000&chd=t:3.1,10.3,50.8,1.6,27.5,6.7&chl=Eclair%20%26%20older|Froyo|Gingerbread|Honeycomb|Ice%20Cream%20Sandwich|Jelly%20Bean&chco=c4df9b,6fad0c" />
+src="http://chart.apis.google.com/chart?&cht=p&chs=460x245&chf=bg,s,00000000&chd=t:2.6,9.0,47.6,1.5,29.1,10.2&chl=Eclair%20%26%20older|Froyo|Gingerbread|Honeycomb|Ice%20Cream%20Sandwich|Jelly%20Bean&chco=c4df9b,6fad0c"
+/>
 
 </div><!-- end dashboard-panel -->
 
-<p style="clear:both"><em>Data collected during a 14-day period ending on December 3, 2012</em></p>
+<p style="clear:both"><em>Data collected during a 14-day period ending on January 3, 2013</em></p>
 <!--
 <p style="font-size:.9em">* <em>Other: 0.1% of devices running obsolete versions</em></p>
 -->
@@ -81,9 +81,9 @@
 Google Play within a 14-day period ending on the date indicated on the x-axis.</p>
 
 <img alt="" height="250" width="660"
-src="http://chart.apis.google.com/chart?&cht=lc&chs=660x250&chxt=x,x,y,r&chf=bg,s,00000000&chxr=0,0,12|1,0,12|2,0,100|3,0,100&chxl=0%3A%7C06/01%7C06/15%7C07/01%7C07/15%7C08/01%7C08/15%7C09/01%7C09/15%7C10/01%7C10/15%7C11/01%7C11/15%7C12/01%7C1%3A%7C2012%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C2012%7C2%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25%7C3%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25&chxp=0,0,1,2,3,4,5,6,7,8,9,10,11,12&chxtc=0,5&chd=t:99.1,99.2,99.2,99.2,99.2,99.2,99.3,99.4,99.5,99.5,99.5,99.6,100.0|93.9,94.2,94.5,94.7,95.0,95.2,95.6,95.8,96.1,96.3,96.4,96.7,96.9|74.8,75.9,77.1,78.3,79.5,80.4,81.4,82.3,83.2,83.8,84.7,85.6,86.4|9.8,11.3,13.0,15.7,18.9,21.2,23.7,25.5,27.4,28.7,31.1,33.0,35.4|7.1,8.7,10.6,13.3,16.6,19.0,21.5,23.5,25.5,26.8,29.4,31.4,33.8|0.0,0.0,0.0,0.0,0.8,0.9,1.1,1.4,1.8,2.1,3.2,4.8,6.5&chm=b,c3df9b,0,1,0|tFroyo,689326,1,0,15,,t::-5|b,b4db77,1,2,0|tGingerbread,547a19,2,0,15,,t::-5|b,a5db51,2,3,0|b,96dd28,3,4,0|tIce%20Cream%20Sandwich,293f07,4,2,15,,t::-5|b,83c916,4,5,0|B,6fad0c,5,6,0&chg=7,25&chdl=Eclair|Froyo|Gingerbread|Honeycomb|Ice%20Cream%20Sandwich|Jelly%20Bean&chco=add274,9dd14f,8ece2a,7ab61c,659b11,507d08"
+src="http://chart.apis.google.com/chart?&cht=lc&chs=660x250&chxt=x,x,y,r&chf=bg,s,00000000&chxr=0,0,12|1,0,12|2,0,100|3,0,100&chxl=0%3A%7C07/01%7C07/15%7C08/01%7C08/15%7C09/01%7C09/15%7C10/01%7C10/15%7C11/01%7C11/15%7C12/01%7C12/15%7C01/01%7C1%3A%7C2012%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C2013%7C2%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25%7C3%3A%7C0%25%7C25%25%7C50%25%7C75%25%7C100%25&chxp=0,0,1,2,3,4,5,6,7,8,9,10,11,12&chxtc=0,5&chd=t:99.2,99.2,99.2,99.2,99.3,99.4,99.5,99.5,99.5,99.6,100.0,100.0,100.0|94.5,94.7,95.0,95.2,95.6,95.8,96.1,96.3,96.4,96.7,96.9,97.2,97.4|77.1,78.3,79.5,80.4,81.4,82.3,83.2,83.8,84.7,85.6,86.4,87.0,88.2|13.0,15.7,18.9,21.2,23.7,25.5,27.4,28.7,31.1,33.0,35.4,36.8,40.3|10.6,13.3,16.6,19.0,21.5,23.5,25.5,26.8,29.4,31.4,33.8,35.2,38.8|0.0,0.0,0.8,0.9,1.1,1.4,1.8,2.1,3.2,4.8,6.5,7.5,9.9&chm=b,c3df9b,0,1,0|tFroyo,689326,1,0,15,,t::-5|b,b4db77,1,2,0|tGingerbread,547a19,2,0,15,,t::-5|b,a5db51,2,3,0|b,96dd28,3,4,0|tIce%20Cream%20Sandwich,293f07,4,0,15,,t::-5|b,83c916,4,5,0|B,6fad0c,5,6,0&chg=7,25&chdl=Eclair|Froyo|Gingerbread|Honeycomb|Ice%20Cream%20Sandwich|Jelly%20Bean&chco=add274,9dd14f,8ece2a,7ab61c,659b11,507d08"
 />
-<p><em>Last historical dataset collected during a 14-day period ending on December 1, 2012</em></p>
+<p><em>Last historical dataset collected during a 14-day period ending on January 1, 2013</em></p>
 
 
 
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java
index 060f526..20e716c 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -171,7 +171,8 @@
         PIXEL_LA (9),
         PIXEL_RGB (10),
         PIXEL_RGBA (11),
-        PIXEL_DEPTH (12);
+        PIXEL_DEPTH (12),
+        PIXEL_YUV(13);
 
         int mID;
         DataKind(int id) {
diff --git a/graphics/java/android/renderscript/ScriptIntrinsic.java b/graphics/java/android/renderscript/ScriptIntrinsic.java
index f54943a..096268a 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsic.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsic.java
@@ -16,11 +16,6 @@
 
 package android.renderscript;
 
-import android.content.Context;
-import android.content.res.Resources;
-import android.util.Log;
-
-
 /**
  * Base class for all Intrinsic scripts. An intrinsic a script
  * which implements a pre-defined function. Intrinsics are
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
index cb458ba..b219978 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
@@ -16,8 +16,6 @@
 
 package android.renderscript;
 
-import android.content.Context;
-import android.content.res.Resources;
 import android.util.Log;
 
 /**
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
index 91efa02..b40ea84 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
@@ -16,8 +16,6 @@
 
 package android.renderscript;
 
-import android.content.Context;
-import android.content.res.Resources;
 import android.util.Log;
 
 /**
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java b/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
index 41bdd25..f5ca261 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicLUT.java
@@ -16,8 +16,6 @@
 
 package android.renderscript;
 
-import android.content.Context;
-import android.content.res.Resources;
 import android.util.Log;
 
 /**
diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java
index b36aee2..93d8b4b 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/graphics/java/android/renderscript/Type.java
@@ -47,6 +47,7 @@
     int mDimZ;
     boolean mDimMipmaps;
     boolean mDimFaces;
+    int mDimYuv;
     int mElementCount;
     Element mElement;
 
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp
index 35a8487..154c0ec 100644
--- a/libs/hwui/GradientCache.cpp
+++ b/libs/hwui/GradientCache.cpp
@@ -49,7 +49,6 @@
 
 hash_t GradientCacheEntry::hash() const {
     uint32_t hash = JenkinsHashMix(0, count);
-    hash = JenkinsHashMix(hash, tileMode);
     for (uint32_t i = 0; i < count; i++) {
         hash = JenkinsHashMix(hash, android::hash_type(colors[i]));
         hash = JenkinsHashMix(hash, android::hash_type(positions[i]));
@@ -61,9 +60,6 @@
     int deltaInt = int(lhs.count) - int(rhs.count);
     if (deltaInt != 0) return deltaInt;
 
-    deltaInt = lhs.tileMode - rhs.tileMode;
-    if (deltaInt != 0) return deltaInt;
-
     deltaInt = memcmp(lhs.colors, rhs.colors, lhs.count * sizeof(uint32_t));
     if (deltaInt != 0) return deltaInt;
 
@@ -127,9 +123,7 @@
     if (texture) {
         const uint32_t size = texture->width * texture->height * GRADIENT_BYTES_PER_PIXEL;
         mSize -= size;
-    }
 
-    if (texture) {
         glDeleteTextures(1, &texture->id);
         delete texture;
     }
@@ -140,7 +134,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 Texture* GradientCache::get(uint32_t* colors, float* positions, int count) {
-
     GradientCacheEntry gradient(colors, positions, count);
     Texture* texture = mCache.get(gradient);
 
@@ -189,7 +182,7 @@
 
     // Asume the cache is always big enough
     const uint32_t size = texture->width * texture->height * GRADIENT_BYTES_PER_PIXEL;
-    while (mSize + size > mMaxSize) {
+    while (getSize() + size > mMaxSize) {
         mCache.removeOldest();
     }
 
diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h
index d183a85..7dc5b8a 100644
--- a/libs/hwui/GradientCache.h
+++ b/libs/hwui/GradientCache.h
@@ -76,10 +76,8 @@
     uint32_t* colors;
     float* positions;
     uint32_t count;
-    SkShader::TileMode tileMode;
 
 private:
-
     void copy(uint32_t* colors, float* positions, uint32_t count) {
         this->count = count;
         this->colors = new uint32_t[count];
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index c7a2014..ca9a38e 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -183,14 +183,7 @@
 
     updateLayers();
 
-    // If we know that we are going to redraw the entire framebuffer,
-    // perform a discard to let the driver know we don't need to preserve
-    // the back buffer for this frame.
-    if (mCaches.extensions.hasDiscardFramebuffer() &&
-            left <= 0.0f && top <= 0.0f && right >= mWidth && bottom >= mHeight) {
-        const GLenum attachments[] = { getTargetFbo() == 0 ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0 };
-        glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments);
-    }
+    discardFramebuffer(left, top, right, bottom);
 
     syncState();
 
@@ -207,6 +200,18 @@
     return clear(left, top, right, bottom, opaque);
 }
 
+void OpenGLRenderer::discardFramebuffer(float left, float top, float right, float bottom) {
+    // If we know that we are going to redraw the entire framebuffer,
+    // perform a discard to let the driver know we don't need to preserve
+    // the back buffer for this frame.
+    if (mCaches.extensions.hasDiscardFramebuffer() &&
+            left <= 0.0f && top <= 0.0f && right >= mWidth && bottom >= mHeight) {
+        const GLenum attachments[] = { getTargetFbo() == 0 ? (const GLenum) GL_COLOR_EXT :
+                (const GLenum) GL_COLOR_ATTACHMENT0 };
+        glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments);
+    }
+}
+
 status_t OpenGLRenderer::clear(float left, float top, float right, float bottom, bool opaque) {
     if (!opaque) {
         mCaches.enableScissor();
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index c5e4c8e..f165581 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -366,6 +366,13 @@
 
 private:
     /**
+     * Discards the content of the framebuffer if supported by the driver.
+     * This method should be called at the beginning of a frame to optimize
+     * rendering on some tiler architectures.
+     */
+    void discardFramebuffer(float left, float top, float right, float bottom);
+
+    /**
      * Ensures the state of the renderer is the same as the state of
      * the GL context.
      */
diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h
index 2687592..bc12b0d 100644
--- a/libs/hwui/SkiaShader.h
+++ b/libs/hwui/SkiaShader.h
@@ -65,7 +65,7 @@
     virtual void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
             GLuint* textureUnit);
 
-    inline SkShader *getSkShader() {
+    inline SkShader* getSkShader() {
         return mKey;
     }
 
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 1c8c7cc..9aac0e6 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -157,6 +157,7 @@
     private static final int MSG_CONFIGURE_SAFE_MEDIA_VOLUME = 26;
     private static final int MSG_CONFIGURE_SAFE_MEDIA_VOLUME_FORCED = 27;
     private static final int MSG_PERSIST_SAFE_VOLUME_STATE = 28;
+    private static final int MSG_PROMOTE_RCC = 29;
 
     // flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
     // persisted
@@ -3527,6 +3528,10 @@
                 case MSG_PERSIST_SAFE_VOLUME_STATE:
                     onPersistSafeVolumeState(msg.arg1);
                     break;
+
+                case MSG_PROMOTE_RCC:
+                    onPromoteRcc(msg.arg1);
+                    break;
             }
         }
     }
@@ -5246,6 +5251,50 @@
     }
 
     /**
+     * Helper function:
+     * Post a message to asynchronously move the media button event receiver associated with the
+     * given remote control client ID to the top of the remote control stack
+     * @param rccId
+     */
+    private void postPromoteRcc(int rccId) {
+        sendMsg(mAudioHandler, MSG_PROMOTE_RCC, SENDMSG_REPLACE,
+                rccId /*arg1*/, 0, null, 0/*delay*/);
+    }
+
+    private void onPromoteRcc(int rccId) {
+        if (DEBUG_RC) { Log.d(TAG, "Promoting RCC " + rccId); }
+        synchronized(mAudioFocusLock) {
+            synchronized(mRCStack) {
+                // ignore if given RCC ID is already at top of remote control stack
+                if (!mRCStack.isEmpty() && (mRCStack.peek().mRccId == rccId)) {
+                    return;
+                }
+                int indexToPromote = -1;
+                try {
+                    for (int index = mRCStack.size()-1; index >= 0; index--) {
+                        final RemoteControlStackEntry rcse = mRCStack.elementAt(index);
+                        if (rcse.mRccId == rccId) {
+                            indexToPromote = index;
+                            break;
+                        }
+                    }
+                    if (indexToPromote >= 0) {
+                        if (DEBUG_RC) { Log.d(TAG, "  moving RCC from index " + indexToPromote
+                                + " to " + (mRCStack.size()-1)); }
+                        final RemoteControlStackEntry rcse = mRCStack.remove(indexToPromote);
+                        mRCStack.push(rcse);
+                        // the RC stack changed, reevaluate the display
+                        checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL);
+                    }
+                } catch (ArrayIndexOutOfBoundsException e) {
+                    // not expected to happen, indicates improper concurrent modification
+                    Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e);
+                }
+            }//synchronized(mRCStack)
+        }//synchronized(mAudioFocusLock)
+    }
+
+    /**
      * see AudioManager.registerMediaButtonIntent(PendingIntent pi, ComponentName c)
      * precondition: mediaIntent != null, target != null
      */
@@ -5389,6 +5438,7 @@
      */
     public void unregisterRemoteControlClient(PendingIntent mediaIntent,
             IRemoteControlClient rcClient) {
+        if (DEBUG_RC) Log.i(TAG, "Unregister remote control client rcClient="+rcClient);
         synchronized(mAudioFocusLock) {
             synchronized(mRCStack) {
                 boolean topRccChange = false;
@@ -5628,6 +5678,12 @@
                                         postReevaluateRemote();
                                     }
                                 }
+                                // an RCC moving to a "playing" state should become the media button
+                                //   event receiver so it can be controlled, without requiring the
+                                //   app to re-register its receiver
+                                if (isPlaystateActive(value)) {
+                                    postPromoteRcc(rccId);
+                                }
                                 break;
                             default:
                                 Log.e(TAG, "unhandled key " + key + " for RCC " + rccId);
diff --git a/services/jni/com_android_server_location_GpsLocationProvider.cpp b/services/jni/com_android_server_location_GpsLocationProvider.cpp
index 50bd46e..036fc43 100644
--- a/services/jni/com_android_server_location_GpsLocationProvider.cpp
+++ b/services/jni/com_android_server_location_GpsLocationProvider.cpp
@@ -490,7 +490,7 @@
 static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* env, jobject obj)
 {
     if (!sAGpsInterface) {
-        ALOGE("no AGPS interface in agps_data_conn_open");
+        ALOGE("no AGPS interface in agps_data_conn_closed");
         return;
     }
     sAGpsInterface->data_conn_closed();
@@ -499,7 +499,7 @@
 static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* env, jobject obj)
 {
     if (!sAGpsInterface) {
-        ALOGE("no AGPS interface in agps_data_conn_open");
+        ALOGE("no AGPS interface in agps_data_conn_failed");
         return;
     }
     sAGpsInterface->data_conn_failed();
@@ -509,7 +509,7 @@
         jint type, jstring hostname, jint port)
 {
     if (!sAGpsInterface) {
-        ALOGE("no AGPS interface in agps_data_conn_open");
+        ALOGE("no AGPS interface in set_agps_server");
         return;
     }
     const char *c_hostname = env->GetStringUTFChars(hostname, NULL);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 2e8de3b..6241a49 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -377,6 +377,8 @@
         case RILConstants.NETWORK_MODE_GSM_ONLY:
         case RILConstants.NETWORK_MODE_WCDMA_ONLY:
         case RILConstants.NETWORK_MODE_GSM_UMTS:
+        case RILConstants.NETWORK_MODE_LTE_GSM_WCDMA:
+        case RILConstants.NETWORK_MODE_LTE_WCDMA:
             return PhoneConstants.PHONE_TYPE_GSM;
 
         // Use CDMA Phone for the global mode including CDMA
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index f501b21..077ad68 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -72,7 +72,7 @@
     int NETWORK_MODE_LTE_GSM_WCDMA  = 9; /* LTE, GSM/WCDMA */
     int NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA = 10; /* LTE, CDMA, EvDo, GSM/WCDMA */
     int NETWORK_MODE_LTE_ONLY       = 11; /* LTE Only mode. */
-
+    int NETWORK_MODE_LTE_WCDMA      = 12; /* LTE/WCDMA */
     int PREFERRED_NETWORK_MODE      = NETWORK_MODE_WCDMA_PREF;
 
     int CDMA_CELL_BROADCAST_SMS_DISABLED = 1;
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
index d1dd47c..1d2cdbd 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
@@ -52,13 +52,11 @@
         for (int z = 0; z < sz; z++) {
             for (int y = 0; y < sy; y++) {
                 for (int x = 0; x < sx; x++ ) {
-
-                    dat[z*sy*sx + y*sx + x] = //0xff000000 |
-                        (((x >> 2) | (x<<3)) << 0) |
-                        (((y >> 2) | (y<<3)) << 8) |
-                        ((z | (z<<4)) << 16);
-
-
+                    int v = 0xff000000;
+                    v |= (0xff * x / (sx - 1));
+                    v |= (0xff * y / (sy - 1)) << 8;
+                    v |= (0xff * z / (sz - 1)) << 16;
+                    dat[z*sy*sx + y*sx + x] = v;
                 }
             }
         }
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
index 09b3f69..5250474 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
@@ -20,78 +20,71 @@
 
 
 static rs_allocation gCube;
-static short4 gDims;
-static short4 gFracMask;
-static short4 gFracBits;
-static short4 gFracShift;
-static int4 gFinalShift;
-static int4 gFinalAdd;
+static int4 gDims;
+static int4 gCoordMul;
+
 
 void setCube(rs_allocation c) {
     gCube = c;
-    gDims.x = rsAllocationGetDimX(gCube) - 1;
-    gDims.y = rsAllocationGetDimY(gCube) - 1;
-    gDims.z = rsAllocationGetDimZ(gCube) - 1;
+    gDims.x = rsAllocationGetDimX(gCube);
+    gDims.y = rsAllocationGetDimY(gCube);
+    gDims.z = rsAllocationGetDimZ(gCube);
     gDims.w = 0;
 
-    gFracMask = gDims;
-    gFracBits = (short4)32 - clz(gFracMask);
-    gFracShift = (short4)8 - gFracBits;
+    float4 m = (float4)(1.f / 255.f) * convert_float4(gDims - 1);
+    gCoordMul = convert_int4(m * (float4)0x10000);
 
     rsDebug("dims", gDims);
-    rsDebug("gFracMask", gFracMask);
-    rsDebug("gFracBits", gFracBits);
-
-    gFinalShift = gFracShift.x + gFracShift.y + gFracShift.z;
-    gFinalAdd = (((int4)1 << gFinalShift) - (int4)1) >> (int4)1;
-
-    rsDebug("gFinalShift", gFinalShift);
-    rsDebug("gFinalAdd", gFinalAdd);
-
+    rsDebug("gCoordMul", gCoordMul);
 }
 
 void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
     //rsDebug("root", in);
 
-    short4 baseCoord = convert_short4(*in);
-    short4 coord1 = baseCoord >> gFracShift;
-    short4 coord2 = min(coord1 + (short4)1, gDims);
+    int4 baseCoord = convert_int4(*in) * gCoordMul;
+    int4 coord1 = baseCoord >> (int4)16;
+    int4 coord2 = min(coord1 + 1, gDims - 1);
 
-    short4 weight2 = baseCoord - (coord1 << gFracShift);
-    short4 weight1 = ((short4)1 << gFracShift) - weight2;
+    int4 weight2 = baseCoord & 0xffff;
+    int4 weight1 = (int4)0x10000 - weight2;
 
-    ushort4 v000 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord1.z));
-    ushort4 v100 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord1.z));
-    ushort4 v010 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord1.z));
-    ushort4 v110 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord1.z));
-    ushort4 v001 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord2.z));
-    ushort4 v101 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord2.z));
-    ushort4 v011 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord2.z));
-    ushort4 v111 = convert_ushort4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord2.z));
+    uint4 v000 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord1.z));
+    uint4 v100 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord1.z));
+    uint4 v010 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord1.z));
+    uint4 v110 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord1.z));
+    uint4 v001 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord1.y, coord2.z));
+    uint4 v101 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord1.y, coord2.z));
+    uint4 v011 = convert_uint4(rsGetElementAt_uchar4(gCube, coord1.x, coord2.y, coord2.z));
+    uint4 v111 = convert_uint4(rsGetElementAt_uchar4(gCube, coord2.x, coord2.y, coord2.z));
 
-    uint4 yz00 = convert_uint4((v000 * weight1.x) + (v100 * weight2.x));
-    uint4 yz10 = convert_uint4((v010 * weight1.x) + (v110 * weight2.x));
-    uint4 yz01 = convert_uint4((v001 * weight1.x) + (v101 * weight2.x));
-    uint4 yz11 = convert_uint4((v011 * weight1.x) + (v111 * weight2.x));
+    uint4 yz00 = ((v000 * weight1.x) + (v100 * weight2.x)) >> (int4)8;
+    uint4 yz10 = ((v010 * weight1.x) + (v110 * weight2.x)) >> (int4)8;
+    uint4 yz01 = ((v001 * weight1.x) + (v101 * weight2.x)) >> (int4)8;
+    uint4 yz11 = ((v011 * weight1.x) + (v111 * weight2.x)) >> (int4)8;
 
-    uint4 z0 = (yz00 * weight1.y) + (yz10 * weight2.y);
-    uint4 z1 = (yz01 * weight1.y) + (yz11 * weight2.y);
+    uint4 z0 = (yz00 * weight1.y) + (yz10 * weight2.y) >> (int4)16;
+    uint4 z1 = (yz01 * weight1.y) + (yz11 * weight2.y) >> (int4)16;
 
-    uint4 v = (z0 * weight1.z) + (z1 * weight2.z);
+    uint4 v = (z0 * weight1.z) + (z1 * weight2.z) >> (int4)16;
+    uint4 v2 = (v + 0x7f) >> (int4)8;
+
+    *out = convert_uchar4(v2);
+    out->a = 0xff;
 
     #if 0
-    if (x + y < 100) {
-        rsDebug("coord1", coord1);
-        rsDebug("coord2", coord2);
-        rsDebug("weight1", weight1);
-        rsDebug("weight2", weight2);
-        rsDebug("yz00", yz00);
-        rsDebug("z0", z0);
-        rsDebug("v", v);
+    if (in->r != out->r) {
+        rsDebug("dr", in->r - out->r);
+        //rsDebug("in", convert_int4(*in));
+        //rsDebug("coord1", coord1);
+        //rsDebug("coord2", coord2);
+        //rsDebug("weight1", weight1);
+        //rsDebug("weight2", weight2);
+        //rsDebug("yz00", yz00);
+        //rsDebug("z0", z0);
+        //rsDebug("v", v);
+        //rsDebug("v2", v2);
+        //rsDebug("out", convert_int4(*out));
     }
     #endif
-
-    *out = convert_uchar4((v + gFinalAdd) >> gFinalShift);
-    out->a = 0xff;
 }