From b9f7aac3488873677377b36c57338d758098f78e Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Wed, 4 Mar 2015 13:08:49 -0500 Subject: 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 --- core/java/android/os/Parcel.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'core/java/android/os/Parcel.java') diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 8c1f44f..1273772 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -502,7 +502,25 @@ public final class Parcel { * {@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); } /** -- cgit v1.1