Add read/writeBlob to Parcel
These are {@hide}en for now.
Bug: 16516353
Change-Id: Ie1635617ee8611a78be9068a7ce674e34c30301d
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 95cb9f3..59cd97c 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -246,6 +246,7 @@
private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue);
private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len);
+ private static native void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len);
private static native void nativeWriteInt(long nativePtr, int val);
private static native void nativeWriteLong(long nativePtr, long val);
private static native void nativeWriteFloat(long nativePtr, float val);
@@ -255,6 +256,7 @@
private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);
private static native byte[] nativeCreateByteArray(long nativePtr);
+ private static native byte[] nativeReadBlob(long nativePtr);
private static native int nativeReadInt(long nativePtr);
private static native long nativeReadLong(long nativePtr);
private static native float nativeReadFloat(long nativePtr);
@@ -479,6 +481,16 @@
}
/**
+ * 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.
+ * {@hide}
+ */
+ public final void writeBlob(byte[] b) {
+ nativeWriteBlob(mNativePtr, b, 0, (b != null) ? b.length : 0);
+ }
+
+ /**
* Write an integer value into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
@@ -1700,6 +1712,14 @@
}
/**
+ * Read a blob of data from the parcel and return it as a byte array.
+ * {@hide}
+ */
+ public final byte[] readBlob() {
+ return nativeReadBlob(mNativePtr);
+ }
+
+ /**
* Read and return a String[] object from the parcel.
* {@hide}
*/