Icon: a clean, parcelable place for images.

Binder APIs which wish to consume Bitmaps *and* drawable
resources can now do so by using Icon, a kind of union type
that accommodates each of these. Icon also accepts byte
arrays holding compressed Bitmaps (PNG, JPEG, etc), which
saves clients the additional memory cost of decoding and
sending full uncompressed bitmaps through Binder interfaces.
Receiving clients can call loadDrawable{,Async} and then
getDrawable to start immediately using the image in an
ImageView or other Drawable-hosting container.

Bug: 19609468
Change-Id: Ic1343711c2ac0b15876b46f0b6008b0108a49470
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 8c1f44f..1273772b 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -502,7 +502,25 @@
      * {@SystemApi}
      */
     public final void writeBlob(byte[] b) {
-        nativeWriteBlob(mNativePtr, b, 0, (b != null) ? b.length : 0);
+        writeBlob(b, 0, (b != null) ? b.length : 0);
+    }
+
+    /**
+     * Write a blob of data into the parcel at the current {@link #dataPosition},
+     * growing {@link #dataCapacity} if needed.
+     * @param b Bytes to place into the parcel.
+     * @param offset Index of first byte to be written.
+     * @param len Number of bytes to write.
+     * {@hide}
+     * {@SystemApi}
+     */
+    public final void writeBlob(byte[] b, int offset, int len) {
+        if (b == null) {
+            writeInt(-1);
+            return;
+        }
+        Arrays.checkOffsetAndCount(b.length, offset, len);
+        nativeWriteBlob(mNativePtr, b, offset, len);
     }
 
     /**