diff options
author | Marco Nelissen <marcone@google.com> | 2014-03-13 14:17:40 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2014-03-17 11:13:30 -0700 |
commit | 37b44969c0ca1d00e213da685dfbb2807f2bab30 (patch) | |
tree | 4f0110372cccf61a5b60766ce90b932f1f1550c9 | |
parent | e0daeb3933e034f037630715e4cd2ecb3880498b (diff) | |
download | android_frameworks_native-37b44969c0ca1d00e213da685dfbb2807f2bab30.tar.gz android_frameworks_native-37b44969c0ca1d00e213da685dfbb2807f2bab30.tar.bz2 android_frameworks_native-37b44969c0ca1d00e213da685dfbb2807f2bab30.zip |
Add support for writing byte arrays to parcels
b/13418320
Cherrypicked from f0190bff38b6c29abbfc4a877442f71fc3d7dad8
https://googleplex-android-review.git.corp.google.com/#/c/433320/
Change-Id: I2285df9e9d3dc8a6a54055b13b352b81660bf45d
-rw-r--r-- | include/binder/Parcel.h | 1 | ||||
-rw-r--r-- | libs/binder/Parcel.cpp | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index 33b2f0050..939cfbea9 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -101,6 +101,7 @@ public: status_t writeStrongBinder(const sp<IBinder>& val); status_t writeWeakBinder(const wp<IBinder>& val); status_t write(const Flattenable& val); + status_t writeByteArray(size_t len, const uint8_t *val); // Place a native_handle into the parcel (the native_handle's file- // descriptors are dup'ed, so it is safe to delete the native_handle diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index dea14bb97..1162681bf 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -617,6 +617,17 @@ status_t Parcel::writeInt32(int32_t val) return writeAligned(val); } +status_t Parcel::writeByteArray(size_t len, const uint8_t *val) { + if (!val) { + return writeAligned(-1); + } + status_t ret = writeAligned(len); + if (ret == NO_ERROR) { + ret = write(val, len * sizeof(*val)); + } + return ret; +} + status_t Parcel::writeInt64(int64_t val) { return writeAligned(val); |