summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2022-06-01 03:21:06 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-06-01 03:21:06 +0000
commitf967183ebc2c97231a831eeda9e4ba83e625c44c (patch)
treeec99c421e6938bf544b1d3a79de095e1f4888d8b
parent0b4f27e34f53ad3d03af12673b60a481f2475144 (diff)
parentc89c535242a2142b8995512e18ab9cef2fefbe3d (diff)
Merge "libbinder*: clarify setDataPosition constraints"
-rw-r--r--libs/binder/include/binder/Parcel.h5
-rw-r--r--libs/binder/ndk/include_ndk/android/binder_parcel.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index e2b2c5128d..39d0c9068f 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -76,6 +76,11 @@ public:
size_t dataCapacity() const;
status_t setDataSize(size_t size);
+
+ // this must only be used to set a data position that was previously returned from
+ // dataPosition(). If writes are made, the exact same types of writes must be made (e.g.
+ // auto i = p.dataPosition(); p.writeInt32(0); p.setDataPosition(i); p.writeInt32(1);).
+ // Writing over objects, such as file descriptors and binders, is not supported.
void setDataPosition(size_t pos) const;
status_t setDataCapacity(size_t size);
diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel.h b/libs/binder/ndk/include_ndk/android/binder_parcel.h
index 84575811f0..f68612c3ba 100644
--- a/libs/binder/ndk/include_ndk/android/binder_parcel.h
+++ b/libs/binder/ndk/include_ndk/android/binder_parcel.h
@@ -59,6 +59,11 @@ void AParcel_delete(AParcel* parcel) __INTRODUCED_IN(29);
/**
* Sets the position within the parcel.
*
+ * This must be called with a position that has been previously returned from
+ * AParcel_getDataPosition. If writes are made after setting the data position, they must
+ * be made in the exact same sequence used before resetting data position. Writing over
+ * objects such as binders or file descriptors is not supported.
+ *
* Available since API level 29.
*
* \param parcel The parcel of which to set the position.