diff options
-rw-r--r-- | include/binder/Parcel.h | 9 | ||||
-rw-r--r-- | libs/binder/Parcel.cpp | 53 |
2 files changed, 62 insertions, 0 deletions
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index 3ada1e9096..9bf62a3a8e 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -108,6 +108,9 @@ public: status_t writeWeakBinder(const wp<IBinder>& val); status_t writeInt32Array(size_t len, const int32_t *val); status_t writeByteArray(size_t len, const uint8_t *val); + status_t writeBool(bool val); + status_t writeChar(char16_t val); + status_t writeByte(int8_t val); template<typename T> status_t write(const Flattenable<T>& val); @@ -169,6 +172,12 @@ public: status_t readDouble(double *pArg) const; intptr_t readIntPtr() const; status_t readIntPtr(intptr_t *pArg) const; + bool readBool() const; + status_t readBool(bool *pArg) const; + char16_t readChar() const; + status_t readChar(char16_t *pArg) const; + int8_t readByte() const; + status_t readByte(int8_t *pArg) const; const char* readCString() const; String8 readString8() const; diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 45191f5bd9..95385db9d9 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -760,6 +760,21 @@ status_t Parcel::writeByteArray(size_t len, const uint8_t *val) { return ret; } +status_t Parcel::writeBool(bool val) +{ + return writeInt32(int32_t(val)); +} + +status_t Parcel::writeChar(char16_t val) +{ + return writeInt32(int32_t(val)); +} + +status_t Parcel::writeByte(int8_t val) +{ + return writeInt32(int32_t(val)); +} + status_t Parcel::writeInt64(int64_t val) { return writeAligned(val); @@ -1252,6 +1267,44 @@ intptr_t Parcel::readIntPtr() const return readAligned<intptr_t>(); } +status_t Parcel::readBool(bool *pArg) const +{ + int32_t tmp; + status_t ret = readInt32(&tmp); + *pArg = (tmp != 0); + return ret; +} + +bool Parcel::readBool() const +{ + return readInt32() != 0; +} + +status_t Parcel::readChar(char16_t *pArg) const +{ + int32_t tmp; + status_t ret = readInt32(&tmp); + *pArg = char16_t(tmp); + return ret; +} + +char16_t Parcel::readChar() const +{ + return char16_t(readInt32()); +} + +status_t Parcel::readByte(int8_t *pArg) const +{ + int32_t tmp; + status_t ret = readInt32(&tmp); + *pArg = int8_t(tmp); + return ret; +} + +int8_t Parcel::readByte() const +{ + return int8_t(readInt32()); +} const char* Parcel::readCString() const { |