From 97f048d19e51da4ea6ff98d8a9daf38f2577f182 Mon Sep 17 00:00:00 2001 From: Christopher Wiley Date: Thu, 19 Nov 2015 06:49:05 -0800 Subject: libbinder: Add support for C++ Parcelable Bug: 23600712 Test: compiles, integration tests for Java/C++ compatibility pass Change-Id: I0919571919a3633350169ed5668bbb000da9691c --- libs/binder/Parcel.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libs/binder/Parcel.cpp') 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& 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 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; -- cgit v1.2.3-59-g8ed1b