Support @utf8InCpp List<String>

Bug: 26729450
Change-Id: I2ac61aadef4c3ff0527fe68b3a104f72821dd2c4
Test: unit, integration tests pass
diff --git a/type_cpp.cpp b/type_cpp.cpp
index cfd7598..2755c83 100644
--- a/type_cpp.cpp
+++ b/type_cpp.cpp
@@ -261,8 +261,9 @@
 class NullableStringListType : public Type {
  public:
   NullableStringListType()
-      : Type(ValidatableType::KIND_BUILT_IN, "java.util", "List<String>",
-             {"utils/String16.h", "vector"},
+      : Type(ValidatableType::KIND_BUILT_IN,
+             "java.util", "List<" + string(kStringCanonicalName) + ">",
+             {"utils/String16.h", "memory", "vector"},
              "::std::unique_ptr<::std::vector<std::unique_ptr<::android::String16>>>",
              "readString16Vector", "writeString16Vector") {}
   virtual ~NullableStringListType() = default;
@@ -275,7 +276,8 @@
 class StringListType : public Type {
  public:
   StringListType()
-      : Type(ValidatableType::KIND_BUILT_IN, "java.util", "List<java.lang.String>",
+      : Type(ValidatableType::KIND_BUILT_IN,
+             "java.util", "List<" + string(kStringCanonicalName) + ">",
              {"utils/String16.h", "vector"},
              "::std::vector<::android::String16>",
              "readString16Vector", "writeString16Vector",
@@ -287,6 +289,37 @@
   DISALLOW_COPY_AND_ASSIGN(StringListType);
 };  // class StringListType
 
+class NullableUtf8InCppStringListType : public Type {
+ public:
+  NullableUtf8InCppStringListType()
+      : Type(ValidatableType::KIND_BUILT_IN,
+             "java.util", "List<" + string(kUtf8InCppStringCanonicalName) + ">",
+             {"memory", "string", "vector"},
+             "::std::unique_ptr<::std::vector<std::unique_ptr<::std::string>>>",
+             "readUtf8VectorFromUtf16Vector", "writeUtf8VectorAsUtf16Vector") {}
+  virtual ~NullableUtf8InCppStringListType() = default;
+  bool CanBeOutParameter() const override { return true; }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(NullableUtf8InCppStringListType);
+};  // class NullableUtf8InCppStringListType
+
+class Utf8InCppStringListType : public Type {
+ public:
+  Utf8InCppStringListType()
+      : Type(ValidatableType::KIND_BUILT_IN,
+             "java.util", "List<" + string(kUtf8InCppStringCanonicalName) + ">",
+             {"string", "vector"},
+             "::std::vector<::std::string>",
+             "readUtf8VectorFromUtf16Vector", "writeUtf8VectorAsUtf16Vector",
+             kNoArrayType, new NullableUtf8InCppStringListType()) {}
+  virtual ~Utf8InCppStringListType() = default;
+  bool CanBeOutParameter() const override { return true; }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(Utf8InCppStringListType);
+};  // class Utf8InCppStringListType
+
 class NullableBinderListType : public Type {
  public:
   NullableBinderListType()
@@ -433,6 +466,7 @@
 
   Add(new BinderListType());
   Add(new StringListType());
+  Add(new Utf8InCppStringListType());
 
   Type* fd_vector_type = new ArrayType(
       ValidatableType::KIND_BUILT_IN, kNoPackage, "FileDescriptor[]",
@@ -480,7 +514,9 @@
     return false;
   }
 
-  if (contained_type == StringType() || contained_type == IBinderType()) {
+  if (contained_type->CanonicalName() == kStringCanonicalName ||
+      contained_type->CanonicalName() == kUtf8InCppStringCanonicalName ||
+      contained_type == IBinderType()) {
     return true;
   }
 
diff --git a/type_cpp.h b/type_cpp.h
index 789140d..776a396 100644
--- a/type_cpp.h
+++ b/type_cpp.h
@@ -128,7 +128,6 @@
                              const std::string& filename) const override;
 
   const Type* VoidType() const { return void_type_; }
-  const Type* StringType() const { return string_type_; }
   const Type* IBinderType() const { return ibinder_type_; }
 
  private:
diff --git a/type_java.cpp b/type_java.cpp
index bc6167b..18d27a2 100644
--- a/type_java.cpp
+++ b/type_java.cpp
@@ -713,7 +713,7 @@
 
 GenericListType::GenericListType(const JavaTypeNamespace* types,
                                  const Type* contained_type)
-    : Type(types, "java.util", "List<" + contained_type->JavaType() + ">",
+    : Type(types, "java.util", "List<" + contained_type->CanonicalName() + ">",
            ValidatableType::KIND_BUILT_IN, true, true),
       m_contained_type(contained_type),
       m_creator(contained_type->CreatorName()) {}
diff --git a/type_java.h b/type_java.h
index f925f95..f74fd62 100644
--- a/type_java.h
+++ b/type_java.h
@@ -416,6 +416,9 @@
 
   std::string CreatorName() const override;
   std::string InstantiableName() const override;
+  std::string JavaType() const override {
+    return "java.util.List<" + m_contained_type->JavaType() + ">";
+  }
 
   void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel,
                      int flags) const override;
diff --git a/type_namespace.cpp b/type_namespace.cpp
index 31159c2..49b96ac 100644
--- a/type_namespace.cpp
+++ b/type_namespace.cpp
@@ -42,6 +42,8 @@
 const char kUtf8StringCanonicalName[] = "aidl-internal.Utf8String";
 const char kUtf8InCppStringCanonicalName[] = "aidl-internal.Utf8InCppString";
 
+const char kStringCanonicalName[] = "java.lang.String";
+
 const char kUtf8Annotation[] = "@utf8";
 const char kUtf8InCppAnnotation[] = "@utfInCpp";
 
diff --git a/type_namespace.h b/type_namespace.h
index 2d86a69..ded96a2 100644
--- a/type_namespace.h
+++ b/type_namespace.h
@@ -39,6 +39,9 @@
 extern const char kUtf8StringCanonicalName[];
 extern const char kUtf8InCppStringCanonicalName[];
 
+// We sometimes special case this class.
+extern const char kStringCanonicalName[];
+
 // Note that these aren't the strings recognized by the parser, we just keep
 // here for the sake of logging a common string constant.
 extern const char kUtf8Annotation[];