Merge "Add percentiles"
diff --git a/api/current.txt b/api/current.txt
index 03e03c9..e6d8546 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4464,10 +4464,10 @@
     method public void setInTouchMode(boolean);
     method public void start();
     method public android.app.Activity startActivitySync(android.content.Intent);
-    method public void startAllocCounting();
+    method public deprecated void startAllocCounting();
     method public void startPerformanceSnapshot();
     method public void startProfiling();
-    method public void stopAllocCounting();
+    method public deprecated void stopAllocCounting();
     method public void stopProfiling();
     method public void waitForIdle(java.lang.Runnable);
     method public void waitForIdleSync();
@@ -5547,6 +5547,7 @@
     method public int setStorageEncryption(android.content.ComponentName, boolean);
     method public void setUninstallBlocked(android.content.ComponentName, java.lang.String, boolean);
     method public boolean setUserEnabled(android.content.ComponentName);
+    method public void setUserIcon(android.content.ComponentName, android.graphics.Bitmap);
     method public boolean switchUser(android.content.ComponentName, android.os.UserHandle);
     method public void uninstallAllUserCaCerts(android.content.ComponentName);
     method public void uninstallCaCert(android.content.ComponentName, byte[]);
@@ -22040,47 +22041,47 @@
     method public static final int getBinderProxyObjectCount();
     method public static int getBinderReceivedTransactions();
     method public static int getBinderSentTransactions();
-    method public static int getGlobalAllocCount();
-    method public static int getGlobalAllocSize();
-    method public static int getGlobalClassInitCount();
-    method public static int getGlobalClassInitTime();
+    method public static deprecated int getGlobalAllocCount();
+    method public static deprecated int getGlobalAllocSize();
+    method public static deprecated int getGlobalClassInitCount();
+    method public static deprecated int getGlobalClassInitTime();
     method public static deprecated int getGlobalExternalAllocCount();
     method public static deprecated int getGlobalExternalAllocSize();
     method public static deprecated int getGlobalExternalFreedCount();
     method public static deprecated int getGlobalExternalFreedSize();
-    method public static int getGlobalFreedCount();
-    method public static int getGlobalFreedSize();
-    method public static int getGlobalGcInvocationCount();
+    method public static deprecated int getGlobalFreedCount();
+    method public static deprecated int getGlobalFreedSize();
+    method public static deprecated int getGlobalGcInvocationCount();
     method public static int getLoadedClassCount();
     method public static void getMemoryInfo(android.os.Debug.MemoryInfo);
     method public static long getNativeHeapAllocatedSize();
     method public static long getNativeHeapFreeSize();
     method public static long getNativeHeapSize();
     method public static long getPss();
-    method public static int getThreadAllocCount();
-    method public static int getThreadAllocSize();
+    method public static deprecated int getThreadAllocCount();
+    method public static deprecated int getThreadAllocSize();
     method public static deprecated int getThreadExternalAllocCount();
     method public static deprecated int getThreadExternalAllocSize();
-    method public static int getThreadGcInvocationCount();
+    method public static deprecated int getThreadGcInvocationCount();
     method public static boolean isDebuggerConnected();
     method public static void printLoadedClasses(int);
-    method public static void resetAllCounts();
-    method public static void resetGlobalAllocCount();
-    method public static void resetGlobalAllocSize();
-    method public static void resetGlobalClassInitCount();
-    method public static void resetGlobalClassInitTime();
+    method public static deprecated void resetAllCounts();
+    method public static deprecated void resetGlobalAllocCount();
+    method public static deprecated void resetGlobalAllocSize();
+    method public static deprecated void resetGlobalClassInitCount();
+    method public static deprecated void resetGlobalClassInitTime();
     method public static deprecated void resetGlobalExternalAllocCount();
     method public static deprecated void resetGlobalExternalAllocSize();
     method public static deprecated void resetGlobalExternalFreedCount();
     method public static deprecated void resetGlobalExternalFreedSize();
-    method public static void resetGlobalFreedCount();
-    method public static void resetGlobalFreedSize();
-    method public static void resetGlobalGcInvocationCount();
-    method public static void resetThreadAllocCount();
-    method public static void resetThreadAllocSize();
+    method public static deprecated void resetGlobalFreedCount();
+    method public static deprecated void resetGlobalFreedSize();
+    method public static deprecated void resetGlobalGcInvocationCount();
+    method public static deprecated void resetThreadAllocCount();
+    method public static deprecated void resetThreadAllocSize();
     method public static deprecated void resetThreadExternalAllocCount();
     method public static deprecated void resetThreadExternalAllocSize();
-    method public static void resetThreadGcInvocationCount();
+    method public static deprecated void resetThreadGcInvocationCount();
     method public static deprecated int setAllocationLimit(int);
     method public static deprecated int setGlobalAllocationLimit(int);
     method public static deprecated void startAllocCounting();
@@ -22099,7 +22100,7 @@
     field public static final int SHOW_CLASSLOADER = 2; // 0x2
     field public static final int SHOW_FULL_DETAIL = 1; // 0x1
     field public static final int SHOW_INITIALIZED = 4; // 0x4
-    field public static final int TRACE_COUNT_ALLOCS = 1; // 0x1
+    field public static final deprecated int TRACE_COUNT_ALLOCS = 1; // 0x1
   }
 
   public static deprecated class Debug.InstructionCount {
@@ -29330,6 +29331,7 @@
   }
 
   public class TelephonyManager {
+    method public boolean canChangeDtmfToneLength();
     method public java.util.List<android.telephony.CellInfo> getAllCellInfo();
     method public int getCallState();
     method public android.telephony.CellLocation getCellLocation();
@@ -29365,6 +29367,7 @@
     method public boolean isNetworkRoaming();
     method public boolean isSmsCapable();
     method public boolean isVoiceCapable();
+    method public boolean isWorldPhone();
     method public void listen(android.telephony.PhoneStateListener, int);
     method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
     method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
@@ -36924,6 +36927,12 @@
     method public abstract void onReceivedIcon(java.lang.String, android.graphics.Bitmap);
   }
 
+  public abstract class WebResourceError {
+    ctor public WebResourceError();
+    method public abstract java.lang.String getDescription();
+    method public abstract int getErrorCode();
+  }
+
   public abstract interface WebResourceRequest {
     method public abstract java.lang.String getMethod();
     method public abstract java.util.Map<java.lang.String, java.lang.String> getRequestHeaders();
@@ -36932,7 +36941,7 @@
     method public abstract boolean isForMainFrame();
   }
 
-  public class WebResourceResponse {
+  public class WebResourceResponse extends android.webkit.WebResourceResponseBase {
     ctor public WebResourceResponse(java.lang.String, java.lang.String, java.io.InputStream);
     ctor public WebResourceResponse(java.lang.String, java.lang.String, int, java.lang.String, java.util.Map<java.lang.String, java.lang.String>, java.io.InputStream);
     method public java.io.InputStream getData();
@@ -36948,6 +36957,16 @@
     method public void setStatusCodeAndReasonPhrase(int, java.lang.String);
   }
 
+  public abstract class WebResourceResponseBase {
+    ctor public WebResourceResponseBase();
+    method public abstract java.io.InputStream getData();
+    method public abstract java.lang.String getEncoding();
+    method public abstract java.lang.String getMimeType();
+    method public abstract java.lang.String getReasonPhrase();
+    method public abstract java.util.Map<java.lang.String, java.lang.String> getResponseHeaders();
+    method public abstract int getStatusCode();
+  }
+
   public abstract class WebSettings {
     ctor public WebSettings();
     method public abstract deprecated boolean enableSmoothTransition();
@@ -37262,8 +37281,10 @@
     method public void onPageFinished(android.webkit.WebView, java.lang.String);
     method public void onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
     method public void onReceivedClientCertRequest(android.webkit.WebView, android.webkit.ClientCertRequest);
-    method public void onReceivedError(android.webkit.WebView, int, java.lang.String, java.lang.String);
+    method public deprecated void onReceivedError(android.webkit.WebView, int, java.lang.String, java.lang.String);
+    method public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
     method public void onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String);
+    method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponseBase);
     method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
     method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
     method public void onScaleChanged(android.webkit.WebView, float, float);
@@ -37276,6 +37297,7 @@
     method public boolean shouldOverrideUrlLoading(android.webkit.WebView, java.lang.String);
     field public static final int ERROR_AUTHENTICATION = -4; // 0xfffffffc
     field public static final int ERROR_BAD_URL = -12; // 0xfffffff4
+    field public static final int ERROR_BLOCKED = -16; // 0xfffffff0
     field public static final int ERROR_CONNECT = -6; // 0xfffffffa
     field public static final int ERROR_FAILED_SSL_HANDSHAKE = -11; // 0xfffffff5
     field public static final int ERROR_FILE = -13; // 0xfffffff3
diff --git a/api/system-current.txt b/api/system-current.txt
index 910d3d3..ca84133 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4554,10 +4554,10 @@
     method public void setInTouchMode(boolean);
     method public void start();
     method public android.app.Activity startActivitySync(android.content.Intent);
-    method public void startAllocCounting();
+    method public deprecated void startAllocCounting();
     method public void startPerformanceSnapshot();
     method public void startProfiling();
-    method public void stopAllocCounting();
+    method public deprecated void stopAllocCounting();
     method public void stopProfiling();
     method public void waitForIdle(java.lang.Runnable);
     method public void waitForIdleSync();
@@ -5649,6 +5649,7 @@
     method public int setStorageEncryption(android.content.ComponentName, boolean);
     method public void setUninstallBlocked(android.content.ComponentName, java.lang.String, boolean);
     method public boolean setUserEnabled(android.content.ComponentName);
+    method public void setUserIcon(android.content.ComponentName, android.graphics.Bitmap);
     method public boolean switchUser(android.content.ComponentName, android.os.UserHandle);
     method public void uninstallAllUserCaCerts(android.content.ComponentName);
     method public void uninstallCaCert(android.content.ComponentName, byte[]);
@@ -23630,47 +23631,47 @@
     method public static final int getBinderProxyObjectCount();
     method public static int getBinderReceivedTransactions();
     method public static int getBinderSentTransactions();
-    method public static int getGlobalAllocCount();
-    method public static int getGlobalAllocSize();
-    method public static int getGlobalClassInitCount();
-    method public static int getGlobalClassInitTime();
+    method public static deprecated int getGlobalAllocCount();
+    method public static deprecated int getGlobalAllocSize();
+    method public static deprecated int getGlobalClassInitCount();
+    method public static deprecated int getGlobalClassInitTime();
     method public static deprecated int getGlobalExternalAllocCount();
     method public static deprecated int getGlobalExternalAllocSize();
     method public static deprecated int getGlobalExternalFreedCount();
     method public static deprecated int getGlobalExternalFreedSize();
-    method public static int getGlobalFreedCount();
-    method public static int getGlobalFreedSize();
-    method public static int getGlobalGcInvocationCount();
+    method public static deprecated int getGlobalFreedCount();
+    method public static deprecated int getGlobalFreedSize();
+    method public static deprecated int getGlobalGcInvocationCount();
     method public static int getLoadedClassCount();
     method public static void getMemoryInfo(android.os.Debug.MemoryInfo);
     method public static long getNativeHeapAllocatedSize();
     method public static long getNativeHeapFreeSize();
     method public static long getNativeHeapSize();
     method public static long getPss();
-    method public static int getThreadAllocCount();
-    method public static int getThreadAllocSize();
+    method public static deprecated int getThreadAllocCount();
+    method public static deprecated int getThreadAllocSize();
     method public static deprecated int getThreadExternalAllocCount();
     method public static deprecated int getThreadExternalAllocSize();
-    method public static int getThreadGcInvocationCount();
+    method public static deprecated int getThreadGcInvocationCount();
     method public static boolean isDebuggerConnected();
     method public static void printLoadedClasses(int);
-    method public static void resetAllCounts();
-    method public static void resetGlobalAllocCount();
-    method public static void resetGlobalAllocSize();
-    method public static void resetGlobalClassInitCount();
-    method public static void resetGlobalClassInitTime();
+    method public static deprecated void resetAllCounts();
+    method public static deprecated void resetGlobalAllocCount();
+    method public static deprecated void resetGlobalAllocSize();
+    method public static deprecated void resetGlobalClassInitCount();
+    method public static deprecated void resetGlobalClassInitTime();
     method public static deprecated void resetGlobalExternalAllocCount();
     method public static deprecated void resetGlobalExternalAllocSize();
     method public static deprecated void resetGlobalExternalFreedCount();
     method public static deprecated void resetGlobalExternalFreedSize();
-    method public static void resetGlobalFreedCount();
-    method public static void resetGlobalFreedSize();
-    method public static void resetGlobalGcInvocationCount();
-    method public static void resetThreadAllocCount();
-    method public static void resetThreadAllocSize();
+    method public static deprecated void resetGlobalFreedCount();
+    method public static deprecated void resetGlobalFreedSize();
+    method public static deprecated void resetGlobalGcInvocationCount();
+    method public static deprecated void resetThreadAllocCount();
+    method public static deprecated void resetThreadAllocSize();
     method public static deprecated void resetThreadExternalAllocCount();
     method public static deprecated void resetThreadExternalAllocSize();
-    method public static void resetThreadGcInvocationCount();
+    method public static deprecated void resetThreadGcInvocationCount();
     method public static deprecated int setAllocationLimit(int);
     method public static deprecated int setGlobalAllocationLimit(int);
     method public static deprecated void startAllocCounting();
@@ -23689,7 +23690,7 @@
     field public static final int SHOW_CLASSLOADER = 2; // 0x2
     field public static final int SHOW_FULL_DETAIL = 1; // 0x1
     field public static final int SHOW_INITIALIZED = 4; // 0x4
-    field public static final int TRACE_COUNT_ALLOCS = 1; // 0x1
+    field public static final deprecated int TRACE_COUNT_ALLOCS = 1; // 0x1
   }
 
   public static deprecated class Debug.InstructionCount {
@@ -31457,6 +31458,7 @@
   public class TelephonyManager {
     method public void answerRingingCall();
     method public void call(java.lang.String, java.lang.String);
+    method public boolean canChangeDtmfToneLength();
     method public int checkCarrierPrivilegesForPackage(java.lang.String);
     method public void dial(java.lang.String);
     method public boolean disableDataConnectivity();
@@ -31516,6 +31518,7 @@
     method public boolean isSmsCapable();
     method public boolean isVideoCallingEnabled();
     method public boolean isVoiceCapable();
+    method public boolean isWorldPhone();
     method public void listen(android.telephony.PhoneStateListener, int);
     method public boolean needsOtaServiceProvisioning();
     method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
@@ -39148,6 +39151,12 @@
     method public abstract void onReceivedIcon(java.lang.String, android.graphics.Bitmap);
   }
 
+  public abstract class WebResourceError {
+    ctor public WebResourceError();
+    method public abstract java.lang.String getDescription();
+    method public abstract int getErrorCode();
+  }
+
   public abstract interface WebResourceRequest {
     method public abstract java.lang.String getMethod();
     method public abstract java.util.Map<java.lang.String, java.lang.String> getRequestHeaders();
@@ -39156,7 +39165,7 @@
     method public abstract boolean isForMainFrame();
   }
 
-  public class WebResourceResponse {
+  public class WebResourceResponse extends android.webkit.WebResourceResponseBase {
     ctor public WebResourceResponse(java.lang.String, java.lang.String, java.io.InputStream);
     ctor public WebResourceResponse(java.lang.String, java.lang.String, int, java.lang.String, java.util.Map<java.lang.String, java.lang.String>, java.io.InputStream);
     method public java.io.InputStream getData();
@@ -39172,6 +39181,16 @@
     method public void setStatusCodeAndReasonPhrase(int, java.lang.String);
   }
 
+  public abstract class WebResourceResponseBase {
+    ctor public WebResourceResponseBase();
+    method public abstract java.io.InputStream getData();
+    method public abstract java.lang.String getEncoding();
+    method public abstract java.lang.String getMimeType();
+    method public abstract java.lang.String getReasonPhrase();
+    method public abstract java.util.Map<java.lang.String, java.lang.String> getResponseHeaders();
+    method public abstract int getStatusCode();
+  }
+
   public abstract class WebSettings {
     ctor public WebSettings();
     method public abstract deprecated boolean enableSmoothTransition();
@@ -39531,8 +39550,10 @@
     method public void onPageFinished(android.webkit.WebView, java.lang.String);
     method public void onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
     method public void onReceivedClientCertRequest(android.webkit.WebView, android.webkit.ClientCertRequest);
-    method public void onReceivedError(android.webkit.WebView, int, java.lang.String, java.lang.String);
+    method public deprecated void onReceivedError(android.webkit.WebView, int, java.lang.String, java.lang.String);
+    method public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
     method public void onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String);
+    method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponseBase);
     method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
     method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
     method public void onScaleChanged(android.webkit.WebView, float, float);
@@ -39545,6 +39566,7 @@
     method public boolean shouldOverrideUrlLoading(android.webkit.WebView, java.lang.String);
     field public static final int ERROR_AUTHENTICATION = -4; // 0xfffffffc
     field public static final int ERROR_BAD_URL = -12; // 0xfffffff4
+    field public static final int ERROR_BLOCKED = -16; // 0xfffffff0
     field public static final int ERROR_CONNECT = -6; // 0xfffffffa
     field public static final int ERROR_FAILED_SSL_HANDSHAKE = -11; // 0xfffffff5
     field public static final int ERROR_FILE = -13; // 0xfffffff3
diff --git a/core/java/android/annotation/CallSuper.java b/core/java/android/annotation/CallSuper.java
new file mode 100644
index 0000000..82e2723
--- /dev/null
+++ b/core/java/android/annotation/CallSuper.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 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 android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that any overriding methods should invoke this method as well.
+ * <p>
+ * Example:
+ * <pre>{@code
+ *  &#64;CallSuper
+ *  public abstract void onFocusLost();
+ * }</pre>
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD})
+public @interface CallSuper {
+}
\ No newline at end of file
diff --git a/core/java/android/annotation/CheckResult.java b/core/java/android/annotation/CheckResult.java
new file mode 100644
index 0000000..787514e
--- /dev/null
+++ b/core/java/android/annotation/CheckResult.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 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 android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that the annotated method returns a result that it typically is
+ * an error to ignore. This is usually used for methods that have no side effect,
+ * so calling it without actually looking at the result usually means the developer
+ * has misunderstood what the method does.
+ * <p>
+ * Example:
+ * <pre>{@code
+ *  public &#64;CheckResult String trim(String s) { return s.trim(); }
+ *  ...
+ *  s.trim(); // this is probably an error
+ *  s = s.trim(); // ok
+ * }</pre>
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD})
+public @interface CheckResult {
+    /** Defines the name of the suggested method to use instead, if applicable (using
+     * the same signature format as javadoc.) If there is more than one possibility,
+     * list them all separated by commas.
+     * <p>
+     * For example, ProcessBuilder has a method named {@code redirectErrorStream()}
+     * which sounds like it might redirect the error stream. It does not. It's just
+     * a getter which returns whether the process builder will redirect the error stream,
+     * and to actually set it, you must call {@code redirectErrorStream(boolean)}.
+     * In that case, the method should be defined like this:
+     * <pre>
+     *  &#64;CheckResult(suggest="#redirectErrorStream(boolean)")
+     *  public boolean redirectErrorStream() { ... }
+     * </pre>
+     */
+    String suggest() default "";
+}
\ No newline at end of file
diff --git a/core/java/android/annotation/ColorInt.java b/core/java/android/annotation/ColorInt.java
new file mode 100644
index 0000000..c4c93ee
--- /dev/null
+++ b/core/java/android/annotation/ColorInt.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 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 android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that the annotated element represents a packed color
+ * int, {@code AARRGGBB}. If applied to an int array, every element
+ * in the array represents a color integer.
+ * <p>
+ *  public abstract void setTextColor(&#64;ColorInt int color);
+ * }</pre>
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({PARAMETER,METHOD,LOCAL_VARIABLE,FIELD})
+public @interface ColorInt {
+}
\ No newline at end of file
diff --git a/core/java/android/annotation/FloatRange.java b/core/java/android/annotation/FloatRange.java
new file mode 100644
index 0000000..3a7c150
--- /dev/null
+++ b/core/java/android/annotation/FloatRange.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 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 android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that the annotated element should be a float or double in the given range
+ * <p>
+ * Example:
+ * <pre>{@code
+ *  &#64;FloatRange(from=0.0,to=1.0)
+ *  public float getAlpha() {
+ *      ...
+ *  }
+ * }</pre>
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD,PARAMETER,FIELD,LOCAL_VARIABLE})
+public @interface FloatRange {
+    /** Smallest value. Whether it is inclusive or not is determined
+     * by {@link #fromInclusive} */
+    double from() default Double.NEGATIVE_INFINITY;
+    /** Largest value. Whether it is inclusive or not is determined
+     * by {@link #toInclusive} */
+    double to() default Double.POSITIVE_INFINITY;
+
+    /** Whether the from value is included in the range */
+    boolean fromInclusive() default true;
+
+    /** Whether the to value is included in the range */
+    boolean toInclusive() default true;
+}
\ No newline at end of file
diff --git a/core/java/android/annotation/IntRange.java b/core/java/android/annotation/IntRange.java
new file mode 100644
index 0000000..1e3c072
--- /dev/null
+++ b/core/java/android/annotation/IntRange.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 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 android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that the annotated element should be an int or long in the given range
+ * <p>
+ * Example:
+ * <pre>{@code
+ *  &#64;IntRange(from=0,to=255)
+ *  public int getAlpha() {
+ *      ...
+ *  }
+ * }</pre>
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD,PARAMETER,FIELD,LOCAL_VARIABLE})
+public @interface IntRange {
+    /** Smallest value, inclusive */
+    long from() default Long.MIN_VALUE;
+    /** Largest value, inclusive */
+    long to() default Long.MAX_VALUE;
+}
\ No newline at end of file
diff --git a/core/java/android/annotation/Size.java b/core/java/android/annotation/Size.java
new file mode 100644
index 0000000..389b819
--- /dev/null
+++ b/core/java/android/annotation/Size.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2015 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 android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that the annotated element should have a given size or length.
+ * Note that "-1" means "unset". Typically used with a parameter or
+ * return value of type array or collection.
+ * <p>
+ * Example:
+ * <pre>{@code
+ *  public void getLocationInWindow(&#64;Size(2) int[] location) {
+ *      ...
+ *  }
+ * }</pre>
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({PARAMETER,LOCAL_VARIABLE,METHOD,FIELD})
+public @interface Size {
+    /** An exact size (or -1 if not specified) */
+    long value() default -1;
+    /** A minimum size, inclusive */
+    long min() default Long.MIN_VALUE;
+    /** A maximum size, inclusive */
+    long max() default Long.MAX_VALUE;
+    /** The size must be a multiple of this factor */
+    long multiple() default 1;
+}
\ No newline at end of file
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index ad2b61f..5572d30 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1322,7 +1322,10 @@
     
     /*
      * Starts allocation counting. This triggers a gc and resets the counts.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public void startAllocCounting() {
         // Before we start trigger a GC and reset the debug counts. Run the 
         // finalizers and another GC before starting and stopping the alloc
@@ -1340,7 +1343,10 @@
     
     /*
      * Stops allocation counting.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public void stopAllocCounting() {
         Runtime.getRuntime().gc();
         Runtime.getRuntime().runFinalization();
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 9c00e1c..593585f 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -16,6 +16,7 @@
 
 package android.app;
 
+import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.annotation.IntDef;
 import android.annotation.SdkConstant;
@@ -338,6 +339,7 @@
      * @see #FLAG_SHOW_LIGHTS
      * @see #flags
      */
