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/Utils.h b/libs/binder/Utils.h
index 150d520..7dcb70e 100644
--- a/libs/binder/Utils.h
+++ b/libs/binder/Utils.h
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include <cstdint>
 #include <stddef.h>
+#include <cstdint>
+#include <optional>
 
 #include <android-base/result.h>
 #include <android-base/unique_fd.h>
@@ -39,4 +40,26 @@
 
 status_t getRandomBytes(uint8_t* data, size_t size);
 
+// View of contiguous sequence. Similar to std::span.
+template <typename T>
+struct Span {
+    T* data = nullptr;
+    size_t size = 0;
+
+    size_t byteSize() { return size * sizeof(T); }
+
+    iovec toIovec() { return {const_cast<std::remove_const_t<T>*>(data), byteSize()}; }
+
+    // Truncates `this` to a length of `offset` and returns a span with the
+    // remainder.
+    //
+    // Aborts if offset > size.
+    Span<T> splitOff(size_t offset) {
+        LOG_ALWAYS_FATAL_IF(offset > size);
+        Span<T> rest = {data + offset, size - offset};
+        size = offset;
+        return rest;
+    }
+};
+
 }   // namespace android