summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Casey Dahlin <sadmac@google.com> 2015-11-05 00:17:07 +0000
committer android-build-merger <android-build-merger@google.com> 2015-11-05 00:17:07 +0000
commite6788fa5c2548db912a098174eb93b784dc8b7dd (patch)
tree33d94857896d0b26332a618c4ca30a07285e842b /libs/binder/Parcel.cpp
parent6ea4e35ab1c4fc93b9dc176423e6e425c85bf360 (diff)
parent4ed5d8c98ea74c953b767a84ebfedf9d038dba3b (diff)
Merge "Add support for reading/writing a vector of binders" am: fd6843236f
am: 4ed5d8c98e * commit '4ed5d8c98ea74c953b767a84ebfedf9d038dba3b': Add support for reading/writing a vector of binders
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 9095048227..10903303c1 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -1073,6 +1073,56 @@ status_t Parcel::writeStrongBinder(const sp<IBinder>& val)
return flatten_binder(ProcessState::self(), val, this);
}
+status_t Parcel::writeStrongBinderVector(const std::vector<sp<IBinder>>& val)
+{
+ if (val.size() > std::numeric_limits<int32_t>::max()) {
+ return BAD_VALUE;
+ }
+
+ status_t status = writeInt32(val.size());
+
+ if (status != OK) {
+ return status;
+ }
+
+ for (const auto& item : val) {
+ status = writeStrongBinder(item);
+
+ if (status != OK) {
+ return status;
+ }
+ }
+
+ return OK;
+}
+
+status_t Parcel::readStrongBinderVector(std::vector<sp<IBinder>>* val) const {
+ val->clear();
+
+ int32_t size;
+ status_t status = readInt32(&size);
+
+ if (status != OK) {
+ return status;
+ }
+
+ if (size < 0) {
+ return BAD_VALUE;
+ }
+
+ val->resize(size);
+
+ for (auto& v : *val) {
+ status = readStrongBinder(&v);
+
+ if (status != OK) {
+ return status;
+ }
+ }
+
+ return OK;
+}
+
status_t Parcel::writeWeakBinder(const wp<IBinder>& val)
{
return flatten_binder(ProcessState::self(), val, this);