+    @ColorInt
     public int ledARGB;
 
     /**
@@ -520,12 +522,14 @@
      * {@link #icon} image (stenciled in white) atop a field of this color. Alpha components are
      * ignored.
      */
+    @ColorInt
     public int color = COLOR_DEFAULT;
 
     /**
      * Special value of {@link #color} telling the system not to decorate this notification with
      * any special color but instead use default colors when presenting this notification.
      */
+    @ColorInt
     public static final int COLOR_DEFAULT = 0; // AKA Color.TRANSPARENT
 
     /**
@@ -2388,7 +2392,7 @@
          * @see Notification#ledOnMS
          * @see Notification#ledOffMS
          */
-        public Builder setLights(int argb, int onMs, int offMs) {
+        public Builder setLights(@ColorInt int argb, int onMs, int offMs) {
             mLedArgb = argb;
             mLedOnMs = onMs;
             mLedOffMs = offMs;
@@ -2712,7 +2716,7 @@
          *
          * @return The same Builder.
          */
-        public Builder setColor(int argb) {
+        public Builder setColor(@ColorInt int argb) {
             mColor = argb;
             return this;
         }
@@ -5160,7 +5164,7 @@
          * automotive setting. This method can be used to override the color provided in the
          * notification in such a situation.
          */
-        public CarExtender setColor(int color) {
+        public CarExtender setColor(@ColorInt int color) {
             mColor = color;
             return this;
         }
@@ -5170,6 +5174,7 @@
          *
          * @see setColor
          */
+        @ColorInt
         public int getColor() {
             return mColor;
         }
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 3d587b6..c708859 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -28,6 +28,7 @@
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
 import android.net.ProxyInfo;
 import android.os.Bundle;
 import android.os.Handler;
@@ -3742,4 +3743,18 @@
         }
         return Collections.emptyList();
     }
+
+    /**
+     * Called by profile or device owners to set the current user's photo.
+     *
+     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+     * @param icon the bitmap to set as the photo.
+     */
+    public void setUserIcon(ComponentName admin, Bitmap icon) {
+        try {
+            mService.setUserIcon(admin, icon);
+        } catch (RemoteException re) {
+            Log.w(TAG, "Could not set the user icon ", re);
+        }
+    }
 }
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 5cbab4b..f69cf36 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -20,6 +20,7 @@
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.graphics.Bitmap;
 import android.net.ProxyInfo;
 import android.os.Bundle;
 import android.os.PersistableBundle;
@@ -205,4 +206,6 @@
     void clearDeviceInitializer(in ComponentName who);
     boolean setDeviceInitializer(in ComponentName who, in ComponentName initializer, String initializerName);
     String getDeviceInitializer();
+
+    void setUserIcon(in ComponentName admin, in Bitmap icon);
 }
diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java
index 1b1e600..7f89100 100644
--- a/core/java/android/app/backup/BackupAgent.java
+++ b/core/java/android/app/backup/BackupAgent.java
@@ -258,6 +258,7 @@
      *
      * <ul>
      * <li>The contents of the {@link #getCacheDir()} directory</li>
+     * <li>The contents of the {@link #getCodeCacheDir()} directory</li>
      * <li>The contents of the {@link #getNoBackupFilesDir()} directory</li>
      * <li>The contents of the app's shared library directory</li>
      * </ul>
@@ -285,6 +286,7 @@
         String databaseDir = getDatabasePath("foo").getParentFile().getCanonicalPath();
         String sharedPrefsDir = getSharedPrefsFile("foo").getParentFile().getCanonicalPath();
         String cacheDir = getCacheDir().getCanonicalPath();
+        String codeCacheDir = getCodeCacheDir().getCanonicalPath();
         String libDir = (appInfo.nativeLibraryDir != null)
                 ? new File(appInfo.nativeLibraryDir).getCanonicalPath()
                 : null;
@@ -298,6 +300,7 @@
             filterSet.add(libDir);
         }
         filterSet.add(cacheDir);
+        filterSet.add(codeCacheDir);
         filterSet.add(databaseDir);
         filterSet.add(sharedPrefsDir);
         filterSet.add(filesDir);
@@ -354,6 +357,7 @@
         String dbDir;
         String spDir;
         String cacheDir;
+        String codeCacheDir;
         String libDir;
         String efDir = null;
         String filePath;
@@ -367,6 +371,7 @@
             dbDir = getDatabasePath("foo").getParentFile().getCanonicalPath();
             spDir = getSharedPrefsFile("foo").getParentFile().getCanonicalPath();
             cacheDir = getCacheDir().getCanonicalPath();
+            codeCacheDir = getCodeCacheDir().getCanonicalPath();
             libDir = (appInfo.nativeLibraryDir == null)
                     ? null
                     : new File(appInfo.nativeLibraryDir).getCanonicalPath();
@@ -380,7 +385,8 @@
             }
 
             // Now figure out which well-defined tree the file is placed in, working from
-            // most to least specific.  We also specifically exclude the lib and cache dirs.
+            // most to least specific.  We also specifically exclude the lib, cache,
+            // and code_cache dirs.
             filePath = file.getCanonicalPath();
         } catch (IOException e) {
             Log.w(TAG, "Unable to obtain canonical paths");
@@ -388,9 +394,10 @@
         }
 
         if (filePath.startsWith(cacheDir)
+                || filePath.startsWith(codeCacheDir)
                 || filePath.startsWith(libDir)
                 || filePath.startsWith(nbFilesDir)) {
-            Log.w(TAG, "lib, cache, and no_backup files are not backed up");
+            Log.w(TAG, "lib, cache, code_cache, and no_backup files are not backed up");
             return;
         }
 
diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java
index ace402a..841b09d 100644
--- a/core/java/android/content/res/ColorStateList.java
+++ b/core/java/android/content/res/ColorStateList.java
@@ -16,6 +16,7 @@
 
 package android.content.res;
 
+import android.annotation.ColorInt;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.content.res.Resources.Theme;
@@ -91,7 +92,7 @@
      * Creates a ColorStateList that returns the specified mapping from
      * states to colors.
      */
