summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Christopher Wiley <wiley@google.com> 2015-11-19 06:49:05 -0800
committer Christopher Wiley <wiley@google.com> 2015-11-19 06:51:27 -0800
commit97f048d19e51da4ea6ff98d8a9daf38f2577f182 (patch)
tree77467ff62c4b0eb222eb428e25d165528502845c /libs/binder/Parcel.cpp
parent03d1eb6bf90bcd0a04b176988478d2e939d3fba0 (diff)
libbinder: Add support for C++ Parcelable
Bug: 23600712 Test: compiles, integration tests for Java/C++ compatibility pass Change-Id: I0919571919a3633350169ed5668bbb000da9691c
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index a5f7d89bd8..03348da773 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -931,6 +931,14 @@ status_t Parcel::writeWeakBinder(const wp<IBinder>& val)
return flatten_binder(ProcessState::self(), val, this);
}
+status_t Parcel::writeParcelable(const Parcelable& parcelable) {
+ status_t status = writeInt32(1); // parcelable is not null.
+ if (status != OK) {
+ return status;
+ }
+ return parcelable.writeToParcel(this);
+}
+
status_t Parcel::writeNativeHandle(const native_handle* handle)
{
if (!handle || handle->version != sizeof(native_handle))
@@ -1543,6 +1551,18 @@ wp<IBinder> Parcel::readWeakBinder() const
return val;
}
+status_t Parcel::readParcelable(Parcelable* parcelable) const {
+ int32_t have_parcelable = 0;
+ status_t status = readInt32(&have_parcelable);
+ if (status != OK) {
+ return status;
+ }
+ if (!have_parcelable) {
+ return UNEXPECTED_NULL;
+ }
+ return parcelable->readFromParcel(this);
+}
+
int32_t Parcel::readExceptionCode() const
{
binder::Status status;