libbinder: Add support for C++ Parcelable

Bug: 23600712
Test: compiles, integration tests for Java/C++ compatibility pass

Change-Id: I0919571919a3633350169ed5668bbb000da9691c
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 277f156..a12d68d 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -28,6 +28,7 @@
 #include <linux/binder.h>
 
 #include <binder/IInterface.h>
+#include <binder/Parcelable.h>
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -128,6 +129,10 @@
     status_t            writeStrongBinderVector(const std::vector<sp<IBinder>>& val);
 
     template<typename T>
+    status_t            writeParcelableVector(const std::vector<T>& val);
+    status_t            writeParcelable(const Parcelable& parcelable);
+
+    template<typename T>
     status_t            write(const Flattenable<T>& val);
 
     template<typename T>
@@ -204,6 +209,10 @@
     wp<IBinder>         readWeakBinder() const;
 
     template<typename T>
+    status_t            readParcelableVector(std::vector<T>* val) const;
+    status_t            readParcelable(Parcelable* parcelable) const;
+
+    template<typename T>
     status_t            readStrongBinder(sp<T>* val) const;
 
     status_t            readStrongBinderVector(std::vector<sp<IBinder>>* val) const;
@@ -543,6 +552,16 @@
     return unsafeWriteTypedVector(val, write_func);
 }
 
+template<typename T>
+status_t Parcel::readParcelableVector(std::vector<T>* val) const {
+    return unsafeReadTypedVector(val, &Parcel::readParcelable);
+}
+
+template<typename T>
+status_t Parcel::writeParcelableVector(const std::vector<T>& val) {
+    return unsafeWriteTypedVector(val, &Parcel::writeParcelable);
+}
+
 // ---------------------------------------------------------------------------
 
 inline TextOutput& operator<<(TextOutput& to, const Parcel& parcel)