Use vector<uint8_t> for byte[]

Most C++ devs want this, and it's more compatible with the rest of
brillo.

Change-Id: Ifed607f7c463651b11b45ce796de61bbc578aee5
Test: Unit and integration tests pass
Bug: 27078230
diff --git a/tests/aidl_test_client_primitives.cpp b/tests/aidl_test_client_primitives.cpp
index f24e50a..405538e 100644
--- a/tests/aidl_test_client_primitives.cpp
+++ b/tests/aidl_test_client_primitives.cpp
@@ -106,7 +106,7 @@
   if (!ReverseArray(s, &ITestService::ReverseBoolean,
                     {true, false, false}) ||
       !ReverseArray(s, &ITestService::ReverseByte,
-                    {int8_t{-128}, int8_t{0}, int8_t{127}}) ||
+                    {uint8_t{255}, uint8_t{0}, uint8_t{127}}) ||
       !ReverseArray(s, &ITestService::ReverseChar,
                     {char16_t{'A'}, char16_t{'B'}, char16_t{'C'}}) ||
       !ReverseArray(s, &ITestService::ReverseInt,
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index a3e83e9..856a67b 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -199,9 +199,9 @@
                         vector<bool>* _aidl_return) override {
     return ReverseArray(input, repeated, _aidl_return);
   }
-  Status ReverseByte(const vector<int8_t>& input,
-                     vector<int8_t>* repeated,
-                     vector<int8_t>* _aidl_return) override {
+  Status ReverseByte(const vector<uint8_t>& input,
+                     vector<uint8_t>* repeated,
+                     vector<uint8_t>* _aidl_return) override {
     return ReverseArray(input, repeated, _aidl_return);
   }
   Status ReverseChar(const vector<char16_t>& input,
diff --git a/type_cpp.cpp b/type_cpp.cpp
index 2755c83..a436935 100644
--- a/type_cpp.cpp
+++ b/type_cpp.cpp
@@ -134,6 +134,38 @@
   DISALLOW_COPY_AND_ASSIGN(PrimitiveType);
 };  // class PrimitiveType
 
+class ByteType : public Type {
+ public:
+  ByteType() : ByteType(false, "byte", "int8_t", "readByte", "writeByte",
+     new ByteType(true, "byte[]", "::std::vector<uint8_t>", "readByteVector",
+         "writeByteVector", kNoArrayType,
+         new ByteType(true, "byte[]",
+             "::std::unique_ptr<::std::vector<uint8_t>>",
+             "readByteVector", "writeByteVector", kNoArrayType,
+             kNoNullableType)), kNoNullableType) {}
+
+  virtual ~ByteType() = default;
+  bool IsCppPrimitive() const override { return true; }
+  bool CanBeOutParameter() const override { return is_array_; }
+
+ protected:
+  ByteType(bool is_array,
+           const std::string& name,
+           const std::string& cpp_type,
+           const std::string& read_method,
+           const std::string& write_method,
+           Type* array_type,
+           Type* nullable_type)
+      : Type(ValidatableType::KIND_BUILT_IN, kNoPackage, name, {"cstdint"},
+             cpp_type, read_method, write_method, array_type, nullable_type),
+        is_array_(is_array) {}
+
+ private:
+  bool is_array_ = false;
+
+  DISALLOW_COPY_AND_ASSIGN(ByteType);
+};  // class PrimitiveType
+
 class BinderType : public Type {
  public:
   BinderType(const AidlInterface& interface, const std::string& src_file_name)
@@ -374,10 +406,7 @@
 bool Type::CanWriteToParcel() const { return true; }
 
 void TypeNamespace::Init() {
-  Add(new PrimitiveType(
-      ValidatableType::KIND_BUILT_IN, kNoPackage, "byte",
-      "cstdint", "int8_t", "readByte", "writeByte",
-      "readByteVector", "writeByteVector"));
+  Add(new ByteType());
   Add(new PrimitiveType(
       ValidatableType::KIND_BUILT_IN, kNoPackage, "int",
       "cstdint", "int32_t", "readInt32", "writeInt32",