-    public ColorStateList(int[][] states, int[] colors) {
+    public ColorStateList(int[][] states, @ColorInt int[] colors) {
         mStateSpecs = states;
         mColors = colors;
 
@@ -102,7 +103,7 @@
      * @return A ColorStateList containing a single color.
      */
     @NonNull
-    public static ColorStateList valueOf(int color) {
+    public static ColorStateList valueOf(@ColorInt int color) {
         synchronized (sCache) {
             final int index = sCache.indexOfKey(color);
             if (index >= 0) {
@@ -436,6 +437,7 @@
      *
      * @return the default color in this {@link ColorStateList}.
      */
+    @ColorInt
     public int getDefaultColor() {
         return mDefaultColor;
     }
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 584f3f6..5dc9ef9 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -16,6 +16,7 @@
 
 package android.content.res;
 
+import android.annotation.ColorInt;
 import com.android.internal.util.XmlUtils;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -925,6 +926,7 @@
      * @return A single color value in the form 0xAARRGGBB.
      * @deprecated Use {@link #getColor(int, Theme)} instead.
      */
+    @ColorInt
     public int getColor(@ColorRes int id) throws NotFoundException {
         return getColor(id, null);
     }
@@ -945,6 +947,7 @@
      *
      * @return A single color value in the form 0xAARRGGBB.
      */
+    @ColorInt
     public int getColor(@ColorRes int id, @Nullable Theme theme) throws NotFoundException {
         TypedValue value;
         synchronized (mAccessLock) {
diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java
index 3e07f0c..410849a 100644
--- a/core/java/android/content/res/TypedArray.java
+++ b/core/java/android/content/res/TypedArray.java
@@ -17,6 +17,7 @@
 package android.content.res;
 
 import android.annotation.AnyRes;
+import android.annotation.ColorInt;
 import android.annotation.Nullable;
 import android.graphics.drawable.Drawable;
 import android.os.StrictMode;
@@ -420,7 +421,8 @@
      * @throws UnsupportedOperationException if the attribute is defined but is
      *         not an integer color or color state list.
      */
-    public int getColor(int index, int defValue) {
+    @ColorInt
+    public int getColor(int index, @ColorInt int defValue) {
         if (mRecycled) {
             throw new RuntimeException("Cannot make calls to a recycled instance!");
         }
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index e1a2a25..e0d454c 100644
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -16,6 +16,7 @@
 
 package android.gesture;
 
+import android.annotation.ColorInt;
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
@@ -204,18 +205,20 @@
         mOrientation = orientation;
     }
 
-    public void setGestureColor(int color) {
+    public void setGestureColor(@ColorInt int color) {
         mCertainGestureColor = color;
     }
 
-    public void setUncertainGestureColor(int color) {
+    public void setUncertainGestureColor(@ColorInt int color) {
         mUncertainGestureColor = color;
     }
 
+    @ColorInt
     public int getUncertainGestureColor() {
         return mUncertainGestureColor;
     }
 
+    @ColorInt
     public int getGestureColor() {
         return mCertainGestureColor;
     }
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index d03365b..512e212 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -63,7 +63,10 @@
      *
      * TRACE_COUNT_ALLOCS adds the results from startAllocCounting to the
      * trace key file.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static final int TRACE_COUNT_ALLOCS  = VMDebug.TRACE_COUNT_ALLOCS;
 
     /**
@@ -760,7 +763,7 @@
     /**
      * Stop counting the number and aggregate size of memory allocations.
      *
-     * @see #startAllocCounting()
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
     @Deprecated
     public static void stopAllocCounting() {
@@ -770,7 +773,10 @@
     /**
      * Returns the global count of objects allocated by the runtime between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalAllocCount() {
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_ALLOCATED_OBJECTS);
     }
@@ -778,7 +784,10 @@
     /**
      * Clears the global count of objects allocated.
      * @see #getGlobalAllocCount()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalAllocCount() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_ALLOCATED_OBJECTS);
     }
@@ -786,7 +795,10 @@
     /**
      * Returns the global size, in bytes, of objects allocated by the runtime between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalAllocSize() {
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_ALLOCATED_BYTES);
     }
@@ -794,7 +806,10 @@
     /**
      * Clears the global size of objects allocated.
      * @see #getGlobalAllocSize()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalAllocSize() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_ALLOCATED_BYTES);
     }
@@ -802,7 +817,10 @@
     /**
      * Returns the global count of objects freed by the runtime between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalFreedCount() {
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_FREED_OBJECTS);
     }
@@ -810,7 +828,10 @@
     /**
      * Clears the global count of objects freed.
      * @see #getGlobalFreedCount()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalFreedCount() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_FREED_OBJECTS);
     }
@@ -818,7 +839,10 @@
     /**
      * Returns the global size, in bytes, of objects freed by the runtime between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalFreedSize() {
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_FREED_BYTES);
     }
@@ -826,7 +850,10 @@
     /**
      * Clears the global size of objects freed.
      * @see #getGlobalFreedSize()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalFreedSize() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_FREED_BYTES);
     }
@@ -834,7 +861,10 @@
     /**
      * Returns the number of non-concurrent GC invocations between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalGcInvocationCount() {
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_GC_INVOCATIONS);
     }
@@ -842,7 +872,10 @@
     /**
      * Clears the count of non-concurrent GC invocations.
      * @see #getGlobalGcInvocationCount()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalGcInvocationCount() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_GC_INVOCATIONS);
     }
@@ -851,7 +884,10 @@
      * Returns the number of classes successfully initialized (ie those that executed without
      * throwing an exception) between a {@link #startAllocCounting() start} and
      * {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalClassInitCount() {
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_CLASS_INIT_COUNT);
     }
@@ -859,7 +895,10 @@
     /**
      * Clears the count of classes initialized.
      * @see #getGlobalClassInitCount()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalClassInitCount() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_CLASS_INIT_COUNT);
     }
@@ -867,7 +906,10 @@
     /**
      * Returns the time spent successfully initializing classes between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getGlobalClassInitTime() {
         /* cumulative elapsed time for class initialization, in usec */
         return VMDebug.getAllocCount(VMDebug.KIND_GLOBAL_CLASS_INIT_TIME);
@@ -876,7 +918,10 @@
     /**
      * Clears the count of time spent initializing classes.
      * @see #getGlobalClassInitTime()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetGlobalClassInitTime() {
         VMDebug.resetAllocCount(VMDebug.KIND_GLOBAL_CLASS_INIT_TIME);
     }
@@ -948,7 +993,10 @@
     /**
      * Returns the thread-local count of objects allocated by the runtime between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getThreadAllocCount() {
         return VMDebug.getAllocCount(VMDebug.KIND_THREAD_ALLOCATED_OBJECTS);
     }
@@ -956,7 +1004,10 @@
     /**
      * Clears the thread-local count of objects allocated.
      * @see #getThreadAllocCount()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetThreadAllocCount() {
         VMDebug.resetAllocCount(VMDebug.KIND_THREAD_ALLOCATED_OBJECTS);
     }
@@ -965,7 +1016,10 @@
      * Returns the thread-local size of objects allocated by the runtime between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
      * @return The allocated size in bytes.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getThreadAllocSize() {
         return VMDebug.getAllocCount(VMDebug.KIND_THREAD_ALLOCATED_BYTES);
     }
@@ -973,7 +1027,10 @@
     /**
      * Clears the thread-local count of objects allocated.
      * @see #getThreadAllocSize()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetThreadAllocSize() {
         VMDebug.resetAllocCount(VMDebug.KIND_THREAD_ALLOCATED_BYTES);
     }
@@ -1013,7 +1070,10 @@
     /**
      * Returns the number of thread-local non-concurrent GC invocations between a
      * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}.
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static int getThreadGcInvocationCount() {
         return VMDebug.getAllocCount(VMDebug.KIND_THREAD_GC_INVOCATIONS);
     }
@@ -1021,7 +1081,10 @@
     /**
      * Clears the thread-local count of non-concurrent GC invocations.
      * @see #getThreadGcInvocationCount()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetThreadGcInvocationCount() {
         VMDebug.resetAllocCount(VMDebug.KIND_THREAD_GC_INVOCATIONS);
     }
@@ -1029,7 +1092,10 @@
     /**
      * Clears all the global and thread-local memory allocation counters.
      * @see #startAllocCounting()
+     *
+     * @deprecated Accurate counting is a burden on the runtime and may be removed.
      */
+    @Deprecated
     public static void resetAllCounts() {
         VMDebug.resetAllocCount(VMDebug.KIND_ALL_COUNTS);
     }
diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java
index 0447117..4f8cff0 100644
--- a/core/java/android/text/TextPaint.java
+++ b/core/java/android/text/TextPaint.java
@@ -16,6 +16,7 @@
 
 package android.text;
 
+import android.annotation.ColorInt;
 import android.graphics.Paint;
 
 /**
@@ -25,8 +26,10 @@
 public class TextPaint extends Paint {
 
     // Special value 0 means no background paint
+    @ColorInt
     public int bgColor;
     public int baselineShift;
+    @ColorInt
     public int linkColor;
     public int[] drawableState;
     public float density = 1.0f;
@@ -34,6 +37,7 @@
      * Special value 0 means no custom underline
      * @hide
      */
+    @ColorInt
     public int underlineColor = 0;
     /**
      * Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness.
diff --git a/core/java/android/text/style/ForegroundColorSpan.java b/core/java/android/text/style/ForegroundColorSpan.java
index c9e09bd..f167aab 100644
--- a/core/java/android/text/style/ForegroundColorSpan.java
+++ b/core/java/android/text/style/ForegroundColorSpan.java
@@ -16,6 +16,7 @@
 
 package android.text.style;
 
+import android.annotation.ColorInt;
 import android.os.Parcel;
 import android.text.ParcelableSpan;
 import android.text.TextPaint;
@@ -26,7 +27,7 @@
 
     private final int mColor;
 
-    public ForegroundColorSpan(int color) {
+    public ForegroundColorSpan(@ColorInt int color) {
         mColor = color;
     }
 
@@ -46,6 +47,7 @@
         dest.writeInt(mColor);
     }
 
+    @ColorInt
     public int getForegroundColor() {
         return mColor;
     }
diff --git a/core/java/android/text/style/QuoteSpan.java b/core/java/android/text/style/QuoteSpan.java
index 29dd273..17748ca 100644
--- a/core/java/android/text/style/QuoteSpan.java
+++ b/core/java/android/text/style/QuoteSpan.java
@@ -16,6 +16,7 @@
 
 package android.text.style;
 
+import android.annotation.ColorInt;
 import android.graphics.Paint;
 import android.graphics.Canvas;
 import android.os.Parcel;
@@ -34,7 +35,7 @@
         mColor = 0xff0000ff;
     }
     
-    public QuoteSpan(int color) {
+    public QuoteSpan(@ColorInt int color) {
         super();
         mColor = color;
     }
@@ -55,6 +56,7 @@
         dest.writeInt(mColor);
     }
 
+    @ColorInt
     public int getColor() {
         return mColor;
     }
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 0d36949..06e196d 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -204,7 +204,7 @@
         Bitmap bitmap = patch.getBitmap();
         throwIfCannotDraw(bitmap);
         final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
-        nDrawPatch(mNativeCanvasWrapper, bitmap.mNativeBitmap, patch.mNativeChunk,
+        nDrawPatch(mNativeCanvasWrapper, bitmap.getSkBitmap(), patch.mNativeChunk,
                 dst.left, dst.top, dst.right, dst.bottom, nativePaint);
     }
 
@@ -214,7 +214,7 @@
         Bitmap bitmap = patch.getBitmap();
         throwIfCannotDraw(bitmap);
         final long nativePaint = paint == null ? 0 : paint.getNativeInstance();
-        nDrawPatch(mNativeCanvasWrapper, bitmap.mNativeBitmap, patch.mNativeChunk,
+        nDrawPatch(mNativeCanvasWrapper, bitmap.getSkBitmap(), patch.mNativeChunk,
                 dst.left, dst.top, dst.right, dst.bottom, nativePaint);
     }
 
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index df0838f..69b4c47 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -364,7 +364,7 @@
     @Override
     boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) {
         return nCopyLayerInto(mNativeProxy,
-                layer.getDeferredLayerUpdater(), bitmap.mNativeBitmap);
+                layer.getDeferredLayerUpdater(), bitmap.getSkBitmap());
     }
 
     @Override
@@ -465,7 +465,7 @@
             for (int i = 0; i < count; i++) {
                 drawables.valueAt(i).addAtlasableBitmaps(tmpList);
                 for (int j = 0; j < tmpList.size(); j++) {
-                    preloadedPointers.add(tmpList.get(j).mNativeBitmap);
+                    preloadedPointers.add(tmpList.get(j).getSkBitmap());
                 }
                 tmpList.clear();
             }
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f25b640..ed1197c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -18,6 +18,7 @@
 
 import android.animation.AnimatorInflater;
 import android.animation.StateListAnimator;
+import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.annotation.IdRes;
 import android.annotation.IntDef;
@@ -5849,7 +5850,7 @@
      *
      * @see AccessibilityDelegate
      */
-    public void setAccessibilityDelegate(AccessibilityDelegate delegate) {
+    public void setAccessibilityDelegate(@Nullable AccessibilityDelegate delegate) {
         mAccessibilityDelegate = delegate;
     }
 
@@ -14311,7 +14312,7 @@
      * @see #buildDrawingCache()
      * @see #getDrawingCache()
      */
-    public void setDrawingCacheBackgroundColor(int color) {
+    public void setDrawingCacheBackgroundColor(@ColorInt int color) {
         if (color != mDrawingCacheBackgroundColor) {
             mDrawingCacheBackgroundColor = color;
             mPrivateFlags &= ~PFLAG_DRAWING_CACHE_VALID;
@@ -14323,6 +14324,7 @@
      *
      * @return The background color to used for the drawing cache's bitmap
      */
+    @ColorInt
     public int getDrawingCacheBackgroundColor() {
         return mDrawingCacheBackgroundColor;
     }
@@ -15536,6 +15538,7 @@
      * @return The known solid color background for this view, or 0 if the color may vary
      */
     @ViewDebug.ExportedProperty(category = "drawing")
+    @ColorInt
     public int getSolidColor() {
         return 0;
     }
@@ -16222,7 +16225,7 @@
      * @param color the color of the background
      */
     @RemotableViewMethod
-    public void setBackgroundColor(int color) {
+    public void setBackgroundColor(@ColorInt int color) {
         if (mBackground instanceof ColorDrawable) {
             ((ColorDrawable) mBackground.mutate()).setColor(color);
             computeOpaqueFlags();
@@ -16238,6 +16241,7 @@
      *
      * @return The color of the ColorDrawable background, if set, otherwise 0.
      */
+    @ColorInt
     public int getBackgroundColor() {
         if (mBackground instanceof ColorDrawable) {
             return ((ColorDrawable) mBackground).getColor();
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index e332135..744f665 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -16,6 +16,7 @@
 
 package android.view;
 
+import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.annotation.IdRes;
 import android.annotation.LayoutRes;
@@ -1069,7 +1070,7 @@
     public abstract void setTitle(CharSequence title);
 
     @Deprecated
-    public abstract void setTitleColor(int textColor);
+    public abstract void setTitleColor(@ColorInt int textColor);
 
     public abstract void openPanel(int featureId, KeyEvent event);
 
@@ -1835,6 +1836,7 @@
     /**
      * @return the color of the status bar.
      */
+    @ColorInt
     public abstract int getStatusBarColor();
 
     /**
@@ -1852,11 +1854,12 @@
      * The transitionName for the view background will be "android:status:background".
      * </p>
      */
-    public abstract void setStatusBarColor(int color);
+    public abstract void setStatusBarColor(@ColorInt int color);
 
     /**
      * @return the color of the navigation bar.
      */
+    @ColorInt
     public abstract int getNavigationBarColor();
 
     /**
@@ -1874,7 +1877,7 @@
      * The transitionName for the view background will be "android:navigation:background".
      * </p>
      */
-    public abstract void setNavigationBarColor(int color);
+    public abstract void setNavigationBarColor(@ColorInt int color);
 
 
 }
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java
index 85d77cb..a5524d8 100644
--- a/core/java/android/view/animation/Animation.java
+++ b/core/java/android/view/animation/Animation.java
@@ -16,6 +16,7 @@
 
 package android.view.animation;
 
+import android.annotation.ColorInt;
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.graphics.RectF;
@@ -622,7 +623,7 @@
      * @param bg The background color.  If 0, no background.  Currently must
      * be black, with any desired alpha level.
      */
-    public void setBackgroundColor(int bg) {
+    public void setBackgroundColor(@ColorInt int bg) {
         mBackgroundColor = bg;
     }
 
@@ -753,6 +754,7 @@
     /**
      * Returns the background color behind the animation.
      */
+    @ColorInt
     public int getBackgroundColor() {
         return mBackgroundColor;
     }
diff --git a/core/java/android/webkit/WebResourceError.java b/core/java/android/webkit/WebResourceError.java
new file mode 100644
index 0000000..080d174
--- /dev/null
+++ b/core/java/android/webkit/WebResourceError.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 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 android.webkit;
+
+/**
+ * Encapsulates information about errors occured during loading of web resources. See
+ * {@link WebViewClient#onReceivedError(WebView, WebResourceRequest, WebResourceError) WebViewClient.onReceivedError(WebView, WebResourceRequest, WebResourceError)}
+ */
+public abstract class WebResourceError {
+    /**
+     * Gets the error code of the error. The code corresponds to one
+     * of the ERROR_* constants in {@link WebViewClient}.
+     *
+     * @return The error code of the error
+     */
+    public abstract int getErrorCode();
+
+    /**
+     * Gets the string describing the error. Descriptions are localized,
+     * and thus can be used for communicating the problem to the user.
+     *
+     * @return The description of the error
+     */
+    public abstract String getDescription();
+}
diff --git a/core/java/android/webkit/WebResourceResponse.java b/core/java/android/webkit/WebResourceResponse.java
index f487a4e..a42aaa7 100644
--- a/core/java/android/webkit/WebResourceResponse.java
+++ b/core/java/android/webkit/WebResourceResponse.java
@@ -25,7 +25,7 @@
  * class from {@link WebViewClient#shouldInterceptRequest} to provide a custom
  * response when the WebView requests a particular resource.
  */
-public class WebResourceResponse {
+public class WebResourceResponse extends WebResourceResponseBase {
     private String mMimeType;
     private String mEncoding;
     private int mStatusCode;
@@ -75,38 +75,36 @@
     }
 
     /**
-     * Sets the resource response's MIME type, for example text/html.
+     * Sets the resource response's MIME type, for example &quot;text/html&quot;.
      *
-     * @param mimeType the resource response's MIME type
+     * @param mimeType The resource response's MIME type
      */
     public void setMimeType(String mimeType) {
         mMimeType = mimeType;
     }
 
     /**
-     * Gets the resource response's MIME type.
-     *
-     * @return the resource response's MIME type
+     * {@inheritDoc}
      */
+    @Override
     public String getMimeType() {
         return mMimeType;
     }
 
     /**
-     * Sets the resource response's encoding, for example UTF-8. This is used
+     * Sets the resource response's encoding, for example &quot;UTF-8&quot;. This is used
      * to decode the data from the input stream.
      *
-     * @param encoding the resource response's encoding
+     * @param encoding The resource response's encoding
      */
     public void setEncoding(String encoding) {
         mEncoding = encoding;
     }
 
     /**
-     * Gets the resource response's encoding.
-     *
-     * @return the resource response's encoding
+     * {@inheritDoc}
      */
+    @Override
     public String getEncoding() {
         return mEncoding;
     }
@@ -142,19 +140,17 @@
     }
 
     /**
-     * Gets the resource response's status code.
-     *
-     * @return the resource response's status code.
+     * {@inheritDoc}
      */
+    @Override
     public int getStatusCode() {
         return mStatusCode;
     }
 
     /**
-     * Gets the description of the resource response's status code.
-     *
-     * @return the description of the resource response's status code.
+     * {@inheritDoc}
      */
+    @Override
     public String getReasonPhrase() {
         return mReasonPhrase;
     }
@@ -162,17 +158,16 @@
     /**
      * Sets the headers for the resource response.
      *
-     * @param headers mapping of header name -> header value.
+     * @param headers Mapping of header name -> header value.
      */
     public void setResponseHeaders(Map<String, String> headers) {
         mResponseHeaders = headers;
     }
 
     /**
-     * Gets the headers for the resource response.
-     *
-     * @return the headers for the resource response.
+     * {@inheritDoc}
      */
+    @Override
     public Map<String, String> getResponseHeaders() {
         return mResponseHeaders;
     }
@@ -190,15 +185,13 @@
             throw new IllegalArgumentException("StringBufferInputStream is deprecated and must " +
                 "not be passed to a WebResourceResponse");
         }
-
         mInputStream = data;
     }
 
     /**
-     * Gets the input stream that provides the resource response's data.
-     *
-     * @return the input stream that provides the resource response's data
+     * {@inheritDoc}
      */
+    @Override
     public InputStream getData() {
         return mInputStream;
     }
diff --git a/core/java/android/webkit/WebResourceResponseBase.java b/core/java/android/webkit/WebResourceResponseBase.java
new file mode 100644
index 0000000..cffde82
--- /dev/null
+++ b/core/java/android/webkit/WebResourceResponseBase.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 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 android.webkit;
+
+import java.io.InputStream;
+import java.util.Map;
+
+/**
+ * Encapsulates a resource response received from the server.
+ * This is an abstract class used by WebView callbacks.
+ */
+public abstract class WebResourceResponseBase {
+    /**
+     * Gets the resource response's MIME type.
+     *
+     * @return The resource response's MIME type
+     */
+    public abstract String getMimeType();
+
+    /**
+     * Gets the resource response's encoding.
+     *
+     * @return The resource response's encoding
+     */
+    public abstract String getEncoding();
+
+    /**
+     * Gets the resource response's status code.
+     *
+     * @return The resource response's status code.
+     */
+    public abstract int getStatusCode();
+
+    /**
+     * Gets the description of the resource response's status code.
+     *
+     * @return The description of the resource response's status code.
+     */
+    public abstract String getReasonPhrase();
+
+    /**
+     * Gets the headers for the resource response.
+     *
+     * @return The headers for the resource response.
+     */
+    public abstract Map<String, String> getResponseHeaders();
+
+    /**
+     * Gets the input stream that provides the resource response's data.
+     *
+     * @return The input stream that provides the resource response's data
+     */
+    public abstract InputStream getData();
+}
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 1d2c311..3df1293 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -1285,7 +1285,7 @@
      * strongly discouraged.
      *
      * @param mode The mixed content mode to use. One of {@link #MIXED_CONTENT_NEVER_ALLOW},
-     *     {@link #MIXED_CONTENT_NEVER_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
+     *     {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
      */
     public abstract void setMixedContentMode(int mode);
 
@@ -1293,7 +1293,7 @@
      * Gets the current behavior of the WebView with regard to loading insecure content from a
      * secure origin.
      * @return The current setting, one of {@link #MIXED_CONTENT_NEVER_ALLOW},
-     *     {@link #MIXED_CONTENT_NEVER_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
+     *     {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
      */
     public abstract int getMixedContentMode();
 
diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java
index 01f9b37..34b8cf6 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -174,6 +174,8 @@
     public static final int ERROR_FILE_NOT_FOUND = -14;
     /** Too many requests during this load */
     public static final int ERROR_TOO_MANY_REQUESTS = -15;
+    /** Request blocked by the browser */
+    public static final int ERROR_BLOCKED = -16;
 
     /**
      * Report an error to the host application. These errors are unrecoverable
@@ -183,12 +185,45 @@
      * @param errorCode The error code corresponding to an ERROR_* value.
      * @param description A String describing the error.
      * @param failingUrl The url that failed to load.
+     * @deprecated Use {@link #onReceivedError(WebView, WebResourceRequest, WebResourceError)
+     *             onReceivedError(WebView, WebResourceRequest, WebResourceError)} instead.
      */
+    @Deprecated
     public void onReceivedError(WebView view, int errorCode,
             String description, String failingUrl) {
     }
 
     /**
+     * Report web resource loading error to the host application. These errors usually indicate
+     * inability to connect to the server. Note that unlike the deprecated version of the callback,
+     * the new version will be called for any resource (iframe, image, etc), not just for the main
+     * page. Thus, it is recommended to perform minimum required work in this callback.
+     * @param view The WebView that is initiating the callback.
+     * @param request The originating request.
+     * @param error Information about the error occured.
+     */
+    public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
+        if (request.isForMainFrame()) {
+            onReceivedError(view,
+                    error.getErrorCode(), error.getDescription(), request.getUrl().toString());
+        }
+    }
+
+    /**
+     * Notify the host application that an HTTP error has been received from the server while
+     * loading a resource.  HTTP errors have status codes &gt;= 400.  This callback will be called
+     * for any resource (iframe, image, etc), not just for the main page. Thus, it is recommended to
+     * perform minimum required work in this callback. Note that the content of the server
+     * response may not be provided within the <b>errorResponse</b> parameter.
+     * @param view The WebView that is initiating the callback.
+     * @param request The originating request.
+     * @param errorResponse Information about the error occured.
+     */
+    public void onReceivedHttpError(
+            WebView view, WebResourceRequest request, WebResourceResponseBase errorResponse) {
+    }
+
+    /**
      * As the host application if the browser should resend data as the
      * requested page was a result of a POST. The default is to not resend the
      * data.
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index a6e2952..168066a 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.content.Context;
 import android.content.Intent;
@@ -5982,7 +5983,7 @@
      *
      * @param color The background color
      */
-    public void setCacheColorHint(int color) {
+    public void setCacheColorHint(@ColorInt int color) {
         if (color != mCacheColorHint) {
             mCacheColorHint = color;
             int count = getChildCount();
@@ -6000,6 +6001,7 @@
      * @return The cache color hint
      */
     @ViewDebug.ExportedProperty(category = "drawing")
+    @ColorInt
     public int getCacheColorHint() {
         return mCacheColorHint;
     }
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java
index fd1c4b8..5bc16cb 100644
--- a/core/java/android/widget/CalendarView.java
+++ b/core/java/android/widget/CalendarView.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.annotation.Widget;
 import android.content.Context;
@@ -140,7 +141,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
      */
-    public void setSelectedWeekBackgroundColor(int color) {
+    public void setSelectedWeekBackgroundColor(@ColorInt int color) {
         mDelegate.setSelectedWeekBackgroundColor(color);
     }
 
@@ -151,6 +152,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
      */
+    @ColorInt
     public int getSelectedWeekBackgroundColor() {
         return mDelegate.getSelectedWeekBackgroundColor();
     }
@@ -162,7 +164,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_focusedMonthDateColor
      */
-    public void setFocusedMonthDateColor(int color) {
+    public void setFocusedMonthDateColor(@ColorInt int color) {
         mDelegate.setFocusedMonthDateColor(color);
     }
 
@@ -173,6 +175,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_focusedMonthDateColor
      */
+    @ColorInt
     public int getFocusedMonthDateColor() {
         return mDelegate.getFocusedMonthDateColor();
     }
@@ -184,7 +187,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor
      */
-    public void setUnfocusedMonthDateColor(int color) {
+    public void setUnfocusedMonthDateColor(@ColorInt int color) {
         mDelegate.setUnfocusedMonthDateColor(color);
     }
 
@@ -195,6 +198,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor
      */
+    @ColorInt
     public int getUnfocusedMonthDateColor() {
         return mDelegate.getUnfocusedMonthDateColor();
     }
@@ -206,7 +210,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_weekNumberColor
      */
-    public void setWeekNumberColor(int color) {
+    public void setWeekNumberColor(@ColorInt int color) {
         mDelegate.setWeekNumberColor(color);
     }
 
@@ -217,6 +221,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_weekNumberColor
      */
+    @ColorInt
     public int getWeekNumberColor() {
         return mDelegate.getWeekNumberColor();
     }
@@ -228,7 +233,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor
      */
-    public void setWeekSeparatorLineColor(int color) {
+    public void setWeekSeparatorLineColor(@ColorInt int color) {
         mDelegate.setWeekSeparatorLineColor(color);
     }
 
@@ -239,6 +244,7 @@
      *
      * @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor
      */
+    @ColorInt
     public int getWeekSeparatorLineColor() {
         return mDelegate.getWeekSeparatorLineColor();
     }
diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java
index 391347e..9019f31 100644
--- a/core/java/android/widget/EdgeEffect.java
+++ b/core/java/android/widget/EdgeEffect.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.annotation.ColorInt;
 import android.content.res.TypedArray;
 import android.graphics.Paint;
 import android.graphics.PorterDuff;
@@ -292,7 +293,7 @@
      *
      * @param color Color in argb
      */
-    public void setColor(int color) {
+    public void setColor(@ColorInt int color) {
         mPaint.setColor(color);
     }
 
@@ -300,6 +301,7 @@
      * Return the color of this edge effect in argb.
      * @return The color of this edge effect in argb
      */
+    @ColorInt
     public int getColor() {
         return mPaint.getColor();
     }
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 5d519ed..8197b3d 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -128,7 +128,7 @@
     // Each Editor manages its own undo stack.
     private final UndoManager mUndoManager = new UndoManager();
     private UndoOwner mUndoOwner = mUndoManager.getOwner(UNDO_OWNER_TAG, this);
-    final InputFilter mUndoInputFilter = new UndoInputFilter(this);
+    final UndoInputFilter mUndoInputFilter = new UndoInputFilter(this);
     boolean mAllowUndo = true;
 
     // Cursor Controllers.
@@ -246,6 +246,15 @@
         mUndoOwner = mUndoManager.getOwner(UNDO_OWNER_TAG, this);
     }
 
+    /**
+     * Forgets all undo and redo operations for this Editor.
+     */
+    void forgetUndoRedo() {
+        UndoOwner[] owners = { mUndoOwner };
+        mUndoManager.forgetUndos(owners, -1 /* all */);
+        mUndoManager.forgetRedos(owners, -1 /* all */);
+    }
+
     boolean canUndo() {
         UndoOwner[] owners = { mUndoOwner };
         return mAllowUndo && mUndoManager.countUndos(owners) > 0;
@@ -1214,6 +1223,7 @@
                     ims.mChangedEnd = EXTRACT_UNKNOWN;
                     ims.mContentChanged = false;
                 }
+                mUndoInputFilter.beginBatchEdit();
                 mTextView.onBeginBatchEdit();
             }
         }
@@ -1240,6 +1250,7 @@
 
     void finishBatchEdit(final InputMethodState ims) {
         mTextView.onEndBatchEdit();
+        mUndoInputFilter.endBatchEdit();
 
         if (ims.mContentChanged || ims.mSelectionModeChanged) {
             mTextView.updateAfterEdit();
@@ -4546,10 +4557,30 @@
     public static class UndoInputFilter implements InputFilter {
         private final Editor mEditor;
 
+        // Whether the current filter pass is directly caused by an end-user text edit.
+        private boolean mIsUserEdit;
+
+        // Whether this is the first pass through the filter for a given end-user text edit.
+        private boolean mFirstFilterPass;
+
         public UndoInputFilter(Editor editor) {
             mEditor = editor;
         }
 
+        /**
+         * Signals that a user-triggered edit is starting.
+         */
+        public void beginBatchEdit() {
+            if (DEBUG_UNDO) Log.d(TAG, "beginBatchEdit");
+            mIsUserEdit = true;
+            mFirstFilterPass = true;
+        }
+
+        public void endBatchEdit() {
+            if (DEBUG_UNDO) Log.d(TAG, "endBatchEdit");
+            mIsUserEdit = false;
+        }
+
         @Override
         public CharSequence filter(CharSequence source, int start, int end,
                 Spanned dest, int dstart, int dend) {
@@ -4558,36 +4589,24 @@
                         "dest=" + dest + " (" + dstart + "-" + dend + ")");
             }
 
-            if (!mEditor.mAllowUndo) {
-                if (DEBUG_UNDO) Log.d(TAG, "filter: undo is disabled");
+            // Check to see if this edit should be tracked for undo.
+            if (!canUndoEdit(source, start, end, dest, dstart, dend)) {
                 return null;
             }
 
-            final UndoManager um = mEditor.mUndoManager;
-            if (um.isInUndo()) {
-                if (DEBUG_UNDO) Log.d(TAG, "filter: skipping, currently performing undo/redo");
-                return null;
-            }
-
-            // Text filters run before input operations are applied. However, some input operations
-            // are invalid and will throw exceptions when applied. This is common in tests. Don't
-            // attempt to undo invalid operations.
-            if (!isValidRange(source, start, end) || !isValidRange(dest, dstart, dend)) {
-                if (DEBUG_UNDO) Log.d(TAG, "filter: invalid op");
-                return null;
-            }
-
-            // Earlier filters can rewrite input to be a no-op, for example due to a length limit
-            // on an input field. Skip no-op changes.
-            if (start == end && dstart == dend) {
-                if (DEBUG_UNDO) Log.d(TAG, "filter: skipping no-op");
-                return null;
-            }
+            // An application may install a TextWatcher to provide additional modifications after
+            // the initial input filters run (e.g. a credit card formatter that adds spaces to a
+            // string). This results in multiple filter() calls for what the user considers to be
+            // a single operation. Always undo the whole set of changes in one step.
+            final boolean forceMerge = !mFirstFilterPass;
+            mFirstFilterPass = false;
 
             // Build a new operation with all the information from this edit.
-            EditOperation edit = new EditOperation(mEditor, source, start, end, dest, dstart, dend);
+            EditOperation edit = new EditOperation(mEditor, forceMerge,
+                    source, start, end, dest, dstart, dend);
 
             // Fetch the last edit operation and attempt to merge in the new edit.
+            final UndoManager um = mEditor.mUndoManager;
             um.beginUpdate("Edit text");
             EditOperation lastEdit = um.getLastOperation(
                   EditOperation.class, mEditor.mUndoOwner, UndoManager.MERGE_MODE_UNIQUE);
@@ -4595,6 +4614,12 @@
                 // Add this as the first edit.
                 if (DEBUG_UNDO) Log.d(TAG, "filter: adding first op " + edit);
                 um.addOperation(edit, UndoManager.MERGE_MODE_NONE);
+            } else if (!mIsUserEdit) {
+                // An application directly modified the Editable outside of a text edit. Treat this
+                // as a new change and don't attempt to merge.
+                if (DEBUG_UNDO) Log.d(TAG, "non-user edit, new op " + edit);
+                um.commitState(mEditor.mUndoOwner);
+                um.addOperation(edit, UndoManager.MERGE_MODE_NONE);
             } else if (lastEdit.mergeWith(edit)) {
                 // Merge succeeded, nothing else to do.
                 if (DEBUG_UNDO) Log.d(TAG, "filter: merge succeeded, created " + lastEdit);
@@ -4607,6 +4632,36 @@
             um.endUpdate();
             return null;  // Text not changed.
         }
+
+        private boolean canUndoEdit(CharSequence source, int start, int end,
+                Spanned dest, int dstart, int dend) {
+            if (!mEditor.mAllowUndo) {
+                if (DEBUG_UNDO) Log.d(TAG, "filter: undo is disabled");
+                return false;
+            }
+
+            if (mEditor.mUndoManager.isInUndo()) {
+                if (DEBUG_UNDO) Log.d(TAG, "filter: skipping, currently performing undo/redo");
+                return false;
+            }
+
+            // Text filters run before input operations are applied. However, some input operations
+            // are invalid and will throw exceptions when applied. This is common in tests. Don't
+            // attempt to undo invalid operations.
+            if (!isValidRange(source, start, end) || !isValidRange(dest, dstart, dend)) {
+                if (DEBUG_UNDO) Log.d(TAG, "filter: invalid op");
+                return false;
+            }
+
+            // Earlier filters can rewrite input to be a no-op, for example due to a length limit
+            // on an input field. Skip no-op changes.
+            if (start == end && dstart == dend) {
+                if (DEBUG_UNDO) Log.d(TAG, "filter: skipping no-op");
+                return false;
+            }
+
+            return true;
+        }
     }
 
     /**
@@ -4618,6 +4673,7 @@
         private static final int TYPE_REPLACE = 2;
 
         private int mType;
+        private boolean mForceMerge;
         private String mOldText;
         private int mOldTextStart;
         private String mNewText;
@@ -4629,10 +4685,12 @@
         /**
          * Constructs an edit operation from a text input operation that replaces the range
          * (dstart, dend) of dest with (start, end) of source. See {@link InputFilter#filter}.
+         * If forceMerge is true then always forcibly merge this operation with any previous one.
          */
-        public EditOperation(Editor editor, CharSequence source, int start, int end,
-                Spanned dest, int dstart, int dend) {
+        public EditOperation(Editor editor, boolean forceMerge,
+                CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
             super(editor.mUndoOwner);
+            mForceMerge = forceMerge;
 
             mOldText = dest.subSequence(dstart, dend).toString();
             mNewText = source.subSequence(start, end).toString();
@@ -4660,6 +4718,7 @@
         public EditOperation(Parcel src, ClassLoader loader) {
             super(src, loader);
             mType = src.readInt();
+            mForceMerge = src.readInt() != 0;
             mOldText = src.readString();
             mOldTextStart = src.readInt();
             mNewText = src.readString();
@@ -4671,6 +4730,7 @@
         @Override
         public void writeToParcel(Parcel dest, int flags) {
             dest.writeInt(mType);
+            dest.writeInt(mForceMerge ? 1 : 0);
             dest.writeString(mOldText);
             dest.writeInt(mOldTextStart);
             dest.writeString(mNewText);
@@ -4679,6 +4739,14 @@
             dest.writeInt(mNewCursorPos);
         }
 
+        private int getNewTextEnd() {
+            return mNewTextStart + mNewText.length();
+        }
+
+        private int getOldTextEnd() {
+            return mOldTextStart + mOldText.length();
+        }
+
         @Override
         public void commit() {
         }
@@ -4687,14 +4755,20 @@
         public void undo() {
             if (DEBUG_UNDO) Log.d(TAG, "undo");
             // Remove the new text and insert the old.
-            modifyText(mNewTextStart, getNewTextEnd(), mOldText, mOldTextStart, mOldCursorPos);
+            Editor editor = getOwnerData();
+            Editable text = (Editable) editor.mTextView.getText();
+            modifyText(text, mNewTextStart, getNewTextEnd(), mOldText, mOldTextStart,
+                    mOldCursorPos);
         }
 
         @Override
         public void redo() {
             if (DEBUG_UNDO) Log.d(TAG, "redo");
             // Remove the old text and insert the new.
-            modifyText(mOldTextStart, getOldTextEnd(), mNewText, mNewTextStart, mNewCursorPos);
+            Editor editor = getOwnerData();
+            Editable text = (Editable) editor.mTextView.getText();
+            modifyText(text, mOldTextStart, getOldTextEnd(), mNewText, mNewTextStart,
+                    mNewCursorPos);
         }
 
         /**
@@ -4704,6 +4778,14 @@
          * object unchanged.
          */
         private boolean mergeWith(EditOperation edit) {
+            if (DEBUG_UNDO) {
+                Log.d(TAG, "mergeWith old " + this);
+                Log.d(TAG, "mergeWith new " + edit);
+            }
+            if (edit.mForceMerge) {
+                forceMergeWith(edit);
+                return true;
+            }
             switch (mType) {
                 case TYPE_INSERT:
                     return mergeInsertWith(edit);
@@ -4717,7 +4799,6 @@
         }
 
         private boolean mergeInsertWith(EditOperation edit) {
-            if (DEBUG_UNDO) Log.d(TAG, "mergeInsertWith " + edit);
             // Only merge continuous insertions.
             if (edit.mType != TYPE_INSERT) {
                 return false;
@@ -4733,7 +4814,6 @@
 
         // TODO: Support forward delete.
         private boolean mergeDeleteWith(EditOperation edit) {
-            if (DEBUG_UNDO) Log.d(TAG, "mergeDeleteWith " + edit);
             // Only merge continuous deletes.
             if (edit.mType != TYPE_DELETE) {
                 return false;
@@ -4749,11 +4829,8 @@
         }
 
         private boolean mergeReplaceWith(EditOperation edit) {
-            if (DEBUG_UNDO) Log.d(TAG, "mergeReplaceWith " + edit);
-            // Replacements can merge only with adjacent inserts and adjacent replacements.
-            if (edit.mType == TYPE_DELETE ||
-                    getNewTextEnd() != edit.mOldTextStart ||
-                    edit.mOldTextStart != edit.mNewTextStart) {
+            // Replacements can merge only with adjacent inserts.
+            if (edit.mType != TYPE_INSERT || getNewTextEnd() != edit.mNewTextStart) {
                 return false;
             }
             mOldText += edit.mOldText;
@@ -4762,18 +4839,42 @@
             return true;
         }
 
-        private int getNewTextEnd() {
-            return mNewTextStart + mNewText.length();
-        }
-
-        private int getOldTextEnd() {
-            return mOldTextStart + mOldText.length();
-        }
-
-        private void modifyText(int deleteFrom, int deleteTo, CharSequence newText,
-                int newTextInsertAt, int newCursorPos) {
+        /**
+         * Forcibly creates a single merged edit operation by simulating the entire text
+         * contents being replaced.
+         */
+        private void forceMergeWith(EditOperation edit) {
+            if (DEBUG_UNDO) Log.d(TAG, "forceMerge");
             Editor editor = getOwnerData();
-            Editable text = (Editable) editor.mTextView.getText();
+
+            // Copy the text of the current field.
+            // NOTE: Using StringBuilder instead of SpannableStringBuilder would be somewhat faster,
+            // but would require two parallel implementations of modifyText() because Editable and
+            // StringBuilder do not share an interface for replace/delete/insert.
+            Editable editable = (Editable) editor.mTextView.getText();
+            Editable originalText = new SpannableStringBuilder(editable.toString());
+
+            // Roll back the last operation.
+            modifyText(originalText, mNewTextStart, getNewTextEnd(), mOldText, mOldTextStart,
+                    mOldCursorPos);
+
+            // Clone the text again and apply the new operation.
+            Editable finalText = new SpannableStringBuilder(editable.toString());
+            modifyText(finalText, edit.mOldTextStart, edit.getOldTextEnd(), edit.mNewText,
+                    edit.mNewTextStart, edit.mNewCursorPos);
+
+            // Convert this operation into a non-mergeable replacement of the entire string.
+            mType = TYPE_REPLACE;
+            mNewText = finalText.toString();
+            mNewTextStart = 0;
+            mOldText = originalText.toString();
+            mOldTextStart = 0;
+            mNewCursorPos = edit.mNewCursorPos;
+            // mOldCursorPos is unchanged.
+        }
+
+        private static void modifyText(Editable text, int deleteFrom, int deleteTo,
+                CharSequence newText, int newTextInsertAt, int newCursorPos) {
             // Apply the edit if it is still valid.
             if (isValidRange(text, deleteFrom, deleteTo) &&
                     newTextInsertAt <= text.length() - (deleteTo - deleteFrom)) {
@@ -4791,10 +4892,22 @@
             }
         }
 
+        private String getTypeString() {
+            switch (mType) {
+                case TYPE_INSERT:
+                    return "insert";
+                case TYPE_DELETE:
+                    return "delete";
+                case TYPE_REPLACE:
+                    return "replace";
+                default:
+                    return "";
+            }
+        }
+
         @Override
         public String toString() {
-            return "EditOperation: [" +
-                    "mType=" + mType + ", " +
+            return "[mType=" + getTypeString() + ", " +
                     "mOldText=" + mOldText + ", " +
                     "mOldTextStart=" + mOldTextStart + ", " +
                     "mNewText=" + mNewText + ", " +
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java
index f599035..da15302 100644
--- a/core/java/android/widget/LinearLayout.java
+++ b/core/java/android/widget/LinearLayout.java
@@ -19,6 +19,7 @@
 import com.android.internal.R;
 
 import android.annotation.IntDef;
+import android.annotation.Nullable;
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
@@ -186,11 +187,11 @@
         this(context, null);
     }
 
-    public LinearLayout(Context context, AttributeSet attrs) {
+    public LinearLayout(Context context, @Nullable AttributeSet attrs) {
         this(context, attrs, 0);
     }
     
-    public LinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+    public LinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
         this(context, attrs, defStyleAttr, 0);
     }
 
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index dd7fa18..a10be11 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.annotation.ColorInt;
 import android.app.ActivityOptions;
 import android.app.ActivityThread;
 import android.app.Application;
@@ -2263,7 +2264,7 @@
      * @param color Sets the text color for all the states (normal, selected,
      *            focused) to be this color.
      */
-    public void setTextColor(int viewId, int color) {
+    public void setTextColor(int viewId, @ColorInt int color) {
         setInt(viewId, "setTextColor", color);
     }
 
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 9bef1fe..faf1c40 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -17,6 +17,7 @@
 package android.widget;
 
 import android.R;
+import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -637,16 +638,17 @@
         this(context, null);
     }
 
-    public TextView(Context context, AttributeSet attrs) {
+    public TextView(Context context, @Nullable AttributeSet attrs) {
         this(context, attrs, com.android.internal.R.attr.textViewStyle);
     }
 
-    public TextView(Context context, AttributeSet attrs, int defStyleAttr) {
+    public TextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
         this(context, attrs, defStyleAttr, 0);
     }
 
     @SuppressWarnings("deprecation")
-    public TextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+    public TextView(
+            Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
         super(context, attrs, defStyleAttr, defStyleRes);
 
         mText = "";
@@ -2996,7 +2998,7 @@
      * @attr ref android.R.styleable#TextView_textColor
      */
     @android.view.RemotableViewMethod
-    public void setTextColor(int color) {
+    public void setTextColor(@ColorInt int color) {
         mTextColor = ColorStateList.valueOf(color);
         updateTextColors();
     }
@@ -3037,6 +3039,7 @@
      *
      * @return Returns the current text color.
      */
+    @ColorInt
     public final int getCurrentTextColor() {
         return mCurTextColor;
     }
@@ -3047,7 +3050,7 @@
      * @attr ref android.R.styleable#TextView_textColorHighlight
      */
     @android.view.RemotableViewMethod
-    public void setHighlightColor(int color) {
+    public void setHighlightColor(@ColorInt int color) {
         if (mHighlightColor != color) {
             mHighlightColor = color;
             invalidate();
@@ -3061,6 +3064,7 @@
      *
      * @attr ref android.R.styleable#TextView_textColorHighlight
      */
+    @ColorInt
     public int getHighlightColor() {
         return mHighlightColor;
     }
@@ -3155,6 +3159,7 @@
      *
      * @attr ref android.R.styleable#TextView_shadowColor
      */
+    @ColorInt
     public int getShadowColor() {
         return mShadowColor;
     }
@@ -3230,7 +3235,7 @@
      * @attr ref android.R.styleable#TextView_textColorHint
      */
     @android.view.RemotableViewMethod
-    public final void setHintTextColor(int color) {
+    public final void setHintTextColor(@ColorInt int color) {
         mHintTextColor = ColorStateList.valueOf(color);
         updateTextColors();
     }
@@ -3269,6 +3274,7 @@
      *
      * @return Returns the current hint text color.
      */
+    @ColorInt
     public final int getCurrentHintTextColor() {
         return mHintTextColor != null ? mCurHintTextColor : mCurTextColor;
     }
@@ -3282,7 +3288,7 @@
      * @attr ref android.R.styleable#TextView_textColorLink
      */
     @android.view.RemotableViewMethod
-    public final void setLinkTextColor(int color) {
+    public final void setLinkTextColor(@ColorInt int color) {
         mLinkTextColor = ColorStateList.valueOf(color);
         updateTextColors();
     }
@@ -4119,6 +4125,7 @@
         if (type == BufferType.EDITABLE || getKeyListener() != null ||
                 needEditableForNotification) {
             createEditorIfNeeded();
+            mEditor.forgetUndoRedo();
             Editable t = mEditableFactory.newEditable(text);
             text = t;
             setFilters(t, mFilters);
diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java
index 9bc2aab..d2430bc 100644
--- a/core/java/android/widget/Toolbar.java
+++ b/core/java/android/widget/Toolbar.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.annotation.ColorInt;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.app.ActionBar;
@@ -685,7 +686,7 @@
      *
      * @param color The new text color in 0xAARRGGBB format
      */
-    public void setTitleTextColor(int color) {
+    public void setTitleTextColor(@ColorInt int color) {
         mTitleTextColor = color;
         if (mTitleTextView != null) {
             mTitleTextView.setTextColor(color);
@@ -697,7 +698,7 @@
      *
      * @param color The new text color in 0xAARRGGBB format
      */
-    public void setSubtitleTextColor(int color) {
+    public void setSubtitleTextColor(@ColorInt int color) {
         mSubtitleTextColor = color;
         if (mSubtitleTextView != null) {
             mSubtitleTextView.setTextColor(color);
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index c3cc60a..fb0ffb0 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -369,6 +369,9 @@
                 return TRANSPORT_ERROR;
             }
         }
+        if (DEBUG) {
+            Log.v(TAG, "   stored " + numBytes + " of data");
+        }
         return TRANSPORT_OK;
     }
 
@@ -431,6 +434,10 @@
 
     @Override
     public RestoreDescription nextRestorePackage() {
+        if (DEBUG) {
+            Log.v(TAG, "nextRestorePackage() : mRestorePackage=" + mRestorePackage
+                    + " length=" + mRestorePackages.length);
+        }
         if (mRestorePackages == null) throw new IllegalStateException("startRestore not called");
 
         boolean found = false;
@@ -441,7 +448,10 @@
             // skip packages where we have a data dir but no actual contents
             String[] contents = (new File(mRestoreSetIncrementalDir, name)).list();
             if (contents != null && contents.length > 0) {
-                if (DEBUG) Log.v(TAG, "  nextRestorePackage(TYPE_KEY_VALUE) = " + name);
+                if (DEBUG) {
+                    Log.v(TAG, "  nextRestorePackage(TYPE_KEY_VALUE) @ "
+                        + mRestorePackage + " = " + name);
+                }
                 mRestoreType = RestoreDescription.TYPE_KEY_VALUE;
                 found = true;
             }
@@ -450,7 +460,10 @@
                 // No key/value data; check for [non-empty] full data
                 File maybeFullData = new File(mRestoreSetFullDir, name);
                 if (maybeFullData.length() > 0) {
-                    if (DEBUG) Log.v(TAG, "  nextRestorePackage(TYPE_FULL_STREAM) = " + name);
+                    if (DEBUG) {
+                        Log.v(TAG, "  nextRestorePackage(TYPE_FULL_STREAM) @ "
+                                + mRestorePackage + " = " + name);
+                    }
                     mRestoreType = RestoreDescription.TYPE_FULL_STREAM;
                     mCurFullRestoreStream = null;   // ensure starting from the ground state
                     found = true;
@@ -460,6 +473,11 @@
             if (found) {
                 return new RestoreDescription(name, mRestoreType);
             }
+
+            if (DEBUG) {
+                Log.v(TAG, "  ... package @ " + mRestorePackage + " = " + name
+                        + " has no data; skipping");
+            }
         }
 
         if (DEBUG) Log.v(TAG, "  no more packages to restore");
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 28f1a3a..97744ea 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -147,7 +147,7 @@
     android_hardware_location_ActivityRecognitionHardware.cpp \
     android_util_FileObserver.cpp \
     android/opengl/poly_clip.cpp.arm \
-    android/opengl/util.cpp.arm \
+    android/opengl/util.cpp \
     android_server_FingerprintManager.cpp \
     android_server_NetworkManagementSocketTagger.cpp \
     android_server_Watchdog.cpp \
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 672008d..6a50b52 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -41,7 +41,6 @@
 jfieldID gOptions_mCancelID;
 jfieldID gOptions_bitmapFieldID;
 
-jfieldID gBitmap_nativeBitmapFieldID;
 jfieldID gBitmap_ninePatchInsetsFieldID;
 
 jclass gInsetStruct_class;
@@ -262,7 +261,7 @@
     SkBitmap* outputBitmap = NULL;
     unsigned int existingBufferSize = 0;
     if (javaBitmap != NULL) {
-        outputBitmap = (SkBitmap*) env->GetLongField(javaBitmap, gBitmap_nativeBitmapFieldID);
+        outputBitmap = GraphicsJNI::getSkBitmap(env, javaBitmap);
         if (outputBitmap->isImmutable()) {
             ALOGW("Unable to reuse an immutable bitmap as an image decoder target.");
             javaBitmap = NULL;
@@ -601,7 +600,6 @@
     gOptions_mCancelID = GetFieldIDOrDie(env, options_class, "mCancel", "Z");
 
     jclass bitmap_class = FindClassOrDie(env, "android/graphics/Bitmap");
-    gBitmap_nativeBitmapFieldID = GetFieldIDOrDie(env, bitmap_class, "mNativeBitmap", "J");
     gBitmap_ninePatchInsetsFieldID = GetFieldIDOrDie(env, bitmap_class, "mNinePatchInsets",
             "Landroid/graphics/NinePatch$InsetStruct;");
 
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index 90a7f69..04afe3e 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -213,7 +213,7 @@
 
     if (tileBitmap != NULL) {
         // Re-use bitmap.
-        bitmap = GraphicsJNI::getNativeBitmap(env, tileBitmap);
+        bitmap = GraphicsJNI::getSkBitmap(env, tileBitmap);
     }
     if (bitmap == NULL) {
         bitmap = new SkBitmap;
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index dde1393..0747969 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -154,7 +154,7 @@
 static jfieldID gPointF_yFieldID;
 
 static jclass   gBitmap_class;
-static jfieldID gBitmap_nativeInstanceID;
+static jfieldID gBitmap_skBitmapPtr;
 static jmethodID gBitmap_constructorMethodID;
 static jmethodID gBitmap_reinitMethodID;
 static jmethodID gBitmap_getAllocationByteCountMethodID;
@@ -338,11 +338,11 @@
     return static_cast<SkColorType>(gConfig2ColorType[legacyConfig]);
 }
 
-SkBitmap* GraphicsJNI::getNativeBitmap(JNIEnv* env, jobject bitmap) {
+SkBitmap* GraphicsJNI::getSkBitmap(JNIEnv* env, jobject bitmap) {
     SkASSERT(env);
     SkASSERT(bitmap);
     SkASSERT(env->IsInstanceOf(bitmap, gBitmap_class));
-    jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_nativeInstanceID);
+    jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_skBitmapPtr);
     SkBitmap* b = reinterpret_cast<SkBitmap*>(bitmapHandle);
     SkASSERT(b);
     return b;
@@ -676,7 +676,7 @@
     gPointF_yFieldID = getFieldIDCheck(env, gPointF_class, "y", "F");
 
     gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
-    gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "J");
+    gBitmap_skBitmapPtr = getFieldIDCheck(env, gBitmap_class, "mSkBitmapPtr", "J");
     gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>", "(J[BIIIZZ[BLandroid/graphics/NinePatch$InsetStruct;)V");
     gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V");
     gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I");
diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h
index a202c38..422d3f1 100644
--- a/core/jni/android/graphics/GraphicsJNI.h
+++ b/core/jni/android/graphics/GraphicsJNI.h
@@ -48,7 +48,7 @@
     static void point_to_jpointf(const SkPoint& point, JNIEnv*, jobject jpointf);
 
     static SkCanvas* getNativeCanvas(JNIEnv*, jobject canvas);
-    static SkBitmap* getNativeBitmap(JNIEnv*, jobject bitmap);
+    static SkBitmap* getSkBitmap(JNIEnv*, jobject bitmap);
     static SkRegion* getNativeRegion(JNIEnv*, jobject region);
 
     // Given the 'native' long held by the Rasterizer.java object, return a
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index 461507f..5c2d0d0 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -16,6 +16,7 @@
 
 #include "jni.h"
 #include "JNIHelp.h"
+#include "GraphicsJNI.h"
 
 #include <math.h>
 #include <stdio.h>
@@ -149,10 +150,6 @@
     return result;
 }
 
-static void doThrowIAE(JNIEnv* env, const char* msg) {
-    jniThrowException(env, "java/lang/IllegalArgumentException", msg);
-}
-
 template<class JArray, class T>
 class ArrayHelper {
 public:
@@ -548,14 +545,6 @@
 
 // ---------------------------------------------------------------------------
 
-static jfieldID nativeBitmapID = 0;
-
-void nativeUtilsClassInit(JNIEnv *env, jclass clazz)
-{
-    jclass bitmapClass = env->FindClass("android/graphics/Bitmap");
-    nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "J");
-}
-
 extern void setGLDebugLevel(int level);
 void setTracingLevel(JNIEnv *env, jclass clazz, jint level)
 {
@@ -629,16 +618,14 @@
 static jint util_getInternalFormat(JNIEnv *env, jclass clazz,
         jobject jbitmap)
 {
-    SkBitmap const * nativeBitmap =
-            (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
+    SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
     return getInternalFormat(nativeBitmap->colorType());
 }
 
 static jint util_getType(JNIEnv *env, jclass clazz,
         jobject jbitmap)
 {
-    SkBitmap const * nativeBitmap =
-            (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
+    SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
     return getType(nativeBitmap->colorType());
 }
 
@@ -646,8 +633,7 @@
         jint target, jint level, jint internalformat,
         jobject jbitmap, jint type, jint border)
 {
-    SkBitmap const * nativeBitmap =
-            (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
+    SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
     SkColorType colorType = bitmap.colorType();
     if (internalformat < 0) {
@@ -694,8 +680,7 @@
         jint target, jint level, jint xoffset, jint yoffset,
         jobject jbitmap, jint format, jint type)
 {
-    SkBitmap const * nativeBitmap =
-            (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
+    SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
     SkColorType colorType = bitmap.colorType();
     if (format < 0) {
@@ -1014,7 +999,6 @@
 };
 
 static JNINativeMethod gUtilsMethods[] = {
-    {"nativeClassInit", "()V",                          (void*)nativeUtilsClassInit },
     { "native_getInternalFormat", "(Landroid/graphics/Bitmap;)I", (void*) util_getInternalFormat },
     { "native_getType", "(Landroid/graphics/Bitmap;)I", (void*) util_getType },
     { "native_texImage2D", "(IIILandroid/graphics/Bitmap;II)I", (void*)util_texImage2D },
diff --git a/core/jni/android_view_PointerIcon.cpp b/core/jni/android_view_PointerIcon.cpp
index bbd031e..f6d9a1a 100644
--- a/core/jni/android_view_PointerIcon.cpp
+++ b/core/jni/android_view_PointerIcon.cpp
@@ -80,7 +80,7 @@
 
     jobject bitmapObj = env->GetObjectField(loadedPointerIconObj, gPointerIconClassInfo.mBitmap);
     if (bitmapObj) {
-        SkBitmap* bitmap = GraphicsJNI::getNativeBitmap(env, bitmapObj);
+        SkBitmap* bitmap = GraphicsJNI::getSkBitmap(env, bitmapObj);
         if (bitmap) {
             outPointerIcon->bitmap = *bitmap; // use a shared pixel ref
         }
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 6c21bab..7080e2a 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -30,6 +30,7 @@
 #include <gui/GLConsumer.h>
 #include <gui/Surface.h>
 
+#include <GraphicsJNI.h>
 #include <SkBitmap.h>
 #include <SkPixelRef.h>
 
@@ -46,7 +47,6 @@
 static jfieldID gSurface_EGLSurfaceFieldID;
 static jfieldID gSurface_NativePixelRefFieldID;
 static jfieldID gConfig_EGLConfigFieldID;
-static jfieldID gBitmap_NativeBitmapFieldID;
 
 static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
     if (!o) return EGL_NO_DISPLAY;
@@ -85,9 +85,6 @@
     jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
     gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "J");
     gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "J");
-
-    jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
-    gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "J");
 }
 
 static const jint gNull_attrib_base[] = {EGL_NONE};
@@ -280,9 +277,7 @@
     EGLConfig  cnf = getConfig(_env, config);
     jint* base = 0;
 
-    SkBitmap const * nativeBitmap =
-            (SkBitmap const *)_env->GetLongField(native_pixmap,
-                    gBitmap_NativeBitmapFieldID);
+    SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(_env, native_pixmap);
     SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0;
     if (ref == NULL) {
         jniThrowException(_env, "java/lang/IllegalArgumentException", "Bitmap has no PixelRef");
diff --git a/docs/html/google/play-services/wallet.jd b/docs/html/google/play-services/wallet.jd
index 3d0c64a..744c8d3 100644
--- a/docs/html/google/play-services/wallet.jd
+++ b/docs/html/google/play-services/wallet.jd
@@ -17,14 +17,14 @@
     available to US-based merchants. Once you've completed integration, you can
     apply for production access by <a class="external-link" href="https://support.google.com/wallet/business/contact/ui_review">submitting your sandbox integration for review</a>.</p>
 
-  <p>Check out the <a 
+  <p>Check out the <a
   href="{@docRoot}reference/com/google/android/gms/wallet/package-summary.html">Instant
   Buy API reference</a> and visit
   <a href="https://developers.google.com/wallet/instant-buy/">developers.google.com/wallet/instant-buy/</a>
   for complete information about integrating Google Wallet Instant Buy into your app.</p>
 </div>
 
-<div class="col-4"> 
+<div class="col-4">
   <img src="{@docRoot}images/google/gps-wallet-instant.png" alt="" style="padding-bottom:14px;width:210px">
 </div>
 </div>
@@ -44,16 +44,16 @@
       <h4>Streamline Purchases with Google+ Sign-On</h4>
       <p>For users ready to purchase, you can simplify the login and account creation steps
       by adding Google+ sign in. Users can sign in with a single click and share their
-      profile information during the purchase. 
+      profile information during the purchase.
       <br />
       <a href="https://developers.google.com/commerce/wallet/instant-buy/wallet-sso#android"
       class="external-link">Add Google+ Sign-In for Wallet</a>.</p>
-       
+
       <h4>Minimize User Data Entry</h4>
       <p>Google Wallet provides auto-completion of addresses, minimizing user data entry. You can also
       retrieve billing and shipping addresses directly from the user’s Wallet to-do form pre-fills.<br />
       <a class="external-link"
-      href="{@docRoot}reference/com/google/android/gms/wallet/MaskedWallet#getBillingAddress()">Get
+      href="{@docRoot}reference/com/google/android/gms/wallet/MaskedWallet.html#getBillingAddress()">Get
       billing addresses</a>.</p>
   </div>
 
@@ -75,7 +75,7 @@
     class="external-link" href="https://developers.google.com/wallet/instant-buy/android/tutorial">Instant Buy Android API tutorial</a>
     provides directions on how to get the Wallet sample up and running.</p>
     <h4>3. Read the documentation</h4>
-    <p>For quick access while developing your Android apps, the <a 
+    <p>For quick access while developing your Android apps, the <a
     href="{@docRoot}reference/com/google/android/gms/wallet/package-summary.html">Google Wallet
     API reference</a> is available here on developer.android.com.</p>
 
diff --git a/docs/html/guide/topics/connectivity/usb/host.jd b/docs/html/guide/topics/connectivity/usb/host.jd
index 355dd2d..f957b60 100644
--- a/docs/html/guide/topics/connectivity/usb/host.jd
+++ b/docs/html/guide/topics/connectivity/usb/host.jd
@@ -31,7 +31,7 @@
         <li><a href="{@docRoot}resources/samples/USB/AdbTest/index.html">AdbTest</a></li>
 
         <li><a href=
-        "{@docRoot}resources/samples/USB/MissileLauncher/index.html">MissleLauncher</a></li>
+        "{@docRoot}resources/samples/USB/MissileLauncher/index.html">MissileLauncher</a></li>
       </ol>
     </div>
   </div>
@@ -283,7 +283,7 @@
 
   <h3 id="permission-d">Obtaining permission to communicate with a device</h3>
 
-  <p>Before communicating with the USB device, your applicaton must have permission from your
+  <p>Before communicating with the USB device, your application must have permission from your
   users.</p>
 
   <p class="note"><strong>Note:</strong> If your application <a href="#using-intents">uses an
@@ -388,7 +388,7 @@
   should have more logic to correctly find the correct interface and endpoints to communicate on
   and also should do any transferring of data in a different thread than the main UI thread:</p>
   <pre>
-private Byte[] bytes
+private Byte[] bytes;
 private static int TIMEOUT = 0;
 private boolean forceClaim = true;
 
@@ -409,7 +409,7 @@
   <p>For more information, see the <a href=
   "{@docRoot}resources/samples/USB/AdbTest/index.html">AdbTest sample</a>, which shows how to do
   asynchronous bulk transfers, and the <a href=
-  "{@docRoot}resources/samples/USB/MissileLauncher/index.html">MissleLauncher sample</a>, which
+  "{@docRoot}resources/samples/USB/MissileLauncher/index.html">MissileLauncher sample</a>, which
   shows how to listen on an interrupt endpoint asynchronously.</p>
 
   <h3 id="terminating-d">Terminating communication with a device</h3>
diff --git a/docs/html/tools/adk/adk.jd b/docs/html/tools/adk/adk.jd
index 7e75c11..3f45c3c 100644
--- a/docs/html/tools/adk/adk.jd
+++ b/docs/html/tools/adk/adk.jd
@@ -331,7 +331,7 @@
     <li>Install the application to your device.</li>
 
     <li>Connect the ADK board (USB-A) to your Android-powered device (micro-USB). Ensure that the
-    power cable to the accessory is plugged in or that the micro-USB port on the accesory is
+    power cable to the accessory is plugged in or that the micro-USB port on the accessory is
     connected to your computer for power (this also allows you to <a href="#monitoring">monitor the
     ADK board</a>). When connected, accept the prompt that asks for whether or not to open the
     DemoKit application to connect to the accessory. If the prompt does not show up, connect and
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 132c6ef..aae11cd 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -16,11 +16,13 @@
 
 package android.graphics;
 
+import android.annotation.ColorInt;
 import android.annotation.NonNull;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.os.Trace;
 import android.util.DisplayMetrics;
+
 import dalvik.system.VMRuntime;
 
 import java.io.OutputStream;
@@ -37,21 +39,14 @@
      * @see Bitmap#setDensity(int)
      */
     public static final int DENSITY_NONE = 0;
-    
-    /**
-     * Note:  mNativeBitmap is used by FaceDetector_jni.cpp
-     * Don't change/rename without updating FaceDetector_jni.cpp
-     * 
-     * @hide
-     */
-    public final long mNativeBitmap;
+
+    private final long mSkBitmapPtr;
 
     /**
      * Backing buffer for the Bitmap.
      */
     private byte[] mBuffer;
 
-    @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources
     private final BitmapFinalizer mFinalizer;
 
     private final boolean mIsMutable;
@@ -92,11 +87,11 @@
         sDefaultDensity = density;
     }
 
+    @SuppressWarnings("deprecation")
     static int getDefaultDensity() {
         if (sDefaultDensity >= 0) {
             return sDefaultDensity;
         }
-        //noinspection deprecation
         sDefaultDensity = DisplayMetrics.DENSITY_DEVICE;
         return sDefaultDensity;
     }
@@ -105,7 +100,7 @@
      * Private constructor that must received an already allocated native bitmap
      * int (pointer).
      */
-    @SuppressWarnings({"UnusedDeclaration"}) // called from JNI
+    // called from JNI
     Bitmap(long nativeBitmap, byte[] buffer, int width, int height, int density,
             boolean isMutable, boolean requestPremultiplied,
             byte[] ninePatchChunk, NinePatch.InsetStruct ninePatchInsets) {
@@ -120,7 +115,7 @@
         mBuffer = buffer;
 
         // we delete this in our finalizer
-        mNativeBitmap = nativeBitmap;
+        mSkBitmapPtr = nativeBitmap;
 
         mNinePatchChunk = ninePatchChunk;
         mNinePatchInsets = ninePatchInsets;
@@ -136,7 +131,7 @@
      * Native bitmap has been reconfigured, so set premult and cached
      * width/height values
      */
-    @SuppressWarnings({"UnusedDeclaration"}) // called from JNI
+    // called from JNI
     void reinit(int width, int height, boolean requestPremultiplied) {
         mWidth = width;
         mHeight = height;
@@ -227,7 +222,7 @@
             throw new IllegalStateException("native-backed bitmaps may not be reconfigured");
         }
 
-        nativeReconfigure(mNativeBitmap, width, height, config.nativeInt, mBuffer.length,
+        nativeReconfigure(mSkBitmapPtr, width, height, config.nativeInt, mBuffer.length,
                 mRequestPremultiplied);
         mWidth = width;
         mHeight = height;
@@ -305,7 +300,7 @@
      */
     public void recycle() {
         if (!mRecycled && mFinalizer.mNativeBitmap != 0) {
-            if (nativeRecycle(mNativeBitmap)) {
+            if (nativeRecycle(mSkBitmapPtr)) {
                 // return value indicates whether native pixel object was actually recycled.
                 // false indicates that it is still in use at the native level and these
                 // objects should not be collected now. They will be collected later when the
@@ -331,13 +326,13 @@
      * Returns the generation ID of this bitmap. The generation ID changes
      * whenever the bitmap is modified. This can be used as an efficient way to
      * check if a bitmap has changed.
-     * 
+     *
      * @return The current generation ID for this bitmap.
      */
     public int getGenerationId() {
-        return nativeGenerationId(mNativeBitmap);
+        return nativeGenerationId(mSkBitmapPtr);
     }
-    
+
     /**
      * This is called by methods that want to throw an exception if the bitmap
      * has already been recycled.
@@ -399,12 +394,12 @@
          * encoded: red is stored with 5 bits of precision (32 possible
          * values), green is stored with 6 bits of precision (64 possible
          * values) and blue is stored with 5 bits of precision.
-         * 
+         *
          * This configuration can produce slight visual artifacts depending
          * on the configuration of the source. For instance, without
          * dithering, the result might show a greenish tint. To get better
          * results dithering should be applied.
-         * 
+         *
          * This configuration may be useful when using opaque bitmaps
          * that do not require high color fidelity.
          */
@@ -414,18 +409,18 @@
          * Each pixel is stored on 2 bytes. The three RGB color channels
          * and the alpha channel (translucency) are stored with a 4 bits
          * precision (16 possible values.)
-         * 
+         *
          * This configuration is mostly useful if the application needs
          * to store translucency information but also needs to save
          * memory.
-         * 
+         *
          * It is recommended to use {@link #ARGB_8888} instead of this
          * configuration.
          *
          * Note: as of {@link android.os.Build.VERSION_CODES#KITKAT},
          * any bitmap created with this configuration will be created
          * using {@link #ARGB_8888} instead.
-         * 
+         *
          * @deprecated Because of the poor quality of this configuration,
          *             it is advised to use {@link #ARGB_8888} instead.
          */
@@ -436,7 +431,7 @@
          * Each pixel is stored on 4 bytes. Each channel (RGB and alpha
          * for translucency) is stored with 8 bits of precision (256
          * possible values.)
-         * 
+         *
          * This configuration is very flexible and offers the best
          * quality. It should be used whenever possible.
          */
@@ -444,11 +439,10 @@
 
         final int nativeInt;
 
-        @SuppressWarnings({"deprecation"})
         private static Config sConfigs[] = {
             null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888
         };
-        
+
         Config(int ni) {
             this.nativeInt = ni;
         }
@@ -492,7 +486,7 @@
             throw new RuntimeException("Buffer not large enough for pixels");
         }
 
-        nativeCopyPixelsToBuffer(mNativeBitmap, dst);
+        nativeCopyPixelsToBuffer(mSkBitmapPtr, dst);
 
         // now update the buffer's position
         int position = dst.position();
@@ -532,7 +526,7 @@
             throw new RuntimeException("Buffer not large enough for pixels");
         }
 
-        nativeCopyPixelsFromBuffer(mNativeBitmap, src);
+        nativeCopyPixelsFromBuffer(mSkBitmapPtr, src);
 
         // now update the buffer's position
         int position = src.position();
@@ -554,7 +548,7 @@
      */
     public Bitmap copy(Config config, boolean isMutable) {
         checkRecycled("Can't copy a recycled bitmap");
-        Bitmap b = nativeCopy(mNativeBitmap, config.nativeInt, isMutable);
+        Bitmap b = nativeCopy(mSkBitmapPtr, config.nativeInt, isMutable);
         if (b != null) {
             b.setPremultiplied(mRequestPremultiplied);
             b.mDensity = mDensity;
@@ -564,7 +558,7 @@
 
     /**
      * Creates a new bitmap, scaled from an existing bitmap, when possible. If the
-     * specified width and height are the same as the current width and height of 
+     * specified width and height are the same as the current width and height of
      * the source bitmap, the source bitmap is returned and no new bitmap is
      * created.
      *
@@ -639,7 +633,7 @@
      * transformed by the optional matrix. The new bitmap may be the
      * same object as source, or a copy may have been made. It is
      * initialized with the same density as the original bitmap.
-     * 
+     *
      * If the source bitmap is immutable and the requested subset is the
      * same as the source bitmap itself, then the source bitmap is
      * returned and no new bitmap is created.
@@ -781,8 +775,8 @@
      * @param config   The bitmap config to create.
      * @param hasAlpha If the bitmap is ARGB_8888 this flag can be used to mark the
      *                 bitmap as opaque. Doing so will clear the bitmap in black
-     *                 instead of transparent.  
-     * 
+     *                 instead of transparent.
+     *
      * @throws IllegalArgumentException if the width or height are <= 0
      */
     private static Bitmap createBitmap(int width, int height, Config config, boolean hasAlpha) {
@@ -800,8 +794,8 @@
      * @param config   The bitmap config to create.
      * @param hasAlpha If the bitmap is ARGB_8888 this flag can be used to mark the
      *                 bitmap as opaque. Doing so will clear the bitmap in black
-     *                 instead of transparent.  
-     * 
+     *                 instead of transparent.
+     *
      * @throws IllegalArgumentException if the width or height are <= 0
      */
     private static Bitmap createBitmap(DisplayMetrics display, int width, int height,
@@ -815,7 +809,7 @@
         }
         bm.setHasAlpha(hasAlpha);
         if (config == Config.ARGB_8888 && !hasAlpha) {
-            nativeErase(bm.mNativeBitmap, 0xff000000);
+            nativeErase(bm.mSkBitmapPtr, 0xff000000);
         }
         // No need to initialize the bitmap to zeroes with other configs;
         // it is backed by a VM byte array which is by definition preinitialized
@@ -1005,7 +999,7 @@
             throw new IllegalArgumentException("quality must be 0..100");
         }
         Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "Bitmap.compress");
-        boolean result = nativeCompress(mNativeBitmap, format.nativeInt, quality,
+        boolean result = nativeCompress(mSkBitmapPtr, format.nativeInt, quality,
                               stream, new byte[WORKING_COMPRESS_STORAGE]);
         Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
         return result;
@@ -1022,12 +1016,12 @@
      * <p>Indicates whether pixels stored in this bitmaps are stored pre-multiplied.
      * When a pixel is pre-multiplied, the RGB components have been multiplied by
      * the alpha component. For instance, if the original color is a 50%
-     * translucent red <code>(128, 255, 0, 0)</code>, the pre-multiplied form is 
+     * translucent red <code>(128, 255, 0, 0)</code>, the pre-multiplied form is
      * <code>(128, 128, 0, 0)</code>.</p>
-     * 
+     *
      * <p>This method always returns false if {@link #getConfig()} is
      * {@link Bitmap.Config#RGB_565}.</p>
-     * 
+     *
      * <p>The return value is undefined if {@link #getConfig()} is
      * {@link Bitmap.Config#ALPHA_8}.</p>
      *
@@ -1046,7 +1040,7 @@
      * @see BitmapFactory.Options#inPremultiplied
      */
     public final boolean isPremultiplied() {
-        return nativeIsPremultiplied(mNativeBitmap);
+        return nativeIsPremultiplied(mSkBitmapPtr);
     }
 
     /**
@@ -1071,7 +1065,7 @@
      */
     public final void setPremultiplied(boolean premultiplied) {
         mRequestPremultiplied = premultiplied;
-        nativeSetPremultiplied(mNativeBitmap, premultiplied);
+        nativeSetPremultiplied(mSkBitmapPtr, premultiplied);
     }
 
     /** Returns the bitmap's width */
@@ -1137,7 +1131,7 @@
     public int getScaledHeight(int targetDensity) {
         return scaleFromDensity(getHeight(), mDensity, targetDensity);
     }
-    
+
     /**
      * @hide
      */
@@ -1145,11 +1139,11 @@
         if (sdensity == DENSITY_NONE || tdensity == DENSITY_NONE || sdensity == tdensity) {
             return size;
         }
-        
+
         // Scale by tdensity / sdensity, rounding up.
         return ((size * tdensity) + (sdensity >> 1)) / sdensity;
     }
-    
+
     /**
      * Return the number of bytes between rows in the bitmap's pixels. Note that
      * this refers to the pixels as stored natively by the bitmap. If you call
@@ -1163,7 +1157,7 @@
      * @return number of bytes between rows of the native bitmap pixels.
      */
     public final int getRowBytes() {
-        return nativeRowBytes(mNativeBitmap);
+        return nativeRowBytes(mSkBitmapPtr);
     }
 
     /**
@@ -1206,7 +1200,7 @@
      * that config, otherwise return null.
      */
     public final Config getConfig() {
-        return Config.nativeToConfig(nativeConfig(mNativeBitmap));
+        return Config.nativeToConfig(nativeConfig(mSkBitmapPtr));
     }
 
     /** Returns true if the bitmap's config supports per-pixel alpha, and
@@ -1218,7 +1212,7 @@
      * it will return true by default.
      */
     public final boolean hasAlpha() {
-        return nativeHasAlpha(mNativeBitmap);
+        return nativeHasAlpha(mSkBitmapPtr);
     }
 
     /**
@@ -1232,28 +1226,28 @@
      * non-opaque per-pixel alpha values.
      */
     public void setHasAlpha(boolean hasAlpha) {
-        nativeSetHasAlpha(mNativeBitmap, hasAlpha, mRequestPremultiplied);
+        nativeSetHasAlpha(mSkBitmapPtr, hasAlpha, mRequestPremultiplied);
     }
 
     /**
      * Indicates whether the renderer responsible for drawing this
      * bitmap should attempt to use mipmaps when this bitmap is drawn
      * scaled down.
-     * 
+     *
      * If you know that you are going to draw this bitmap at less than
      * 50% of its original size, you may be able to obtain a higher
      * quality
-     * 
+     *
      * This property is only a suggestion that can be ignored by the
      * renderer. It is not guaranteed to have any effect.
-     * 
+     *
      * @return true if the renderer should attempt to use mipmaps,
      *         false otherwise
-     * 
+     *
      * @see #setHasMipMap(boolean)
      */
     public final boolean hasMipMap() {
-        return nativeHasMipMap(mNativeBitmap);
+        return nativeHasMipMap(mSkBitmapPtr);
     }
 
     /**
@@ -1264,7 +1258,7 @@
      * If you know that you are going to draw this bitmap at less than
      * 50% of its original size, you may be able to obtain a higher
      * quality by turning this property on.
-     * 
+     *
      * Note that if the renderer respects this hint it might have to
      * allocate extra memory to hold the mipmap levels for this bitmap.
      *
@@ -1277,7 +1271,7 @@
      * @see #hasMipMap()
      */
     public final void setHasMipMap(boolean hasMipMap) {
-        nativeSetHasMipMap(mNativeBitmap, hasMipMap);
+        nativeSetHasMipMap(mSkBitmapPtr, hasMipMap);
     }
 
     /**
@@ -1285,12 +1279,12 @@
      *
      * @throws IllegalStateException if the bitmap is not mutable.
      */
-    public void eraseColor(int c) {
+    public void eraseColor(@ColorInt int c) {
         checkRecycled("Can't erase a recycled bitmap");
         if (!isMutable()) {
             throw new IllegalStateException("cannot erase immutable bitmaps");
         }
-        nativeErase(mNativeBitmap, c);
+        nativeErase(mSkBitmapPtr, c);
     }
 
     /**
@@ -1303,10 +1297,11 @@
      * @return     The argb {@link Color} at the specified coordinate
      * @throws IllegalArgumentException if x, y exceed the bitmap's bounds
      */
+    @ColorInt
     public int getPixel(int x, int y) {
         checkRecycled("Can't call getPixel() on a recycled bitmap");
         checkPixelAccess(x, y);
-        return nativeGetPixel(mNativeBitmap, x, y);
+        return nativeGetPixel(mSkBitmapPtr, x, y);
     }
 
     /**
@@ -1332,21 +1327,21 @@
      * @throws ArrayIndexOutOfBoundsException if the pixels array is too small
      *         to receive the specified number of pixels.
      */
-    public void getPixels(int[] pixels, int offset, int stride,
+    public void getPixels(@ColorInt int[] pixels, int offset, int stride,
                           int x, int y, int width, int height) {
         checkRecycled("Can't call getPixels() on a recycled bitmap");
         if (width == 0 || height == 0) {
             return; // nothing to do
         }
         checkPixelsAccess(x, y, width, height, offset, stride, pixels);
-        nativeGetPixels(mNativeBitmap, pixels, offset, stride,
+        nativeGetPixels(mSkBitmapPtr, pixels, offset, stride,
                         x, y, width, height);
     }
 
     /**
      * Shared code to check for illegal arguments passed to getPixel()
      * or setPixel()
-     * 
+     *
      * @param x x coordinate of the pixel
      * @param y y coordinate of the pixel
      */
@@ -1414,13 +1409,13 @@
      * @throws IllegalArgumentException if x, y are outside of the bitmap's
      *         bounds.
      */
-    public void setPixel(int x, int y, int color) {
+    public void setPixel(int x, int y, @ColorInt int color) {
         checkRecycled("Can't call setPixel() on a recycled bitmap");
         if (!isMutable()) {
             throw new IllegalStateException();
         }
         checkPixelAccess(x, y);
-        nativeSetPixel(mNativeBitmap, x, y, color);
+        nativeSetPixel(mSkBitmapPtr, x, y, color);
     }
 
     /**
@@ -1446,7 +1441,7 @@
      * @throws ArrayIndexOutOfBoundsException if the pixels array is too small
      *         to receive the specified number of pixels.
      */
-    public void setPixels(int[] pixels, int offset, int stride,
+    public void setPixels(@ColorInt int[] pixels, int offset, int stride,
             int x, int y, int width, int height) {
         checkRecycled("Can't call setPixels() on a recycled bitmap");
         if (!isMutable()) {
@@ -1456,7 +1451,7 @@
             return; // nothing to do
         }
         checkPixelsAccess(x, y, width, height, offset, stride, pixels);
-        nativeSetPixels(mNativeBitmap, pixels, offset, stride,
+        nativeSetPixels(mSkBitmapPtr, pixels, offset, stride,
                         x, y, width, height);
     }
 
@@ -1494,7 +1489,7 @@
      */
     public void writeToParcel(Parcel p, int flags) {
         checkRecycled("Can't parcel a recycled bitmap");
-        if (!nativeWriteToParcel(mNativeBitmap, mIsMutable, mDensity, p)) {
+        if (!nativeWriteToParcel(mSkBitmapPtr, mIsMutable, mDensity, p)) {
             throw new RuntimeException("native writeToParcel failed");
         }
     }
@@ -1522,9 +1517,9 @@
      * -2, -2, so that drawing the alpha bitmap offset by (-2, -2) and then
      * drawing the original would result in the blur visually aligning with
      * the original.
-     * 
+     *
      * <p>The initial density of the returned bitmap is the same as the original's.
-     * 
+     *
      * @param paint Optional paint used to modify the alpha values in the
      *              resulting bitmap. Pass null for default behavior.
      * @param offsetXY Optional array that returns the X (index 0) and Y
@@ -1538,7 +1533,7 @@
     public Bitmap extractAlpha(Paint paint, int[] offsetXY) {
         checkRecycled("Can't extractAlpha on a recycled bitmap");
         long nativePaint = paint != null ? paint.getNativeInstance() : 0;
-        Bitmap bm = nativeExtractAlpha(mNativeBitmap, nativePaint, offsetXY);
+        Bitmap bm = nativeExtractAlpha(mSkBitmapPtr, nativePaint, offsetXY);
         if (bm == null) {
             throw new RuntimeException("Failed to extractAlpha on Bitmap");
         }
@@ -1552,7 +1547,7 @@
      *  If other is null, return false.
      */
     public boolean sameAs(Bitmap other) {
-        return this == other || (other != null && nativeSameAs(mNativeBitmap, other.mNativeBitmap));
+        return this == other || (other != null && nativeSameAs(mSkBitmapPtr, other.mSkBitmapPtr));
     }
 
     /**
@@ -1567,7 +1562,12 @@
      * and therefore is harmless.
      */
     public void prepareToDraw() {
-        nativePrepareToDraw(mNativeBitmap);
+        nativePrepareToDraw(mSkBitmapPtr);
+    }
+
+    /** @hide */
+    public final long getSkBitmap() {
+        return mSkBitmapPtr;
     }
 
     private static class BitmapFinalizer {
@@ -1658,8 +1658,4 @@
     private static native boolean nativeHasMipMap(long nativeBitmap);
     private static native void nativeSetHasMipMap(long nativeBitmap, boolean hasMipMap);
     private static native boolean nativeSameAs(long nativeBitmap0, long nativeBitmap1);
-
-    /* package */ final long ni() {
-        return mNativeBitmap;
-    }
 }
diff --git a/graphics/java/android/graphics/BitmapShader.java b/graphics/java/android/graphics/BitmapShader.java
index 5e004a3..f2f890e 100644
--- a/graphics/java/android/graphics/BitmapShader.java
+++ b/graphics/java/android/graphics/BitmapShader.java
@@ -42,7 +42,7 @@
         mBitmap = bitmap;
         mTileX = tileX;
         mTileY = tileY;
-        final long b = bitmap.ni();
+        final long b = bitmap.getSkBitmap();
         init(nativeCreate(b, tileX.nativeInt, tileY.nativeInt));
     }
 
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index e4c2f0e..55b7277 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -16,6 +16,7 @@
 
 package android.graphics;
 
+import android.annotation.ColorInt;
 import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -154,7 +155,7 @@
             throw new IllegalStateException("Immutable bitmap passed to Canvas constructor");
         }
         throwIfCannotDraw(bitmap);
-        mNativeCanvasWrapper = initRaster(bitmap.ni());
+        mNativeCanvasWrapper = initRaster(bitmap.getSkBitmap());
         mFinalizer = new CanvasFinalizer(mNativeCanvasWrapper);
         mBitmap = bitmap;
         mDensity = bitmap.mDensity;
@@ -219,7 +220,7 @@
             }
             throwIfCannotDraw(bitmap);
 
-            native_setBitmap(mNativeCanvasWrapper, bitmap.ni(), true);
+            native_setBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), true);
             mDensity = bitmap.mDensity;
         }
 
@@ -1012,7 +1013,7 @@
      *
      * @param color the color to draw onto the canvas
      */
-    public void drawColor(int color) {
+    public void drawColor(@ColorInt int color) {
         native_drawColor(mNativeCanvasWrapper, color, PorterDuff.Mode.SRC_OVER.nativeInt);
     }
 
@@ -1023,7 +1024,7 @@
      * @param color the color to draw with
      * @param mode  the porter-duff mode to apply to the color
      */
-    public void drawColor(int color, @NonNull PorterDuff.Mode mode) {
+    public void drawColor(@ColorInt int color, @NonNull PorterDuff.Mode mode) {
         native_drawColor(mNativeCanvasWrapper, color, mode.nativeInt);
     }
 
@@ -1339,7 +1340,7 @@
      */
     public void drawBitmap(@NonNull Bitmap bitmap, float left, float top, @Nullable Paint paint) {
         throwIfCannotDraw(bitmap);
-        native_drawBitmap(mNativeCanvasWrapper, bitmap.ni(), left, top,
+        native_drawBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), left, top,
                 paint != null ? paint.getNativeInstance() : 0, mDensity, mScreenDensity, bitmap.mDensity);
     }
 
@@ -1385,7 +1386,7 @@
           bottom = src.bottom;
       }
 
-      native_drawBitmap(mNativeCanvasWrapper, bitmap.ni(), left, top, right, bottom,
+      native_drawBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), left, top, right, bottom,
               dst.left, dst.top, dst.right, dst.bottom, nativePaint, mScreenDensity,
               bitmap.mDensity);
   }
@@ -1432,7 +1433,7 @@
             bottom = src.bottom;
         }
 
-        native_drawBitmap(mNativeCanvasWrapper, bitmap.ni(), left, top, right, bottom,
+        native_drawBitmap(mNativeCanvasWrapper, bitmap.getSkBitmap(), left, top, right, bottom,
             dst.left, dst.top, dst.right, dst.bottom, nativePaint, mScreenDensity,
             bitmap.mDensity);
     }
@@ -1513,7 +1514,7 @@
      * @param paint  May be null. The paint used to draw the bitmap
      */
     public void drawBitmap(@NonNull Bitmap bitmap, @NonNull Matrix matrix, @Nullable Paint paint) {
-        nativeDrawBitmapMatrix(mNativeCanvasWrapper, bitmap.ni(), matrix.ni(),
+        nativeDrawBitmapMatrix(mNativeCanvasWrapper, bitmap.getSkBitmap(), matrix.ni(),
                 paint != null ? paint.getNativeInstance() : 0);
     }
 
@@ -1568,7 +1569,7 @@
             // no mul by 2, since we need only 1 color per vertex
             checkRange(colors.length, colorOffset, count);
         }
-        nativeDrawBitmapMesh(mNativeCanvasWrapper, bitmap.ni(), meshWidth, meshHeight,
+        nativeDrawBitmapMesh(mNativeCanvasWrapper, bitmap.getSkBitmap(), meshWidth, meshHeight,
                 verts, vertOffset, colors, colorOffset,
                 paint != null ? paint.getNativeInstance() : 0);
     }
diff --git a/graphics/java/android/graphics/Color.java b/graphics/java/android/graphics/Color.java
index 3fe5672..df0ebee 100644
--- a/graphics/java/android/graphics/Color.java
+++ b/graphics/java/android/graphics/Color.java
@@ -16,6 +16,7 @@
 
 package android.graphics;
 
+import android.annotation.ColorInt;
 import android.util.MathUtils;
 import com.android.internal.util.XmlUtils;
 
@@ -35,23 +36,24 @@
  * 0xFFFFFFFF
  */
 public class Color {
-    public static final int BLACK       = 0xFF000000;
-    public static final int DKGRAY      = 0xFF444444;
-    public static final int GRAY        = 0xFF888888;
-    public static final int LTGRAY      = 0xFFCCCCCC;
-    public static final int WHITE       = 0xFFFFFFFF;
-    public static final int RED         = 0xFFFF0000;
-    public static final int GREEN       = 0xFF00FF00;
-    public static final int BLUE        = 0xFF0000FF;
-    public static final int YELLOW      = 0xFFFFFF00;
-    public static final int CYAN        = 0xFF00FFFF;
-    public static final int MAGENTA     = 0xFFFF00FF;
-    public static final int TRANSPARENT = 0;
+    @ColorInt public static final int BLACK       = 0xFF000000;
+    @ColorInt public static final int DKGRAY      = 0xFF444444;
+    @ColorInt public static final int GRAY        = 0xFF888888;
+    @ColorInt public static final int LTGRAY      = 0xFFCCCCCC;
+    @ColorInt public static final int WHITE       = 0xFFFFFFFF;
+    @ColorInt public static final int RED         = 0xFFFF0000;
+    @ColorInt public static final int GREEN       = 0xFF00FF00;
+    @ColorInt public static final int BLUE        = 0xFF0000FF;
+    @ColorInt public static final int YELLOW      = 0xFFFFFF00;
+    @ColorInt public static final int CYAN        = 0xFF00FFFF;
+    @ColorInt public static final int MAGENTA     = 0xFFFF00FF;
+    @ColorInt public static final int TRANSPARENT = 0;
 
     /**
      * Return the alpha component of a color int. This is the same as saying
      * color >>> 24
      */
+    @ColorInt
     public static int alpha(int color) {
         return color >>> 24;
     }
@@ -60,6 +62,7 @@
      * Return the red component of a color int. This is the same as saying
      * (color >> 16) & 0xFF
      */
+    @ColorInt
     public static int red(int color) {
         return (color >> 16) & 0xFF;
     }
@@ -68,6 +71,7 @@
      * Return the green component of a color int. This is the same as saying
      * (color >> 8) & 0xFF
      */
+    @ColorInt
     public static int green(int color) {
         return (color >> 8) & 0xFF;
     }
@@ -76,6 +80,7 @@
      * Return the blue component of a color int. This is the same as saying
      * color & 0xFF
      */
+    @ColorInt
     public static int blue(int color) {
         return color & 0xFF;
     }
@@ -90,6 +95,7 @@
      * @param green Green component [0..255] of the color
      * @param blue  Blue component [0..255] of the color
      */
+    @ColorInt
     public static int rgb(int red, int green, int blue) {
         return (0xFF << 24) | (red << 16) | (green << 8) | blue;
     }
@@ -104,6 +110,7 @@
      * @param green Green component [0..255] of the color
      * @param blue  Blue component [0..255] of the color
      */
+    @ColorInt
     public static int argb(int alpha, int red, int green, int blue) {
         return (alpha << 24) | (red << 16) | (green << 8) | blue;
     }
@@ -115,7 +122,7 @@
      * 
      * @hide Pending API council
      */
-    public static float hue(int color) {
+    public static float hue(@ColorInt int color) {
         int r = (color >> 16) & 0xFF;
         int g = (color >> 8) & 0xFF;
         int b = color & 0xFF;
@@ -157,7 +164,7 @@
      * 
      * @hide Pending API council
      */
-    public static float saturation(int color) {
+    public static float saturation(@ColorInt int color) {
         int r = (color >> 16) & 0xFF;
         int g = (color >> 8) & 0xFF;
         int b = color & 0xFF;
@@ -184,7 +191,7 @@
      *
      * @hide Pending API council
      */
-    public static float brightness(int color) {
+    public static float brightness(@ColorInt int color) {
         int r = (color >> 16) & 0xFF;
         int g = (color >> 8) & 0xFF;
         int b = color & 0xFF;
@@ -206,6 +213,7 @@
      * 'aqua', 'fuchsia', 'lime', 'maroon', 'navy', 'olive', 'purple',
      * 'silver', 'teal'.
      */
+    @ColorInt
     public static int parseColor(String colorString) {
         if (colorString.charAt(0) == '#') {
             // Use a long to avoid rollovers on #ffXXXXXX
@@ -237,6 +245,7 @@
      * 
      * @hide Pending API council
      */
+    @ColorInt
     public static int HSBtoColor(float[] hsb) {
         return HSBtoColor(hsb[0], hsb[1], hsb[2]);
     }
@@ -254,6 +263,7 @@
      * 
      * @hide Pending API council
      */
+    @ColorInt
     public static int HSBtoColor(float h, float s, float b) {
         h = MathUtils.constrain(h, 0.0f, 1.0f);
         s = MathUtils.constrain(s, 0.0f, 1.0f);
@@ -332,7 +342,7 @@
      * @param color the argb color to convert. The alpha component is ignored.
      * @param hsv  3 element array which holds the resulting HSV components.
      */
-    public static void colorToHSV(int color, float hsv[]) {
+    public static void colorToHSV(@ColorInt int color, float hsv[]) {
         RGBToHSV((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, hsv);
     }
 
@@ -379,6 +389,7 @@
      *
      * @hide
      */
+    @ColorInt
     public static int getHtmlColor(String color) {
         Integer i = sColorNameMap.get(color.toLowerCase(Locale.ROOT));
         if (i != null) {
diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java
index ebc86aa..9c4299a 100644
--- a/graphics/java/android/graphics/NinePatch.java
+++ b/graphics/java/android/graphics/NinePatch.java
@@ -98,7 +98,7 @@
     public NinePatch(Bitmap bitmap, byte[] chunk, String srcName) {
         mBitmap = bitmap;
         mSrcName = srcName;
-        mNativeChunk = validateNinePatchChunk(mBitmap.ni(), chunk);
+        mNativeChunk = validateNinePatchChunk(mBitmap.getSkBitmap(), chunk);
     }
 
     /**
@@ -199,12 +199,12 @@
     }
 
     void drawSoftware(Canvas canvas, RectF location, Paint paint) {
-        nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap.ni(), mNativeChunk,
+        nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap.getSkBitmap(), mNativeChunk,
                 paint != null ? paint.getNativeInstance() : 0, canvas.mDensity, mBitmap.mDensity);
     }
 
     void drawSoftware(Canvas canvas, Rect location, Paint paint) {
-        nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap.ni(), mNativeChunk,
+        nativeDraw(canvas.getNativeCanvasWrapper(), location, mBitmap.getSkBitmap(), mNativeChunk,
                 paint != null ? paint.getNativeInstance() : 0, canvas.mDensity, mBitmap.mDensity);
     }
 
@@ -252,7 +252,7 @@
      * that are transparent.
      */
     public final Region getTransparentRegion(Rect bounds) {
-        long r = nativeGetTransparentRegion(mBitmap.ni(), mNativeChunk, bounds);
+        long r = nativeGetTransparentRegion(mBitmap.getSkBitmap(), mNativeChunk, bounds);
         return r != 0 ? new Region(r) : null;
     }
 
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 681bc62..0656b2e 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -16,6 +16,7 @@
 
 package android.graphics;
 
+import android.annotation.ColorInt;
 import android.text.GraphicsOperations;
 import android.text.SpannableString;
 import android.text.SpannedString;
@@ -777,6 +778,7 @@
      *
      * @return the paint's color (and alpha).
      */
+    @ColorInt
     public native int getColor();
 
     /**
@@ -787,7 +789,7 @@
      *
      * @param color The new color (including alpha) to set in the paint.
      */
-    public native void setColor(int color);
+    public native void setColor(@ColorInt int color);
 
     /**
      * Helper to getColor() that just returns the color's alpha value. This is
diff --git a/graphics/java/android/graphics/PorterDuff.java b/graphics/java/android/graphics/PorterDuff.java
index f5fbe70..dcccf35 100644
--- a/graphics/java/android/graphics/PorterDuff.java
+++ b/graphics/java/android/graphics/PorterDuff.java
@@ -51,7 +51,7 @@
              Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] */
         LIGHTEN     (17),
         /** [Sa * Da, Sc * Dc] */
-        MULTIPLY    (24),
+        MULTIPLY    (13),
         /** [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] */
         SCREEN      (14),
         /** Saturate(S + D) */
diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java
index 85e02b7..f75ab36 100644
--- a/graphics/java/android/graphics/drawable/ColorDrawable.java
+++ b/graphics/java/android/graphics/drawable/ColorDrawable.java
@@ -16,6 +16,7 @@
 
 package android.graphics.drawable;
 
+import android.annotation.ColorInt;
 import android.annotation.NonNull;
 import android.graphics.*;
 import android.graphics.PorterDuff.Mode;
@@ -62,7 +63,7 @@
      *
      * @param color The color to draw.
      */
-    public ColorDrawable(int color) {
+    public ColorDrawable(@ColorInt int color) {
         mColorState = new ColorState();
 
         setColor(color);
@@ -117,6 +118,7 @@
      *
      * @return int The color to draw.
      */
+    @ColorInt
     public int getColor() {
         return mColorState.mUseColor;
     }
@@ -128,7 +130,7 @@
      *
      * @param color The color to draw.
      */
-    public void setColor(int color) {
+    public void setColor(@ColorInt int color) {
         if (mColorState.mBaseColor != color || mColorState.mUseColor != color) {
             mColorState.mBaseColor = mColorState.mUseColor = color;
             invalidateSelf();
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 2cc192c..16760c7 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -16,6 +16,7 @@
 
 package android.graphics.drawable;
 
+import android.annotation.ColorInt;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.content.res.ColorStateList;
@@ -544,7 +545,7 @@
      * @see #setTintList(ColorStateList)
      * @see #setTintMode(PorterDuff.Mode)
      */
-    public void setTint(int tintColor) {
+    public void setTint(@ColorInt int tintColor) {
         setTintList(ColorStateList.valueOf(tintColor));
     }
 
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index 6ea23d4..eff152c 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -16,6 +16,7 @@
 
 package android.graphics.drawable;
 
+import android.annotation.ColorInt;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
@@ -181,7 +182,7 @@
      * Create a new gradient drawable given an orientation and an array
      * of colors for the gradient.
      */
-    public GradientDrawable(Orientation orientation, int[] colors) {
+    public GradientDrawable(Orientation orientation, @ColorInt int[] colors) {
         this(new GradientState(orientation, colors), null);
     }
 
@@ -250,7 +251,7 @@
      * @see #mutate()
      * @see #setStroke(int, int, float, float)
      */
-    public void setStroke(int width, int color) {
+    public void setStroke(int width, @ColorInt int color) {
         setStroke(width, color, 0, 0);
     }
 
@@ -286,7 +287,7 @@
      * @see #mutate()
      * @see #setStroke(int, int)
      */
-    public void setStroke(int width, int color, float dashWidth, float dashGap) {
+    public void setStroke(int width, @ColorInt int color, float dashWidth, float dashGap) {
         mGradientState.setStroke(width, ColorStateList.valueOf(color), dashWidth, dashGap);
         setStrokeInternal(width, color, dashWidth, dashGap);
     }
@@ -501,7 +502,7 @@
      * @see #mutate()
      * @see #setColor(int)
      */
-    public void setColors(int[] colors) {
+    public void setColors(@ColorInt int[] colors) {
         mGradientState.setColors(colors);
         mGradientIsDirty = true;
         invalidateSelf();
@@ -713,7 +714,7 @@
      * @see #mutate()
      * @see #setColors(int[])
      */
-    public void setColor(int argb) {
+    public void setColor(@ColorInt int argb) {
         mGradientState.setColorStateList(ColorStateList.valueOf(argb));
         mFillPaint.setColor(argb);
         invalidateSelf();
diff --git a/graphics/java/android/graphics/pdf/PdfRenderer.java b/graphics/java/android/graphics/pdf/PdfRenderer.java
index 79934da..b32dcc6 100644
--- a/graphics/java/android/graphics/pdf/PdfRenderer.java
+++ b/graphics/java/android/graphics/pdf/PdfRenderer.java
@@ -380,7 +380,7 @@
 
             final long transformPtr = (transform != null) ? transform.native_instance : 0;
 
-            nativeRenderPage(mNativeDocument, mNativePage, destination.mNativeBitmap, contentLeft,
+            nativeRenderPage(mNativeDocument, mNativePage, destination.getSkBitmap(), contentLeft,
                     contentTop, contentRight, contentBottom, transformPtr, renderMode);
         }
 
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 8c6a91cc..e9b22e2 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -380,9 +380,9 @@
         // Xor
         "return vec4(src.rgb * (1.0 - dst.a) + (1.0 - src.a) * dst.rgb, "
                 "src.a + dst.a - 2.0 * src.a * dst.a);\n",
-        // Add
+        // Plus
         "return min(src + dst, 1.0);\n",
-        // Multiply
+        // Modulate
         "return src * dst;\n",
         // Screen
         "return src + dst - src * dst;\n",
@@ -830,7 +830,7 @@
     while ((index = shader.find("\n", index)) > -1) {
         String8 line(str, index - lastIndex);
         if (line.length() == 0) line.append("\n");
-        PROGRAM_LOGD("%s", line.string());
+        ALOGD("%s", line.string());
         index++;
         str += (index - lastIndex);
         lastIndex = index;
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index 1cf589d..16758d0 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -215,7 +215,7 @@
 status_t JMediaCodec::setCallback(jobject cb) {
     if (cb != NULL) {
         if (mCallbackNotification == NULL) {
-            mCallbackNotification = new AMessage(kWhatCallbackNotify, id());
+            mCallbackNotification = new AMessage(kWhatCallbackNotify, this);
         }
     } else {
         mCallbackNotification.clear();
diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp
index 93138fa..2f6bbf4 100644
--- a/media/jni/android_media_MediaMetadataRetriever.cpp
+++ b/media/jni/android_media_MediaMetadataRetriever.cpp
@@ -40,7 +40,6 @@
 struct fields_t {
     jfieldID context;
     jclass bitmapClazz;  // Must be a global ref
-    jfieldID nativeBitmap;
     jmethodID createBitmapMethod;
     jmethodID createScaledBitmapMethod;
     jclass configClazz;  // Must be a global ref
@@ -282,8 +281,7 @@
         return NULL;
     }
 
-    SkBitmap *bitmap =
-            (SkBitmap *) env->GetLongField(jBitmap, fields.nativeBitmap);
+    SkBitmap *bitmap = GraphicsJNI::getSkBitmap(env, jBitmap);
 
     bitmap->lockPixels();
     rotate((uint16_t*)bitmap->getPixels(),
@@ -421,10 +419,6 @@
     if (fields.createScaledBitmapMethod == NULL) {
         return;
     }
-    fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "J");
-    if (fields.nativeBitmap == NULL) {
-        return;
-    }
 
     jclass configClazz = env->FindClass("android/graphics/Bitmap$Config");
     if (configClazz == NULL) {
diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp
index ea32edc..ddb01a0 100644
--- a/native/graphics/jni/bitmap.cpp
+++ b/native/graphics/jni/bitmap.cpp
@@ -27,7 +27,7 @@
         return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
     }
 
-    SkBitmap* bm = GraphicsJNI::getNativeBitmap(env, jbitmap);
+    SkBitmap* bm = GraphicsJNI::getSkBitmap(env, jbitmap);
     if (NULL == bm) {
         return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
     }
@@ -64,7 +64,7 @@
         return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
     }
 
-    SkBitmap* bm = GraphicsJNI::getNativeBitmap(env, jbitmap);
+    SkBitmap* bm = GraphicsJNI::getSkBitmap(env, jbitmap);
     if (NULL == bm) {
         return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
     }
@@ -87,7 +87,7 @@
         return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
     }
 
-    SkBitmap* bm = GraphicsJNI::getNativeBitmap(env, jbitmap);
+    SkBitmap* bm = GraphicsJNI::getSkBitmap(env, jbitmap);
     if (NULL == bm) {
         return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
     }
diff --git a/opengl/java/android/opengl/GLUtils.java b/opengl/java/android/opengl/GLUtils.java
index a9d33dd..4d890c9 100644
--- a/opengl/java/android/opengl/GLUtils.java
+++ b/opengl/java/android/opengl/GLUtils.java
@@ -29,14 +29,6 @@
 
 public final class GLUtils {
 
-    /*
-     * We use a class initializer to allow the native code to cache some
-     * field offsets.
-     */
-    static {
-        nativeClassInit();
-    }
-
     private GLUtils() {
     }
 
@@ -275,8 +267,6 @@
      */
     native public static void setTracingLevel(int level);
 
-    native private static void nativeClassInit();
-
     native private static int native_getInternalFormat(Bitmap bitmap);
     native private static int native_getType(Bitmap bitmap);
     native private static int native_texImage2D(int target, int level, int internalformat,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 3a812cc..37d9a73 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -59,6 +59,7 @@
 import android.service.notification.StatusBarNotification;
 import android.text.TextUtils;
 import android.util.Log;
+import android.util.Slog;
 import android.util.SparseArray;
 import android.util.SparseBooleanArray;
 import android.view.Display;
@@ -2150,6 +2151,14 @@
     }
 
     public boolean isKeyguardSecure() {
+        if (mStatusBarKeyguardViewManager == null) {
+            // startKeyguard() hasn't been called yet, so we don't know.
+            // Make sure anything that needs to know isKeyguardSecure() checks and re-checks this
+            // value onVisibilityChanged().
+            Slog.w(TAG, "isKeyguardSecure() called before startKeyguard(), returning false",
+                    new Throwable());
+            return false;
+        }
         return mStatusBarKeyguardViewManager.isSecure();
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index acf7af9..0c21b20 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -220,6 +220,7 @@
 
     public void setPhoneStatusBar(PhoneStatusBar phoneStatusBar) {
         mPhoneStatusBar = phoneStatusBar;
+        updateCameraVisibility(); // in case onFinishInflate() was called too early
     }
 
     private Intent getCameraIntent() {
@@ -231,6 +232,10 @@
     }
 
     private void updateCameraVisibility() {
+        if (mCameraImageView == null) {
+            // Things are not set up yet; reply hazy, ask again later
+            return;
+        }
         ResolveInfo resolved = mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(),
                 PackageManager.MATCH_DEFAULT_ONLY,
                 mLockPatternUtils.getCurrentUser());
@@ -253,7 +258,7 @@
     private boolean isCameraDisabledByDpm() {
         final DevicePolicyManager dpm =
                 (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
-        if (dpm != null) {
+        if (dpm != null && mPhoneStatusBar != null) {
             try {
                 final int userId = ActivityManagerNative.getDefault().getCurrentUser().id;
                 final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);
diff --git a/rs/jni/Android.mk b/rs/jni/Android.mk
index f1f0bfc..94f0859 100644
--- a/rs/jni/Android.mk
+++ b/rs/jni/Android.mk
@@ -14,7 +14,8 @@
     libskia \
     libutils \
     libui \
-    libgui
+    libgui \
+    libjnigraphics
 
 LOCAL_STATIC_LIBRARIES :=
 
@@ -23,6 +24,7 @@
 LOCAL_C_INCLUDES += \
     $(JNI_H_INCLUDE) \
     frameworks/rs \
+    frameworks/base/core/jni \
     $(rs_generated_include_dir)
 
 LOCAL_CFLAGS += -Wno-unused-parameter -std=c++11
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index a145166..d8e1464 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -24,8 +24,6 @@
 #include <utils/misc.h>
 #include <inttypes.h>
 
-#include <SkBitmap.h>
-
 #include <androidfw/Asset.h>
 #include <androidfw/AssetManager.h>
 #include <androidfw/ResourceTypes.h>
@@ -35,6 +33,7 @@
 #include "android_runtime/AndroidRuntime.h"
 #include "android_runtime/android_view_Surface.h"
 #include "android_runtime/android_util_AssetManager.h"
+#include "android/graphics/GraphicsJNI.h"
 
 #include <rs.h>
 #include <rsEnv.h>
@@ -172,14 +171,10 @@
 // ---------------------------------------------------------------------------
 
 static jfieldID gContextId = 0;
-static jfieldID gNativeBitmapID = 0;
 
 static void _nInit(JNIEnv *_env, jclass _this)
 {
     gContextId             = _env->GetFieldID(_this, "mContext", "J");
-
-    jclass bitmapClass = _env->FindClass("android/graphics/Bitmap");
-    gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "J");
 }
 
 // ---------------------------------------------------------------------------
@@ -934,7 +929,7 @@
                             jobject jbitmap, jint usage)
 {
     SkBitmap const * nativeBitmap =
-            (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+            GraphicsJNI::getSkBitmap(_env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
 
     bitmap.lockPixels();
@@ -951,7 +946,7 @@
                                         jint mip, jobject jbitmap, jint usage)
 {
     SkBitmap const * nativeBitmap =
-            (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+            GraphicsJNI::getSkBitmap(_env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
 
     bitmap.lockPixels();
@@ -968,7 +963,7 @@
                                 jobject jbitmap, jint usage)
 {
     SkBitmap const * nativeBitmap =
-            (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+            GraphicsJNI::getSkBitmap(_env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
 
     bitmap.lockPixels();
@@ -984,7 +979,7 @@
 nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap)
 {
     SkBitmap const * nativeBitmap =
-            (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+            GraphicsJNI::getSkBitmap(_env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
     int w = bitmap.width();
     int h = bitmap.height();
@@ -1001,7 +996,7 @@
 nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap)
 {
     SkBitmap const * nativeBitmap =
-            (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+            GraphicsJNI::getSkBitmap(_env, jbitmap);
     const SkBitmap& bitmap(*nativeBitmap);
 
     bitmap.lockPixels();
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index 94d400a..26510328 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -601,7 +601,7 @@
         return token;
     }
 
-    // High level policy: apps are ineligible for backup if certain conditions apply
+    // High level policy: apps are generally ineligible for backup if certain conditions apply
     public static boolean appIsEligibleForBackup(ApplicationInfo app) {
         // 1. their manifest states android:allowBackup="false"
         if ((app.flags&ApplicationInfo.FLAG_ALLOW_BACKUP) == 0) {
@@ -628,7 +628,7 @@
             return (pkg.applicationInfo.flags & ApplicationInfo.FLAG_FULL_BACKUP_ONLY) != 0;
         }
 
-        // No agent means we do full backups for it
+        // No agent or fullBackupOnly="true" means we do indeed perform full-data backups for it
         return true;
     }
 
@@ -1266,7 +1266,23 @@
                     for (int i = 0; i < N; i++) {
                         String pkgName = in.readUTF();
                         long lastBackup = in.readLong();
-                        schedule.add(new FullBackupEntry(pkgName, lastBackup));
+                        try {
+                            PackageInfo pkg = mPackageManager.getPackageInfo(pkgName, 0);
+                            if (appGetsFullBackup(pkg)
+                                    && appIsEligibleForBackup(pkg.applicationInfo)) {
+                                schedule.add(new FullBackupEntry(pkgName, lastBackup));
+                            } else {
+                                if (DEBUG) {
+                                    Slog.i(TAG, "Package " + pkgName
+                                            + " no longer eligible for full backup");
+                                }
+                            }
+                        } catch (NameNotFoundException e) {
+                            if (DEBUG) {
+                                Slog.i(TAG, "Package " + pkgName
+                                        + " not installed; dropping from full backup");
+                            }
+                        }
                     }
                     Collections.sort(schedule);
                 } catch (Exception e) {
@@ -1289,7 +1305,7 @@
                 schedule = new ArrayList<FullBackupEntry>(N);
                 for (int i = 0; i < N; i++) {
                     PackageInfo info = apps.get(i);
-                    if (appGetsFullBackup(info)) {
+                    if (appGetsFullBackup(info) && appIsEligibleForBackup(info.applicationInfo)) {
                         schedule.add(new FullBackupEntry(info.packageName, 0));
                     }
                 }
@@ -1761,11 +1777,11 @@
                     addPackageParticipantsLocked(pkgList);
                 }
                 // If they're full-backup candidates, add them there instead
+                final long now = System.currentTimeMillis();
                 for (String packageName : pkgList) {
                     try {
                         PackageInfo app = mPackageManager.getPackageInfo(packageName, 0);
-                        long now = System.currentTimeMillis();
-                        if (appGetsFullBackup(app)) {
+                        if (appGetsFullBackup(app) && appIsEligibleForBackup(app.applicationInfo)) {
                             enqueueFullBackup(packageName, now);
                             scheduleNextFullBackupJob();
                         }
@@ -2462,7 +2478,7 @@
             BackupRequest request = mQueue.get(0);
             mQueue.remove(0);
 
-            Slog.d(TAG, "starting agent for backup of " + request);
+            Slog.d(TAG, "starting key/value backup of " + request);
             addBackupTrace("launch agent for " + request.packageName);
 
             // Verify that the requested app exists; it might be something that
@@ -2473,13 +2489,24 @@
             try {
                 mCurrentPackage = mPackageManager.getPackageInfo(request.packageName,
                         PackageManager.GET_SIGNATURES);
-                if (mCurrentPackage.applicationInfo.backupAgentName == null) {
+                if (!appIsEligibleForBackup(mCurrentPackage.applicationInfo)) {
                     // The manifest has changed but we had a stale backup request pending.
                     // This won't happen again because the app won't be requesting further
                     // backups.
                     Slog.i(TAG, "Package " + request.packageName
                             + " no longer supports backup; skipping");
-                    addBackupTrace("skipping - no agent, completion is noop");
+                    addBackupTrace("skipping - not eligible, completion is noop");
+                    executeNextState(BackupState.RUNNING_QUEUE);
+                    return;
+                }
+
+                if (appGetsFullBackup(mCurrentPackage)) {
+                    // It's possible that this app *formerly* was enqueued for key/value backup,
+                    // but has since been updated and now only supports the full-data path.
+                    // Don't proceed with a key/value backup for it in this case.
+                    Slog.i(TAG, "Package " + request.packageName
+                            + " requests full-data rather than key/value; skipping");
+                    addBackupTrace("skipping - fullBackupOnly, completion is noop");
                     executeNextState(BackupState.RUNNING_QUEUE);
                     return;
                 }
@@ -9161,6 +9188,8 @@
             // check whether there is data for it in the current dataset, falling back
             // to the ancestral dataset if not.
             long token = getAvailableRestoreToken(packageName);
+            if (DEBUG) Slog.v(TAG, "restorePackage pkg=" + packageName
+                    + " token=" + Long.toHexString(token));
 
             // If we didn't come up with a place to look -- no ancestral dataset and
             // the app has never been backed up from this device -- there's nothing
diff --git a/services/core/java/com/android/server/AssetAtlasService.java b/services/core/java/com/android/server/AssetAtlasService.java
index a2c87b9..e6dc1c7 100644
--- a/services/core/java/com/android/server/AssetAtlasService.java
+++ b/services/core/java/com/android/server/AssetAtlasService.java
@@ -291,7 +291,7 @@
                         }
                         canvas.drawBitmap(bitmap, 0.0f, 0.0f, null);
                         canvas.restore();
-                        atlasMap[mapIndex++] = bitmap.mNativeBitmap;
+                        atlasMap[mapIndex++] = bitmap.getSkBitmap();
                         atlasMap[mapIndex++] = entry.x;
                         atlasMap[mapIndex++] = entry.y;
                         atlasMap[mapIndex++] = entry.rotated ? 1 : 0;
diff --git a/services/core/java/com/android/server/pm/KeySetManagerService.java b/services/core/java/com/android/server/pm/KeySetManagerService.java
index 773b164..aa63932 100644
--- a/services/core/java/com/android/server/pm/KeySetManagerService.java
+++ b/services/core/java/com/android/server/pm/KeySetManagerService.java
@@ -414,9 +414,9 @@
         // Get the package's known keys and KeySets
         ArraySet<Long> deletableKeySets = getOriginalKeySetsByPackageNameLPr(packageName);
         ArraySet<Long> deletableKeys = new ArraySet<Long>();
-        ArraySet<Long> knownKeys = null;
-        for (Long ks : deletableKeySets) {
-            knownKeys = mKeySetMapping.get(ks);
+        final int origDksSize = deletableKeySets.size();
+        for (int i = 0; i < origDksSize; i++) {
+            ArraySet<Long> knownKeys = mKeySetMapping.get(deletableKeySets.valueAt(i));
             if (knownKeys != null) {
                 deletableKeys.addAll(knownKeys);
             }
@@ -429,9 +429,9 @@
             }
             ArraySet<Long> knownKeySets = getOriginalKeySetsByPackageNameLPr(pkgName);
             deletableKeySets.removeAll(knownKeySets);
-            knownKeys = new ArraySet<Long>();
-            for (Long ks : knownKeySets) {
-                knownKeys = mKeySetMapping.get(ks);
+            final int kksSize = knownKeySets.size();
+            for (int i = 0; i < kksSize; i++) {
+                ArraySet<Long> knownKeys = mKeySetMapping.get(knownKeySets.valueAt(i));
                 if (knownKeys != null) {
                     deletableKeys.removeAll(knownKeys);
                 }
@@ -440,18 +440,22 @@
 
         // The remaining keys and KeySets are not relied on by any other
         // application and so can be safely deleted.
-        for (Long ks : deletableKeySets) {
+        final int dksSize = deletableKeySets.size();
+        for (int i = 0; i < dksSize; i++) {
+            Long ks = deletableKeySets.valueAt(i);
             mKeySets.delete(ks);
             mKeySetMapping.delete(ks);
         }
-        for (Long keyId : deletableKeys) {
-            mPublicKeys.delete(keyId);
+        final int dkSize = deletableKeys.size();
+        for (int i = 0; i < dkSize; i++) {
+            mPublicKeys.delete(deletableKeys.valueAt(i));
         }
 
         // Now remove the deleted KeySets from each package's signingKeySets
         for (String pkgName : mPackages.keySet()) {
             PackageSetting p = mPackages.get(pkgName);
-            for (Long ks : deletableKeySets) {
+            for (int i = 0; i < dksSize; i++) {
+                Long ks = deletableKeySets.valueAt(i);
                 p.keySetData.removeSigningKeySet(ks);
             }
         }
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index fc9ff76..b90666f 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -51,6 +51,7 @@
 import android.content.pm.ServiceInfo;
 import android.content.pm.UserInfo;
 import android.database.ContentObserver;
+import android.graphics.Bitmap;
 import android.hardware.usb.UsbManager;
 import android.media.AudioManager;
 import android.media.IAudioService;
@@ -5491,6 +5492,22 @@
         }
     }
 
+    @Override
+    public void setUserIcon(ComponentName who, Bitmap icon) {
+        synchronized (this) {
+            Preconditions.checkNotNull(who, "ComponentName is null");
+            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+
+            int userId = UserHandle.getCallingUserId();
+            long id = Binder.clearCallingIdentity();
+            try {
+                mUserManager.setUserIcon(userId, icon);
+            } finally {
+                restoreCallingIdentity(id);
+            }
+        }
+    }
+
     /**
      * We need to update the internal state of whether a user has completed setup once. After
      * that, we ignore any changes that reset the Settings.Secure.USER_SETUP_COMPLETE changes
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 0a4b787..f3b2d2e 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3716,6 +3716,34 @@
     }
 
     /**
+     * Whether the device supports configuring the DTMF tone length.
+     *
+     * @return {@code true} if the DTMF tone length can be changed, and {@code false} otherwise.
+     */
+    public boolean canChangeDtmfToneLength() {
+        try {
+            return getITelephony().canChangeDtmfToneLength();
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e);
+        }
+        return false;
+    }
+
+    /**
+     * Whether the device is a world phone.
+     *
+     * @return {@code true} if the device is a world phone, and {@code false} otherwise.
+     */
+    public boolean isWorldPhone() {
+        try {
+            return getITelephony().isWorldPhone();
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error calling ITelephony#isWorldPhone", e);
+        }
+        return false;
+    }
+
+    /**
      * This function retrieves value for setting "name+subId", and if that is not found
      * retrieves value for setting "name", and if that is not found uses def as default
      *
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 62c8746..3769dee 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -863,11 +863,25 @@
     /**
      * Whether video calling has been enabled by the user.
      *
-     * @return {@code True} if the user has enabled video calling, {@code false} otherwise.
+     * @return {@code true} if the user has enabled video calling, {@code false} otherwise.
      */
     boolean isVideoCallingEnabled();
 
     /**
+     * Whether the DTMF tone length can be changed.
+     *
+     * @return {@code true} if the DTMF tone length can be changed.
+     */
+    boolean canChangeDtmfToneLength();
+
+    /**
+     * Whether the device is a world phone.
+     *
+     * @return {@code true} if the devices is a world phone.
+     */
+    boolean isWorldPhone();
+
+    /**
      * Get IMS Registration Status
      */
     boolean isImsRegistered();
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index 5ab177b..063b4e6 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -481,8 +481,9 @@
 
     // assuming the image is a round rect, compute the radius by marching
     // diagonally from the top left corner towards the center
-    image->outlineAlpha = max(max_alpha_over_row(image->rows[innerMidY], innerStartX, innerEndX),
-            max_alpha_over_col(image->rows, innerMidX, innerStartY, innerStartY));
+    image->outlineAlpha = std::max(
+        max_alpha_over_row(image->rows[innerMidY], innerStartX, innerEndX),
+        max_alpha_over_col(image->rows, innerMidX, innerStartY, innerStartY));
 
     int diagonalInset = 0;
     find_max_opacity(image->rows, innerStartX, innerStartY, innerMidX, innerMidY, 1, 1,
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 6fbc17c..941a288 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -1807,7 +1807,7 @@
         }
 
         const ResTable& featureTable = featureAssetManager.getResources(false);
-        mTypeIdOffset = max(mTypeIdOffset,
+        mTypeIdOffset = std::max(mTypeIdOffset,
                 findLargestTypeIdForPackage(featureTable, mAssetsPackage)); 
     }
 
@@ -2703,20 +2703,16 @@
     const String8 defaultLocale;
 
     // For all strings...
-    for (map<String16, map<String8, SourcePos> >::iterator nameIter = mLocalizations.begin();
-         nameIter != mLocalizations.end();
-         nameIter++) {
-        const map<String8, SourcePos>& configSrcMap = nameIter->second;
+    for (const auto& nameIter : mLocalizations) {
+        const std::map<String8, SourcePos>& configSrcMap = nameIter.second;
 
         // Look for strings with no default localization
         if (configSrcMap.count(defaultLocale) == 0) {
             SourcePos().warning("string '%s' has no default translation.",
-                    String8(nameIter->first).string());
+                    String8(nameIter.first).string());
             if (mBundle->getVerbose()) {
-                for (map<String8, SourcePos>::const_iterator locales = configSrcMap.begin();
-                    locales != configSrcMap.end();
-                    locales++) {
-                    locales->second.printf("locale %s found", locales->first.string());
+                for (const auto& locale : configSrcMap) {
+                    locale.second.printf("locale %s found", locale.first.string());
                 }
             }
             // !!! TODO: throw an error here in some circumstances
@@ -2727,8 +2723,8 @@
             const char* allConfigs = mBundle->getConfigurations().string();
             const char* start = allConfigs;
             const char* comma;
-            
-            set<String8> missingConfigs;
+
+            std::set<String8> missingConfigs;
             AaptLocaleValue locale;
             do {
                 String8 config;
@@ -2762,13 +2758,11 @@
 
             if (!missingConfigs.empty()) {
                 String8 configStr;
-                for (set<String8>::iterator iter = missingConfigs.begin();
-                     iter != missingConfigs.end();
-                     iter++) {
-                    configStr.appendFormat(" %s", iter->string());
+                for (const auto& iter : missingConfigs) {
+                    configStr.appendFormat(" %s", iter.string());
                 }
                 SourcePos().warning("string '%s' is missing %u required localizations:%s",
-                        String8(nameIter->first).string(),
+                        String8(nameIter.first).string(),
                         (unsigned int)missingConfigs.size(),
                         configStr.string());
             }
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index eef0ae1..9644224 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -17,8 +17,6 @@
 #include "StringPool.h"
 #include "Symbol.h"
 
-using namespace std;
-
 class XMLNode;
 class ResourceTable;
 
@@ -29,7 +27,7 @@
     XML_COMPILE_STRIP_WHITESPACE = 1<<3,
     XML_COMPILE_STRIP_RAW_VALUES = 1<<4,
     XML_COMPILE_UTF8 = 1<<5,
-    
+
     XML_COMPILE_STANDARD_RESOURCE =
             XML_COMPILE_STRIP_COMMENTS | XML_COMPILE_ASSIGN_ATTRIBUTE_IDS
             | XML_COMPILE_STRIP_WHITESPACE | XML_COMPILE_STRIP_RAW_VALUES
@@ -116,7 +114,7 @@
      * and would mess up iteration order for the existing
      * resources.
      */
-    queue<CompileResourceWorkItem>& getWorkQueue() {
+    std::queue<CompileResourceWorkItem>& getWorkQueue() {
         return mWorkQueue;
     }
 
@@ -587,10 +585,10 @@
     size_t mNumLocal;
     SourcePos mCurrentXmlPos;
     Bundle* mBundle;
-    
+
     // key = string resource name, value = set of locales in which that name is defined
-    map<String16, map<String8, SourcePos> > mLocalizations;
-    queue<CompileResourceWorkItem> mWorkQueue;
+    std::map<String16, std::map<String8, SourcePos>> mLocalizations;
+    std::queue<CompileResourceWorkItem> mWorkQueue;
 };
 
 #endif
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index 8d24d38..970b9d0 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -76,13 +76,6 @@
     // ---- Public Helper methods ----
 
     /**
-     * Returns the native delegate associated to a given {@link Bitmap_Delegate} object.
-     */
-    public static Bitmap_Delegate getDelegate(Bitmap bitmap) {
-        return sManager.getDelegate(bitmap.mNativeBitmap);
-    }
-
-    /**
      * Returns the native delegate associated to a given an int referencing a {@link Bitmap} object.
      */
     public static Bitmap_Delegate getDelegate(long native_bitmap) {
@@ -187,19 +180,6 @@
         return createBitmap(delegate, createFlags, density.getDpiValue());
     }
 
-    /**
-     * Returns the {@link BufferedImage} used by the delegate of the given {@link Bitmap}.
-     */
-    public static BufferedImage getImage(Bitmap bitmap) {
-        // get the delegate from the native int.
-        Bitmap_Delegate delegate = sManager.getDelegate(bitmap.mNativeBitmap);
-        if (delegate == null) {
-            return null;
-        }
-
-        return delegate.mImage;
-    }
-
     public static int getBufferedImageType(int nativeBitmapConfig) {
         switch (Config.nativeToConfig(nativeBitmapConfig)) {
             case ALPHA_8: