libbinder: Add object offsets to RPC Binder protocol
The list of object offsets is always empty in this CL. That will change
in follow up CLs when file descriptor support is added.
The size of the parcel data is included in the RpcWireTransaction and
RpcWireReply headers and then the object offsets are written after the
parcel data.
There was no space in RpcWireReply, so we must start a new wire protocol
version. I've added some reserved space to RpcWireReply to match
RpcWireTransaction so that it might be easier to make backwards
compatible changes later.
binderRpcTest on host went from 36 seconds to 2 minutes 24 seconds
because of the added parameterization (x4 the tests => x4 the time).
Bug: 185909244
Test: TH
Change-Id: I0121a42f8b60362e6a6d0294a350255b5f9f5673
diff --git a/libs/binder/RpcWireFormat.h b/libs/binder/RpcWireFormat.h
index d9b5ca0..7e2aa79 100644
--- a/libs/binder/RpcWireFormat.h
+++ b/libs/binder/RpcWireFormat.h
@@ -131,7 +131,10 @@
uint64_t asyncNumber;
- uint32_t reserved[4];
+ // The size of the Parcel data directly following RpcWireTransaction.
+ uint32_t parcelDataSize;
+
+ uint32_t reserved[3];
uint8_t data[];
};
@@ -139,8 +142,23 @@
struct RpcWireReply {
int32_t status; // transact return
+
+ // -- Fields below only transmitted starting at protocol version 1 --
+
+ // The size of the Parcel data directly following RpcWireReply.
+ uint32_t parcelDataSize;
+
+ uint32_t reserved[3];
+
+ // Byte size of RpcWireReply in the wire protocol.
+ static size_t wireSize(uint32_t protocolVersion) {
+ if (protocolVersion == 0) {
+ return sizeof(int32_t);
+ }
+ return sizeof(RpcWireReply);
+ }
};
-static_assert(sizeof(RpcWireReply) == 4);
+static_assert(sizeof(RpcWireReply) == 20);
#pragma clang diagnostic pop