Snap for 7110675 from 5e5aac0e1b07a933094913227d0175d8d993390a to sdk-release

Change-Id: Ibd254c9a5b81962a7e453fe8922f5cdb5f745c70
diff --git a/Android.bp b/Android.bp
index e1bc914..7ee632e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,11 +25,13 @@
     static_libs: [
         "libbase",
         "libcutils",
+        "libgtest",
     ],
-    sanitize: {
-        integer_overflow: true,
-        misc_undefined: ["integer"],
-    },
+    // TODO(b/174366536): basic_stringbuf::overflow causes "ubsan: implicit-conversion"
+    // sanitize: {
+    //     integer_overflow: true,
+    //     misc_undefined: ["integer"],
+    // },
     target: {
         windows: {
             enabled: true,
@@ -55,31 +57,34 @@
     host_supported: true,
 
     srcs: [
-        "aidl.cpp",
         "aidl_checkapi.cpp",
         "aidl_const_expressions.cpp",
-        "aidl_language.cpp",
         "aidl_language_l.ll",
         "aidl_language_y.yy",
-        "aidl_typenames.cpp",
+        "aidl_language.cpp",
+        "aidl_to_cpp_common.cpp",
         "aidl_to_cpp.cpp",
         "aidl_to_java.cpp",
         "aidl_to_ndk.cpp",
         "aidl_to_rust.cpp",
+        "aidl_typenames.cpp",
+        "aidl.cpp",
         "ast_cpp.cpp",
         "ast_java.cpp",
         "code_writer.cpp",
-        "generate_cpp.cpp",
-        "aidl_to_cpp_common.cpp",
-        "generate_ndk.cpp",
-        "generate_java.cpp",
-        "generate_java_binder.cpp",
+        "comments.cpp",
+        "diagnostics.cpp",
         "generate_aidl_mappings.cpp",
+        "generate_cpp.cpp",
+        "generate_java_binder.cpp",
+        "generate_java.cpp",
+        "generate_ndk.cpp",
         "generate_rust.cpp",
         "import_resolver.cpp",
-        "line_reader.cpp",
-        "logging.cpp",
         "io_delegate.cpp",
+        "line_reader.cpp",
+        "location.cpp",
+        "logging.cpp",
         "options.cpp",
         "parser.cpp",
     ],
@@ -133,15 +138,12 @@
         "ast_cpp_unittest.cpp",
         "ast_java_unittest.cpp",
         "code_writer_unittest.cpp",
+        "diagnostics_unittest.cpp",
         "generate_cpp_unittest.cpp",
         "io_delegate_unittest.cpp",
         "options_unittest.cpp",
-        "tests/end_to_end_tests.cpp",
         "tests/fake_io_delegate.cpp",
         "tests/main.cpp",
-        "tests/test_data_example_interface.cpp",
-        "tests/test_data_ping_responder.cpp",
-        "tests/test_data_string_constants.cpp",
         "tests/test_util.cpp",
     ],
 
@@ -152,6 +154,8 @@
         "libgmock",
         "liblog",
     ],
+
+    required: ["aidl-golden-test-build-hook"],
 }
 
 cc_fuzz {
@@ -180,6 +184,7 @@
         "libaidl-common",
         "libbase",
         "libcutils",
+        "libgtest",
         "liblog",
     ],
     // Enable this to show additional information about what is being parsed during fuzzing.
@@ -198,7 +203,9 @@
     target_required: [
         "aidl_test_client",
         "aidl_test_service",
-        "aidl_test_services",
+        "aidl_test_java",
+        "aidl_test_rust_client",
+        "aidl_test_rust_service",
     ],
     test_suites: ["general-tests"],
 }
@@ -242,7 +249,34 @@
 
 filegroup {
     name: "libaidl-integration-test-files",
-    srcs: ["tests/android/aidl/tests/*.aidl", "tests/android/aidl/tests/extension/*.aidl"],
+    srcs: [
+        "tests/android/aidl/tests/BackendType.aidl",
+        "tests/android/aidl/tests/ByteEnum.aidl",
+        "tests/android/aidl/tests/ConstantExpressionEnum.aidl",
+        "tests/android/aidl/tests/GenericStructuredParcelable.aidl",
+        "tests/android/aidl/tests/INamedCallback.aidl",
+        "tests/android/aidl/tests/INewName.aidl",
+        "tests/android/aidl/tests/IntEnum.aidl",
+        "tests/android/aidl/tests/IOldName.aidl",
+        "tests/android/aidl/tests/ITestService.aidl",
+        "tests/android/aidl/tests/LongEnum.aidl",
+        "tests/android/aidl/tests/OtherParcelableForToString.aidl",
+        "tests/android/aidl/tests/ParcelableForToString.aidl",
+        "tests/android/aidl/tests/StructuredParcelable.aidl",
+        "tests/android/aidl/tests/Union.aidl",
+        "tests/android/aidl/tests/UnionWithFd.aidl",
+        "tests/android/aidl/tests/unions/*.aidl",
+    ],
+    path: "tests",
+}
+
+filegroup {
+    name: "libaidl-integration-cpp-java-test-files",
+    srcs: [
+        "tests/android/aidl/tests/ICppJavaTests.aidl",
+        "tests/android/aidl/tests/SimpleParcelable.aidl",
+        "tests/android/aidl/tests/extension/*.aidl",
+    ],
     path: "tests",
 }
 
@@ -256,6 +290,11 @@
         "1",
         "2",
     ],
+    backend: {
+        rust: {
+            enabled: true,
+        },
+    },
 }
 
 cc_library_static {
@@ -269,6 +308,7 @@
     },
     srcs: [
         ":libaidl-integration-test-files",
+        ":libaidl-integration-cpp-java-test-files",
         "tests/simple_parcelable.cpp",
     ],
 }
@@ -282,6 +322,7 @@
         "libcutils",
         // service uses the old version
         "aidl-test-versioned-interface-V1-cpp",
+        "aidl_test_loggable_interface-cpp",
     ],
     srcs: ["tests/aidl_test_service.cpp"],
 }
@@ -294,7 +335,8 @@
         "libcutils",
         "libgmock",
         //  client uses the latest version
-        "aidl-test-versioned-interface-cpp",
+        "aidl-test-versioned-interface-V2-cpp",
+        "aidl_test_loggable_interface-cpp"
     ],
     srcs: [
         "tests/aidl_test_client.cpp",
@@ -307,47 +349,40 @@
         "tests/aidl_test_client_defaultimpl.cpp",
         "tests/aidl_test_client_versioned_interface.cpp",
         "tests/aidl_test_client_renamed_interface.cpp",
+        "tests/aidl_test_client_loggable_interface.cpp",
     ],
 }
 
-android_test_helper_app {
-    name: "aidl_test_services",
+java_test {
+    name: "aidl_test_java",
     platform_apis: true,
     // Turn off Java optimization tools to speed up our test iterations.
     optimize: {
         enabled: false,
     },
-    static_libs: [
-        "androidx.test.core",
-        "androidx.test.runner",
-        "aidl_test_nonvintf_parcelable-java",
-        "aidl_test_unstable_parcelable-java",
-        "aidl_test_vintf_parcelable-java",
-        // client uses the newest version
-        "aidl-test-versioned-interface-java",
-    ],
     dex_preopt: {
         enabled: false,
     },
-    certificate: "platform",
-    manifest: "tests/java_app/AndroidManifest.xml",
-    resource_dirs: ["tests/java_app/resources"],
+    static_libs: [
+        "androidx.test.core",
+        "androidx.test.runner",
+        "aidl_test_nonvintf_parcelable-V1-java",
+        "aidl_test_unstable_parcelable-java",
+        "aidl_test_vintf_parcelable-V1-java",
+        // client uses the newest version
+        "aidl-test-versioned-interface-V2-java",
+        // TODO: remove once Android migrates to JUnit 4.12,
+        // which provides assertThrows
+        "testng",
+    ],
     srcs: [
         "tests/android/aidl/tests/*.aidl",
         "tests/android/aidl/tests/generic/*.aidl",
         "tests/android/aidl/tests/immutable/*.aidl",
         "tests/android/aidl/tests/map/*.aidl",
         "tests/android/aidl/tests/extension/*.aidl",
-        "tests/java_app/src/android/aidl/tests/ExtensionTests.java",
-        "tests/java_app/src/android/aidl/tests/GenericTests.java",
-        "tests/java_app/src/android/aidl/tests/MapTests.java",
-        "tests/java_app/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java",
-        "tests/java_app/src/android/aidl/tests/NullableTests.java",
-        "tests/java_app/src/android/aidl/tests/SimpleParcelable.java",
-        "tests/java_app/src/android/aidl/tests/TestFailException.java",
-        "tests/java_app/src/android/aidl/tests/TestServiceClient.java",
-        "tests/java_app/src/android/aidl/tests/generic/Pair.java",
-        "tests/java_app/src/android/aidl/tests/TestVersionedInterface.java",
+        "tests/android/aidl/tests/unions/*.aidl",
+        "tests/java/src/android/aidl/tests/**/*.java",
     ],
     aidl: {
         include_dirs: [
@@ -360,6 +395,41 @@
 }
 
 //
+// "Golden" test of compiler output
+//
+
+sh_binary_host {
+    name: "aidl-golden-test",
+    src: "tests/golden_test.sh",
+}
+
+genrule {
+    name: "aidl-golden-test-build-hook-gen",
+    tools: ["aidl-golden-test"],
+    cmd: "$(location aidl-golden-test) check && " +
+         "echo 'int main(){return 0;}' > $(genDir)/TODO_b_37575883.cpp",
+    srcs: [
+        // warning: keep this list up to date with tests/golden_test.sh
+        ":aidl-test-interface-cpp-source",
+        ":aidl-test-interface-java-source",
+        ":aidl-test-interface-ndk_platform-source",
+        ":aidl-test-interface-rust-source",
+        ":aidl_test_loggable_interface-cpp-source",
+        ":aidl_test_loggable_interface-java-source",
+        ":aidl_test_loggable_interface-ndk_platform-source",
+        ":aidl_test_loggable_interface-ndk-source",
+        "tests/golden_output/**/*",
+    ],
+    out: ["TODO_b_37575883.cpp"],
+}
+
+cc_test_host {
+    name: "aidl-golden-test-build-hook",
+    generated_sources: ["aidl-golden-test-build-hook-gen"],
+    gtest: false,
+}
+
+//
 // Testing generation of logs
 //
 
@@ -369,17 +439,98 @@
     local_include_dir: "tests",
     srcs: [
         "tests/android/aidl/loggable/ILoggableInterface.aidl",
+        "tests/android/aidl/loggable/Data.aidl",
+        "tests/android/aidl/loggable/Enum.aidl",
+        "tests/android/aidl/loggable/Union.aidl",
     ],
     gen_trace: true,
     backend: {
         cpp: {
+            srcs_available: true,
             gen_log: true,
         },
         ndk: {
+            srcs_available: true,
             gen_log: true,
         },
         java: {
+            srcs_available: true,
             platform_apis: true,
         },
     },
 }
+
+//
+// Rust tests
+//
+
+aidl_interface {
+    name: "aidl-test-interface",
+    unstable: true,
+    srcs: [":libaidl-integration-test-files"],
+    local_include_dir: "tests",
+    backend: {
+        cpp: {
+            srcs_available: true,
+        },
+        java: {
+            platform_apis: true,
+            srcs_available: true,
+        },
+        rust: {
+            enabled: true,
+            srcs_available: true,
+        },
+        ndk: {
+            apps_enabled: false,
+            srcs_available: true,
+        },
+    },
+}
+
+rust_test {
+    name: "aidl_test_rust_client",
+    srcs: [
+        "tests/rust/test_client.rs",
+    ],
+    rustlibs: [
+        "aidl-test-interface-rust",
+        "aidl-test-versioned-interface-V2-rust",
+        "liblibc",
+    ],
+    prefer_rlib: true,
+    compile_multilib: "both",
+    multilib: {
+        lib32: {
+            suffix: "32",
+        },
+        lib64: {
+            suffix: "64",
+        },
+    },
+    test_suites: ["general-tests"],
+}
+
+rust_test {
+    name: "aidl_test_rust_service",
+    test_harness: false,
+    srcs: [
+        "tests/rust/test_service.rs",
+    ],
+    rustlibs: [
+        "aidl-test-interface-rust",
+        "aidl-test-versioned-interface-V1-rust",
+        "liblibc",
+    ],
+    prefer_rlib: true,
+    compile_multilib: "both",
+    multilib: {
+        lib32: {
+            suffix: "32",
+        },
+        lib64: {
+            suffix: "64",
+        },
+    },
+    test_suites: ["general-tests"],
+}
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index cdb5588..12545e1 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -4,3 +4,4 @@
 [Builtin Hooks]
 clang_format = true
 gofmt = true
+aidl_format = true
diff --git a/aidl-format.sh b/aidl-format.sh
new file mode 100755
index 0000000..61c900d
--- /dev/null
+++ b/aidl-format.sh
@@ -0,0 +1,184 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+# future considerations:
+# - could we make this work with git-clang-format instead?
+# - should we have our own formatter?
+
+function _aidl-format() (
+    # Find .aidl-format file to use. The file is located in one of the parent
+    # directories of the source file
+    function find-aidl-format-style() {
+        local path="$1"
+        while [[ "$path" != / ]];
+        do
+            if find "$path" -maxdepth 1 -mindepth 1 -name .aidl-format | grep "."; then
+                return
+            fi
+            path="$(readlink -f "$path"/..)"
+        done
+    }
+
+    # Do a "reversible" conversion of the input file so that it is more friendly
+    # to clang-format. For example 'oneway interface Foo{}' is not recognized as
+    # an interface. Convert it to 'interface __aidl_oneway__ Foo{}'.
+    function prepare() {
+      # oneway interface Foo {} is not correctly recognized as an interface by
+      # clang-format. Change it to interface __aidl_oneway__ Foo {}.
+      sed -i -E 's/oneway[[:space:]]+interface/interface\ __aidl_oneway__/g' "$1"
+
+      # When a declaration becomes too long, clang-format splits the declaration
+      # into multiple lines. In doing so, annotations that are at the front of
+      # the declaration are always split. i.e.
+      #
+      # @utf8InCpp @nullable void foo(int looooooo....ong, int looo....ong);
+      #
+      # becomes
+      #
+      # @utf8InCpp
+      # @nullable
+      # void foo(int loooooo...ong,
+      #     int looo.....ong);
+      #
+      # This isn't desirable for utf8InCpp and nullable annotations which are
+      # semantically tagged to the type, not the member (field/method). We want
+      # to have the annotations in the same line as the type that they actually
+      # annotate. i.e.
+      #
+      # @utf8InCpp @nullable void foo(int looo....ong,
+      #     int looo.....ong);
+      #
+      # To do so, the annotations are temporarily replaced with tokens that are
+      # not annotations.
+      sed -i -E 's/@utf8InCpp/__aidl_utf8inCpp__/g' "$1"
+      sed -i -E 's/@nullable/__aidl_nullable__/g' "$1"
+    }
+
+    function apply-clang-format() {
+      local input="$1"
+      local style="$2"
+      local temp="$(mktemp)"
+      local styletext="$([ -n "$style" ] && cat "$style" | tr '\n' ',' 2> /dev/null)"
+      cat "$input" | clang-format \
+        --style='{BasedOnStyle: Google,
+        ColumnLimit: 100,
+        IndentWidth: 4,
+        ContinuationIndentWidth: 8, '"${styletext}"'}' \
+        --assume-filename=${input%.*}.java \
+        > "$temp"
+      mv "$temp" "$input"
+    }
+
+    # clang-format is good, but doesn't perfectly fit to our needs. Fix the
+    # minor mismatches manually.
+    function fixup() {
+      # Revert the changes done during the prepare call. Notice that the
+      # original tokens (@utf8InCpp, etc.) are shorter than the temporary tokens
+      # (__aidl_utf8InCpp, etc.). This can make the output text length shorter
+      # than the specified column limit. We can try to reduce the undesirable
+      # effect by keeping the tokens to have similar lengths, but that seems to
+      # be an overkill at this moment. We can revisit this when this becomes a
+      # real problem.
+      sed -i -E 's/interface\ __aidl_oneway__/oneway\ interface/g' "$1"
+      sed -i -E 's/__aidl_utf8inCpp__/@utf8InCpp/g' "$1"
+      sed -i -E 's/__aidl_nullable__/@nullable/g' "$1"
+
+      # clang-format adds space around "=" in annotation parameters. e.g.
+      # @Anno(a = 100). The following awk script removes the spaces back.
+      # @Anno(a = 1, b = 2) @Anno(c = 3, d = 4) int foo = 3; becomes
+      # @Anno(a=1, b=2) @Anno(c=3, d=4) int foo = 3;
+      # [^@,=] ensures that the match doesn't cross the characters, otherwise
+      # "a = 1, b = 2" would match only once and will become "a = 1, b=2".
+      gawk -i inplace \
+        '/@[^@]+\(.*=.*\)/ { # matches a line having @anno(param = val) \
+              print(gensub(/([^@,=]+) = ([^@,=]+)/, "\\1=\\2", "g", $0)); \
+              done=1;\
+        } \
+        {if (!done) {print($0);} done=0;}' "$1"
+    }
+
+    function format-one() {
+      local mode="$1"
+      local input="$2"
+      local style="$3"
+      local output="$(mktemp)"
+
+      cp "$input" "$output"
+      prepare "$output"
+      apply-clang-format "$output" "$style"
+      fixup "$output"
+
+      if [ $mode = "diff" ]; then
+        diff "$input" "$output"
+        rm "$output"
+      elif [ $mode = "write" ]; then
+        if diff -q "$output" "$input" >/dev/null; then
+            rm "$output"
+        else
+            mv "$output" "$input"
+        fi
+      elif [ $mode = "print" ]; then
+        cat "$output"
+        rm "$output"
+      fi
+    }
+
+    function show-help-and-exit() {
+      echo "Usage: $0 [options] [path...]"
+      echo "  -d: display diff instead of the formatted result"
+      echo "  -w: rewrite the result back to the source file, instead of stdout"
+      echo "  -h: show this help message"
+      echo "  [path...]: source files. if none, input is read from stdin"
+      exit 1
+    }
+
+    local mode=print
+    if [ $# -gt 0 ]; then
+      case "$1" in
+        -d) mode=diff; shift;;
+        -w) mode=write; shift;;
+        -h) show-help-and-exit;;
+        -*) echo "$1" is wrong option; show-help-and-exit;;
+      esac
+    fi
+
+    if [ $# -lt 1 ]; then
+      if [ $mode = "write" ]; then
+        echo "-w not supported when input is stdin"
+        exit 1
+      fi
+      local input="$(mktemp)"
+      cat /dev/stdin > "$input"
+      local style="$(pwd)/.aidl-format"
+      format-one $mode "$input" "$style"
+      rm "$input"
+    else
+      for file in "$@"
+      do
+        if [ ! -f "$file" ]; then
+          echo "$file": no such file
+          exit 1
+        fi
+        local style="$(find-aidl-format-style $(dirname "$filename"))"
+        format-one $mode "$file" "$style"
+      done
+    fi
+)
+
+
+_aidl-format "$@"
diff --git a/aidl.cpp b/aidl.cpp
index d6d2735..612a376 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -59,6 +59,7 @@
 using std::set;
 using std::string;
 using std::unique_ptr;
+using std::unordered_set;
 using std::vector;
 
 namespace android {
@@ -216,25 +217,24 @@
   return true;
 }
 
-string generate_outputFileName(const Options& options, const AidlDefinedType& defined_type) {
-  // create the path to the destination folder based on the
-  // defined_type package name
+// Returns the path to the destination file of `defined_type`.
+string GetOutputFilePath(const Options& options, const AidlDefinedType& defined_type) {
   string result = options.OutputDir();
 
+  // add the package
   string package = defined_type.GetPackage();
-  size_t len = package.length();
-  for (size_t i = 0; i < len; i++) {
-    if (package[i] == '.') {
-      package[i] = OS_PATH_SEPARATOR;
+  if (!package.empty()) {
+    for (auto& c : package) {
+      if (c == '.') {
+        c = OS_PATH_SEPARATOR;
+      }
     }
+    result += package;
+    result += OS_PATH_SEPARATOR;
   }
 
-  result += package;
-
-  // add the filename by replacing the .aidl extension to .java
-  const string& name = defined_type.GetName();
-  result += OS_PATH_SEPARATOR;
-  result.append(name, 0, name.find('.'));
+  // add the filename
+  result += defined_type.GetName();
   if (options.TargetLanguage() == Options::Language::JAVA) {
     result += ".java";
   } else if (options.IsCppOutput()) {
@@ -346,6 +346,57 @@
   return true;
 }
 
+bool ValidateAnnotationContext(const AidlDocument& doc) {
+  struct AnnotationValidator : AidlVisitor {
+    bool success = true;
+
+    void Check(const AidlAnnotatable& annotatable, AidlAnnotation::TargetContext context) {
+      for (const auto& annot : annotatable.GetAnnotations()) {
+        if (!annot.CheckContext(context)) {
+          success = false;
+        }
+      }
+    }
+    void Visit(const AidlInterface& m) override {
+      Check(m, AidlAnnotation::CONTEXT_TYPE_INTERFACE);
+    }
+    void Visit(const AidlParcelable& m) override {
+      Check(m, AidlAnnotation::CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE);
+    }
+    void Visit(const AidlStructuredParcelable& m) override {
+      Check(m, AidlAnnotation::CONTEXT_TYPE_STRUCTURED_PARCELABLE);
+    }
+    void Visit(const AidlEnumDeclaration& m) override {
+      Check(m, AidlAnnotation::CONTEXT_TYPE_ENUM);
+    }
+    void Visit(const AidlUnionDecl& m) override { Check(m, AidlAnnotation::CONTEXT_TYPE_UNION); }
+    void Visit(const AidlMethod& m) override {
+      Check(m.GetType(), AidlAnnotation::CONTEXT_TYPE_SPECIFIER | AidlAnnotation::CONTEXT_METHOD);
+      for (const auto& arg : m.GetArguments()) {
+        Check(arg->GetType(), AidlAnnotation::CONTEXT_TYPE_SPECIFIER);
+      }
+    }
+    void Visit(const AidlConstantDeclaration& m) override {
+      Check(m.GetType(), AidlAnnotation::CONTEXT_TYPE_SPECIFIER | AidlAnnotation::CONTEXT_CONST);
+    }
+    void Visit(const AidlVariableDeclaration& m) override {
+      Check(m.GetType(), AidlAnnotation::CONTEXT_TYPE_SPECIFIER | AidlAnnotation::CONTEXT_FIELD);
+    }
+    void Visit(const AidlTypeSpecifier& m) override {
+      // nested generic type parameters are checked as well
+      if (m.IsGeneric()) {
+        for (const auto& tp : m.GetTypeParameters()) {
+          Check(*tp, AidlAnnotation::CONTEXT_TYPE_SPECIFIER);
+        }
+      }
+    }
+  };
+
+  AnnotationValidator validator;
+  VisitTopDown(validator, doc);
+  return validator.success;
+}
+
 }  // namespace
 
 namespace internals {
@@ -386,16 +437,15 @@
       if (AidlTypenames::IsBuiltinTypename(class_name)) {
         continue;
       }
-      AidlParcelable* doc = new AidlParcelable(location, class_name, package, "" /* comments */);
+      AidlParcelable* doc = new AidlParcelable(location, class_name, package, Comments{});
       typenames->AddPreprocessedType(unique_ptr<AidlParcelable>(doc));
     } else if (decl == "structured_parcelable") {
-      auto temp = new std::vector<std::unique_ptr<AidlVariableDeclaration>>();
-      AidlStructuredParcelable* doc = new AidlStructuredParcelable(
-          location, class_name, package, "" /* comments */, temp, nullptr);
+      AidlStructuredParcelable* doc =
+          new AidlStructuredParcelable(location, class_name, package, Comments{}, nullptr, nullptr);
       typenames->AddPreprocessedType(unique_ptr<AidlStructuredParcelable>(doc));
     } else if (decl == "interface") {
-      auto temp = new std::vector<std::unique_ptr<AidlMember>>();
-      AidlInterface* doc = new AidlInterface(location, class_name, "", false, temp, package);
+      AidlInterface* doc =
+          new AidlInterface(location, class_name, Comments{}, false, package, nullptr);
       typenames->AddPreprocessedType(unique_ptr<AidlInterface>(doc));
     } else {
       success = false;
@@ -424,11 +474,11 @@
   if (main_parser == nullptr) {
     return AidlError::PARSE_ERROR;
   }
-  int num_interfaces_or_structured_parcelables = 0;
+  int num_top_level_decls = 0;
   for (const auto& type : main_parser->ParsedDocument().DefinedTypes()) {
-    if (type->AsInterface() != nullptr || type->AsStructuredParcelable() != nullptr) {
-      num_interfaces_or_structured_parcelables++;
-      if (num_interfaces_or_structured_parcelables > 1) {
+    if (type->AsUnstructuredParcelable() == nullptr) {
+      num_top_level_decls++;
+      if (num_top_level_decls > 1) {
         AIDL_ERROR(*type) << "You must declare only one type per file.";
         return AidlError::BAD_TYPE;
       }
@@ -449,51 +499,25 @@
   vector<string> import_paths;
   ImportResolver import_resolver{io_delegate, input_file_name, options.ImportDirs(),
                                  options.InputFiles()};
-
-  vector<string> type_from_import_statements;
   for (const auto& import : main_parser->ParsedDocument().Imports()) {
-    if (!AidlTypenames::IsBuiltinTypename(import->GetNeededClass())) {
-      type_from_import_statements.emplace_back(import->GetNeededClass());
+    if (AidlTypenames::IsBuiltinTypename(import->GetNeededClass())) {
+      continue;
     }
-  }
-
-  // When referencing a type using fully qualified name it should be imported
-  // without the import statement. To support that, add all unresolved
-  // typespecs encountered during the parsing to the import_candidates list.
-  // Note that there is no guarantee that the typespecs are all fully qualified.
-  // It will be determined by calling FindImportFile().
-  set<string> unresolved_types;
-  for (const auto type : main_parser->GetUnresolvedTypespecs()) {
-    if (!AidlTypenames::IsBuiltinTypename(type->GetName())) {
-      unresolved_types.emplace(type->GetName());
-    }
-  }
-  vector<string> import_candidates(type_from_import_statements);
-  import_candidates.insert(import_candidates.end(), unresolved_types.begin(),
-                           unresolved_types.end());
-  for (const auto& import : import_candidates) {
-    if (typenames->IsIgnorableImport(import)) {
+    if (typenames->IsIgnorableImport(import->GetNeededClass())) {
       // There are places in the Android tree where an import doesn't resolve,
       // but we'll pick the type up through the preprocessed types.
       // This seems like an error, but legacy support demands we support it...
       continue;
     }
-    string import_path = import_resolver.FindImportFile(import);
+    string import_path = import_resolver.FindImportFile(import->GetNeededClass());
     if (import_path.empty()) {
-      if (typenames->ResolveTypename(import).is_resolved) {
-        // Couldn't find the *.aidl file for the type from the include paths, but we
-        // have the type already resolved. This could happen when the type is
-        // from the preprocessed aidl file. In that case, use the type from the
-        // preprocessed aidl file as a last resort.
+      if (typenames->ResolveTypename(import->GetNeededClass()).is_resolved) {
+        // This could happen when the type is from the preprocessed aidl file.
+        // In that case, use the type from preprocessed aidl file
         continue;
       }
-
-      if (std::find(type_from_import_statements.begin(), type_from_import_statements.end(),
-                    import) != type_from_import_statements.end()) {
-        // Complain only when the import from the import statement has failed.
-        AIDL_ERROR(input_file_name) << "Couldn't find import for class " << import;
-        err = AidlError::BAD_IMPORT;
-      }
+      AIDL_ERROR(input_file_name) << "Couldn't find import for class " << import->GetNeededClass();
+      err = AidlError::BAD_IMPORT;
       continue;
     }
 
@@ -523,39 +547,44 @@
   if (err != AidlError::OK) {
     return err;
   }
+
+  TypeResolver resolver = [&](const AidlDocument* doc, AidlTypeSpecifier* type) {
+    if (type->Resolve(*typenames)) return true;
+
+    const string unresolved_name = type->GetUnresolvedName();
+    const std::optional<string> canonical_name = doc->ResolveName(unresolved_name);
+    if (!canonical_name) {
+      return false;
+    }
+    const string import_path = import_resolver.FindImportFile(*canonical_name);
+    if (import_path.empty()) {
+      return false;
+    }
+    import_paths.push_back(import_path);
+
+    std::unique_ptr<Parser> import_parser = Parser::Parse(import_path, io_delegate, *typenames);
+    if (import_parser == nullptr) {
+      AIDL_ERROR(import_path) << "error while importing " << import_path << " for " << import_path;
+      return false;
+    }
+    if (!type->Resolve(*typenames)) {
+      AIDL_ERROR(type) << "Can't resolve " << type->GetName();
+      return false;
+    }
+    return true;
+  };
   const bool is_check_api = options.GetTask() == Options::Task::CHECK_API;
+  const bool is_dump_api = options.GetTask() == Options::Task::DUMP_API;
 
   // Resolve the unresolved type references found from the input file
-  if (!is_check_api && !main_parser->Resolve()) {
+  if (!is_check_api && !main_parser->Resolve(resolver)) {
     // Resolution is not need for check api because all typespecs are
     // using fully qualified names.
     return AidlError::BAD_TYPE;
   }
 
-  typenames->IterateTypes([&](const AidlDefinedType& type) {
-    AidlEnumDeclaration* enum_decl = const_cast<AidlEnumDeclaration*>(type.AsEnumDeclaration());
-    if (enum_decl != nullptr) {
-      // BackingType is filled in for all known enums, including imported enums,
-      // because other types that may use enums, such as Interface or
-      // StructuredParcelable, need to know the enum BackingType when
-      // generating code.
-      if (auto backing_type = enum_decl->BackingType(*typenames); backing_type != nullptr) {
-        enum_decl->SetBackingType(std::unique_ptr<const AidlTypeSpecifier>(backing_type));
-      } else {
-        // Default to byte type for enums.
-        auto byte_type =
-            std::make_unique<AidlTypeSpecifier>(AIDL_LOCATION_HERE, "byte", false, nullptr, "");
-        byte_type->Resolve(*typenames);
-        enum_decl->SetBackingType(std::move(byte_type));
-      }
-
-      if (!enum_decl->Autofill()) {
-        err = AidlError::BAD_TYPE;
-      }
-    }
-  });
-  if (err != AidlError::OK) {
-    return err;
+  if (!typenames->Autofill()) {
+    return AidlError::BAD_TYPE;
   }
 
   //////////////////////////////////////////////////////////////////////////
@@ -573,32 +602,58 @@
   for (const auto& defined_type : types) {
     AIDL_FATAL_IF(defined_type == nullptr, main_parser->FileName());
 
-    // Language specific validation
-    if (!defined_type->LanguageSpecificCheckValid(*typenames, options.TargetLanguage())) {
-      return AidlError::BAD_TYPE;
+    // Ensure type is exactly one of the following:
+    AidlInterface* interface = defined_type->AsInterface();
+    AidlStructuredParcelable* parcelable = defined_type->AsStructuredParcelable();
+    AidlParcelable* unstructured_parcelable = defined_type->AsUnstructuredParcelable();
+    AidlEnumDeclaration* enum_decl = defined_type->AsEnumDeclaration();
+    AidlUnionDecl* union_decl = defined_type->AsUnionDeclaration();
+    AIDL_FATAL_IF(
+        !!interface + !!parcelable + !!unstructured_parcelable + !!enum_decl + !!union_decl != 1,
+        defined_type);
+
+    // Ensure that foo.bar.IFoo is defined in <some_path>/foo/bar/IFoo.aidl
+    if (num_defined_types == 1 && !check_filename(input_file_name, *defined_type)) {
+      return AidlError::BAD_PACKAGE;
     }
 
-    AidlParcelable* unstructuredParcelable = defined_type->AsUnstructuredParcelable();
-    if (unstructuredParcelable != nullptr) {
-      if (!unstructuredParcelable->CheckValid(*typenames)) {
+    {
+      bool valid_type = true;
+
+      if (!is_check_api) {
+        // Ideally, we could do this for check api, but we can't resolve imports
+        if (!defined_type->CheckValid(*typenames)) {
+          valid_type = false;
+        }
+      }
+
+      if (!is_dump_api && !is_check_api) {
+        if (!defined_type->LanguageSpecificCheckValid(*typenames, options.TargetLanguage())) {
+          valid_type = false;
+        }
+      }
+
+      if (!valid_type) {
         return AidlError::BAD_TYPE;
       }
-      bool isStable = unstructuredParcelable->IsStableApiParcelable(options.TargetLanguage());
+    }
+
+    if (unstructured_parcelable != nullptr) {
+      bool isStable = unstructured_parcelable->IsStableApiParcelable(options.TargetLanguage());
       if (options.IsStructured() && !isStable) {
-        AIDL_ERROR(unstructuredParcelable)
+        AIDL_ERROR(unstructured_parcelable)
             << "Cannot declared parcelable in a --structured interface. Parcelable must be defined "
                "in AIDL directly.";
         return AidlError::NOT_STRUCTURED;
       }
       if (options.FailOnParcelable()) {
-        AIDL_ERROR(unstructuredParcelable)
+        AIDL_ERROR(unstructured_parcelable)
             << "Refusing to generate code with unstructured parcelables. Declared parcelables "
                "should be in their own file and/or cannot be used with --structured interfaces.";
         // Continue parsing for more errors
       }
 
       contains_unstructured_parcelable = true;
-      continue;
     }
 
     if (defined_type->IsVintfStability()) {
@@ -616,81 +671,57 @@
       if (!success) return AidlError::NOT_STRUCTURED;
     }
 
-    // Ensure that a type is either an interface, structured parcelable, or
-    // enum.
-    AidlInterface* interface = defined_type->AsInterface();
-    AidlStructuredParcelable* parcelable = defined_type->AsStructuredParcelable();
-    AidlEnumDeclaration* enum_decl = defined_type->AsEnumDeclaration();
-    AIDL_FATAL_IF(!!interface + !!parcelable + !!enum_decl != 1, defined_type);
-
-    // Ensure that foo.bar.IFoo is defined in <some_path>/foo/bar/IFoo.aidl
-    if (num_defined_types == 1 && !check_filename(input_file_name, *defined_type)) {
-      return AidlError::BAD_PACKAGE;
-    }
-
-    // Check the referenced types in parsed_doc to make sure we've imported them
-    if (!is_check_api) {
-      // No need to do this for check api because all typespecs are already
-      // using fully qualified name and we don't import in AIDL files.
-      if (!defined_type->CheckValid(*typenames)) {
-        return AidlError::BAD_TYPE;
-      }
-    }
-
     if (interface != nullptr) {
       // add the meta-method 'int getInterfaceVersion()' if version is specified.
       if (options.Version() > 0) {
         AidlTypeSpecifier* ret =
-            new AidlTypeSpecifier(AIDL_LOCATION_HERE, "int", false, nullptr, "");
+            new AidlTypeSpecifier(AIDL_LOCATION_HERE, "int", false, nullptr, Comments{});
         ret->Resolve(*typenames);
         vector<unique_ptr<AidlArgument>>* args = new vector<unique_ptr<AidlArgument>>();
-        AidlMethod* method =
-            new AidlMethod(AIDL_LOCATION_HERE, false, ret, "getInterfaceVersion", args, "",
-                           kGetInterfaceVersionId, false /* is_user_defined */);
-        interface->GetMutableMethods().emplace_back(method);
+        auto method = std::make_unique<AidlMethod>(
+            AIDL_LOCATION_HERE, false, ret, "getInterfaceVersion", args, Comments{},
+            kGetInterfaceVersionId, false /* is_user_defined */);
+        interface->AddMethod(std::move(method));
       }
       // add the meta-method 'string getInterfaceHash()' if hash is specified.
       if (!options.Hash().empty()) {
         AidlTypeSpecifier* ret =
-            new AidlTypeSpecifier(AIDL_LOCATION_HERE, "String", false, nullptr, "");
+            new AidlTypeSpecifier(AIDL_LOCATION_HERE, "String", false, nullptr, Comments{});
         ret->Resolve(*typenames);
         vector<unique_ptr<AidlArgument>>* args = new vector<unique_ptr<AidlArgument>>();
-        AidlMethod* method = new AidlMethod(AIDL_LOCATION_HERE, false, ret, kGetInterfaceHash, args,
-                                            "", kGetInterfaceHashId, false /* is_user_defined */);
-        interface->GetMutableMethods().emplace_back(method);
+        auto method = std::make_unique<AidlMethod>(
+            AIDL_LOCATION_HERE, false, ret, kGetInterfaceHash, args, Comments{},
+            kGetInterfaceHashId, false /* is_user_defined */);
+        interface->AddMethod(std::move(method));
       }
       if (!check_and_assign_method_ids(interface->GetMethods())) {
         return AidlError::BAD_METHOD_ID;
       }
-
-      // Verify and resolve the constant declarations
-      for (const auto& constant : interface->GetConstantDeclarations()) {
-        switch (constant->GetValue().GetType()) {
-          case AidlConstantValue::Type::STRING:    // fall-through
-          case AidlConstantValue::Type::INT8:      // fall-through
-          case AidlConstantValue::Type::INT32:     // fall-through
-          case AidlConstantValue::Type::INT64:     // fall-through
-          case AidlConstantValue::Type::FLOATING:  // fall-through
-          case AidlConstantValue::Type::UNARY:     // fall-through
-          case AidlConstantValue::Type::BINARY: {
-            bool success = constant->CheckValid(*typenames);
-            if (!success) {
-              return AidlError::BAD_TYPE;
-            }
-            if (constant->ValueString(cpp::ConstantValueDecorator).empty()) {
-              return AidlError::BAD_TYPE;
-            }
-            break;
-          }
-          default:
-            AIDL_FATAL(constant) << "Unrecognized constant type: "
-                                 << static_cast<int>(constant->GetValue().GetType());
-            break;
+    }
+    // Verify the var/const declarations.
+    // const expressions should be non-empty when evaluated with the var/const type.
+    if (!is_check_api) {
+      for (const auto& constant : defined_type->GetConstantDeclarations()) {
+        if (constant->ValueString(AidlConstantValueDecorator).empty()) {
+          return AidlError::BAD_TYPE;
+        }
+      }
+      for (const auto& var : defined_type->GetFields()) {
+        if (var->GetDefaultValue() && var->ValueString(AidlConstantValueDecorator).empty()) {
+          return AidlError::BAD_TYPE;
         }
       }
     }
   }
 
+  if (!ValidateAnnotationContext(main_parser->ParsedDocument())) {
+    return AidlError::BAD_TYPE;
+  }
+
+  if (!is_check_api && !Diagnose(main_parser->ParsedDocument(), options.GetDiagnosticMapping())) {
+    return AidlError::BAD_TYPE;
+  }
+
   typenames->IterateTypes([&](const AidlDefinedType& type) {
     if (options.IsStructured() && type.AsUnstructuredParcelable() != nullptr &&
         !type.AsUnstructuredParcelable()->IsStableApiParcelable(options.TargetLanguage())) {
@@ -704,34 +735,37 @@
                        << " does not have VINTF level stability, but this interface requires it.";
     }
 
-    // Ensure that untyped List/Map is not used in stable AIDL.
-    if (options.IsStructured()) {
-      const AidlInterface* iface = type.AsInterface();
-      const AidlStructuredParcelable* parcelable = type.AsStructuredParcelable();
+    // Ensure that untyped List/Map is not used in a parcelable, a union and a stable interface.
 
-      auto check = [&err](const AidlTypeSpecifier& type, const AidlNode* node) {
-        if (!type.IsGeneric() && (type.GetName() == "List" || type.GetName() == "Map")) {
-          err = AidlError::BAD_TYPE;
-          AIDL_ERROR(node)
-              << "Encountered an untyped List or Map. The use of untyped List/Map is prohibited "
-              << "because it is not guaranteed that the objects in the list are recognizable in "
-              << "the receiving side. Consider switching to an array or a generic List/Map.";
-        }
-      };
-
-      if (iface != nullptr) {
-        for (const auto& method : iface->GetMethods()) {
-          check(method->GetType(), method.get());
-          for (const auto& arg : method->GetArguments()) {
-            check(arg->GetType(), method.get());
+    std::function<void(const AidlTypeSpecifier&, const AidlNode*)> check_untyped_container =
+        [&err, &check_untyped_container](const AidlTypeSpecifier& type, const AidlNode* node) {
+          if (type.IsGeneric()) {
+            std::for_each(type.GetTypeParameters().begin(), type.GetTypeParameters().end(),
+                          [&node, &check_untyped_container](auto& nested) {
+                            check_untyped_container(*nested, node);
+                          });
+            return;
           }
-        }
-      } else if (parcelable != nullptr) {
-        for (const auto& field : parcelable->GetFields()) {
-          check(field->GetType(), field.get());
+          if (type.GetName() == "List" || type.GetName() == "Map") {
+            err = AidlError::BAD_TYPE;
+            AIDL_ERROR(node)
+                << "Encountered an untyped List or Map. The use of untyped List/Map is prohibited "
+                << "because it is not guaranteed that the objects in the list are recognizable in "
+                << "the receiving side. Consider switching to an array or a generic List/Map.";
+          }
+        };
+
+    if (type.AsInterface() && options.IsStructured()) {
+      for (const auto& method : type.GetMethods()) {
+        check_untyped_container(method->GetType(), method.get());
+        for (const auto& arg : method->GetArguments()) {
+          check_untyped_container(arg->GetType(), method.get());
         }
       }
     }
+    for (const auto& field : type.GetFields()) {
+      check_untyped_container(field->GetType(), field.get());
+    }
   });
 
   if (err != AidlError::OK) {
@@ -772,7 +806,7 @@
       string output_file_name = options.OutputFile();
       // if needed, generate the output file name from the base folder
       if (output_file_name.empty() && !options.OutputDir().empty()) {
-        output_file_name = generate_outputFileName(options, *defined_type);
+        output_file_name = GetOutputFilePath(options, *defined_type);
         if (output_file_name.empty()) {
           return 1;
         }
@@ -868,11 +902,18 @@
     AidlTypenames typenames;
     if (internals::load_and_validate_aidl(file, options, io_delegate, &typenames, nullptr) ==
         AidlError::OK) {
-      for (const auto& type : typenames.MainDocument().DefinedTypes()) {
+      const auto& doc = typenames.MainDocument();
+
+      for (const auto& type : doc.DefinedTypes()) {
         unique_ptr<CodeWriter> writer =
             io_delegate.GetCodeWriter(GetApiDumpPathFor(*type, options));
+        // dump doc comments (license) as well for each type
+        for (const auto& c : doc.GetComments()) {
+          (*writer) << c.body;
+        }
+        (*writer) << kPreamble;
         if (!type->GetPackage().empty()) {
-          (*writer) << kPreamble << "package " << type->GetPackage() << ";\n";
+          (*writer) << "package " << type->GetPackage() << ";\n";
         }
         type->Dump(writer.get());
       }
diff --git a/aidl.h b/aidl.h
index 21598d5..22bd2f7 100644
--- a/aidl.h
+++ b/aidl.h
@@ -58,13 +58,14 @@
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/aidl_api/aidl-test-versioned-interface/1/.hash b/aidl_api/aidl-test-versioned-interface/1/.hash
index 46ddc97..e802595 100644
--- a/aidl_api/aidl-test-versioned-interface/1/.hash
+++ b/aidl_api/aidl-test-versioned-interface/1/.hash
@@ -1 +1 @@
-fcd4f9c806cbc8af3694d569fd1de1ecc8cf7d22
+796b4ab269d476662bed4ab57092ed000e48d5d7
diff --git a/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/BazUnion.aidl b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/BazUnion.aidl
new file mode 100644
index 0000000..f0ee62e
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/BazUnion.aidl
@@ -0,0 +1,21 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
+// edit this file. It looks like you are doing that because you have modified
+// an AIDL interface in a backward-incompatible way, e.g., deleting a function
+// from an interface or a field from a parcelable and it broke the build. That
+// breakage is intended.
+//
+// You must not make a backward incompatible changes to the AIDL files built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.aidl.versioned.tests;
+union BazUnion {
+  int intNum;
+}
diff --git a/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/IFooInterface.aidl b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/IFooInterface.aidl
index 5972a79..ca832b9 100644
--- a/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/IFooInterface.aidl
+++ b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/IFooInterface.aidl
@@ -17,5 +17,6 @@
 
 package android.aidl.versioned.tests;
 interface IFooInterface {
-  void foo();
+  void originalApi();
+  @utf8InCpp String acceptUnionAndReturnString(in android.aidl.versioned.tests.BazUnion u);
 }
diff --git a/aidl_api/aidl-test-versioned-interface/2/.hash b/aidl_api/aidl-test-versioned-interface/2/.hash
index eb92314..dd11e30 100644
--- a/aidl_api/aidl-test-versioned-interface/2/.hash
+++ b/aidl_api/aidl-test-versioned-interface/2/.hash
@@ -1 +1 @@
-9f3f20769043bbae5b80d86605c1c94b3ed31fcf
+508a201b25adaf663c1928022a02d0fe86edb6fe
diff --git a/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/BazUnion.aidl b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/BazUnion.aidl
new file mode 100644
index 0000000..154b59c
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/BazUnion.aidl
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
+// edit this file. It looks like you are doing that because you have modified
+// an AIDL interface in a backward-incompatible way, e.g., deleting a function
+// from an interface or a field from a parcelable and it broke the build. That
+// breakage is intended.
+//
+// You must not make a backward incompatible changes to the AIDL files built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.aidl.versioned.tests;
+union BazUnion {
+  int intNum;
+  long longNum;
+}
diff --git a/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/IFooInterface.aidl b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/IFooInterface.aidl
index c3442bd..d9c2446 100644
--- a/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/IFooInterface.aidl
+++ b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/IFooInterface.aidl
@@ -17,6 +17,7 @@
 
 package android.aidl.versioned.tests;
 interface IFooInterface {
-  void foo();
-  void bar();
+  void originalApi();
+  @utf8InCpp String acceptUnionAndReturnString(in android.aidl.versioned.tests.BazUnion u);
+  void newApi();
 }
diff --git a/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/BazUnion.aidl b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/BazUnion.aidl
new file mode 100644
index 0000000..668973f
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/BazUnion.aidl
@@ -0,0 +1,23 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.aidl.versioned.tests;
+union BazUnion {
+  int intNum;
+  long longNum;
+}
diff --git a/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/IFooInterface.aidl b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/IFooInterface.aidl
index c3442bd..fa709a6 100644
--- a/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/IFooInterface.aidl
+++ b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/IFooInterface.aidl
@@ -2,13 +2,14 @@
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
@@ -17,6 +18,7 @@
 
 package android.aidl.versioned.tests;
 interface IFooInterface {
-  void foo();
-  void bar();
+  void originalApi();
+  @utf8InCpp String acceptUnionAndReturnString(in android.aidl.versioned.tests.BazUnion u);
+  void newApi();
 }
diff --git a/aidl_checkapi.cpp b/aidl_checkapi.cpp
index 0f2f4b0..6337f8e 100644
--- a/aidl_checkapi.cpp
+++ b/aidl_checkapi.cpp
@@ -26,18 +26,38 @@
 
 #include <android-base/result.h>
 #include <android-base/strings.h>
+#include <gtest/gtest.h>
 
 namespace android {
 namespace aidl {
 
 using android::base::Error;
 using android::base::Result;
+using android::base::StartsWith;
 using std::map;
 using std::set;
 using std::string;
 using std::vector;
 
-static set<AidlAnnotation> get_strict_annotations(const AidlAnnotatable& node) {
+static std::string Dump(const AidlDefinedType& type) {
+  std::string dump;
+  type.Dump(CodeWriter::ForString(&dump).get());
+  return dump;
+}
+
+// Uses each type's Dump() and GTest utility(EqHelper).
+static bool CheckEquality(const AidlDefinedType& older, const AidlDefinedType& newer) {
+  using testing::internal::EqHelper;
+  auto older_file = older.GetLocation().GetFile();
+  auto newer_file = newer.GetLocation().GetFile();
+  auto result = EqHelper::Compare(older_file.data(), newer_file.data(), Dump(older), Dump(newer));
+  if (!result) {
+    AIDL_ERROR(newer) << result.failure_message();
+  }
+  return result;
+}
+
+static vector<string> get_strict_annotations(const AidlAnnotatable& node) {
   // This must be symmetrical (if you can add something, you must be able to
   // remove it). The reason is that we have no way of knowing which interface a
   // server serves and which interface a client serves (e.g. a callback
@@ -51,23 +71,36 @@
   // - a new implementation might start accepting null values (add @nullable)
   static const set<AidlAnnotation::Type> kIgnoreAnnotations{
       AidlAnnotation::Type::NULLABLE,
-      AidlAnnotation::Type::JAVA_DEBUG,
+      // @JavaDerive doesn't affect read/write
+      AidlAnnotation::Type::JAVA_DERIVE,
       AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE,
+      // @Backing for a enum type is checked by the enum checker
+      AidlAnnotation::Type::BACKING,
+      // @RustDerive doesn't affect read/write
+      AidlAnnotation::Type::RUST_DERIVE,
+      AidlAnnotation::Type::SUPPRESS_WARNINGS,
   };
-  set<AidlAnnotation> annotations;
+  vector<string> annotations;
   for (const AidlAnnotation& annotation : node.GetAnnotations()) {
-    if (kIgnoreAnnotations.find(annotation.GetType()) == kIgnoreAnnotations.end()) {
-      annotations.insert(annotation);
+    if (kIgnoreAnnotations.find(annotation.GetType()) != kIgnoreAnnotations.end()) {
+      continue;
     }
+    auto annotation_string = annotation.ToString();
+    // adding @Deprecated (with optional args) is okay
+    if (StartsWith(annotation_string, "@JavaPassthrough(annotation=\"@Deprecated")) {
+      continue;
+    }
+    annotations.push_back(annotation_string);
   }
   return annotations;
 }
 
 static bool have_compatible_annotations(const AidlAnnotatable& older,
                                         const AidlAnnotatable& newer) {
-  set<AidlAnnotation> olderAnnotations = get_strict_annotations(older);
-  set<AidlAnnotation> newerAnnotations = get_strict_annotations(newer);
-
+  vector<string> olderAnnotations = get_strict_annotations(older);
+  vector<string> newerAnnotations = get_strict_annotations(newer);
+  sort(olderAnnotations.begin(), olderAnnotations.end());
+  sort(newerAnnotations.begin(), newerAnnotations.end());
   if (olderAnnotations != newerAnnotations) {
     const string from = older.ToString().empty() ? "(empty)" : older.ToString();
     const string to = newer.ToString().empty() ? "(empty)" : newer.ToString();
@@ -79,14 +112,46 @@
 
 static bool are_compatible_types(const AidlTypeSpecifier& older, const AidlTypeSpecifier& newer) {
   bool compatible = true;
-  if (older.ToString() != newer.ToString()) {
-    AIDL_ERROR(newer) << "Type changed: " << older.ToString() << " to " << newer.ToString() << ".";
+  if (older.Signature() != newer.Signature()) {
+    AIDL_ERROR(newer) << "Type changed: " << older.Signature() << " to " << newer.Signature()
+                      << ".";
     compatible = false;
   }
   compatible &= have_compatible_annotations(older, newer);
   return compatible;
 }
 
+static bool are_compatible_constants(const AidlDefinedType& older, const AidlDefinedType& newer) {
+  bool compatible = true;
+
+  map<string, AidlConstantDeclaration*> new_constdecls;
+  for (const auto& c : newer.GetConstantDeclarations()) {
+    new_constdecls[c->GetName()] = &*c;
+  }
+
+  for (const auto& old_c : older.GetConstantDeclarations()) {
+    const auto found = new_constdecls.find(old_c->GetName());
+    if (found == new_constdecls.end()) {
+      AIDL_ERROR(old_c) << "Removed constant declaration: " << older.GetCanonicalName() << "."
+                        << old_c->GetName();
+      compatible = false;
+      continue;
+    }
+
+    const auto new_c = found->second;
+    compatible &= are_compatible_types(old_c->GetType(), new_c->GetType());
+
+    const string old_value = old_c->GetValue().Literal();
+    const string new_value = new_c->GetValue().Literal();
+    if (old_value != new_value) {
+      AIDL_ERROR(newer) << "Changed constant value: " << older.GetCanonicalName() << "."
+                        << old_c->GetName() << " from " << old_value << " to " << new_value << ".";
+      compatible = false;
+    }
+  }
+  return compatible;
+}
+
 static bool are_compatible_interfaces(const AidlInterface& older, const AidlInterface& newer) {
   bool compatible = true;
 
@@ -141,49 +206,21 @@
     }
   }
 
-  map<string, AidlConstantDeclaration*> new_constdecls;
-  for (const auto& c : newer.AsInterface()->GetConstantDeclarations()) {
-    new_constdecls.emplace(c->GetName(), c.get());
-  }
+  compatible = are_compatible_constants(older, newer) && compatible;
 
-  for (const auto& old_c : older.AsInterface()->GetConstantDeclarations()) {
-    const auto found = new_constdecls.find(old_c->GetName());
-    if (found == new_constdecls.end()) {
-      AIDL_ERROR(old_c) << "Removed constant declaration: " << older.GetCanonicalName() << "."
-                        << old_c->GetName();
-      compatible = false;
-      continue;
-    }
-
-    const auto new_c = found->second;
-    compatible &= are_compatible_types(old_c->GetType(), new_c->GetType());
-
-    const string old_value = old_c->ValueString(AidlConstantValueDecorator);
-    const string new_value = new_c->ValueString(AidlConstantValueDecorator);
-    if (old_value != new_value) {
-      AIDL_ERROR(newer) << "Changed constant value: " << older.GetCanonicalName() << "."
-                        << old_c->GetName() << " from " << old_value << " to " << new_value << ".";
-      compatible = false;
-    }
-  }
   return compatible;
 }
 
-// returns whether the given type when defaulted will be accepted by
-// unmarshalling code
-static bool has_usable_nil_type(const AidlTypeSpecifier& specifier) {
-  // TODO(b/155238508): fix for primitives
-
-  // This technically only applies in C++, but even if both the client and the
-  // server of an interface are in Java at a particular point in time, where
-  // null is currently always acceptable, we want to make sure that versions
-  // of this service can work in native and future backends without a problem.
-  // Also, in that case, adding nullable does not hurt.
-  return specifier.IsNullable();
+static bool HasZeroEnumerator(const AidlEnumDeclaration& enum_decl) {
+  return std::any_of(enum_decl.GetEnumerators().begin(), enum_decl.GetEnumerators().end(),
+                     [&](const unique_ptr<AidlEnumerator>& enumerator) {
+                       return enumerator->GetValue()->Literal() == "0";
+                     });
 }
 
-static bool are_compatible_parcelables(const AidlStructuredParcelable& older,
-                                       const AidlStructuredParcelable& newer) {
+static bool are_compatible_parcelables(const AidlDefinedType& older, const AidlTypenames&,
+                                       const AidlDefinedType& newer,
+                                       const AidlTypenames& new_types) {
   const auto& old_fields = older.GetFields();
   const auto& new_fields = newer.GetFields();
   if (old_fields.size() > new_fields.size()) {
@@ -205,8 +242,8 @@
     const auto& new_field = new_fields.at(i);
     compatible &= are_compatible_types(old_field->GetType(), new_field->GetType());
 
-    const string old_value = old_field->ValueString(AidlConstantValueDecorator);
-    const string new_value = new_field->ValueString(AidlConstantValueDecorator);
+    string old_value = old_field->GetDefaultValue() ? old_field->GetDefaultValue()->Literal() : "";
+    string new_value = new_field->GetDefaultValue() ? new_field->GetDefaultValue()->Literal() : "";
     if (old_value != new_value) {
       AIDL_ERROR(new_field) << "Changed default value: " << old_value << " to " << new_value << ".";
       compatible = false;
@@ -231,38 +268,59 @@
 
   for (size_t i = old_fields.size(); i < new_fields.size(); i++) {
     const auto& new_field = new_fields.at(i);
-    if (!new_field->GetDefaultValue() && !has_usable_nil_type(new_field->GetType())) {
-      // Old API versions may suffer from the issue presented here. There is
-      // only a finite number in Android, which we must allow indefinitely.
-      struct HistoricalException {
-        std::string canonical;
-        std::string field;
-      };
-      static std::vector<HistoricalException> exceptions = {
-          {"android.net.DhcpResultsParcelable", "serverHostName"},
-          {"android.net.ResolverParamsParcel", "resolverOptions"},
-      };
-      bool excepted = false;
-      for (const HistoricalException& exception : exceptions) {
-        if (older.GetCanonicalName() == exception.canonical &&
-            new_field->GetName() == exception.field) {
-          excepted = true;
-          break;
-        }
-      }
-      if (excepted) continue;
-
-      AIDL_ERROR(new_field)
-          << "Field '" << new_field->GetName()
-          << "' does not have a useful default in some backends. Please either provide a default "
-             "value for this field or mark the field as @nullable. This value or a null value will "
-             "be used automatically when an old version of this parcelable is sent to a process "
-             "which understands a new version of this parcelable. In order to make sure your code "
-             "continues to be backwards compatible, make sure the default or null value does not "
-             "cause a semantic change to this parcelable.";
-      compatible = false;
+    if (new_field->HasUsefulDefaultValue()) {
+      continue;
     }
+
+    // enum can't be nullable, but it's okay if it has 0 as a valid enumerator.
+    if (const auto& enum_decl = new_types.GetEnumDeclaration(new_field->GetType());
+        enum_decl != nullptr) {
+      if (HasZeroEnumerator(*enum_decl)) {
+        continue;
+      }
+
+      // TODO(b/142893595): Rephrase the message: "provide a default value or make sure ..."
+      AIDL_ERROR(new_field) << "Field '" << new_field->GetName() << "' of enum '"
+                            << enum_decl->GetName()
+                            << "' can't be initialized as '0'. Please make sure '"
+                            << enum_decl->GetName() << "' has '0' as a valid value.";
+      compatible = false;
+      continue;
+    }
+
+    // Old API versions may suffer from the issue presented here. There is
+    // only a finite number in Android, which we must allow indefinitely.
+    struct HistoricalException {
+      std::string canonical;
+      std::string field;
+    };
+    static std::vector<HistoricalException> exceptions = {
+        {"android.net.DhcpResultsParcelable", "serverHostName"},
+        {"android.net.ResolverParamsParcel", "resolverOptions"},
+    };
+    bool excepted = false;
+    for (const HistoricalException& exception : exceptions) {
+      if (older.GetCanonicalName() == exception.canonical &&
+          new_field->GetName() == exception.field) {
+        excepted = true;
+        break;
+      }
+    }
+    if (excepted) continue;
+
+    AIDL_ERROR(new_field)
+        << "Field '" << new_field->GetName()
+        << "' does not have a useful default in some backends. Please either provide a default "
+           "value for this field or mark the field as @nullable. This value or a null value will "
+           "be used automatically when an old version of this parcelable is sent to a process "
+           "which understands a new version of this parcelable. In order to make sure your code "
+           "continues to be backwards compatible, make sure the default or null value does not "
+           "cause a semantic change to this parcelable.";
+    compatible = false;
   }
+
+  compatible = are_compatible_constants(older, newer) && compatible;
+
   return compatible;
 }
 
@@ -289,10 +347,8 @@
       compatible = false;
       continue;
     }
-    const string old_value =
-        old_enum_map[name]->ValueString(older.GetBackingType(), AidlConstantValueDecorator);
-    const string new_value =
-        new_enum_map[name]->ValueString(newer.GetBackingType(), AidlConstantValueDecorator);
+    const string old_value = old_enum_map[name]->Literal();
+    const string new_value = new_enum_map[name]->Literal();
     if (old_value != new_value) {
       AIDL_ERROR(newer) << "Changed enumerator value: " << older.GetCanonicalName() << "::" << name
                         << " from " << old_value << " to " << new_value << ".";
@@ -330,15 +386,33 @@
     return false;
   }
 
+  const Options::CheckApiLevel level = options.GetCheckApiLevel();
+
   std::vector<AidlDefinedType*> old_types = old_tns->AllDefinedTypes();
   std::vector<AidlDefinedType*> new_types = new_tns->AllDefinedTypes();
 
+  bool compatible = true;
+
+  if (level == Options::CheckApiLevel::EQUAL) {
+    std::set<string> old_type_names;
+    for (const auto t : old_types) {
+      old_type_names.insert(t->GetCanonicalName());
+    }
+    for (const auto new_type : new_types) {
+      const auto found = old_type_names.find(new_type->GetCanonicalName());
+      if (found == old_type_names.end()) {
+        AIDL_ERROR(new_type) << "Added type: " << new_type->GetCanonicalName();
+        compatible = false;
+        continue;
+      }
+    }
+  }
+
   map<string, AidlDefinedType*> new_map;
   for (const auto t : new_types) {
     new_map.emplace(t->GetCanonicalName(), t);
   }
 
-  bool compatible = true;
   for (const auto old_type : old_types) {
     const auto found = new_map.find(old_type->GetCanonicalName());
     if (found == new_map.end()) {
@@ -348,6 +422,13 @@
     }
     const auto new_type = found->second;
 
+    if (level == Options::CheckApiLevel::EQUAL) {
+      if (!CheckEquality(*old_type, *new_type)) {
+        compatible = false;
+      }
+      continue;
+    }
+
     if (!have_compatible_annotations(*old_type, *new_type)) {
       compatible = false;
     }
@@ -368,8 +449,18 @@
         compatible = false;
         continue;
       }
-      compatible &= are_compatible_parcelables(*(old_type->AsStructuredParcelable()),
-                                               *(new_type->AsStructuredParcelable()));
+      compatible &= are_compatible_parcelables(*(old_type->AsStructuredParcelable()), *old_tns,
+                                               *(new_type->AsStructuredParcelable()), *new_tns);
+    } else if (old_type->AsUnionDeclaration() != nullptr) {
+      if (new_type->AsUnionDeclaration() == nullptr) {
+        AIDL_ERROR(new_type) << "Type mismatch: " << old_type->GetCanonicalName()
+                             << " is changed from " << old_type->GetPreprocessDeclarationName()
+                             << " to " << new_type->GetPreprocessDeclarationName();
+        compatible = false;
+        continue;
+      }
+      compatible &= are_compatible_parcelables(*(old_type->AsUnionDeclaration()), *old_tns,
+                                               *(new_type->AsUnionDeclaration()), *new_tns);
     } else if (old_type->AsEnumDeclaration() != nullptr) {
       if (new_type->AsEnumDeclaration() == nullptr) {
         AIDL_ERROR(new_type) << "Type mismatch: " << old_type->GetCanonicalName()
diff --git a/aidl_const_expressions.cpp b/aidl_const_expressions.cpp
index bac8dac..b97889d 100644
--- a/aidl_const_expressions.cpp
+++ b/aidl_const_expressions.cpp
@@ -38,6 +38,8 @@
 
 template <typename T>
 constexpr int CLZ(T x) {
+  // __builtin_clz(0) is undefined
+  if (x == 0) return sizeof(T) * 8;
   return (sizeof(T) == sizeof(uint64_t)) ? __builtin_clzl(x) : __builtin_clz(x);
 }
 
@@ -113,7 +115,7 @@
     return mValue >> o;
   }
   T operator<<(T o) {
-    if (o < 0 || mValue < 0 || o > CLZ(mValue)) {
+    if (o < 0 || mValue < 0 || o > CLZ(mValue) || o >= static_cast<T>(sizeof(T) * 8)) {
       mOverflowed = true;
       return 0;
     }
@@ -246,6 +248,20 @@
            c == '\\');   // Disallow backslashes for future proofing.
 }
 
+bool ParseFloating(std::string_view sv, double* parsed) {
+  // float literal should be parsed successfully.
+  android::base::ConsumeSuffix(&sv, "f");
+  return android::base::ParseDouble(std::string(sv).data(), parsed);
+}
+
+bool ParseFloating(std::string_view sv, float* parsed) {
+  // we only care about float literal (with suffix "f").
+  if (!android::base::ConsumeSuffix(&sv, "f")) {
+    return false;
+  }
+  return android::base::ParseFloat(std::string(sv).data(), parsed);
+}
+
 bool AidlUnaryConstExpression::IsCompatibleType(Type type, const string& op) {
   // Verify the unary type here
   switch (type) {
@@ -310,15 +326,6 @@
   return (Type::INT32 < in) ? in : Type::INT32;
 }
 
-template <typename T>
-T AidlConstantValue::cast() const {
-  AIDL_FATAL_IF(!is_evaluated_, this);
-
-#define CASE_CAST_T(__type__) return static_cast<T>(static_cast<__type__>(final_value_));
-
-  SWITCH_KIND(final_type_, CASE_CAST_T, SHOULD_NOT_REACH(); return 0;);
-}
-
 AidlConstantValue* AidlConstantValue::Default(const AidlTypeSpecifier& specifier) {
   AidlLocation location = specifier.GetLocation();
 
@@ -438,7 +445,11 @@
 AidlConstantValue* AidlConstantValue::Array(
     const AidlLocation& location, std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values) {
   AIDL_FATAL_IF(values == nullptr, location);
-  return new AidlConstantValue(location, Type::ARRAY, std::move(values));
+  std::vector<std::string> str_values;
+  for (const auto& v : *values) {
+    str_values.push_back(v->value_);
+  }
+  return new AidlConstantValue(location, Type::ARRAY, std::move(values), Join(str_values, ", "));
 }
 
 AidlConstantValue* AidlConstantValue::String(const AidlLocation& location, const string& value) {
@@ -453,26 +464,6 @@
   return new AidlConstantValue(location, Type::STRING, value);
 }
 
-AidlConstantValue* AidlConstantValue::ShallowIntegralCopy(const AidlConstantValue& other) {
-  // TODO(b/141313220) Perform a full copy instead of parsing+unparsing
-  AidlTypeSpecifier type = AidlTypeSpecifier(AIDL_LOCATION_HERE, "long", false, nullptr, "");
-  // TODO(b/142722772) CheckValid() should be called before ValueString()
-  if (!other.CheckValid() || !other.evaluate(type)) {
-    AIDL_ERROR(other) << "Failed to parse expression as integer: " << other.value_;
-    return nullptr;
-  }
-  const std::string& value = other.ValueString(type, AidlConstantValueDecorator);
-  if (value.empty()) {
-    return nullptr;  // error already logged
-  }
-
-  AidlConstantValue* result = Integral(AIDL_LOCATION_HERE, value);
-  if (result == nullptr) {
-    AIDL_FATAL(other) << "Unable to perform ShallowIntegralCopy.";
-  }
-  return result;
-}
-
 string AidlConstantValue::ValueString(const AidlTypeSpecifier& type,
                                       const ConstantValueDecorator& decorator) const {
   if (type.IsGeneric()) {
@@ -482,7 +473,7 @@
   if (!is_evaluated_) {
     // TODO(b/142722772) CheckValid() should be called before ValueString()
     bool success = CheckValid();
-    success &= evaluate(type);
+    success &= evaluate();
     if (!success) {
       // the detailed error message shall be printed in evaluate
       return "";
@@ -492,6 +483,23 @@
     AIDL_ERROR(this) << "Invalid constant value: " + value_;
     return "";
   }
+
+  const AidlDefinedType* defined_type = type.GetDefinedType();
+  if (defined_type && !type.IsArray()) {
+    const AidlEnumDeclaration* enum_type = defined_type->AsEnumDeclaration();
+    if (!enum_type) {
+      AIDL_ERROR(this) << "Invalid type (" << defined_type->GetCanonicalName()
+                       << ") for a const value (" << value_ << ")";
+      return "";
+    }
+    if (type_ != Type::REF) {
+      AIDL_ERROR(this) << "Invalid value (" << value_ << ") for enum "
+                       << enum_type->GetCanonicalName();
+      return "";
+    }
+    return decorator(type, value_);
+  }
+
   const string& type_string = type.GetName();
   int err = 0;
 
@@ -557,22 +565,18 @@
       return decorator(type, "{" + Join(value_strings, ", ") + "}");
     }
     case Type::FLOATING: {
-      std::string_view raw_view(value_.c_str());
-      bool is_float_literal = ConsumeSuffix(&raw_view, "f");
-      std::string stripped_value = std::string(raw_view);
-
       if (type_string == "double") {
         double parsed_value;
-        if (!android::base::ParseDouble(stripped_value, &parsed_value)) {
+        if (!ParseFloating(value_, &parsed_value)) {
           AIDL_ERROR(this) << "Could not parse " << value_;
           err = -1;
           break;
         }
         return decorator(type, std::to_string(parsed_value));
       }
-      if (is_float_literal && type_string == "float") {
+      if (type_string == "float") {
         float parsed_value;
-        if (!android::base::ParseFloat(stripped_value, &parsed_value)) {
+        if (!ParseFloating(value_, &parsed_value)) {
           AIDL_ERROR(this) << "Could not parse " << value_;
           err = -1;
           break;
@@ -602,14 +606,18 @@
     case Type::INT8:       // fall-through
     case Type::INT32:      // fall-through
     case Type::INT64:      // fall-through
-    case Type::ARRAY:      // fall-through
     case Type::CHARACTER:  // fall-through
     case Type::STRING:     // fall-through
+    case Type::REF:        // fall-through
     case Type::FLOATING:   // fall-through
     case Type::UNARY:      // fall-through
     case Type::BINARY:
       is_valid_ = true;
       break;
+    case Type::ARRAY:
+      is_valid_ = true;
+      for (const auto& v : values_) is_valid_ &= v->CheckValid();
+      break;
     case Type::ERROR:
       return false;
     default:
@@ -620,7 +628,7 @@
   return true;
 }
 
-bool AidlConstantValue::evaluate(const AidlTypeSpecifier& type) const {
+bool AidlConstantValue::evaluate() const {
   if (is_evaluated_) {
     return is_valid_;
   }
@@ -629,17 +637,12 @@
 
   switch (type_) {
     case Type::ARRAY: {
-      if (!type.IsArray()) {
-        AIDL_ERROR(this) << "Invalid constant array type: " << type.GetName();
-        err = -1;
-        break;
-      }
       Type array_type = Type::ERROR;
       bool success = true;
       for (const auto& value : values_) {
         success = value->CheckValid();
         if (success) {
-          success = value->evaluate(type.ArrayBase());
+          success = value->evaluate();
           if (!success) {
             AIDL_ERROR(this) << "Invalid array element: " << value->value_;
             break;
@@ -712,6 +715,8 @@
       return "a literal char";
     case Type::STRING:
       return "a literal string";
+    case Type::REF:
+      return "a reference";
     case Type::FLOATING:
       return "a literal float";
     case Type::UNARY:
@@ -728,6 +733,77 @@
   }
 }
 
+AidlConstantReference::AidlConstantReference(const AidlLocation& location, const std::string& value)
+    : AidlConstantValue(location, Type::REF, value) {
+  const auto pos = value.find_last_of('.');
+  if (pos == string::npos) {
+    field_name_ = value;
+  } else {
+    ref_type_ = std::make_unique<AidlTypeSpecifier>(location, value.substr(0, pos), false, nullptr,
+                                                    Comments{});
+    field_name_ = value.substr(pos + 1);
+  }
+}
+
+const AidlConstantValue* AidlConstantReference::Resolve(const AidlDefinedType* scope) const {
+  if (resolved_) return resolved_;
+
+  const AidlDefinedType* defined_type;
+  if (ref_type_) {
+    defined_type = ref_type_->GetDefinedType();
+  } else {
+    defined_type = scope;
+  }
+
+  if (!defined_type) {
+    // This can happen when "const reference" is used in an unsupported way,
+    // but missed in checks there. It works as a safety net.
+    AIDL_ERROR(*this) << "Can't resolve the reference (" << value_ << ")";
+    return nullptr;
+  }
+
+  if (auto enum_decl = defined_type->AsEnumDeclaration(); enum_decl) {
+    for (const auto& e : enum_decl->GetEnumerators()) {
+      if (e->GetName() == field_name_) {
+        return resolved_ = e->GetValue();
+      }
+    }
+  } else {
+    for (const auto& c : defined_type->GetConstantDeclarations()) {
+      if (c->GetName() == field_name_) {
+        return resolved_ = &c->GetValue();
+      }
+    }
+  }
+  AIDL_ERROR(*this) << "Can't find " << field_name_ << " in " << defined_type->GetName();
+  return nullptr;
+}
+
+bool AidlConstantReference::CheckValid() const {
+  if (is_evaluated_) return is_valid_;
+  AIDL_FATAL_IF(!resolved_, this) << "Should be resolved first: " << value_;
+  is_valid_ = resolved_->CheckValid();
+  return is_valid_;
+}
+
+bool AidlConstantReference::evaluate() const {
+  if (is_evaluated_) return is_valid_;
+  AIDL_FATAL_IF(!resolved_, this) << "Should be resolved first: " << value_;
+  is_evaluated_ = true;
+
+  resolved_->evaluate();
+  is_valid_ = resolved_->is_valid_;
+  final_type_ = resolved_->final_type_;
+  if (is_valid_) {
+    if (final_type_ == Type::STRING) {
+      final_string_value_ = resolved_->final_string_value_;
+    } else {
+      final_value_ = resolved_->final_value_;
+    }
+  }
+  return is_valid_;
+}
+
 bool AidlUnaryConstExpression::CheckValid() const {
   if (is_evaluated_) return is_valid_;
   AIDL_FATAL_IF(unary_ == nullptr, this);
@@ -741,7 +817,7 @@
   return AidlConstantValue::CheckValid();
 }
 
-bool AidlUnaryConstExpression::evaluate(const AidlTypeSpecifier& type) const {
+bool AidlUnaryConstExpression::evaluate() const {
   if (is_evaluated_) {
     return is_valid_;
   }
@@ -751,7 +827,7 @@
   if (!unary_->is_evaluated_) {
     // TODO(b/142722772) CheckValid() should be called before ValueString()
     bool success = CheckValid();
-    success &= unary_->evaluate(type);
+    success &= unary_->evaluate();
     if (!success) {
       is_valid_ = false;
       return false;
@@ -778,7 +854,8 @@
   }
 
 #define CASE_UNARY(__type__) \
-  return handleUnary(*this, op_, static_cast<__type__>(unary_->final_value_), &final_value_);
+  return is_valid_ =         \
+             handleUnary(*this, op_, static_cast<__type__>(unary_->final_value_), &final_value_);
 
   SWITCH_KIND(final_type_, CASE_UNARY, SHOULD_NOT_REACH(); final_type_ = Type::ERROR;
               is_valid_ = false; return false;)
@@ -811,20 +888,20 @@
   return AidlConstantValue::CheckValid();
 }
 
-bool AidlBinaryConstExpression::evaluate(const AidlTypeSpecifier& type) const {
+bool AidlBinaryConstExpression::evaluate() const {
   if (is_evaluated_) {
     return is_valid_;
   }
   is_evaluated_ = true;
-  AIDL_FATAL_IF(left_val_ == nullptr, type);
-  AIDL_FATAL_IF(right_val_ == nullptr, type);
+  AIDL_FATAL_IF(left_val_ == nullptr, this);
+  AIDL_FATAL_IF(right_val_ == nullptr, this);
 
   // Recursively evaluate the binary expression tree
   if (!left_val_->is_evaluated_ || !right_val_->is_evaluated_) {
     // TODO(b/142722772) CheckValid() should be called before ValueString()
     bool success = CheckValid();
-    success &= left_val_->evaluate(type);
-    success &= right_val_->evaluate(type);
+    success &= left_val_->evaluate();
+    success &= right_val_->evaluate();
     if (!success) {
       is_valid_ = false;
       return false;
@@ -886,9 +963,10 @@
                       ? promoted        // arithmetic or bitflip operators generates promoted type
                       : Type::BOOLEAN;  // comparison operators generates bool
 
-#define CASE_BINARY_COMMON(__type__)                                                    \
-  return handleBinaryCommon(*this, static_cast<__type__>(left_val_->final_value_), op_, \
-                            static_cast<__type__>(right_val_->final_value_), &final_value_);
+#define CASE_BINARY_COMMON(__type__)                                                        \
+  return is_valid_ =                                                                        \
+             handleBinaryCommon(*this, static_cast<__type__>(left_val_->final_value_), op_, \
+                                static_cast<__type__>(right_val_->final_value_), &final_value_);
 
     SWITCH_KIND(promoted, CASE_BINARY_COMMON, SHOULD_NOT_REACH(); final_type_ = Type::ERROR;
                 is_valid_ = false; return false;)
@@ -908,9 +986,9 @@
       numBits = -numBits;
     }
 
-#define CASE_SHIFT(__type__)                                                       \
-  return handleShift(*this, static_cast<__type__>(left_val_->final_value_), newOp, \
-                     static_cast<__type__>(numBits), &final_value_);
+#define CASE_SHIFT(__type__)                                                                   \
+  return is_valid_ = handleShift(*this, static_cast<__type__>(left_val_->final_value_), newOp, \
+                                 static_cast<__type__>(numBits), &final_value_);
 
     SWITCH_KIND(final_type_, CASE_SHIFT, SHOULD_NOT_REACH(); final_type_ = Type::ERROR;
                 is_valid_ = false; return false;)
@@ -960,10 +1038,12 @@
 }
 
 AidlConstantValue::AidlConstantValue(const AidlLocation& location, Type type,
-                                     std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values)
+                                     std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values,
+                                     const std::string& value)
     : AidlNode(location),
       type_(type),
       values_(std::move(*values)),
+      value_(value),
       is_valid_(false),
       is_evaluated_(false),
       final_type_(type) {
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 15ecd08..f06b8a4 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -33,6 +33,7 @@
 #include <android-base/strings.h>
 
 #include "aidl_language_y.h"
+#include "comments.h"
 #include "logging.h"
 
 #include "aidl.h"
@@ -68,39 +69,10 @@
   };
   return std::find(kJavaKeywords.begin(), kJavaKeywords.end(), str) != kJavaKeywords.end();
 }
-
-inline std::string CapitalizeFirstLetter(const AidlNode& context, const std::string& str) {
-  AIDL_FATAL_IF(str.size() <= 0, context) << "Input cannot be empty.";
-  std::ostringstream out;
-  out << static_cast<char>(toupper(str[0])) << str.substr(1);
-  return out.str();
-}
-
-void AddHideComment(CodeWriter* writer) {
-  writer->Write("/* @hide */\n");
-}
-
-inline bool HasHideComment(const std::string& comment) {
-  return std::regex_search(comment, std::regex("@hide\\b"));
-}
 }  // namespace
 
-AidlLocation::AidlLocation(const std::string& file, Point begin, Point end, Source source)
-    : file_(file), begin_(begin), end_(end), source_(source) {}
-
-std::ostream& operator<<(std::ostream& os, const AidlLocation& l) {
-  os << l.file_;
-  if (l.LocationKnown()) {
-    os << ":" << l.begin_.line << "." << l.begin_.column << "-";
-    if (l.begin_.line != l.end_.line) {
-      os << l.end_.line << ".";
-    }
-    os << l.end_.column;
-  }
-  return os;
-}
-
-AidlNode::AidlNode(const AidlLocation& location) : location_(location) {}
+AidlNode::AidlNode(const AidlLocation& location, const Comments& comments)
+    : location_(location), comments_(comments) {}
 
 std::string AidlNode::PrintLine() const {
   std::stringstream ss;
@@ -115,35 +87,71 @@
   return ss.str();
 }
 
+static const AidlTypeSpecifier kStringType{AIDL_LOCATION_HERE, "String", false, nullptr,
+                                           Comments{}};
+static const AidlTypeSpecifier kStringArrayType{AIDL_LOCATION_HERE, "String", true, nullptr,
+                                                Comments{}};
+static const AidlTypeSpecifier kIntType{AIDL_LOCATION_HERE, "int", false, nullptr, Comments{}};
+static const AidlTypeSpecifier kLongType{AIDL_LOCATION_HERE, "long", false, nullptr, Comments{}};
+static const AidlTypeSpecifier kBooleanType{AIDL_LOCATION_HERE, "boolean", false, nullptr,
+                                            Comments{}};
+
 const std::vector<AidlAnnotation::Schema>& AidlAnnotation::AllSchemas() {
   static const std::vector<Schema> kSchemas{
-      {AidlAnnotation::Type::NULLABLE, "nullable", {}},
-      {AidlAnnotation::Type::UTF8_IN_CPP, "utf8InCpp", {}},
-      {AidlAnnotation::Type::VINTF_STABILITY, "VintfStability", {}},
+      {AidlAnnotation::Type::NULLABLE, "nullable", CONTEXT_TYPE_SPECIFIER, {}},
+      {AidlAnnotation::Type::UTF8_IN_CPP, "utf8InCpp", CONTEXT_TYPE_SPECIFIER, {}},
+      {AidlAnnotation::Type::SENSITIVE_DATA, "SensitiveData", CONTEXT_TYPE_INTERFACE, {}},
+      {AidlAnnotation::Type::VINTF_STABILITY, "VintfStability", CONTEXT_TYPE, {}},
       {AidlAnnotation::Type::UNSUPPORTED_APP_USAGE,
        "UnsupportedAppUsage",
-       {{"expectedSignature", "String"},
-        {"implicitMember", "String"},
-        {"maxTargetSdk", "int"},
-        {"publicAlternatives", "String"},
-        {"trackingBug", "long"}}},
-      {AidlAnnotation::Type::JAVA_STABLE_PARCELABLE, "JavaOnlyStableParcelable", {}},
-      {AidlAnnotation::Type::HIDE, "Hide", {}},
-      {AidlAnnotation::Type::BACKING, "Backing", {{"type", "String"}}},
-      {AidlAnnotation::Type::JAVA_PASSTHROUGH, "JavaPassthrough", {{"annotation", "String"}}},
-      {AidlAnnotation::Type::JAVA_DEBUG, "JavaDebug", {}},
-      {AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE, "JavaOnlyImmutable", {}},
-      {AidlAnnotation::Type::FIXED_SIZE, "FixedSize", {}},
-      {AidlAnnotation::Type::DESCRIPTOR, "Descriptor", {{"value", "String"}}},
+       CONTEXT_TYPE | CONTEXT_MEMBER,
+       {{"expectedSignature", kStringType},
+        {"implicitMember", kStringType},
+        {"maxTargetSdk", kIntType},
+        {"publicAlternatives", kStringType},
+        {"trackingBug", kLongType}}},
+      {AidlAnnotation::Type::JAVA_STABLE_PARCELABLE,
+       "JavaOnlyStableParcelable",
+       CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE,
+       {}},
+      {AidlAnnotation::Type::HIDE, "Hide", CONTEXT_TYPE | CONTEXT_MEMBER, {}},
+      {AidlAnnotation::Type::BACKING,
+       "Backing",
+       CONTEXT_TYPE_ENUM,
+       {{"type", kStringType, /* required= */ true}}},
+      {AidlAnnotation::Type::JAVA_PASSTHROUGH,
+       "JavaPassthrough",
+       CONTEXT_ALL,
+       {{"annotation", kStringType, /* required= */ true}},
+       /* repeatable= */ true},
+      {AidlAnnotation::Type::JAVA_DERIVE,
+       "JavaDerive",
+       CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION,
+       {{"toString", kBooleanType}, {"equals", kBooleanType}}},
+      {AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE,
+       "JavaOnlyImmutable",
+       CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION |
+           CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE,
+       {}},
+      {AidlAnnotation::Type::FIXED_SIZE, "FixedSize", CONTEXT_TYPE_STRUCTURED_PARCELABLE, {}},
+      {AidlAnnotation::Type::DESCRIPTOR,
+       "Descriptor",
+       CONTEXT_TYPE_INTERFACE,
+       {{"value", kStringType, /* required= */ true}}},
       {AidlAnnotation::Type::RUST_DERIVE,
        "RustDerive",
-       {{"Copy", "boolean"},
-        {"Clone", "boolean"},
-        {"PartialOrd", "boolean"},
-        {"Ord", "boolean"},
-        {"PartialEq", "boolean"},
-        {"Eq", "boolean"},
-        {"Hash", "boolean"}}},
+       CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION,
+       {{"Copy", kBooleanType},
+        {"Clone", kBooleanType},
+        {"PartialOrd", kBooleanType},
+        {"Ord", kBooleanType},
+        {"PartialEq", kBooleanType},
+        {"Eq", kBooleanType},
+        {"Hash", kBooleanType}}},
+      {AidlAnnotation::Type::SUPPRESS_WARNINGS,
+       "SuppressWarnings",
+       CONTEXT_TYPE | CONTEXT_MEMBER,
+       {{"value", kStringArrayType, /* required= */ true}}},
   };
   return kSchemas;
 }
@@ -158,7 +166,8 @@
 
 AidlAnnotation* AidlAnnotation::Parse(
     const AidlLocation& location, const string& name,
-    std::map<std::string, std::shared_ptr<AidlConstantValue>>* parameter_list) {
+    std::map<std::string, std::shared_ptr<AidlConstantValue>>* parameter_list,
+    const Comments& comments) {
   const Schema* schema = nullptr;
   for (const Schema& a_schema : AllSchemas()) {
     if (a_schema.name == name) {
@@ -178,40 +187,66 @@
     return nullptr;
   }
   if (parameter_list == nullptr) {
-    return new AidlAnnotation(location, *schema, {});
+    return new AidlAnnotation(location, *schema, {}, comments);
   }
 
-  return new AidlAnnotation(location, *schema, std::move(*parameter_list));
+  return new AidlAnnotation(location, *schema, std::move(*parameter_list), comments);
 }
 
 AidlAnnotation::AidlAnnotation(
     const AidlLocation& location, const Schema& schema,
-    std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters)
-    : AidlNode(location), schema_(schema), parameters_(std::move(parameters)) {}
+    std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters,
+    const Comments& comments)
+    : AidlNode(location, comments), schema_(schema), parameters_(std::move(parameters)) {}
 
+struct ConstReferenceFinder : AidlVisitor {
+  const AidlConstantReference* found;
+  void Visit(const AidlConstantReference& ref) override {
+    if (!found) found = &ref;
+  }
+  static const AidlConstantReference* Find(const AidlConstantValue& c) {
+    ConstReferenceFinder finder;
+    VisitTopDown(finder, c);
+    return finder.found;
+  }
+};
+
+// Checks if annotation complies with the schema
+// - every parameter is known and has well-typed value.
+// - every required parameter is present.
 bool AidlAnnotation::CheckValid() const {
   for (const auto& name_and_param : parameters_) {
     const std::string& param_name = name_and_param.first;
     const std::shared_ptr<AidlConstantValue>& param = name_and_param.second;
+
+    const ParamType* param_type = schema_.ParamType(param_name);
+    if (!param_type) {
+      std::ostringstream stream;
+      stream << "Parameter " << param_name << " not supported ";
+      stream << "for annotation " << GetName() << ". ";
+      stream << "It must be one of:";
+      for (const auto& param : schema_.parameters) {
+        stream << " " << param.name;
+      }
+      AIDL_ERROR(this) << stream.str();
+      return false;
+    }
+
+    const auto& found = ConstReferenceFinder::Find(*param);
+    if (found) {
+      AIDL_ERROR(found) << "Value must be a constant expression but contains reference to "
+                        << found->GetFieldName() << ".";
+      return false;
+    }
+
     if (!param->CheckValid()) {
       AIDL_ERROR(this) << "Invalid value for parameter " << param_name << " on annotation "
                        << GetName() << ".";
       return false;
     }
-    auto parameter_mapping_it = schema_.supported_parameters.find(param_name);
-    if (parameter_mapping_it == schema_.supported_parameters.end()) {
-      std::ostringstream stream;
-      stream << "Parameter " << param_name << " not supported ";
-      stream << "for annotation " << GetName() << ". ";
-      stream << "It must be one of:";
-      for (const auto& kv : schema_.supported_parameters) {
-        stream << " " << kv.first;
-      }
-      AIDL_ERROR(this) << stream.str();
-      return false;
-    }
-    AidlTypeSpecifier type{AIDL_LOCATION_HERE, parameter_mapping_it->second, false, nullptr, ""};
-    const std::string param_value = param->ValueString(type, AidlConstantValueDecorator);
+
+    const std::string param_value =
+        param->ValueString(param_type->type, AidlConstantValueDecorator);
     // Assume error on empty string.
     if (param_value == "") {
       AIDL_ERROR(this) << "Invalid value for parameter " << param_name << " on annotation "
@@ -219,7 +254,43 @@
       return false;
     }
   }
-  return true;
+  bool success = true;
+  for (const auto& param : schema_.parameters) {
+    if (param.required && parameters_.count(param.name) == 0) {
+      AIDL_ERROR(this) << "Missing '" << param.name << "' on @" << GetName() << ".";
+      success = false;
+    }
+  }
+  return success;
+}
+
+// Checks if the annotation is applicable to the current context.
+// For example, annotations like @VintfStability, @FixedSize is not applicable to AidlTypeSpecifier
+// nodes.
+bool AidlAnnotation::CheckContext(TargetContext context) const {
+  if (schema_.target_context & static_cast<uint32_t>(context)) {
+    return true;
+  }
+  const static map<TargetContext, string> context_name_map{
+      {CONTEXT_TYPE_INTERFACE, "interface"},
+      {CONTEXT_TYPE_ENUM, "enum"},
+      {CONTEXT_TYPE_STRUCTURED_PARCELABLE, "structured parcelable"},
+      {CONTEXT_TYPE_UNION, "union"},
+      {CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE, "parcelable"},
+      {CONTEXT_CONST, "constant"},
+      {CONTEXT_FIELD, "field"},
+      {CONTEXT_METHOD, "method"},
+      {CONTEXT_TYPE_SPECIFIER, "type"},
+  };
+  vector<string> available;
+  for (const auto& [context, name] : context_name_map) {
+    if (schema_.target_context & context) {
+      available.push_back(name);
+    }
+  }
+  AIDL_ERROR(this) << "@" << GetName() << " is not available. It can annotate {"
+                   << Join(available, ", ") << "}.";
+  return false;
 }
 
 std::map<std::string, std::string> AidlAnnotation::AnnotationParams(
@@ -228,53 +299,46 @@
   for (const auto& name_and_param : parameters_) {
     const std::string& param_name = name_and_param.first;
     const std::shared_ptr<AidlConstantValue>& param = name_and_param.second;
-    if (schema_.supported_parameters.find(param_name) == schema_.supported_parameters.end()) {
-      std::ostringstream stream;
-      stream << "Parameter " << param_name << " not supported ";
-      stream << "for annotation " << GetName() << ". ";
-      stream << "It must be one of:";
-      for (const auto& kv : schema_.supported_parameters) {
-        stream << " " << kv.first;
-      }
-      AIDL_ERROR(this) << stream.str();
-      continue;
-    }
-    AidlTypeSpecifier type{AIDL_LOCATION_HERE, schema_.supported_parameters.at(param_name), false,
-                           nullptr, ""};
-    if (!param->CheckValid()) {
-      AIDL_ERROR(this) << "Invalid value for parameter " << param_name << " on annotation "
-                       << GetName() << ".";
-      continue;
-    }
-
-    raw_params.emplace(param_name, param->ValueString(type, decorator));
+    const ParamType* param_type = schema_.ParamType(param_name);
+    AIDL_FATAL_IF(!param_type, this);
+    raw_params.emplace(param_name, param->ValueString(param_type->type, decorator));
   }
   return raw_params;
 }
 
-std::string AidlAnnotation::ToString(const ConstantValueDecorator& decorator) const {
+std::string AidlAnnotation::ToString() const {
   if (parameters_.empty()) {
     return "@" + GetName();
   } else {
     vector<string> param_strings;
-    for (const auto& [name, value] : AnnotationParams(decorator)) {
+    for (const auto& [name, value] : AnnotationParams(AidlConstantValueDecorator)) {
       param_strings.emplace_back(name + "=" + value);
     }
     return "@" + GetName() + "(" + Join(param_strings, ", ") + ")";
   }
 }
 
+void AidlAnnotation::TraverseChildren(std::function<void(const AidlNode&)> traverse) const {
+  for (const auto& [name, value] : parameters_) {
+    (void)name;
+    traverse(*value);
+  }
+}
+
 static const AidlAnnotation* GetAnnotation(const vector<AidlAnnotation>& annotations,
                                            AidlAnnotation::Type type) {
   for (const auto& a : annotations) {
     if (a.GetType() == type) {
+      AIDL_FATAL_IF(a.Repeatable(), a)
+          << "Trying to get a single annotation when it is repeatable.";
       return &a;
     }
   }
   return nullptr;
 }
 
-AidlAnnotatable::AidlAnnotatable(const AidlLocation& location) : AidlNode(location) {}
+AidlAnnotatable::AidlAnnotatable(const AidlLocation& location, const Comments& comments)
+    : AidlCommentable(location, comments) {}
 
 bool AidlAnnotatable::IsNullable() const {
   return GetAnnotation(annotations_, AidlAnnotation::Type::NULLABLE);
@@ -284,6 +348,10 @@
   return GetAnnotation(annotations_, AidlAnnotation::Type::UTF8_IN_CPP);
 }
 
+bool AidlAnnotatable::IsSensitiveData() const {
+  return GetAnnotation(annotations_, AidlAnnotation::Type::SENSITIVE_DATA);
+}
+
 bool AidlAnnotatable::IsVintfStability() const {
   return GetAnnotation(annotations_, AidlAnnotation::Type::VINTF_STABILITY);
 }
@@ -300,33 +368,22 @@
   return GetAnnotation(annotations_, AidlAnnotation::Type::UNSUPPORTED_APP_USAGE);
 }
 
-const AidlAnnotation* AidlAnnotatable::JavaPassthrough() const {
-  return GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_PASSTHROUGH);
-}
-
 const AidlAnnotation* AidlAnnotatable::RustDerive() const {
   return GetAnnotation(annotations_, AidlAnnotation::Type::RUST_DERIVE);
 }
 
-const AidlTypeSpecifier* AidlAnnotatable::BackingType(const AidlTypenames& typenames) const {
-  auto annotation = GetAnnotation(annotations_, AidlAnnotation::Type::BACKING);
-  if (annotation != nullptr) {
-    auto annotation_params = annotation->AnnotationParams(AidlConstantValueDecorator);
-    if (auto it = annotation_params.find("type"); it != annotation_params.end()) {
-      const string& type = it->second;
+const AidlAnnotation* AidlAnnotatable::BackingType() const {
+  return GetAnnotation(annotations_, AidlAnnotation::Type::BACKING);
+}
 
-      AIDL_FATAL_IF(type.size() < 2, this) << type;
-      AIDL_FATAL_IF(type[0] != '"', this) << type;
-      AIDL_FATAL_IF(type[type.length() - 1] != '"', this) << type;
-      string unquoted_type = type.substr(1, type.length() - 2);
-
-      AidlTypeSpecifier* type_specifier =
-          new AidlTypeSpecifier(AIDL_LOCATION_HERE, unquoted_type, false, nullptr, "");
-      type_specifier->Resolve(typenames);
-      return type_specifier;
-    }
+std::vector<std::string> AidlAnnotatable::SuppressWarnings() const {
+  auto annot = GetAnnotation(annotations_, AidlAnnotation::Type::SUPPRESS_WARNINGS);
+  if (annot) {
+    auto names = annot->ParamValue<std::vector<std::string>>("value");
+    AIDL_FATAL_IF(!names.has_value(), this);
+    return std::move(names.value());
   }
-  return nullptr;
+  return {};
 }
 
 bool AidlAnnotatable::IsStableApiParcelable(Options::Language lang) const {
@@ -338,23 +395,18 @@
   return GetAnnotation(annotations_, AidlAnnotation::Type::HIDE);
 }
 
-bool AidlAnnotatable::IsJavaDebug() const {
-  return GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_DEBUG);
+bool AidlAnnotatable::JavaDerive(const std::string& method) const {
+  auto annotation = GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_DERIVE);
+  if (annotation != nullptr) {
+    return annotation->ParamValue<bool>(method).value_or(false);
+  }
+  return false;
 }
 
 std::string AidlAnnotatable::GetDescriptor() const {
   auto annotation = GetAnnotation(annotations_, AidlAnnotation::Type::DESCRIPTOR);
   if (annotation != nullptr) {
-    auto params = annotation->AnnotationParams(AidlConstantValueDecorator);
-    if (auto it = params.find("value"); it != params.end()) {
-      const string& value = it->second;
-
-      AIDL_FATAL_IF(value.size() < 2, this) << value;
-      AIDL_FATAL_IF(value[0] != '"', this) << value;
-      AIDL_FATAL_IF(value[value.length() - 1] != '"', this) << value;
-      std::string unquoted_value = value.substr(1, value.length() - 2);
-      return unquoted_value;
-    }
+    return annotation->ParamValue<std::string>("value").value();
   }
   return "";
 }
@@ -366,22 +418,18 @@
 }
 
 bool AidlAnnotatable::CheckValid(const AidlTypenames&) const {
-  std::set<AidlAnnotation::Type> supported_annotations = GetSupportedAnnotations();
   for (const auto& annotation : GetAnnotations()) {
     if (!annotation.CheckValid()) {
       return false;
     }
+  }
 
-    std::vector<std::string> supported_annot_strings;
-    for (AidlAnnotation::Type type : supported_annotations) {
-      supported_annot_strings.push_back(AidlAnnotation::TypeToString(type));
-    }
-
-    if (supported_annotations.find(annotation.GetType()) == supported_annotations.end()) {
+  std::map<AidlAnnotation::Type, AidlLocation> declared;
+  for (const auto& annotation : GetAnnotations()) {
+    const auto& [iter, inserted] = declared.emplace(annotation.GetType(), annotation.GetLocation());
+    if (!inserted && !annotation.Repeatable()) {
       AIDL_ERROR(this) << "'" << annotation.GetName()
-                       << "' is not a supported annotation for this node. "
-                       << "It must be one of: "
-                       << android::base::Join(supported_annot_strings, ", ");
+                       << "' is repeated, but not allowed. Previous location: " << iter->second;
       return false;
     }
   }
@@ -392,7 +440,7 @@
 string AidlAnnotatable::ToString() const {
   vector<string> ret;
   for (const auto& a : annotations_) {
-    ret.emplace_back(a.ToString(AidlConstantValueDecorator));
+    ret.emplace_back(a.ToString());
   }
   std::sort(ret.begin(), ret.end());
   return Join(ret, " ");
@@ -401,34 +449,31 @@
 AidlTypeSpecifier::AidlTypeSpecifier(const AidlLocation& location, const string& unresolved_name,
                                      bool is_array,
                                      vector<unique_ptr<AidlTypeSpecifier>>* type_params,
-                                     const string& comments)
-    : AidlAnnotatable(location),
+                                     const Comments& comments)
+    : AidlAnnotatable(location, comments),
       AidlParameterizable<unique_ptr<AidlTypeSpecifier>>(type_params),
       unresolved_name_(unresolved_name),
       is_array_(is_array),
-      comments_(comments),
       split_name_(Split(unresolved_name, ".")) {}
 
-AidlTypeSpecifier AidlTypeSpecifier::ArrayBase() const {
+const AidlTypeSpecifier& AidlTypeSpecifier::ArrayBase() const {
   AIDL_FATAL_IF(!is_array_, this);
   // Declaring array of generic type cannot happen, it is grammar error.
   AIDL_FATAL_IF(IsGeneric(), this);
 
-  AidlTypeSpecifier array_base = *this;
-  array_base.is_array_ = false;
-  return array_base;
+  if (!array_base_) {
+    array_base_.reset(new AidlTypeSpecifier(*this));
+    array_base_->is_array_ = false;
+  }
+  return *array_base_;
 }
 
-bool AidlTypeSpecifier::IsHidden() const {
-  return HasHideComment(GetComments());
-}
-
-string AidlTypeSpecifier::ToString() const {
+string AidlTypeSpecifier::Signature() const {
   string ret = GetName();
   if (IsGeneric()) {
     vector<string> arg_names;
     for (const auto& ta : GetTypeParameters()) {
-      arg_names.emplace_back(ta->ToString());
+      arg_names.emplace_back(ta->Signature());
     }
     ret += "<" + Join(arg_names, ",") + ">";
   }
@@ -438,8 +483,8 @@
   return ret;
 }
 
-string AidlTypeSpecifier::Signature() const {
-  string ret = ToString();
+string AidlTypeSpecifier::ToString() const {
+  string ret = Signature();
   string annotations = AidlAnnotatable::ToString();
   if (annotations != "") {
     ret = annotations + " " + ret;
@@ -453,16 +498,13 @@
   if (result.is_resolved) {
     fully_qualified_name_ = result.canonical_name;
     split_name_ = Split(fully_qualified_name_, ".");
+    defined_type_ = result.defined_type;
   }
   return result.is_resolved;
 }
 
-std::set<AidlAnnotation::Type> AidlTypeSpecifier::GetSupportedAnnotations() const {
-  // kHide and kUnsupportedAppUsage are both method return annotations
-  // which we don't distinguish from other type specifiers.
-  return {AidlAnnotation::Type::NULLABLE, AidlAnnotation::Type::UTF8_IN_CPP,
-          AidlAnnotation::Type::UNSUPPORTED_APP_USAGE, AidlAnnotation::Type::HIDE,
-          AidlAnnotation::Type::JAVA_PASSTHROUGH};
+const AidlDefinedType* AidlTypeSpecifier::GetDefinedType() const {
+  return defined_type_;
 }
 
 bool AidlTypeSpecifier::CheckValid(const AidlTypenames& typenames) const {
@@ -475,8 +517,9 @@
     auto& types = GetTypeParameters();
     // TODO(b/136048684) Disallow to use primitive types only if it is List or Map.
     if (type_name == "List" || type_name == "Map") {
-      if (std::any_of(types.begin(), types.end(), [](auto& type_ptr) {
-            return AidlTypenames::IsPrimitiveTypename(type_ptr->GetName());
+      if (std::any_of(types.begin(), types.end(), [&](auto& type_ptr) {
+            return (typenames.GetEnumDeclaration(*type_ptr)) ||
+                   AidlTypenames::IsPrimitiveTypename(type_ptr->GetName());
           })) {
         AIDL_ERROR(this) << "A generic type cannot have any primitive type parameters.";
         return false;
@@ -490,14 +533,32 @@
     const size_t num_params = GetTypeParameters().size();
     if (type_name == "List") {
       if (num_params > 1) {
-        AIDL_ERROR(this) << " List cannot have type parameters more than one, but got "
-                         << "'" << ToString() << "'";
+        AIDL_ERROR(this) << "List can only have one type parameter, but got: '" << Signature()
+                         << "'";
         return false;
       }
+      const AidlTypeSpecifier& contained_type = *GetTypeParameters()[0];
+      const string& contained_type_name = contained_type.GetName();
+      if (AidlTypenames::IsBuiltinTypename(contained_type_name)) {
+        if (contained_type_name != "String" && contained_type_name != "IBinder" &&
+            contained_type_name != "ParcelFileDescriptor") {
+          AIDL_ERROR(this) << "List<" << contained_type_name
+                           << "> is not supported. List<T> supports parcelable/union, String, "
+                              "IBinder, and ParcelFileDescriptor.";
+          return false;
+        }
+      } else {  // Defined types
+        if (typenames.GetInterface(contained_type)) {
+          AIDL_ERROR(this) << "List<" << contained_type_name
+                           << "> is not supported. List<T> supports parcelable/union, String, "
+                              "IBinder, and ParcelFileDescriptor.";
+          return false;
+        }
+      }
     } else if (type_name == "Map") {
       if (num_params != 0 && num_params != 2) {
         AIDL_ERROR(this) << "Map must have 0 or 2 type parameters, but got "
-                         << "'" << ToString() << "'";
+                         << "'" << Signature() << "'";
         return false;
       }
       if (num_params == 2) {
@@ -558,12 +619,25 @@
       AIDL_ERROR(this) << "Enum type cannot get nullable annotation";
       return false;
     }
+    if (GetName() == "ParcelableHolder") {
+      AIDL_ERROR(this) << "ParcelableHolder cannot be nullable.";
+      return false;
+    }
   }
   return true;
 }
 
-std::string AidlConstantValueDecorator(const AidlTypeSpecifier& /*type*/,
+std::string AidlConstantValueDecorator(const AidlTypeSpecifier& type,
                                        const std::string& raw_value) {
+  if (type.IsArray()) {
+    return raw_value;
+  }
+
+  if (auto defined_type = type.GetDefinedType(); defined_type) {
+    auto enum_type = defined_type->AsEnumDeclaration();
+    AIDL_FATAL_IF(!enum_type, type) << "Invalid type for \"" << raw_value << "\"";
+    return type.GetName() + "." + raw_value.substr(raw_value.find_last_of('.') + 1);
+  }
   return raw_value;
 }
 
@@ -576,12 +650,23 @@
 AidlVariableDeclaration::AidlVariableDeclaration(const AidlLocation& location,
                                                  AidlTypeSpecifier* type, const std::string& name,
                                                  AidlConstantValue* default_value)
-    : AidlNode(location),
+    : AidlMember(location, type->GetComments()),
       type_(type),
       name_(name),
       default_user_specified_(true),
       default_value_(default_value) {}
 
+bool AidlVariableDeclaration::HasUsefulDefaultValue() const {
+  if (GetDefaultValue()) {
+    return true;
+  }
+  // null is accepted as a valid default value in all backends
+  if (GetType().IsNullable()) {
+    return true;
+  }
+  return false;
+}
+
 bool AidlVariableDeclaration::CheckValid(const AidlTypenames& typenames) const {
   bool valid = true;
   valid &= type_->CheckValid(typenames);
@@ -600,8 +685,15 @@
   return !ValueString(AidlConstantValueDecorator).empty();
 }
 
+string AidlVariableDeclaration::GetCapitalizedName() const {
+  AIDL_FATAL_IF(name_.size() <= 0, *this) << "Name can't be empty.";
+  string str = name_;
+  str[0] = static_cast<char>(toupper(str[0]));
+  return str;
+}
+
 string AidlVariableDeclaration::ToString() const {
-  string ret = type_->Signature() + " " + name_;
+  string ret = type_->ToString() + " " + name_;
   if (default_value_ != nullptr && default_user_specified_) {
     ret += " = " + ValueString(AidlConstantValueDecorator);
   }
@@ -620,6 +712,14 @@
   }
 }
 
+void AidlVariableDeclaration::TraverseChildren(
+    std::function<void(const AidlNode&)> traverse) const {
+  traverse(GetType());
+  if (IsDefaultUserSpecified()) {
+    traverse(*GetDefaultValue());
+  }
+}
+
 AidlArgument::AidlArgument(const AidlLocation& location, AidlArgument::Direction direction,
                            AidlTypeSpecifier* type, const std::string& name)
     : AidlVariableDeclaration(location, type, name),
@@ -658,26 +758,38 @@
   }
 }
 
-std::string AidlArgument::Signature() const {
-  class AidlInterface;
-  class AidlInterface;
-  class AidlParcelable;
-  class AidlStructuredParcelable;
-  class AidlParcelable;
-  class AidlStructuredParcelable;
-  if (direction_specified_) {
-    return GetDirectionSpecifier() + " " + AidlVariableDeclaration::Signature();
-  } else {
-    return AidlVariableDeclaration::Signature();
+bool AidlCommentable::IsHidden() const {
+  return android::aidl::HasHideInComments(GetComments());
+}
+
+bool AidlCommentable::IsDeprecated() const {
+  return android::aidl::FindDeprecated(GetComments()).has_value();
+}
+
+// Dumps comment only if its has meaningful tags.
+void AidlCommentable::DumpComments(CodeWriter& out) const {
+  using namespace android::aidl;
+  const auto hidden = IsHidden();
+  const auto deprecated = FindDeprecated(GetComments());
+  if (hidden || deprecated) {
+    out << "/**\n";
+    if (hidden) {
+      out << " * @hide\n";
+    }
+    if (deprecated) {
+      out << " * @deprecated " << deprecated->note << "\n";
+    }
+    out << " */\n";
   }
 }
 
-AidlMember::AidlMember(const AidlLocation& location) : AidlNode(location) {}
+AidlMember::AidlMember(const AidlLocation& location, const Comments& comments)
+    : AidlCommentable(location, comments) {}
 
 AidlConstantDeclaration::AidlConstantDeclaration(const AidlLocation& location,
                                                  AidlTypeSpecifier* type, const std::string& name,
                                                  AidlConstantValue* value)
-    : AidlMember(location), type_(type), name_(name), value_(value) {}
+    : AidlMember(location, type->GetComments()), type_(type), name_(name), value_(value) {}
 
 bool AidlConstantDeclaration::CheckValid(const AidlTypenames& typenames) const {
   bool valid = true;
@@ -685,9 +797,9 @@
   valid &= value_->CheckValid();
   if (!valid) return false;
 
-  const static set<string> kSupportedConstTypes = {"String", "int"};
-  if (kSupportedConstTypes.find(type_->ToString()) == kSupportedConstTypes.end()) {
-    AIDL_ERROR(this) << "Constant of type " << type_->ToString() << " is not supported.";
+  const static set<string> kSupportedConstTypes = {"String", "byte", "int", "long"};
+  if (kSupportedConstTypes.find(type_->Signature()) == kSupportedConstTypes.end()) {
+    AIDL_ERROR(this) << "Constant of type " << type_->Signature() << " is not supported.";
     return false;
   }
 
@@ -705,17 +817,16 @@
 
 AidlMethod::AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type,
                        const std::string& name, std::vector<std::unique_ptr<AidlArgument>>* args,
-                       const std::string& comments)
+                       const Comments& comments)
     : AidlMethod(location, oneway, type, name, args, comments, 0, true) {
   has_id_ = false;
 }
 
 AidlMethod::AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type,
                        const std::string& name, std::vector<std::unique_ptr<AidlArgument>>* args,
-                       const std::string& comments, int id, bool is_user_defined)
-    : AidlMember(location),
+                       const Comments& comments, int id, bool is_user_defined)
+    : AidlMember(location, comments),
       oneway_(oneway),
-      comments_(comments),
       type_(type),
       name_(name),
       arguments_(std::move(*args)),
@@ -729,14 +840,10 @@
   }
 }
 
-bool AidlMethod::IsHidden() const {
-  return HasHideComment(GetComments());
-}
-
 string AidlMethod::Signature() const {
   vector<string> arg_signatures;
   for (const auto& arg : GetArguments()) {
-    arg_signatures.emplace_back(arg->GetType().ToString());
+    arg_signatures.emplace_back(arg->GetType().Signature());
   }
   return GetName() + "(" + Join(arg_signatures, ", ") + ")";
 }
@@ -744,9 +851,9 @@
 string AidlMethod::ToString() const {
   vector<string> arg_strings;
   for (const auto& arg : GetArguments()) {
-    arg_strings.emplace_back(arg->Signature());
+    arg_strings.emplace_back(arg->ToString());
   }
-  string ret = (IsOneway() ? "oneway " : "") + GetType().Signature() + " " + GetName() + "(" +
+  string ret = (IsOneway() ? "oneway " : "") + GetType().ToString() + " " + GetName() + "(" +
                Join(arg_strings, ", ") + ")";
   if (HasId()) {
     ret += " = " + std::to_string(GetId());
@@ -755,26 +862,40 @@
 }
 
 AidlDefinedType::AidlDefinedType(const AidlLocation& location, const std::string& name,
-                                 const std::string& comments, const std::string& package)
-    : AidlAnnotatable(location),
+                                 const Comments& comments, const std::string& package,
+                                 std::vector<std::unique_ptr<AidlMember>>* members)
+    : AidlAnnotatable(location, comments),
       name_(name),
-      comments_(comments),
       package_(package),
       split_package_(package.empty() ? std::vector<std::string>()
-                                     : android::base::Split(package, ".")) {}
+                                     : android::base::Split(package, ".")) {
+  if (members) {
+    for (auto& m : *members) {
+      if (auto constant = m->AsConstantDeclaration(); constant) {
+        constants_.emplace_back(constant);
+      } else if (auto variable = m->AsVariableDeclaration(); variable) {
+        variables_.emplace_back(variable);
+      } else if (auto method = m->AsMethod(); method) {
+        methods_.emplace_back(method);
+      } else {
+        AIDL_FATAL(*m);
+      }
+      members_.push_back(m.release());
+    }
+    delete members;
+  }
+}
 
 bool AidlDefinedType::CheckValid(const AidlTypenames& typenames) const {
   if (!AidlAnnotatable::CheckValid(typenames)) {
     return false;
   }
-
+  if (!CheckValidWithMembers(typenames)) {
+    return false;
+  }
   return true;
 }
 
-bool AidlDefinedType::IsHidden() const {
-  return HasHideComment(GetComments());
-}
-
 std::string AidlDefinedType::GetCanonicalName() const {
   if (package_.empty()) {
     return GetName();
@@ -783,16 +904,86 @@
 }
 
 void AidlDefinedType::DumpHeader(CodeWriter* writer) const {
-  if (this->IsHidden()) {
-    AddHideComment(writer);
-  }
+  DumpComments(*writer);
   DumpAnnotations(writer);
 }
 
+void AidlDefinedType::DumpMembers(CodeWriter& out) const {
+  for (const auto& method : GetMethods()) {
+    method->DumpComments(out);
+    out << method->ToString() << ";\n";
+  }
+  for (const auto& field : GetFields()) {
+    field->DumpComments(out);
+    out << field->ToString() << ";\n";
+  }
+  for (const auto& constdecl : GetConstantDeclarations()) {
+    constdecl->DumpComments(out);
+    out << constdecl->ToString() << ";\n";
+  }
+}
+
+bool AidlDefinedType::CheckValidWithMembers(const AidlTypenames& typenames) const {
+  bool success = true;
+
+  for (const auto& v : GetFields()) {
+    const bool field_valid = v->CheckValid(typenames);
+    success = success && field_valid;
+  }
+
+  // field names should be unique
+  std::set<std::string> fieldnames;
+  for (const auto& v : GetFields()) {
+    bool duplicated = !fieldnames.emplace(v->GetName()).second;
+    if (duplicated) {
+      AIDL_ERROR(v) << "'" << GetName() << "' has duplicate field name '" << v->GetName() << "'";
+      success = false;
+    }
+  }
+
+  // immutable parcelables should have immutable fields.
+  if (IsJavaOnlyImmutable()) {
+    for (const auto& v : GetFields()) {
+      if (!typenames.CanBeJavaOnlyImmutable(v->GetType())) {
+        AIDL_ERROR(v) << "The @JavaOnlyImmutable '" << GetName() << "' has a "
+                      << "non-immutable field named '" << v->GetName() << "'.";
+        success = false;
+      }
+    }
+  }
+
+  set<string> constant_names;
+  for (const auto& constant : GetConstantDeclarations()) {
+    if (constant_names.count(constant->GetName()) > 0) {
+      AIDL_ERROR(constant) << "Found duplicate constant name '" << constant->GetName() << "'";
+      success = false;
+    }
+    constant_names.insert(constant->GetName());
+    success = success && constant->CheckValid(typenames);
+  }
+
+  return success;
+}
+
+bool AidlDefinedType::CheckValidForGetterNames() const {
+  bool success = true;
+  std::set<std::string> getters;
+  for (const auto& v : GetFields()) {
+    bool duplicated = !getters.emplace(v->GetCapitalizedName()).second;
+    if (duplicated) {
+      AIDL_ERROR(v) << "'" << GetName() << "' has duplicate field name '" << v->GetName()
+                    << "' after capitalizing the first letter";
+      success = false;
+    }
+  }
+  return success;
+}
+
 AidlParcelable::AidlParcelable(const AidlLocation& location, const std::string& name,
-                               const std::string& package, const std::string& comments,
-                               const std::string& cpp_header, std::vector<std::string>* type_params)
-    : AidlDefinedType(location, name, comments, package),
+                               const std::string& package, const Comments& comments,
+                               const std::string& cpp_header, std::vector<std::string>* type_params,
+                               std::vector<std::unique_ptr<AidlMember>>* members)
+    : AidlDefinedType(location, name, comments, package, members),
       AidlParameterizable<std::string>(type_params),
       cpp_header_(cpp_header) {
   // Strip off quotation marks if we actually have a cpp header.
@@ -826,12 +1017,6 @@
   return true;
 }
 
-std::set<AidlAnnotation::Type> AidlParcelable::GetSupportedAnnotations() const {
-  return {AidlAnnotation::Type::VINTF_STABILITY,        AidlAnnotation::Type::UNSUPPORTED_APP_USAGE,
-          AidlAnnotation::Type::JAVA_STABLE_PARCELABLE, AidlAnnotation::Type::HIDE,
-          AidlAnnotation::Type::JAVA_PASSTHROUGH,       AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE};
-}
-
 bool AidlParcelable::CheckValid(const AidlTypenames& typenames) const {
   if (!AidlDefinedType::CheckValid(typenames)) {
     return false;
@@ -850,65 +1035,40 @@
 
 AidlStructuredParcelable::AidlStructuredParcelable(
     const AidlLocation& location, const std::string& name, const std::string& package,
-    const std::string& comments, std::vector<std::unique_ptr<AidlVariableDeclaration>>* variables,
-    std::vector<std::string>* type_params)
-    : AidlParcelable(location, name, package, comments, "" /*cpp_header*/, type_params),
-      variables_(std::move(*variables)) {}
+    const Comments& comments, std::vector<std::string>* type_params,
+    std::vector<std::unique_ptr<AidlMember>>* members)
+    : AidlParcelable(location, name, package, comments, "" /*cpp_header*/, type_params, members) {}
 
 void AidlStructuredParcelable::Dump(CodeWriter* writer) const {
   DumpHeader(writer);
   writer->Write("parcelable %s {\n", GetName().c_str());
   writer->Indent();
-  for (const auto& field : GetFields()) {
-    if (field->GetType().IsHidden()) {
-      AddHideComment(writer);
-    }
-    writer->Write("%s;\n", field->ToString().c_str());
-  }
+  DumpMembers(*writer);
   writer->Dedent();
   writer->Write("}\n");
 }
 
-std::set<AidlAnnotation::Type> AidlStructuredParcelable::GetSupportedAnnotations() const {
-  return {AidlAnnotation::Type::VINTF_STABILITY,
-          AidlAnnotation::Type::UNSUPPORTED_APP_USAGE,
-          AidlAnnotation::Type::HIDE,
-          AidlAnnotation::Type::JAVA_PASSTHROUGH,
-          AidlAnnotation::Type::JAVA_DEBUG,
-          AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE,
-          AidlAnnotation::Type::FIXED_SIZE,
-          AidlAnnotation::Type::RUST_DERIVE};
-}
-
 bool AidlStructuredParcelable::CheckValid(const AidlTypenames& typenames) const {
-  bool success = true;
   if (!AidlParcelable::CheckValid(typenames)) {
     return false;
   }
-  std::set<std::string> fieldnames;
-  for (const auto& v : GetFields()) {
-    const bool field_valid = v->CheckValid(typenames);
-    success = success && field_valid;
-    bool duplicated;
-    if (IsJavaOnlyImmutable()) {
-      success = success && typenames.CanBeJavaOnlyImmutable(v->GetType());
-      duplicated = !fieldnames.emplace(CapitalizeFirstLetter(*v, v->GetName())).second;
-    } else {
-      if (IsFixedSize()) {
-        if (field_valid && !typenames.CanBeFixedSize(v->GetType())) {
-          AIDL_ERROR(v) << "The @FixedSize parcelable '" << this->GetName() << "' has a "
-                        << "non-fixed size field named " << v->GetName() << ".";
-          success = false;
-        }
-      }
-      duplicated = !fieldnames.emplace(v->GetName()).second;
-    }
 
-    if (duplicated) {
-      AIDL_ERROR(this) << "The parcelable '" << this->GetName() << "' has duplicate field name '"
-                       << v->GetName() << "'"
-                       << (IsJavaOnlyImmutable() ? " after capitalizing the first letter" : "");
-      return false;
+  bool success = true;
+
+  if (IsFixedSize()) {
+    for (const auto& v : GetFields()) {
+      if (!typenames.CanBeFixedSize(v->GetType())) {
+        AIDL_ERROR(v) << "The @FixedSize parcelable '" << this->GetName() << "' has a "
+                      << "non-fixed size field named " << v->GetName() << ".";
+        success = false;
+      }
+    }
+  }
+
+  if (IsJavaOnlyImmutable()) {
+    // Immutable parcelables provide getters
+    if (!CheckValidForGetterNames()) {
+      success = false;
     }
   }
 
@@ -920,60 +1080,48 @@
                                                    Options::Language lang) const {
   if ((lang == Options::Language::NDK || lang == Options::Language::RUST) && IsArray() &&
       GetName() == "IBinder") {
-    AIDL_ERROR(this) << "The " << Options::LanguageToString(lang)
-                     << " backend does not support array of IBinder";
+    AIDL_ERROR(this) << "The " << to_string(lang) << " backend does not support array of IBinder";
     return false;
   }
-  if ((lang == Options::Language::NDK || lang == Options::Language::RUST) &&
-      GetName() == "ParcelableHolder") {
-    // TODO(b/146611855): Remove it when both NDK and Rust backend support ParcelableHolder
-    AIDL_ERROR(this) << "The NDK and Rust backend does not support ParcelableHolder yet.";
+  if (lang == Options::Language::RUST && GetName() == "ParcelableHolder") {
+    // TODO(b/146611855): Remove it when Rust backend supports ParcelableHolder
+    AIDL_ERROR(this) << "The Rust backend does not support ParcelableHolder yet.";
     return false;
   }
   if ((lang == Options::Language::NDK || lang == Options::Language::RUST) && IsArray() &&
       IsNullable()) {
     if (GetName() == "ParcelFileDescriptor") {
-      AIDL_ERROR(this) << "The " << Options::LanguageToString(lang)
+      AIDL_ERROR(this) << "The " << to_string(lang)
                        << " backend does not support nullable array of ParcelFileDescriptor";
       return false;
     }
 
     const auto defined_type = typenames.TryGetDefinedType(GetName());
     if (defined_type != nullptr && defined_type->AsParcelable() != nullptr) {
-      AIDL_ERROR(this) << "The " << Options::LanguageToString(lang)
+      AIDL_ERROR(this) << "The " << to_string(lang)
                        << " backend does not support nullable array of parcelable";
       return false;
     }
   }
   if (this->GetName() == "FileDescriptor" &&
       (lang == Options::Language::NDK || lang == Options::Language::RUST)) {
-    AIDL_ERROR(this) << "FileDescriptor isn't supported by the " << Options::LanguageToString(lang)
-                     << " backend.";
+    AIDL_ERROR(this) << "FileDescriptor isn't supported by the " << to_string(lang) << " backend.";
     return false;
   }
   if (this->IsGeneric()) {
     if (this->GetName() == "List") {
-      if (this->GetTypeParameters().size() != 1) {
-        AIDL_ERROR(this) << "List must have only one type parameter.";
-        return false;
-      }
-      if (lang == Options::Language::CPP) {
-        const string& contained_type = this->GetTypeParameters()[0]->GetName();
-        if (!(contained_type == "String" || contained_type == "IBinder")) {
-          AIDL_ERROR(this) << "List<" << contained_type
-                           << "> is not supported. List in cpp supports only String and IBinder.";
+      if (lang == Options::Language::NDK) {
+        const AidlTypeSpecifier& contained_type = *GetTypeParameters()[0];
+        const string& contained_type_name = contained_type.GetName();
+        if (typenames.GetInterface(contained_type)) {
+          AIDL_ERROR(this) << "List<" << contained_type_name
+                           << "> is not supported. List in NDK doesn't support interface.";
           return false;
         }
-      } else if (lang == Options::Language::JAVA) {
-        const string& contained_type = this->GetTypeParameters()[0]->GetName();
-        if (AidlTypenames::IsBuiltinTypename(contained_type)) {
-          if (contained_type != "String" && contained_type != "IBinder" &&
-              contained_type != "ParcelFileDescriptor") {
-            AIDL_ERROR(this) << "List<" << contained_type
-                             << "> is not supported. List in Java supports only String, IBinder, "
-                                "and ParcelFileDescriptor.";
-            return false;
-          }
+        if (contained_type_name == "IBinder") {
+          AIDL_ERROR(this) << "List<" << contained_type_name
+                           << "> is not supported. List in NDK doesn't support IBinder.";
+          return false;
         }
       }
     }
@@ -1032,8 +1180,11 @@
 }
 
 AidlEnumerator::AidlEnumerator(const AidlLocation& location, const std::string& name,
-                               AidlConstantValue* value, const std::string& comments)
-    : AidlNode(location), name_(name), value_(value), comments_(comments) {}
+                               AidlConstantValue* value, const Comments& comments)
+    : AidlCommentable(location, comments),
+      name_(name),
+      value_(value),
+      value_user_specified_(value != nullptr) {}
 
 bool AidlEnumerator::CheckValid(const AidlTypeSpecifier& enum_backing_type) const {
   if (GetValue() == nullptr) {
@@ -1056,45 +1207,62 @@
 
 AidlEnumDeclaration::AidlEnumDeclaration(const AidlLocation& location, const std::string& name,
                                          std::vector<std::unique_ptr<AidlEnumerator>>* enumerators,
-                                         const std::string& package, const std::string& comments)
-    : AidlDefinedType(location, name, comments, package), enumerators_(std::move(*enumerators)) {}
-
-void AidlEnumDeclaration::SetBackingType(std::unique_ptr<const AidlTypeSpecifier> type) {
-  backing_type_ = std::move(type);
-}
-
-bool AidlEnumDeclaration::Autofill() {
+                                         const std::string& package, const Comments& comments)
+    : AidlDefinedType(location, name, comments, package, nullptr),
+      enumerators_(std::move(*enumerators)) {
+  // Fill missing enumerator values with <prev + 1>
+  // This can't be done in Autofill() because type/ref resolution depends on this.
+  // For example, with enum E { A, B = A }, B's value 'A' is a reference which can't be
+  // resolved if A has no value set.
   const AidlEnumerator* previous = nullptr;
   for (const auto& enumerator : enumerators_) {
     if (enumerator->GetValue() == nullptr) {
+      auto loc = enumerator->GetLocation();
       if (previous == nullptr) {
         enumerator->SetValue(
-            std::unique_ptr<AidlConstantValue>(AidlConstantValue::Integral(GetLocation(), "0")));
+            std::unique_ptr<AidlConstantValue>(AidlConstantValue::Integral(loc, "0")));
       } else {
-        auto prev_value = std::unique_ptr<AidlConstantValue>(
-            AidlConstantValue::ShallowIntegralCopy(*previous->GetValue()));
-        if (prev_value == nullptr) {
-          return false;
-        }
+        auto prev_value = std::make_unique<AidlConstantReference>(loc, previous->GetName());
         enumerator->SetValue(std::make_unique<AidlBinaryConstExpression>(
-            GetLocation(), std::move(prev_value), "+",
-            std::unique_ptr<AidlConstantValue>(AidlConstantValue::Integral(GetLocation(), "1"))));
+            loc, std::move(prev_value), "+",
+            std::unique_ptr<AidlConstantValue>(AidlConstantValue::Integral(loc, "1"))));
       }
     }
     previous = enumerator.get();
   }
-  return true;
 }
 
-std::set<AidlAnnotation::Type> AidlEnumDeclaration::GetSupportedAnnotations() const {
-  return {AidlAnnotation::Type::VINTF_STABILITY, AidlAnnotation::Type::BACKING,
-          AidlAnnotation::Type::HIDE, AidlAnnotation::Type::JAVA_PASSTHROUGH};
+bool AidlEnumDeclaration::Autofill(const AidlTypenames& typenames) {
+  if (auto annot = BackingType(); annot != nullptr) {
+    // Autofill() is called before the grand CheckValid(). But AidlAnnotation::ParamValue()
+    // calls AidlConstantValue::evaluate() which requires CheckValid() to be called before. So we
+    // need to call CheckValid().
+    if (!annot->CheckValid()) {
+      return false;
+    }
+    auto type = annot->ParamValue<std::string>("type").value();
+    backing_type_ =
+        std::make_unique<AidlTypeSpecifier>(annot->GetLocation(), type, false, nullptr, Comments{});
+  } else {
+    // Default to byte type for enums.
+    backing_type_ =
+        std::make_unique<AidlTypeSpecifier>(AIDL_LOCATION_HERE, "byte", false, nullptr, Comments{});
+  }
+  // Autofill() is called after type resolution, we resolve the backing type manually.
+  if (!backing_type_->Resolve(typenames)) {
+    AIDL_ERROR(this) << "Invalid backing type: " << backing_type_->GetName();
+  }
+  return true;
 }
 
 bool AidlEnumDeclaration::CheckValid(const AidlTypenames& typenames) const {
   if (!AidlDefinedType::CheckValid(typenames)) {
     return false;
   }
+  if (!GetMembers().empty()) {
+    AIDL_ERROR(this) << "Enum doesn't support fields/constants/methods.";
+    return false;
+  }
   if (backing_type_ == nullptr) {
     AIDL_ERROR(this) << "Enum declaration missing backing type.";
     return false;
@@ -1103,6 +1271,7 @@
   for (const auto& enumerator : enumerators_) {
     success = success && enumerator->CheckValid(GetBackingType());
   }
+
   return success;
 }
 
@@ -1118,6 +1287,88 @@
   writer->Write("}\n");
 }
 
+AidlUnionDecl::AidlUnionDecl(const AidlLocation& location, const std::string& name,
+                             const std::string& package, const Comments& comments,
+                             std::vector<std::string>* type_params,
+                             std::vector<std::unique_ptr<AidlMember>>* members)
+    : AidlParcelable(location, name, package, comments, "" /*cpp_header*/, type_params, members) {}
+
+void AidlUnionDecl::Dump(CodeWriter* writer) const {
+  DumpHeader(writer);
+  writer->Write("union %s {\n", GetName().c_str());
+  writer->Indent();
+  DumpMembers(*writer);
+  writer->Dedent();
+  writer->Write("}\n");
+}
+
+bool AidlUnionDecl::CheckValid(const AidlTypenames& typenames) const {
+  // visit parents
+  if (!AidlParcelable::CheckValid(typenames)) {
+    return false;
+  }
+
+  // unions provide getters always
+  if (!CheckValidForGetterNames()) {
+    return false;
+  }
+
+  // now, visit self!
+  bool success = true;
+
+  // TODO(b/170807936) do we need to allow ParcelableHolder in union?
+  for (const auto& v : GetFields()) {
+    if (v->GetType().GetName() == "ParcelableHolder") {
+      AIDL_ERROR(*v) << "A union can't have a member of ParcelableHolder '" << v->GetName() << "'";
+      success = false;
+    }
+  }
+
+  if (GetFields().empty()) {
+    AIDL_ERROR(*this) << "The union '" << this->GetName() << "' has no fields.";
+    return false;
+  }
+
+  // first member should have useful default value (implicit or explicit)
+  const auto& first = GetFields()[0];
+  if (!first->HasUsefulDefaultValue()) {
+    // Most types can be initialized without a default value. For example,
+    // interface types are inherently nullable. But, enum types should have
+    // an explicit default value.
+    if (!first->GetType().IsArray() && typenames.GetEnumDeclaration(first->GetType())) {
+      AIDL_ERROR(first)
+          << "The union's first member should have a useful default value. Enum types can be "
+             "initialized with a reference. (e.g. ... = MyEnum.FOO;)";
+      return false;
+    }
+    // In Java, array types are initialized as null without a default value. To be sure that default
+    // initialized unions are accepted by other backends we require arrays also have a default
+    // value.
+    if (first->GetType().IsArray()) {
+      AIDL_ERROR(first)
+          << "The union's first member should have a useful default value. Arrays can be "
+             "initialized with values(e.g. ... = { values... };) or marked as @nullable.";
+      return false;
+    }
+  }
+
+  return success;
+}
+
+// TODO: we should treat every backend all the same in future.
+bool AidlUnionDecl::LanguageSpecificCheckValid(const AidlTypenames& typenames,
+                                               Options::Language lang) const {
+  if (!AidlParcelable::LanguageSpecificCheckValid(typenames, lang)) {
+    return false;
+  }
+  for (const auto& v : this->GetFields()) {
+    if (!v->GetType().LanguageSpecificCheckValid(typenames, lang)) {
+      return false;
+    }
+  }
+  return true;
+}
+
 // TODO: we should treat every backend all the same in future.
 bool AidlInterface::LanguageSpecificCheckValid(const AidlTypenames& typenames,
                                                Options::Language lang) const {
@@ -1135,56 +1386,23 @@
 }
 
 AidlInterface::AidlInterface(const AidlLocation& location, const std::string& name,
-                             const std::string& comments, bool oneway,
-                             std::vector<std::unique_ptr<AidlMember>>* members,
-                             const std::string& package)
-    : AidlDefinedType(location, name, comments, package) {
-  for (auto& member : *members) {
-    AidlMember* local = member.release();
-    AidlMethod* method = local->AsMethod();
-    AidlConstantDeclaration* constant = local->AsConstantDeclaration();
-
-    AIDL_FATAL_IF(method != nullptr && constant != nullptr, member);
-
-    if (method) {
-      method->ApplyInterfaceOneway(oneway);
-      methods_.emplace_back(method);
-    } else if (constant) {
-      constants_.emplace_back(constant);
-    } else {
-      AIDL_FATAL(this) << "Member is neither method nor constant!";
-    }
+                             const Comments& comments, bool oneway, const std::string& package,
+                             std::vector<std::unique_ptr<AidlMember>>* members)
+    : AidlDefinedType(location, name, comments, package, members) {
+  for (auto& m : GetMethods()) {
+    m.get()->ApplyInterfaceOneway(oneway);
   }
-
-  delete members;
 }
 
 void AidlInterface::Dump(CodeWriter* writer) const {
   DumpHeader(writer);
   writer->Write("interface %s {\n", GetName().c_str());
   writer->Indent();
-  for (const auto& method : GetMethods()) {
-    if (method->IsHidden()) {
-      AddHideComment(writer);
-    }
-    writer->Write("%s;\n", method->ToString().c_str());
-  }
-  for (const auto& constdecl : GetConstantDeclarations()) {
-    if (constdecl->GetType().IsHidden()) {
-      AddHideComment(writer);
-    }
-    writer->Write("%s;\n", constdecl->ToString().c_str());
-  }
+  DumpMembers(*writer);
   writer->Dedent();
   writer->Write("}\n");
 }
 
-std::set<AidlAnnotation::Type> AidlInterface::GetSupportedAnnotations() const {
-  return {AidlAnnotation::Type::VINTF_STABILITY, AidlAnnotation::Type::UNSUPPORTED_APP_USAGE,
-          AidlAnnotation::Type::HIDE, AidlAnnotation::Type::JAVA_PASSTHROUGH,
-          AidlAnnotation::Type::DESCRIPTOR};
-}
-
 bool AidlInterface::CheckValid(const AidlTypenames& typenames) const {
   if (!AidlDefinedType::CheckValid(typenames)) {
     return false;
@@ -1229,15 +1447,17 @@
         AIDL_ERROR(m) << "oneway method '" << m->GetName() << "' cannot have out parameters";
         return false;
       }
-      const bool can_be_out = typenames.CanBeOutParameter(arg->GetType());
+
+      const auto [can_be_out, type_aspect] = typenames.CanBeOutParameter(arg->GetType());
       if (!arg->DirectionWasSpecified() && can_be_out) {
-        AIDL_ERROR(arg) << "'" << arg->GetType().ToString()
+        AIDL_ERROR(arg) << "'" << arg->GetType().Signature()
                         << "' can be an out type, so you must declare it as in, out, or inout.";
         return false;
       }
 
       if (arg->GetDirection() != AidlArgument::IN_DIR && !can_be_out) {
-        AIDL_ERROR(arg) << "'" << arg->ToString() << "' can only be an in parameter.";
+        AIDL_ERROR(arg) << "'" << arg->GetName() << "' can't be an " << arg->GetDirectionSpecifier()
+                        << " parameter because " << type_aspect << " can only be an in parameter.";
         return false;
       }
 
@@ -1275,7 +1495,7 @@
 
   bool success = true;
   set<string> constant_names;
-  for (const std::unique_ptr<AidlConstantDeclaration>& constant : GetConstantDeclarations()) {
+  for (const auto& constant : GetConstantDeclarations()) {
     if (constant_names.count(constant->GetName()) > 0) {
       AIDL_ERROR(constant) << "Found duplicate constant name '" << constant->GetName() << "'";
       success = false;
@@ -1283,7 +1503,6 @@
     constant_names.insert(constant->GetName());
     success = success && constant->CheckValid(typenames);
   }
-
   return success;
 }
 
@@ -1295,5 +1514,35 @@
   return GetCanonicalName();
 }
 
-AidlImport::AidlImport(const AidlLocation& location, const std::string& needed_class)
-    : AidlNode(location), needed_class_(needed_class) {}
+AidlImport::AidlImport(const AidlLocation& location, const std::string& needed_class,
+                       const Comments& comments)
+    : AidlNode(location, comments), needed_class_(needed_class) {}
+
+// Resolves unresolved type name to fully qualified typename to import
+// case #1: SimpleName --> import p.SimpleName
+// case #2: Outer.Inner --> import p.Outer
+// case #3: p.SimpleName --> (as is)
+std::optional<std::string> AidlDocument::ResolveName(const std::string& unresolved_name) const {
+  std::string canonical_name;
+  const auto first_dot = unresolved_name.find_first_of('.');
+  const std::string class_name =
+      (first_dot == std::string::npos) ? unresolved_name : unresolved_name.substr(0, first_dot);
+  for (const auto& import : Imports()) {
+    const auto& fq_name = import->GetNeededClass();
+    const auto last_dot = fq_name.find_last_of('.');
+    const std::string imported_type_name =
+        (last_dot == std::string::npos) ? fq_name : fq_name.substr(last_dot + 1);
+    if (imported_type_name == class_name) {
+      if (canonical_name != "" && canonical_name != fq_name) {
+        AIDL_ERROR(import) << "Ambiguous type: " << canonical_name << " vs. " << fq_name;
+        return {};
+      }
+      canonical_name = fq_name;
+    }
+  }
+  // if not found, use unresolved_name as it is
+  if (canonical_name == "") {
+    return unresolved_name;
+  }
+  return canonical_name;
+}
diff --git a/aidl_language.h b/aidl_language.h
index ae9bf15..ca45103 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -16,11 +16,6 @@
 
 #pragma once
 
-#include "aidl_typenames.h"
-#include "code_writer.h"
-#include "io_delegate.h"
-#include "options.h"
-
 #include <memory>
 #include <regex>
 #include <string>
@@ -29,8 +24,18 @@
 
 #include <android-base/strings.h>
 
+#include "aidl_typenames.h"
+#include "code_writer.h"
+#include "comments.h"
+#include "diagnostics.h"
+#include "io_delegate.h"
+#include "location.h"
+#include "logging.h"
+#include "options.h"
+
 using android::aidl::AidlTypenames;
 using android::aidl::CodeWriter;
+using android::aidl::Comments;
 using android::aidl::Options;
 using std::shared_ptr;
 using std::string;
@@ -38,6 +43,26 @@
 using std::vector;
 class AidlNode;
 
+// helper to see if T is the same to one of Args types.
+template <typename T, typename... Args>
+struct is_one_of : std::false_type {};
+
+template <typename T, typename S, typename... Args>
+struct is_one_of<T, S, Args...> {
+  enum { value = std::is_same_v<T, S> || is_one_of<T, Args...>::value };
+};
+
+// helper to see if T is std::vector of something.
+template <typename>
+struct is_vector : std::false_type {};
+
+template <typename T>
+struct is_vector<std::vector<T>> : std::true_type {};
+
+// helper for static_assert(false)
+template <typename T>
+struct unsupported_type : std::false_type {};
+
 namespace android {
 namespace aidl {
 namespace mappings {
@@ -49,51 +74,57 @@
 }  // namespace aidl
 }  // namespace android
 
-class AidlLocation {
+bool ParseFloating(std::string_view sv, double* parsed);
+bool ParseFloating(std::string_view sv, float* parsed);
+
+class AidlDocument;
+class AidlPackage;
+class AidlImport;
+class AidlInterface;
+class AidlParcelable;
+class AidlStructuredParcelable;
+class AidlEnumDeclaration;
+class AidlUnionDecl;
+class AidlVariableDeclaration;
+class AidlConstantDeclaration;
+class AidlEnumerator;
+class AidlMethod;
+class AidlArgument;
+class AidlConstantValue;
+class AidlConstantReference;
+class AidlUnaryConstExpression;
+class AidlBinaryConstExpression;
+class AidlAnnotation;
+
+// Interface for visitors that can traverse AidlTraversable nodes.
+class AidlVisitor {
  public:
-  struct Point {
-    int line;
-    int column;
-  };
-
-  enum class Source {
-    // From internal aidl source code
-    INTERNAL = 0,
-    // From a parsed file
-    EXTERNAL = 1
-  };
-
-  AidlLocation(const std::string& file, Point begin, Point end, Source source);
-  AidlLocation(const std::string& file, Source source)
-      : AidlLocation(file, {0, 0}, {0, 0}, source) {}
-
-  bool IsInternal() const { return source_ == Source::INTERNAL; }
-
-  // The first line of a file is line 1.
-  bool LocationKnown() const { return begin_.line != 0; }
-
-  friend std::ostream& operator<<(std::ostream& os, const AidlLocation& l);
-  friend class AidlNode;
-
- private:
-  // INTENTIONALLY HIDDEN: only operator<< should access details here.
-  // Otherwise, locations should only ever be copied around to construct new
-  // objects.
-  const std::string file_;
-  Point begin_;
-  Point end_;
-  Source source_;
+  virtual ~AidlVisitor() = default;
+  virtual void Visit(const AidlDocument&) {}
+  virtual void Visit(const AidlInterface&) {}
+  virtual void Visit(const AidlParcelable&) {}
+  virtual void Visit(const AidlStructuredParcelable&) {}
+  virtual void Visit(const AidlUnionDecl&) {}
+  virtual void Visit(const AidlEnumDeclaration&) {}
+  virtual void Visit(const AidlEnumerator&) {}
+  virtual void Visit(const AidlMethod&) {}
+  virtual void Visit(const AidlVariableDeclaration&) {}
+  virtual void Visit(const AidlConstantDeclaration&) {}
+  virtual void Visit(const AidlArgument&) {}
+  virtual void Visit(const AidlTypeSpecifier&) {}
+  virtual void Visit(const AidlConstantValue&) {}
+  virtual void Visit(const AidlConstantReference&) {}
+  virtual void Visit(const AidlUnaryConstExpression&) {}
+  virtual void Visit(const AidlBinaryConstExpression&) {}
+  virtual void Visit(const AidlAnnotation&) {}
+  virtual void Visit(const AidlImport&) {}
+  virtual void Visit(const AidlPackage&) {}
 };
 
-#define AIDL_LOCATION_HERE \
-  (AidlLocation{__FILE__, {__LINE__, 0}, {__LINE__, 0}, AidlLocation::Source::INTERNAL})
-
-std::ostream& operator<<(std::ostream& os, const AidlLocation& l);
-
 // Anything that is locatable in a .aidl file.
 class AidlNode {
  public:
-  AidlNode(const AidlLocation& location);
+  AidlNode(const AidlLocation& location, const Comments& comments = {});
 
   AidlNode(const AidlNode&) = default;
   virtual ~AidlNode() = default;
@@ -107,21 +138,19 @@
   friend std::string android::aidl::java::dump_location(const AidlNode&);
 
   const AidlLocation& GetLocation() const { return location_; }
+  virtual void TraverseChildren(std::function<void(const AidlNode&)> traverse) const = 0;
+  virtual void DispatchVisit(AidlVisitor&) const = 0;
+
+  const Comments& GetComments() const { return comments_; }
+  void SetComments(const Comments& comments) { comments_ = comments; }
 
  private:
   std::string PrintLine() const;
   std::string PrintLocation() const;
   const AidlLocation location_;
+  Comments comments_;
 };
 
-namespace android {
-namespace aidl {
-
-class AidlTypenames;
-
-}  // namespace aidl
-}  // namespace android
-
 // unique_ptr<AidlTypeSpecifier> for type arugment,
 // std::string for type parameter(T, U, and so on).
 template <typename T>
@@ -133,21 +162,35 @@
   const std::vector<T>& GetTypeParameters() const { return *type_params_; }
   bool CheckValid() const;
 
+  __attribute__((warn_unused_result)) bool SetTypeParameters(std::vector<T>* type_params) {
+    if (type_params_) return false;
+    type_params_.reset(type_params);
+    return true;
+  }
+
   virtual const AidlNode& AsAidlNode() const = 0;
 
  protected:
   AidlParameterizable(const AidlParameterizable&);
 
  private:
-  const unique_ptr<std::vector<T>> type_params_;
+  unique_ptr<std::vector<T>> type_params_;
   static_assert(std::is_same<T, unique_ptr<AidlTypeSpecifier>>::value ||
                 std::is_same<T, std::string>::value);
 };
 template <>
 bool AidlParameterizable<std::string>::CheckValid() const;
 
-class AidlConstantValue;
-class AidlConstantDeclaration;
+class AidlCommentable : public AidlNode {
+ public:
+  AidlCommentable(const AidlLocation& location, const Comments& comments)
+      : AidlNode(location, comments) {}
+  virtual ~AidlCommentable() = default;
+
+  bool IsHidden() const;
+  bool IsDeprecated() const;
+  void DumpComments(CodeWriter& out) const;
+};
 
 // Transforms a value string into a language specific form. Raw value as produced by
 // AidlConstantValue.
@@ -164,49 +207,93 @@
     VINTF_STABILITY,
     NULLABLE,
     UTF8_IN_CPP,
+    SENSITIVE_DATA,
     JAVA_PASSTHROUGH,
-    JAVA_DEBUG,
+    JAVA_DERIVE,
     JAVA_ONLY_IMMUTABLE,
     FIXED_SIZE,
     DESCRIPTOR,
     RUST_DERIVE,
+    SUPPRESS_WARNINGS,
   };
+
+  using TargetContext = uint16_t;
+  static constexpr TargetContext CONTEXT_TYPE_INTERFACE = 0x1 << 0;
+  static constexpr TargetContext CONTEXT_TYPE_ENUM = 0x1 << 1;
+  static constexpr TargetContext CONTEXT_TYPE_STRUCTURED_PARCELABLE = 0x1 << 2;
+  static constexpr TargetContext CONTEXT_TYPE_UNION = 0x1 << 3;
+  static constexpr TargetContext CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE = 0x1 << 4;
+  static constexpr TargetContext CONTEXT_TYPE =
+      CONTEXT_TYPE_INTERFACE | CONTEXT_TYPE_ENUM | CONTEXT_TYPE_STRUCTURED_PARCELABLE |
+      CONTEXT_TYPE_UNION | CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE;
+  static constexpr TargetContext CONTEXT_CONST = 0x1 << 5;
+  static constexpr TargetContext CONTEXT_FIELD = 0x1 << 6;
+  static constexpr TargetContext CONTEXT_METHOD = 0x1 << 7;
+  static constexpr TargetContext CONTEXT_MEMBER = CONTEXT_CONST | CONTEXT_FIELD | CONTEXT_METHOD;
+  static constexpr TargetContext CONTEXT_TYPE_SPECIFIER = 0x1 << 8;
+  static constexpr TargetContext CONTEXT_ALL =
+      CONTEXT_TYPE | CONTEXT_MEMBER | CONTEXT_TYPE_SPECIFIER;
+
   static std::string TypeToString(Type type);
 
   static AidlAnnotation* Parse(
       const AidlLocation& location, const string& name,
-      std::map<std::string, std::shared_ptr<AidlConstantValue>>* parameter_list);
+      std::map<std::string, std::shared_ptr<AidlConstantValue>>* parameter_list,
+      const Comments& comments);
 
   AidlAnnotation(const AidlAnnotation&) = default;
   AidlAnnotation(AidlAnnotation&&) = default;
   virtual ~AidlAnnotation() = default;
   bool CheckValid() const;
-
-  const string& GetName() const { return schema_.name; };
+  bool CheckContext(TargetContext context) const;
+  const string& GetName() const { return schema_.name; }
   const Type& GetType() const { return schema_.type; }
-  string ToString(const ConstantValueDecorator& decorator) const;
+  bool Repeatable() const { return schema_.repeatable; }
+
+  // ToString is for dumping AIDL.
+  // Returns string representation of this annotation.
+  // e.g) "@RustDerive(Clone=true, Copy=true)"
+  string ToString() const;
+
+  template <typename T>
+  std::optional<T> ParamValue(const std::string& param_name) const;
+
   std::map<std::string, std::string> AnnotationParams(
       const ConstantValueDecorator& decorator) const;
-  const string& GetComments() const { return comments_; }
-  void SetComments(const string& comments) { comments_ = comments; }
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override;
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
+  struct ParamType {
+    std::string name;
+    const AidlTypeSpecifier& type;
+    bool required = false;
+  };
+
   struct Schema {
     AidlAnnotation::Type type;
-
-    // text name in .aidl file, e.g. "nullable"
     std::string name;
+    TargetContext target_context;
+    std::vector<ParamType> parameters;
+    bool repeatable = false;
 
-    // map from param name -> value type
-    std::map<std::string, std::string> supported_parameters;
+    const ParamType* ParamType(const std::string& name) const {
+      for (const auto& param : parameters) {
+        if (param.name == name) {
+          return &param;
+        }
+      }
+      return nullptr;
+    }
   };
+
   static const std::vector<Schema>& AllSchemas();
 
   AidlAnnotation(const AidlLocation& location, const Schema& schema,
-                 std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters);
+                 std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters,
+                 const Comments& comments);
 
   const Schema& schema_;
-  string comments_;
   std::map<std::string, std::shared_ptr<AidlConstantValue>> parameters_;
 };
 
@@ -217,9 +304,9 @@
   return lhs.GetName() == rhs.GetName();
 }
 
-class AidlAnnotatable : public AidlNode {
+class AidlAnnotatable : public AidlCommentable {
  public:
-  AidlAnnotatable(const AidlLocation& location);
+  AidlAnnotatable(const AidlLocation& location, const Comments& comments);
 
   AidlAnnotatable(const AidlAnnotatable&) = default;
   AidlAnnotatable(AidlAnnotatable&&) = default;
@@ -232,27 +319,34 @@
   }
   bool IsNullable() const;
   bool IsUtf8InCpp() const;
+  bool IsSensitiveData() const;
   bool IsVintfStability() const;
   bool IsJavaOnlyImmutable() const;
   bool IsFixedSize() const;
   bool IsStableApiParcelable(Options::Language lang) const;
   bool IsHide() const;
-  bool IsJavaDebug() const;
+  bool JavaDerive(const std::string& method) const;
   std::string GetDescriptor() const;
 
   void DumpAnnotations(CodeWriter* writer) const;
 
   const AidlAnnotation* UnsupportedAppUsage() const;
-  const AidlAnnotation* JavaPassthrough() const;
   const AidlAnnotation* RustDerive() const;
-  const AidlTypeSpecifier* BackingType(const AidlTypenames& typenames) const;
+  const AidlAnnotation* BackingType() const;
+  std::vector<std::string> SuppressWarnings() const;
+
+  // ToString is for dumping AIDL.
+  // Returns string representation of annotations.
+  // e.g) "@JavaDerive(toString=true) @RustDerive(Clone=true, Copy=true)"
   std::string ToString() const;
 
   const vector<AidlAnnotation>& GetAnnotations() const { return annotations_; }
-  virtual bool CheckValid(const AidlTypenames&) const;
-
- protected:
-  virtual std::set<AidlAnnotation::Type> GetSupportedAnnotations() const = 0;
+  bool CheckValid(const AidlTypenames&) const;
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    for (const auto& annot : GetAnnotations()) {
+      traverse(annot);
+    }
+  }
 
  private:
   vector<AidlAnnotation> annotations_;
@@ -264,11 +358,11 @@
                                 public AidlParameterizable<unique_ptr<AidlTypeSpecifier>> {
  public:
   AidlTypeSpecifier(const AidlLocation& location, const string& unresolved_name, bool is_array,
-                    vector<unique_ptr<AidlTypeSpecifier>>* type_params, const string& comments);
+                    vector<unique_ptr<AidlTypeSpecifier>>* type_params, const Comments& comments);
   virtual ~AidlTypeSpecifier() = default;
 
   // Copy of this type which is not an array.
-  AidlTypeSpecifier ArrayBase() const;
+  const AidlTypeSpecifier& ArrayBase() const;
 
   // Returns the full-qualified name of the base type.
   // int -> int
@@ -283,53 +377,97 @@
     }
   }
 
-  // Returns string representation of this type specifier.
-  // This is GetBaseTypeName() + array modifier or generic type parameters
-  string ToString() const;
+  // ToString is for dumping AIDL.
+  // Returns string representation of this type specifier including annotations.
+  // This is "annotations type_name type_params? array_marker?".
+  // e.g) "@utf8InCpp String[]";
+  std::string ToString() const;
 
+  // Signature is for comparing AIDL types.
+  // Returns string representation of this type specifier.
+  // This is "type_name type_params? array_marker?".
+  // e.g.) "String[]" (even if it is annotated with @utf8InCpp)
   std::string Signature() const;
 
   const string& GetUnresolvedName() const { return unresolved_name_; }
 
-  bool IsHidden() const;
-
-  const string& GetComments() const { return comments_; }
-
   const std::vector<std::string> GetSplitName() const { return split_name_; }
 
-  void SetComments(const string& comment) { comments_ = comment; }
-
   bool IsResolved() const { return fully_qualified_name_ != ""; }
 
   bool IsArray() const { return is_array_; }
 
+  __attribute__((warn_unused_result)) bool SetArray() {
+    if (is_array_) return false;
+    is_array_ = true;
+    return true;
+  }
+
   // Resolve the base type name to a fully-qualified name. Return false if the
   // resolution fails.
   bool Resolve(const AidlTypenames& typenames);
 
-  std::set<AidlAnnotation::Type> GetSupportedAnnotations() const override;
-  bool CheckValid(const AidlTypenames& typenames) const override;
+  bool CheckValid(const AidlTypenames& typenames) const;
   bool LanguageSpecificCheckValid(const AidlTypenames& typenames, Options::Language lang) const;
   const AidlNode& AsAidlNode() const override { return *this; }
 
+  const AidlDefinedType* GetDefinedType() const;
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    AidlAnnotatable::TraverseChildren(traverse);
+    if (IsGeneric()) {
+      for (const auto& tp : GetTypeParameters()) {
+        traverse(*tp);
+      }
+    }
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+
  private:
   AidlTypeSpecifier(const AidlTypeSpecifier&) = default;
 
   const string unresolved_name_;
   string fully_qualified_name_;
   bool is_array_;
-  string comments_;
   vector<string> split_name_;
+  const AidlDefinedType* defined_type_ = nullptr;  // set when Resolve() for defined types
+  mutable shared_ptr<AidlTypeSpecifier> array_base_;
 };
 
 // Returns the universal value unaltered.
 std::string AidlConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value);
 
-class AidlConstantValue;
+class AidlMember : public AidlCommentable {
+ public:
+  AidlMember(const AidlLocation& location, const Comments& comments);
+  virtual ~AidlMember() = default;
+
+  // non-copyable, non-movable
+  AidlMember(const AidlMember&) = delete;
+  AidlMember(AidlMember&&) = delete;
+  AidlMember& operator=(const AidlMember&) = delete;
+  AidlMember& operator=(AidlMember&&) = delete;
+
+  virtual const AidlMethod* AsMethod() const { return nullptr; }
+  virtual const AidlConstantDeclaration* AsConstantDeclaration() const { return nullptr; }
+  virtual const AidlVariableDeclaration* AsVariableDeclaration() const { return nullptr; }
+
+  AidlMethod* AsMethod() {
+    return const_cast<AidlMethod*>(const_cast<const AidlMember*>(this)->AsMethod());
+  }
+  AidlConstantDeclaration* AsConstantDeclaration() {
+    return const_cast<AidlConstantDeclaration*>(
+        const_cast<const AidlMember*>(this)->AsConstantDeclaration());
+  }
+  AidlVariableDeclaration* AsVariableDeclaration() {
+    return const_cast<AidlVariableDeclaration*>(
+        const_cast<const AidlMember*>(this)->AsVariableDeclaration());
+  }
+};
+
 // TODO: This class is used for method arguments and also parcelable fields,
 // and it should be split up since default values don't apply to method
 // arguments
-class AidlVariableDeclaration : public AidlNode {
+class AidlVariableDeclaration : public AidlMember {
  public:
   AidlVariableDeclaration(const AidlLocation& location, AidlTypeSpecifier* type,
                           const std::string& name);
@@ -343,22 +481,39 @@
   AidlVariableDeclaration& operator=(const AidlVariableDeclaration&) = delete;
   AidlVariableDeclaration& operator=(AidlVariableDeclaration&&) = delete;
 
+  const AidlVariableDeclaration* AsVariableDeclaration() const override { return this; }
+
   std::string GetName() const { return name_; }
+  std::string GetCapitalizedName() const;
   const AidlTypeSpecifier& GetType() const { return *type_; }
   // if this was constructed explicitly with a default value
   bool IsDefaultUserSpecified() const { return default_user_specified_; }
   // will return the default value this is constructed with or a default value
   // if one is available
   const AidlConstantValue* GetDefaultValue() const { return default_value_.get(); }
+  bool HasUsefulDefaultValue() const;
 
   AidlTypeSpecifier* GetMutableType() { return type_.get(); }
 
   bool CheckValid(const AidlTypenames& typenames) const;
+
+  // ToString is for dumping AIDL.
+  // Returns string representation of this variable decl including default value.
+  // This is "annotations type name default_value?".
+  // e.g) "@utf8InCpp String[] names = {"hello"}"
   std::string ToString() const;
+
+  // Signature is for comparing AIDL types.
+  // Returns string representation of this variable decl.
+  // This is "type name".
+  // e.g) "String[] name" (even if it is annotated with @utf8InCpp and has a default value.)
   std::string Signature() const;
 
   std::string ValueString(const ConstantValueDecorator& decorator) const;
 
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override;
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+
  private:
   std::unique_ptr<AidlTypeSpecifier> type_;
   std::string name_;
@@ -387,34 +542,25 @@
   bool DirectionWasSpecified() const { return direction_specified_; }
   string GetDirectionSpecifier() const;
 
+  // ToString is for dumping AIDL.
+  // Returns string representation of this argument including direction
+  // This is "direction annotations type name".
+  // e.g) "in @utf8InCpp String[] names"
   std::string ToString() const;
-  std::string Signature() const;
+
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    traverse(GetType());
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
   Direction direction_;
   bool direction_specified_;
 };
 
-class AidlMethod;
-class AidlConstantDeclaration;
-class AidlEnumDeclaration;
-class AidlMember : public AidlNode {
- public:
-  AidlMember(const AidlLocation& location);
-  virtual ~AidlMember() = default;
-
-  // non-copyable, non-movable
-  AidlMember(const AidlMember&) = delete;
-  AidlMember(AidlMember&&) = delete;
-  AidlMember& operator=(const AidlMember&) = delete;
-  AidlMember& operator=(AidlMember&&) = delete;
-
-  virtual AidlMethod* AsMethod() { return nullptr; }
-  virtual AidlConstantDeclaration* AsConstantDeclaration() { return nullptr; }
-};
-
 class AidlUnaryConstExpression;
 class AidlBinaryConstExpression;
+class AidlConstantReference;
 
 class AidlConstantValue : public AidlNode {
  public:
@@ -428,17 +574,48 @@
     ARRAY,
     CHARACTER,
     STRING,
+    REF,
     FLOATING,
     UNARY,
     BINARY,
     ERROR,
   };
 
-  /*
-   * Return the value casted to the given type.
-   */
+  // Returns the evaluated value. T> should match to the actual type.
   template <typename T>
-  T cast() const;
+  T EvaluatedValue() const {
+    is_evaluated_ || (CheckValid() && evaluate());
+    AIDL_FATAL_IF(!is_valid_, this);
+
+    if constexpr (is_vector<T>::value) {
+      AIDL_FATAL_IF(final_type_ != Type::ARRAY, this);
+      T result;
+      for (const auto& v : values_) {
+        result.push_back(v->EvaluatedValue<typename T::value_type>());
+      }
+      return result;
+    } else if constexpr (is_one_of<T, float, double>::value) {
+      AIDL_FATAL_IF(final_type_ != Type::FLOATING, this);
+      T result;
+      AIDL_FATAL_IF(!ParseFloating(value_, &result), this);
+      return result;
+    } else if constexpr (std::is_same<T, std::string>::value) {
+      AIDL_FATAL_IF(final_type_ != Type::STRING, this);
+      return final_string_value_.substr(1, final_string_value_.size() - 2);  // unquote "
+    } else if constexpr (is_one_of<T, int8_t, int32_t, int64_t>::value) {
+      AIDL_FATAL_IF(final_type_ < Type::INT8 && final_type_ > Type::INT64, this);
+      return static_cast<T>(final_value_);
+    } else if constexpr (std::is_same<T, char>::value) {
+      AIDL_FATAL_IF(final_type_ != Type::CHARACTER, this);
+      return final_string_value_.at(1);  // unquote '
+    } else if constexpr (std::is_same<T, bool>::value) {
+      static_assert(std::is_same<T, bool>::value, "..");
+      AIDL_FATAL_IF(final_type_ != Type::BOOLEAN, this);
+      return final_value_ != 0;
+    } else {
+      static_assert(unsupported_type<T>::value);
+    }
+  }
 
   virtual ~AidlConstantValue() = default;
 
@@ -462,29 +639,35 @@
   // example: "\"asdf\""
   static AidlConstantValue* String(const AidlLocation& location, const string& value);
 
-  // Construct an AidlConstantValue by evaluating the other integral constant's
-  // value string. This does not preserve the structure of the copied constant.
-  // Returns nullptr and logs if value cannot be copied.
-  static AidlConstantValue* ShallowIntegralCopy(const AidlConstantValue& other);
-
   Type GetType() const { return final_type_; }
+  const std::string& Literal() const { return value_; }
 
   virtual bool CheckValid() const;
 
   // Raw value of type (currently valid in C++ and Java). Empty string on error.
   string ValueString(const AidlTypeSpecifier& type, const ConstantValueDecorator& decorator) const;
 
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const {
+    if (type_ == Type::ARRAY) {
+      for (const auto& v : values_) {
+        traverse(*v);
+      }
+    }
+  }
+  void DispatchVisit(AidlVisitor& visitor) const override { visitor.Visit(*this); }
+
  private:
   AidlConstantValue(const AidlLocation& location, Type parsed_type, int64_t parsed_value,
                     const string& checked_value);
   AidlConstantValue(const AidlLocation& location, Type type, const string& checked_value);
   AidlConstantValue(const AidlLocation& location, Type type,
-                    std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values);
+                    std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values,
+                    const std::string& value);
   static string ToString(Type type);
   static bool ParseIntegral(const string& value, int64_t* parsed_value, Type* parsed_type);
   static bool IsHex(const string& value);
 
-  virtual bool evaluate(const AidlTypeSpecifier& type) const;
+  virtual bool evaluate() const;
 
   const Type type_ = Type::ERROR;
   const vector<unique_ptr<AidlConstantValue>> values_;  // if type_ == ARRAY
@@ -499,6 +682,33 @@
 
   friend AidlUnaryConstExpression;
   friend AidlBinaryConstExpression;
+  friend AidlConstantReference;
+};
+
+// Represents "<type>.<field>" which resolves to a constant which is one of
+// - constant declartion
+// - enumerator
+// When a <type> is missing, <field> is of the enclosing type.
+class AidlConstantReference : public AidlConstantValue {
+ public:
+  AidlConstantReference(const AidlLocation& location, const std::string& value);
+
+  const std::unique_ptr<AidlTypeSpecifier>& GetRefType() const { return ref_type_; }
+  const std::string& GetFieldName() const { return field_name_; }
+
+  bool CheckValid() const override;
+  void TraverseChildren(std::function<void(const AidlNode&)>) const override {
+    // resolved_ is not my child.
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+  const AidlConstantValue* Resolve(const AidlDefinedType* scope) const;
+
+ private:
+  bool evaluate() const override;
+
+  std::unique_ptr<AidlTypeSpecifier> ref_type_;
+  std::string field_name_;
+  mutable const AidlConstantValue* resolved_ = nullptr;
 };
 
 class AidlUnaryConstExpression : public AidlConstantValue {
@@ -508,8 +718,13 @@
 
   static bool IsCompatibleType(Type type, const string& op);
   bool CheckValid() const override;
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    traverse(*unary_);
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+
  private:
-  bool evaluate(const AidlTypeSpecifier& type) const override;
+  bool evaluate() const override;
 
   std::unique_ptr<AidlConstantValue> unary_;
   const string op_;
@@ -527,9 +742,14 @@
   static Type UsualArithmeticConversion(Type left, Type right);
   // Returns the promoted integral type where INT32 is the smallest type
   static Type IntegralPromotion(Type in);
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    traverse(*left_val_);
+    traverse(*right_val_);
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
-  bool evaluate(const AidlTypeSpecifier& type) const override;
+  bool evaluate() const override;
 
   std::unique_ptr<AidlConstantValue> left_val_;
   std::unique_ptr<AidlConstantValue> right_val_;
@@ -559,13 +779,29 @@
   const AidlConstantValue& GetValue() const { return *value_; }
   bool CheckValid(const AidlTypenames& typenames) const;
 
+  // ToString is for dumping AIDL.
+  // Returns string representation of this const decl including a const value.
+  // This is "`const` annotations type name value".
+  // e.g) "const @utf8InCpp String[] names = { "hello" }"
   string ToString() const;
+
+  // Signature is for comparing types.
+  // Returns string representation of this const decl.
+  // This is "direction annotations type name".
+  // e.g) "String[] names"
   string Signature() const;
+
   string ValueString(const ConstantValueDecorator& decorator) const {
     return value_->ValueString(GetType(), decorator);
   }
 
-  AidlConstantDeclaration* AsConstantDeclaration() override { return this; }
+  const AidlConstantDeclaration* AsConstantDeclaration() const override { return this; }
+
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    traverse(GetType());
+    traverse(GetValue());
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
   const unique_ptr<AidlTypeSpecifier> type_;
@@ -576,9 +812,9 @@
 class AidlMethod : public AidlMember {
  public:
   AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type, const string& name,
-             vector<unique_ptr<AidlArgument>>* args, const string& comments);
+             vector<unique_ptr<AidlArgument>>* args, const Comments& comments);
   AidlMethod(const AidlLocation& location, bool oneway, AidlTypeSpecifier* type, const string& name,
-             vector<unique_ptr<AidlArgument>>* args, const string& comments, int id,
+             vector<unique_ptr<AidlArgument>>* args, const Comments& comments, int id,
              bool is_user_defined = true);
   virtual ~AidlMethod() = default;
 
@@ -588,9 +824,7 @@
   AidlMethod& operator=(const AidlMethod&) = delete;
   AidlMethod& operator=(AidlMethod&&) = delete;
 
-  AidlMethod* AsMethod() override { return this; }
-  bool IsHidden() const;
-  const string& GetComments() const { return comments_; }
+  const AidlMethod* AsMethod() const override { return this; }
   const AidlTypeSpecifier& GetType() const { return *type_; }
   AidlTypeSpecifier* GetMutableType() { return type_.get(); }
 
@@ -618,17 +852,27 @@
     return out_arguments_;
   }
 
-  // name + type parameter types
-  // i.e, foo(int, String)
+  // ToString is for dumping AIDL.
+  // Returns string representation of this method including everything.
+  // This is "ret_type name ( arg_list ) = id".
+  // e.g) "boolean foo(int, @Nullable String) = 1"
+  std::string ToString() const;
+
+  // Signature is for comparing AIDL types.
+  // Returns string representation of this method's name & type.
+  // e.g) "foo(int, String)"
   std::string Signature() const;
 
-  // return type + name + type parameter types + annotations
-  // i.e, boolean foo(int, @Nullable String)
-  std::string ToString() const;
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    traverse(GetType());
+    for (const auto& a : GetArguments()) {
+      traverse(*a);
+    }
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
   bool oneway_;
-  std::string comments_;
   std::unique_ptr<AidlTypeSpecifier> type_;
   std::string name_;
   const std::vector<std::unique_ptr<AidlArgument>> arguments_;
@@ -639,20 +883,12 @@
   bool is_user_defined_ = true;
 };
 
-class AidlDefinedType;
-class AidlInterface;
-class AidlParcelable;
-class AidlStructuredParcelable;
-
-class AidlInterface;
-class AidlParcelable;
-class AidlStructuredParcelable;
 // AidlDefinedType represents either an interface, parcelable, or enum that is
 // defined in the source file.
 class AidlDefinedType : public AidlAnnotatable {
  public:
-  AidlDefinedType(const AidlLocation& location, const std::string& name,
-                  const std::string& comments, const std::string& package);
+  AidlDefinedType(const AidlLocation& location, const std::string& name, const Comments& comments,
+                  const std::string& package, std::vector<std::unique_ptr<AidlMember>>* members);
   virtual ~AidlDefinedType() = default;
 
   // non-copyable, non-movable
@@ -662,9 +898,6 @@
   AidlDefinedType& operator=(AidlDefinedType&&) = delete;
 
   const std::string& GetName() const { return name_; };
-  bool IsHidden() const;
-  const std::string& GetComments() const { return comments_; }
-  void SetComments(const std::string comments) { comments_ = comments; }
 
   /* dot joined package, example: "android.package.foo" */
   std::string GetPackage() const { return package_; }
@@ -677,9 +910,10 @@
   virtual const AidlStructuredParcelable* AsStructuredParcelable() const { return nullptr; }
   virtual const AidlParcelable* AsParcelable() const { return nullptr; }
   virtual const AidlEnumDeclaration* AsEnumDeclaration() const { return nullptr; }
+  virtual const AidlUnionDecl* AsUnionDeclaration() const { return nullptr; }
   virtual const AidlInterface* AsInterface() const { return nullptr; }
   virtual const AidlParameterizable<std::string>* AsParameterizable() const { return nullptr; }
-  bool CheckValid(const AidlTypenames& typenames) const override;
+  virtual bool CheckValid(const AidlTypenames& typenames) const;
   virtual bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
                                           Options::Language lang) const = 0;
   AidlStructuredParcelable* AsStructuredParcelable() {
@@ -693,6 +927,10 @@
     return const_cast<AidlEnumDeclaration*>(
         const_cast<const AidlDefinedType*>(this)->AsEnumDeclaration());
   }
+  AidlUnionDecl* AsUnionDeclaration() {
+    return const_cast<AidlUnionDecl*>(
+        const_cast<const AidlDefinedType*>(this)->AsUnionDeclaration());
+  }
   AidlInterface* AsInterface() {
     return const_cast<AidlInterface*>(const_cast<const AidlDefinedType*>(this)->AsInterface());
   }
@@ -704,6 +942,7 @@
 
   const AidlParcelable* AsUnstructuredParcelable() const {
     if (this->AsStructuredParcelable() != nullptr) return nullptr;
+    if (this->AsUnionDeclaration() != nullptr) return nullptr;
     return this->AsParcelable();
   }
   AidlParcelable* AsUnstructuredParcelable() {
@@ -713,19 +952,46 @@
 
   virtual void Dump(CodeWriter* writer) const = 0;
   void DumpHeader(CodeWriter* writer) const;
+  void DumpMembers(CodeWriter& out) const;
+
+  const std::vector<std::unique_ptr<AidlVariableDeclaration>>& GetFields() const {
+    return variables_;
+  }
+  const std::vector<std::unique_ptr<AidlConstantDeclaration>>& GetConstantDeclarations() const {
+    return constants_;
+  }
+  const std::vector<std::unique_ptr<AidlMethod>>& GetMethods() const { return methods_; }
+  void AddMethod(std::unique_ptr<AidlMethod> method) { methods_.push_back(std::move(method)); }
+  const std::vector<const AidlMember*>& GetMembers() const { return members_; }
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    AidlAnnotatable::TraverseChildren(traverse);
+    for (const auto c : GetMembers()) {
+      traverse(*c);
+    }
+  }
+
+ protected:
+  // utility for subclasses with getter names
+  bool CheckValidForGetterNames() const;
 
  private:
+  bool CheckValidWithMembers(const AidlTypenames& typenames) const;
+
   std::string name_;
-  std::string comments_;
   const std::string package_;
   const std::vector<std::string> split_package_;
+  std::vector<std::unique_ptr<AidlVariableDeclaration>> variables_;
+  std::vector<std::unique_ptr<AidlConstantDeclaration>> constants_;
+  std::vector<std::unique_ptr<AidlMethod>> methods_;
+  std::vector<const AidlMember*> members_;  // keep members in order of appearance.
 };
 
 class AidlParcelable : public AidlDefinedType, public AidlParameterizable<std::string> {
  public:
   AidlParcelable(const AidlLocation& location, const std::string& name, const std::string& package,
-                 const std::string& comments, const std::string& cpp_header = "",
-                 std::vector<std::string>* type_params = nullptr);
+                 const Comments& comments, const std::string& cpp_header = "",
+                 std::vector<std::string>* type_params = nullptr,
+                 std::vector<std::unique_ptr<AidlMember>>* members = nullptr);
   virtual ~AidlParcelable() = default;
 
   // non-copyable, non-movable
@@ -736,7 +1002,6 @@
 
   std::string GetCppHeader() const { return cpp_header_; }
 
-  std::set<AidlAnnotation::Type> GetSupportedAnnotations() const override;
   bool CheckValid(const AidlTypenames& typenames) const override;
   bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
                                   Options::Language lang) const override;
@@ -747,6 +1012,8 @@
 
   void Dump(CodeWriter* writer) const override;
 
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+
  private:
   std::string cpp_header_;
 };
@@ -754,9 +1021,9 @@
 class AidlStructuredParcelable : public AidlParcelable {
  public:
   AidlStructuredParcelable(const AidlLocation& location, const std::string& name,
-                           const std::string& package, const std::string& comments,
-                           std::vector<std::unique_ptr<AidlVariableDeclaration>>* variables,
-                           std::vector<std::string>* type_params);
+                           const std::string& package, const Comments& comments,
+                           std::vector<std::string>* type_params,
+                           std::vector<std::unique_ptr<AidlMember>>* members);
   virtual ~AidlStructuredParcelable() = default;
 
   // non-copyable, non-movable
@@ -765,28 +1032,22 @@
   AidlStructuredParcelable& operator=(const AidlStructuredParcelable&) = delete;
   AidlStructuredParcelable& operator=(AidlStructuredParcelable&&) = delete;
 
-  const std::vector<std::unique_ptr<AidlVariableDeclaration>>& GetFields() const {
-    return variables_;
-  }
-
   const AidlStructuredParcelable* AsStructuredParcelable() const override { return this; }
   std::string GetPreprocessDeclarationName() const override { return "structured_parcelable"; }
 
   void Dump(CodeWriter* writer) const override;
 
-  std::set<AidlAnnotation::Type> GetSupportedAnnotations() const override;
   bool CheckValid(const AidlTypenames& typenames) const override;
   bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
                                   Options::Language lang) const override;
 
- private:
-  const std::vector<std::unique_ptr<AidlVariableDeclaration>> variables_;
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 };
 
-class AidlEnumerator : public AidlNode {
+class AidlEnumerator : public AidlCommentable {
  public:
   AidlEnumerator(const AidlLocation& location, const std::string& name, AidlConstantValue* value,
-                 const std::string& comments);
+                 const Comments& comments);
   virtual ~AidlEnumerator() = default;
 
   // non-copyable, non-movable
@@ -797,25 +1058,30 @@
 
   const std::string& GetName() const { return name_; }
   AidlConstantValue* GetValue() const { return value_.get(); }
-  const std::string& GetComments() const { return comments_; }
   bool CheckValid(const AidlTypeSpecifier& enum_backing_type) const;
 
   string ValueString(const AidlTypeSpecifier& backing_type,
                      const ConstantValueDecorator& decorator) const;
 
   void SetValue(std::unique_ptr<AidlConstantValue> value) { value_ = std::move(value); }
+  bool IsValueUserSpecified() const { return value_user_specified_; }
+
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    traverse(*value_);
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 
  private:
   const std::string name_;
   unique_ptr<AidlConstantValue> value_;
-  const std::string comments_;
+  const bool value_user_specified_;
 };
 
 class AidlEnumDeclaration : public AidlDefinedType {
  public:
   AidlEnumDeclaration(const AidlLocation& location, const string& name,
                       std::vector<std::unique_ptr<AidlEnumerator>>* enumerators,
-                      const std::string& package, const std::string& comments);
+                      const std::string& package, const Comments& comments);
   virtual ~AidlEnumDeclaration() = default;
 
   // non-copyable, non-movable
@@ -824,13 +1090,11 @@
   AidlEnumDeclaration& operator=(const AidlEnumDeclaration&) = delete;
   AidlEnumDeclaration& operator=(AidlEnumDeclaration&&) = delete;
 
-  void SetBackingType(std::unique_ptr<const AidlTypeSpecifier> type);
+  bool Autofill(const AidlTypenames&);
   const AidlTypeSpecifier& GetBackingType() const { return *backing_type_; }
   const std::vector<std::unique_ptr<AidlEnumerator>>& GetEnumerators() const {
     return enumerators_;
   }
-  bool Autofill();
-  std::set<AidlAnnotation::Type> GetSupportedAnnotations() const override;
   bool CheckValid(const AidlTypenames& typenames) const override;
   bool LanguageSpecificCheckValid(const AidlTypenames& /*typenames*/,
                                   Options::Language) const override {
@@ -841,17 +1105,51 @@
 
   const AidlEnumDeclaration* AsEnumDeclaration() const override { return this; }
 
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    AidlDefinedType::TraverseChildren(traverse);
+    for (const auto& c : GetEnumerators()) {
+      traverse(*c);
+    }
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+
  private:
+
   const std::string name_;
   const std::vector<std::unique_ptr<AidlEnumerator>> enumerators_;
-  std::unique_ptr<const AidlTypeSpecifier> backing_type_;
+  std::unique_ptr<AidlTypeSpecifier> backing_type_;
+};
+
+class AidlUnionDecl : public AidlParcelable {
+ public:
+  AidlUnionDecl(const AidlLocation& location, const std::string& name, const std::string& package,
+                const Comments& comments, std::vector<std::string>* type_params,
+                std::vector<std::unique_ptr<AidlMember>>* members);
+  virtual ~AidlUnionDecl() = default;
+
+  // non-copyable, non-movable
+  AidlUnionDecl(const AidlUnionDecl&) = delete;
+  AidlUnionDecl(AidlUnionDecl&&) = delete;
+  AidlUnionDecl& operator=(const AidlUnionDecl&) = delete;
+  AidlUnionDecl& operator=(AidlUnionDecl&&) = delete;
+
+
+  const AidlNode& AsAidlNode() const override { return *this; }
+  bool CheckValid(const AidlTypenames& typenames) const override;
+  bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
+                                  Options::Language lang) const override;
+  std::string GetPreprocessDeclarationName() const override { return "union"; }
+
+  void Dump(CodeWriter* writer) const override;
+  const AidlUnionDecl* AsUnionDeclaration() const override { return this; }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
 };
 
 class AidlInterface final : public AidlDefinedType {
  public:
-  AidlInterface(const AidlLocation& location, const std::string& name, const std::string& comments,
-                bool oneway_, std::vector<std::unique_ptr<AidlMember>>* members,
-                const std::string& package);
+  AidlInterface(const AidlLocation& location, const std::string& name, const Comments& comments,
+                bool oneway_, const std::string& package,
+                std::vector<std::unique_ptr<AidlMember>>* members);
   virtual ~AidlInterface() = default;
 
   // non-copyable, non-movable
@@ -860,33 +1158,32 @@
   AidlInterface& operator=(const AidlInterface&) = delete;
   AidlInterface& operator=(AidlInterface&&) = delete;
 
-  const std::vector<std::unique_ptr<AidlMethod>>& GetMethods() const
-      { return methods_; }
-  std::vector<std::unique_ptr<AidlMethod>>& GetMutableMethods() { return methods_; }
-  const std::vector<std::unique_ptr<AidlConstantDeclaration>>& GetConstantDeclarations() const {
-    return constants_;
-  }
-
   const AidlInterface* AsInterface() const override { return this; }
   std::string GetPreprocessDeclarationName() const override { return "interface"; }
 
   void Dump(CodeWriter* writer) const override;
 
-  std::set<AidlAnnotation::Type> GetSupportedAnnotations() const override;
   bool CheckValid(const AidlTypenames& typenames) const override;
   bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
                                   Options::Language lang) const override;
 
   std::string GetDescriptor() const;
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+};
 
- private:
-  std::vector<std::unique_ptr<AidlMethod>> methods_;
-  std::vector<std::unique_ptr<AidlConstantDeclaration>> constants_;
+class AidlPackage : public AidlNode {
+ public:
+  AidlPackage(const AidlLocation& location, const Comments& comments)
+      : AidlNode(location, comments) {}
+  virtual ~AidlPackage() = default;
+  void TraverseChildren(std::function<void(const AidlNode&)>) const {}
+  void DispatchVisit(AidlVisitor& v) const { v.Visit(*this); }
 };
 
 class AidlImport : public AidlNode {
  public:
-  AidlImport(const AidlLocation& location, const std::string& needed_class);
+  AidlImport(const AidlLocation& location, const std::string& needed_class,
+             const Comments& comments);
   virtual ~AidlImport() = default;
 
   // non-copyable, non-movable
@@ -895,20 +1192,21 @@
   AidlImport& operator=(const AidlImport&) = delete;
   AidlImport& operator=(AidlImport&&) = delete;
 
-  const std::string& GetFilename() const { return filename_; }
   const std::string& GetNeededClass() const { return needed_class_; }
+  void TraverseChildren(std::function<void(const AidlNode&)>) const {}
+  void DispatchVisit(AidlVisitor& v) const { v.Visit(*this); }
 
  private:
-  std::string filename_;
   std::string needed_class_;
 };
 
 // AidlDocument models an AIDL file
-class AidlDocument : public AidlNode {
+class AidlDocument : public AidlCommentable {
  public:
-  AidlDocument(const AidlLocation& location, std::vector<std::unique_ptr<AidlImport>>& imports,
-               std::vector<std::unique_ptr<AidlDefinedType>>&& defined_types)
-      : AidlNode(location),
+  AidlDocument(const AidlLocation& location, const Comments& comments,
+               std::vector<std::unique_ptr<AidlImport>> imports,
+               std::vector<std::unique_ptr<AidlDefinedType>> defined_types)
+      : AidlCommentable(location, comments),
         imports_(std::move(imports)),
         defined_types_(std::move(defined_types)) {}
   ~AidlDocument() = default;
@@ -919,12 +1217,45 @@
   AidlDocument& operator=(const AidlDocument&) = delete;
   AidlDocument& operator=(AidlDocument&&) = delete;
 
+  std::optional<std::string> ResolveName(const std::string& unresolved_type) const;
   const std::vector<std::unique_ptr<AidlImport>>& Imports() const { return imports_; }
   const std::vector<std::unique_ptr<AidlDefinedType>>& DefinedTypes() const {
     return defined_types_;
   }
 
+  void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+    for (const auto& i : Imports()) {
+      traverse(*i);
+    }
+    for (const auto& t : DefinedTypes()) {
+      traverse(*t);
+    }
+  }
+  void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+
  private:
   const std::vector<std::unique_ptr<AidlImport>> imports_;
   const std::vector<std::unique_ptr<AidlDefinedType>> defined_types_;
 };
+
+template <typename T>
+std::optional<T> AidlAnnotation::ParamValue(const std::string& param_name) const {
+  auto it = parameters_.find(param_name);
+  if (it == parameters_.end()) {
+    return std::nullopt;
+  }
+  return it->second->EvaluatedValue<T>();
+}
+
+// Utility to make a visitor to visit AST tree in top-down order
+// Given:       foo
+//              / \
+//            bar baz
+// VisitTopDown(v, foo) makes v visit foo -> bar -> baz.
+inline void VisitTopDown(AidlVisitor& v, const AidlNode& node) {
+  std::function<void(const AidlNode&)> top_down = [&](const AidlNode& n) {
+    n.DispatchVisit(v);
+    n.TraverseChildren(top_down);
+  };
+  top_down(node);
+}
\ No newline at end of file
diff --git a/aidl_language_l.ll b/aidl_language_l.ll
index 7646f3f..e43ef45 100644
--- a/aidl_language_l.ll
+++ b/aidl_language_l.ll
@@ -43,20 +43,27 @@
 %%
 %{
   /* This happens at every call to yylex (every time we receive one token) */
+  using android::aidl::Comments;
+  using android::aidl::Comment;
   std::string extra_text;
+  Comments comments;
   yylloc->step();
 %}
 
 \/\*                  { extra_text += yytext; BEGIN(LONG_COMMENT); }
-<LONG_COMMENT>\*+\/   { extra_text += yytext; yylloc->step(); BEGIN(INITIAL);  }
+<LONG_COMMENT>\*+\/   { extra_text += yytext; yylloc->step(); BEGIN(INITIAL);
+                        comments.push_back({extra_text});
+                        extra_text.clear(); }
 <LONG_COMMENT>\*+     { extra_text += yytext; }
 <LONG_COMMENT>\n+     { extra_text += yytext; yylloc->lines(yyleng); }
 <LONG_COMMENT>[^*\n]+ { extra_text += yytext; }
 
-\"[^\"]*\"            { yylval->token = new AidlToken(yytext, extra_text);
+\"[^\"]*\"            { yylval->token = new AidlToken(yytext, comments);
                         return yy::parser::token::C_STR; }
 
-\/\/.*                { extra_text += yytext; extra_text += "\n"; }
+\/\/.*                { extra_text += yytext; extra_text += "\n";
+                        comments.push_back({extra_text});
+                        extra_text.clear(); }
 
 \n+                   { yylloc->lines(yyleng); yylloc->step(); }
 {whitespace}          {}
@@ -96,47 +103,53 @@
 "!="                  { return(yy::parser::token::NEQ); }
 
     /* annotations */
-@{identifier}         { yylval->token = new AidlToken(yytext + 1, extra_text);
+@{identifier}         { yylval->token = new AidlToken(yytext + 1, comments);
                         return yy::parser::token::ANNOTATION;
                       }
 
     /* keywords */
-parcelable            { yylval->token = new AidlToken("parcelable", extra_text);
+parcelable            { yylval->token = new AidlToken("parcelable", comments);
                         return yy::parser::token::PARCELABLE;
                       }
-import                { return yy::parser::token::IMPORT; }
-package               { return yy::parser::token::PACKAGE; }
+import                { yylval->token = new AidlToken("import", comments);
+                        return yy::parser::token::IMPORT; }
+package               { yylval->token = new AidlToken("package", comments);
+                        return yy::parser::token::PACKAGE; }
 in                    { return yy::parser::token::IN; }
 out                   { return yy::parser::token::OUT; }
 inout                 { return yy::parser::token::INOUT; }
-cpp_header            { return yy::parser::token::CPP_HEADER; }
-const                 { yylval->token = new AidlToken("const", extra_text);
+cpp_header            { yylval->token = new AidlToken("cpp_header", comments);
+                        return yy::parser::token::CPP_HEADER; }
+const                 { yylval->token = new AidlToken("const", comments);
                         return yy::parser::token::CONST; }
 true                  { return yy::parser::token::TRUE_LITERAL; }
 false                 { return yy::parser::token::FALSE_LITERAL; }
 
-interface             { yylval->token = new AidlToken("interface", extra_text);
+interface             { yylval->token = new AidlToken("interface", comments);
                         return yy::parser::token::INTERFACE;
                       }
-oneway                { yylval->token = new AidlToken("oneway", extra_text);
+oneway                { yylval->token = new AidlToken("oneway", comments);
                         return yy::parser::token::ONEWAY;
                       }
-enum                  { yylval->token = new AidlToken("enum", extra_text);
+enum                  { yylval->token = new AidlToken("enum", comments);
                         return yy::parser::token::ENUM;
                       }
+union                 { yylval->token = new AidlToken("union", comments);
+                        return yy::parser::token::UNION;
+                      }
 
     /* scalars */
-{identifier}          { yylval->token = new AidlToken(yytext, extra_text);
+{identifier}          { yylval->token = new AidlToken(yytext, comments);
                         return yy::parser::token::IDENTIFIER;
                       }
 '.'                   { yylval->character = yytext[1];
                         return yy::parser::token::CHARVALUE;
                       }
-{intvalue}            { yylval->token = new AidlToken(yytext, extra_text);
+{intvalue}            { yylval->token = new AidlToken(yytext, comments);
                         return yy::parser::token::INTVALUE; }
-{floatvalue}          { yylval->token = new AidlToken(yytext, extra_text);
+{floatvalue}          { yylval->token = new AidlToken(yytext, comments);
                         return yy::parser::token::FLOATVALUE; }
-{hexvalue}            { yylval->token = new AidlToken(yytext, extra_text);
+{hexvalue}            { yylval->token = new AidlToken(yytext, comments);
                         return yy::parser::token::HEXVALUE; }
 
   /* lexical error! */
diff --git a/aidl_language_y.yy b/aidl_language_y.yy
index 78fdd43..5099b5b 100644
--- a/aidl_language_y.yy
+++ b/aidl_language_y.yy
@@ -81,21 +81,18 @@
     AidlConstantValue* const_expr;
     AidlEnumerator* enumerator;
     std::vector<std::unique_ptr<AidlEnumerator>>* enumerators;
-    AidlEnumDeclaration* enum_decl;
     std::vector<std::unique_ptr<AidlConstantValue>>* constant_value_list;
     std::vector<std::unique_ptr<AidlArgument>>* arg_list;
     AidlVariableDeclaration* variable;
-    std::vector<std::unique_ptr<AidlVariableDeclaration>>* variable_list;
     AidlMethod* method;
     AidlMember* constant;
-    std::vector<std::unique_ptr<AidlMember>>* interface_members;
-    AidlInterface* interface;
-    AidlParcelable* parcelable;
+    std::vector<std::unique_ptr<AidlMember>>* members;
     AidlDefinedType* declaration;
     std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args;
     std::vector<std::string>* type_params;
     std::vector<std::unique_ptr<AidlImport>>* imports;
     AidlImport* import;
+    AidlPackage* package;
     std::vector<std::unique_ptr<AidlDefinedType>>* declarations;
 }
 
@@ -103,6 +100,8 @@
 %destructor { } <direction>
 %destructor { delete ($$); } <*>
 
+%token<token> PACKAGE "package"
+%token<token> IMPORT "import"
 %token<token> ANNOTATION "annotation"
 %token<token> C_STR "string literal"
 %token<token> IDENTIFIER "identifier"
@@ -110,6 +109,7 @@
 %token<token> PARCELABLE "parcelable"
 %token<token> ONEWAY "oneway"
 %token<token> ENUM "enum"
+%token<token> UNION "union"
 %token<token> CONST "const"
 
 %token<character> CHARVALUE "char literal"
@@ -119,12 +119,10 @@
 
 %token '(' ')' ',' '=' '[' ']' '.' '{' '}' ';'
 %token UNKNOWN "unrecognized character"
-%token CPP_HEADER "cpp_header (which can also be used as an identifier)"
-%token IMPORT "import"
+%token<token> CPP_HEADER "cpp_header (which can also be used as an identifier)"
 %token IN "in"
 %token INOUT "inout"
 %token OUT "out"
-%token PACKAGE "package"
 %token TRUE_LITERAL "true"
 %token FALSE_LITERAL "false"
 
@@ -151,18 +149,18 @@
 %right UNARY_PLUS UNARY_MINUS  '!' '~'
 
 %type<declaration> decl
-%type<variable_list> variable_decls
+%type<declaration> unannotated_decl
+%type<declaration> interface_decl
+%type<declaration> parcelable_decl
+%type<declaration> enum_decl
+%type<declaration> union_decl
+%type<members> parcelable_members interface_members
 %type<variable> variable_decl
 %type<type_params> optional_type_params
-%type<interface_members> interface_members
-%type<declaration> unannotated_decl
-%type<interface> interface_decl
-%type<parcelable> parcelable_decl
 %type<method> method_decl
 %type<constant> constant_decl
 %type<enumerator> enumerator
 %type<enumerators> enumerators enum_decl_body
-%type<enum_decl> enum_decl
 %type<param> parameter
 %type<param_list> parameter_list
 %type<param_list> parameter_non_empty_list
@@ -180,17 +178,26 @@
 %type<constant_value_list> constant_value_non_empty_list
 %type<imports> imports
 %type<import> import
+%type<package> package
 %type<declarations> decls
 %type<token> identifier error qualified_name
 
 %%
 
 document
- : package imports decls
-  { ps->SetDocument(std::make_unique<AidlDocument>(loc(@1), *$2, std::move(*$3)));
+ : package imports decls {
+    Comments comments;
+    if ($1) {
+      comments = $1->GetComments();
+    } else if (!$2->empty()) {
+      comments = $2->front()->GetComments();
+    }
+    ps->SetDocument(std::make_unique<AidlDocument>(loc(@1), comments, std::move(*$2), std::move(*$3)));
+    delete $1;
     delete $2;
     delete $3;
   }
+ ;
 
 /* A couple of tokens that are keywords elsewhere are identifiers when
  * occurring in the identifier position. Therefore identifier is a
@@ -199,17 +206,20 @@
  */
 identifier
  : IDENTIFIER
-  { $$ = $1; }
  | CPP_HEADER
-  { $$ = new AidlToken("cpp_header", ""); }
  ;
 
 package
- : {}
- | PACKAGE qualified_name ';'
-  { ps->SetPackage($2->GetText());
+ : {
+    $$ = nullptr;
+ }
+ | PACKAGE qualified_name ';' {
+    $$ = new AidlPackage(loc(@1, @3), $1->GetComments());
+    ps->SetPackage($2->GetText());
+    delete $1;
     delete $2;
   }
+ ;
 
 imports
  : { $$ = new std::vector<std::unique_ptr<AidlImport>>(); }
@@ -227,9 +237,9 @@
   }
 
 import
- : IMPORT qualified_name ';'
-  {
-    $$ = new AidlImport(loc(@2), $2->GetText());
+ : IMPORT qualified_name ';' {
+    $$ = new AidlImport(loc(@2), $2->GetText(), $1->GetComments());
+    delete $1;
     delete $2;
   };
 
@@ -238,8 +248,9 @@
     $$ = $1;
   }
  | qualified_name '.' identifier
-  { $$ = new AidlToken($1->GetText() + "." + $3->GetText(), $1->GetComments());
-    delete $1;
+  { $$ = $1;
+    $$->Append('.');
+    $$->Append($3->GetText());
     delete $3;
   };
 
@@ -274,11 +285,9 @@
 
 unannotated_decl
  : parcelable_decl
-  { $$ = $1; }
  | interface_decl
-  { $$ = $1; }
  | enum_decl
-  { $$ = $1; }
+ | union_decl
  ;
 
 type_params
@@ -305,16 +314,16 @@
     delete $1;
     delete $2;
  }
- | PARCELABLE qualified_name optional_type_params '{' variable_decls '}' {
-    $$ = new AidlStructuredParcelable(loc(@2), $2->GetText(), ps->Package(), $1->GetComments(), $5, $3);
+ | PARCELABLE qualified_name optional_type_params '{' parcelable_members '}' {
+    $$ = new AidlStructuredParcelable(loc(@2), $2->GetText(), ps->Package(), $1->GetComments(), $3, $5);
     delete $1;
     delete $2;
-    delete $5;
  }
  | PARCELABLE qualified_name CPP_HEADER C_STR ';' {
     $$ = new AidlParcelable(loc(@2), $2->GetText(), ps->Package(), $1->GetComments(), $4->GetText());
     delete $1;
     delete $2;
+    delete $3;
     delete $4;
   }
  | PARCELABLE error ';' {
@@ -323,16 +332,22 @@
     delete $1;
   };
 
-variable_decls
+parcelable_members
  : /* empty */ {
-    $$ = new std::vector<std::unique_ptr<AidlVariableDeclaration>>;
- }
- | variable_decls variable_decl {
+    $$ = new std::vector<std::unique_ptr<AidlMember>>();
+  }
+ | parcelable_members variable_decl {
+    $1->emplace_back($2);
     $$ = $1;
-    if ($2 != nullptr) {
-      $$->push_back(std::unique_ptr<AidlVariableDeclaration>($2));
-    }
- };
+  }
+ | parcelable_members constant_decl {
+    $1->emplace_back($2);
+    $$ = $1;
+  }
+ | parcelable_members error ';' {
+    ps->AddError();
+    $$ = $1;
+  };
 
 variable_decl
  : type identifier ';' {
@@ -344,19 +359,16 @@
    $$ = new AidlVariableDeclaration(loc(@2), $1, $2->GetText(),  $4);
    delete $2;
  }
- | error ';' {
-   ps->AddError();
-   $$ = nullptr;
- }
+ ;
 
 interface_decl
  : INTERFACE identifier '{' interface_members '}' {
-    $$ = new AidlInterface(loc(@1), $2->GetText(), $1->GetComments(), false, $4, ps->Package());
+    $$ = new AidlInterface(loc(@1), $2->GetText(), $1->GetComments(), false, ps->Package(), $4);
     delete $1;
     delete $2;
   }
  | ONEWAY INTERFACE identifier '{' interface_members '}' {
-    $$ = new AidlInterface(loc(@2), $3->GetText(),  $1->GetComments(), true, $5, ps->Package());
+    $$ = new AidlInterface(loc(@2), $3->GetText(),  $1->GetComments(), true, ps->Package(), $5);
     delete $1;
     delete $2;
     delete $3;
@@ -412,6 +424,10 @@
     $$ = AidlConstantValue::String(loc(@1), $1->GetText());
     delete $1;
   }
+ | qualified_name {
+    $$ = new AidlConstantReference(loc(@1), $1->GetText());
+    delete $1;
+ }
  | '{' constant_value_list '}' {
     $$ = AidlConstantValue::Array(loc(@1), std::unique_ptr<vector<unique_ptr<AidlConstantValue>>>($2));
   }
@@ -518,11 +534,18 @@
  ;
 
 constant_decl
- : CONST type identifier '=' const_expr ';' {
-    $2->SetComments($1->GetComments());
-    $$ = new AidlConstantDeclaration(loc(@3), $2, $3->GetText(), $5);
+ : annotation_list CONST type identifier '=' const_expr ';' {
+    if ($1->size() > 0) {
+      $3->SetComments($1->begin()->GetComments());
+    } else {
+      $3->SetComments($2->GetComments());
+    }
+    // TODO(b/151102494) do not merge annotations.
+    $3->Annotate(std::move(*$1));
+    $$ = new AidlConstantDeclaration(loc(@4), $3, $4->GetText(), $6);
     delete $1;
-    delete $3;
+    delete $2;
+    delete $4;
    }
  ;
 
@@ -562,13 +585,21 @@
    }
  ;
 
+union_decl
+ : UNION qualified_name optional_type_params '{' parcelable_members '}' {
+    $$ = new AidlUnionDecl(loc(@2), $2->GetText(), ps->Package(), $1->GetComments(), $3, $5);
+    delete $1;
+    delete $2;
+  }
+ ;
+
 method_decl
  : type identifier '(' arg_list ')' ';' {
     $$ = new AidlMethod(loc(@2), false, $1, $2->GetText(), $4, $1->GetComments());
     delete $2;
   }
  | annotation_list ONEWAY type identifier '(' arg_list ')' ';' {
-    const std::string& comments = ($1->size() > 0) ? $1->begin()->GetComments() : $2->GetComments();
+    const auto& comments = ($1->size() > 0) ? $1->begin()->GetComments() : $2->GetComments();
     $$ = new AidlMethod(loc(@4), true, $3, $4->GetText(), $6, comments);
     $3->Annotate(std::move(*$1));
     delete $1;
@@ -586,7 +617,7 @@
     delete $7;
   }
  | annotation_list ONEWAY type identifier '(' arg_list ')' '=' INTVALUE ';' {
-    const std::string& comments = ($1->size() > 0) ? $1->begin()->GetComments() : $2->GetComments();
+    const auto& comments = ($1->size() > 0) ? $1->begin()->GetComments() : $2->GetComments();
     int32_t serial = 0;
     if (!android::base::ParseInt($9->GetText(), &serial)) {
         AIDL_ERROR(loc(@9)) << "Could not parse int value: " << $9->GetText();
@@ -624,8 +655,7 @@
  | type identifier {
     $$ = new AidlArgument(loc(@2), $1, $2->GetText());
     delete $2;
-  }
- ;
+  };
 
 unannotated_type
  : qualified_name {
@@ -633,15 +663,29 @@
     ps->DeferResolution($$);
     delete $1;
   }
- | qualified_name '[' ']' {
-    $$ = new AidlTypeSpecifier(loc(@1), $1->GetText(), true, nullptr, $1->GetComments());
-    ps->DeferResolution($$);
-    delete $1;
+ | unannotated_type '[' ']' {
+    if (!$1->SetArray()) {
+      AIDL_ERROR(loc(@1)) << "Can only have one dimensional arrays.";
+      ps->AddError();
+    }
+    $$ = $1;
   }
- | qualified_name '<' type_args '>' {
-    $$ = new AidlTypeSpecifier(loc(@1), $1->GetText(), false, $3, $1->GetComments());
-    ps->DeferResolution($$);
-    delete $1;
+ | unannotated_type '<' type_args '>' {
+    ps->SetTypeParameters($1, $3);
+    $$ = $1;
+  }
+ | unannotated_type '<' unannotated_type '<' type_args RSHIFT {
+    ps->SetTypeParameters($3, $5);
+    auto params = new std::vector<std::unique_ptr<AidlTypeSpecifier>>();
+    params->emplace_back($3);
+    ps->SetTypeParameters($1, params);
+    $$ = $1;
+  }
+ | unannotated_type '<' type_args ',' unannotated_type '<' type_args RSHIFT {
+    ps->SetTypeParameters($5, $7);
+    $3->emplace_back($5);
+    ps->SetTypeParameters($1, $3);
+    $$ = $1;
   };
 
 type
@@ -708,26 +752,22 @@
   };
 
 annotation
- : ANNOTATION
-  {
-    $$ = AidlAnnotation::Parse(loc(@1), $1->GetText(), nullptr);
-    if ($$) {
-      $$->SetComments($1->GetComments());
-    } else {
+ : ANNOTATION {
+    $$ = AidlAnnotation::Parse(loc(@1), $1->GetText(), nullptr, $1->GetComments());
+    if (!$$) {
       ps->AddError();
     }
     delete $1;
-  };
+  }
  | ANNOTATION '(' parameter_list ')' {
-    $$ = AidlAnnotation::Parse(loc(@1, @4), $1->GetText(), $3);
-    if ($$) {
-      $$->SetComments($1->GetComments());
-    } else {
+    $$ = AidlAnnotation::Parse(loc(@1, @4), $1->GetText(), $3, $1->GetComments());
+    if (!$$) {
       ps->AddError();
     }
     delete $1;
     delete $3;
- }
+  }
+ ;
 
 direction
  : IN
diff --git a/aidl_to_cpp.cpp b/aidl_to_cpp.cpp
index 3b8dfc3..40552c8 100644
--- a/aidl_to_cpp.cpp
+++ b/aidl_to_cpp.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "aidl_to_cpp.h"
+#include "aidl_to_cpp_common.h"
 #include "aidl_language.h"
 #include "logging.h"
 
@@ -93,44 +94,43 @@
       }
       return kBuiltinVector[element_name];
     }
-    AIDL_FATAL_IF(typenames.IsList(type), type);
-  } else {
-    const string& type_name = type.GetName();
-    if (kBuiltin.find(type_name) != kBuiltin.end()) {
-      AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(type_name), type);
-      if (type_name == "IBinder" && nullable && readMethod) {
-        return "NullableStrongBinder";
-      }
-      if (type_name == "ParcelFileDescriptor" && nullable && !readMethod) {
-        return "NullableParcelable";
-      }
-      if (utf8) {
-        AIDL_FATAL_IF(type_name != "String", type);
-        return readMethod ? "Utf8FromUtf16" : "Utf8AsUtf16";
-      }
-      return kBuiltin[type_name];
-    }
-  }
-  AIDL_FATAL_IF(AidlTypenames::IsBuiltinTypename(type.GetName()), type);
-  auto definedType = typenames.TryGetDefinedType(type.GetName());
-  if (definedType != nullptr && definedType->AsInterface() != nullptr) {
-    if (isVector) {
+    auto definedType = typenames.TryGetDefinedType(element_name);
+    if (definedType != nullptr && definedType->AsInterface() != nullptr) {
       return "StrongBinderVector";
     }
+    return "ParcelableVector";
+  }
+
+  const string& type_name = type.GetName();
+  if (kBuiltin.find(type_name) != kBuiltin.end()) {
+    AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(type_name), type);
+    if (type_name == "IBinder" && nullable && readMethod) {
+      return "NullableStrongBinder";
+    }
+    if (type_name == "ParcelFileDescriptor" && nullable && !readMethod) {
+      return "NullableParcelable";
+    }
+    if (utf8) {
+      AIDL_FATAL_IF(type_name != "String", type);
+      return readMethod ? "Utf8FromUtf16" : "Utf8AsUtf16";
+    }
+    return kBuiltin[type_name];
+  }
+
+  AIDL_FATAL_IF(AidlTypenames::IsBuiltinTypename(type.GetName()), type);
+  auto definedType = typenames.TryGetDefinedType(type.GetName());
+  // The type must be either primitive or interface or parcelable,
+  // so it cannot be nullptr.
+  AIDL_FATAL_IF(definedType == nullptr, type) << type.GetName() << " is not found.";
+
+  if (definedType->AsInterface() != nullptr) {
     if (nullable && readMethod) {
       return "NullableStrongBinder";
     }
     return "StrongBinder";
   }
 
-  // The type must be either primitive or interface or parcelable,
-  // so it cannot be nullptr.
-  AIDL_FATAL_IF(definedType == nullptr, type) << type.GetName() << " is not found.";
-
   // Parcelable
-  if (isVector) {
-    return "ParcelableVector";
-  }
   if (nullable && !readMethod) {
     return "NullableParcelable";
   }
@@ -203,15 +203,17 @@
     return "::android::String16(" + raw_value + ")";
   }
 
+  if (auto defined_type = type.GetDefinedType(); defined_type) {
+    auto enum_type = defined_type->AsEnumDeclaration();
+    AIDL_FATAL_IF(!enum_type, type) << "Invalid type for \"" << raw_value << "\"";
+    return GetRawCppName(type) + "::" + raw_value.substr(raw_value.find_last_of('.') + 1);
+  }
+
   return raw_value;
 };
 
-std::string GetTransactionIdFor(const AidlMethod& method) {
-  ostringstream output;
-
-  output << "::android::IBinder::FIRST_CALL_TRANSACTION + ";
-  output << method.GetId() << " /* " << method.GetName() << " */";
-  return output.str();
+std::string GetTransactionIdFor(const AidlInterface& iface, const AidlMethod& method) {
+  return ClassName(iface, ClassNames::SERVER) + "::TRANSACTION_" + method.GetName();
 }
 
 std::string CppNameOf(const AidlTypeSpecifier& type, const AidlTypenames& typenames) {
@@ -339,7 +341,7 @@
   AIDL_FATAL_IF(definedType == nullptr, type) << "Unexpected type: " << type.GetName();
 
   if (definedType->AsInterface() != nullptr || definedType->AsStructuredParcelable() != nullptr ||
-      definedType->AsEnumDeclaration() != nullptr) {
+      definedType->AsEnumDeclaration() != nullptr || definedType->AsUnionDeclaration() != nullptr) {
     AddHeaders(*definedType, headers);
   } else if (definedType->AsParcelable() != nullptr) {
     const std::string cpp_header = definedType->AsParcelable()->GetCppHeader();
diff --git a/aidl_to_cpp.h b/aidl_to_cpp.h
index ecd9f38..f6974f5 100644
--- a/aidl_to_cpp.h
+++ b/aidl_to_cpp.h
@@ -32,10 +32,9 @@
   const AidlTypeSpecifier& type;  // an argument or return type to generate code for
   const string name;              // name of the variable for the argument or the return value
   const bool isPointer;           // whether the variable 'name' is a pointer or not
-  const string log;               // name of the variable of type Json::Value to write the log into
 };
 
-std::string GetTransactionIdFor(const AidlMethod& method);
+std::string GetTransactionIdFor(const AidlInterface& iface, const AidlMethod& method);
 
 std::string CppNameOf(const AidlTypeSpecifier& type, const AidlTypenames& typenames);
 
diff --git a/aidl_to_cpp_common.cpp b/aidl_to_cpp_common.cpp
index c1953ac..f47a40a 100644
--- a/aidl_to_cpp_common.cpp
+++ b/aidl_to_cpp_common.cpp
@@ -15,11 +15,15 @@
  */
 #include "aidl_to_cpp_common.h"
 
+#include <android-base/format.h>
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
+
+#include <set>
 #include <unordered_map>
 
 #include "ast_cpp.h"
+#include "comments.h"
 #include "logging.h"
 #include "os.h"
 
@@ -29,6 +33,33 @@
 namespace aidl {
 namespace cpp {
 
+char kTransactionLogStruct[] = R"(struct TransactionLog {
+  double duration_ms;
+  std::string interface_name;
+  std::string method_name;
+  const void* proxy_address;
+  const void* stub_address;
+  std::vector<std::pair<std::string, std::string>> input_args;
+  std::vector<std::pair<std::string, std::string>> output_args;
+  std::string result;
+  std::string exception_message;
+  int32_t exception_code;
+  int32_t transaction_error;
+  int32_t service_specific_error_code;
+};
+)";
+
+char kToStringHelper[] = R"(template <typename _T> class _has_toString {
+  template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+  template <typename _U> static std::false_type __has_toString(...);
+  public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+};
+template <typename _T> inline static std::string _call_toString(const _T& t) {
+  if constexpr (_has_toString<_T>::value) return t.toString();
+  return "{no toString() implemented}";
+}
+)";
+
 string ClassName(const AidlDefinedType& defined_type, ClassNames type) {
   string base_name = defined_type.GetName();
   if (base_name.length() >= 2 && base_name[0] == 'I' && isupper(base_name[1])) {
@@ -91,157 +122,116 @@
   return prefix + a.GetName();
 }
 
-struct TypeInfo {
-  // name of the type in C++ output
-  std::string cpp_name;
+string ToString(const AidlTypeSpecifier& type, const string& expr);
+string ToStringNullable(const AidlTypeSpecifier& type, const string& expr);
+string ToStringNullableVector(const AidlTypeSpecifier& element_type, const string& expr);
+string ToStringVector(const AidlTypeSpecifier& element_type, const string& expr);
+string ToStringRaw(const AidlTypeSpecifier& type, const string& expr);
 
-  // function that writes an expression to convert a variable to a Json::Value
-  // object
-  std::function<void(CodeWriter& w, const string& var_name, bool isNdk)> toJsonValueExpr;
-};
+string ToStringNullable(const AidlTypeSpecifier& type, const string& expr) {
+  if (AidlTypenames::IsPrimitiveTypename(type.GetName())) {
+    // we don't allow @nullable for primitives
+    return ToStringRaw(type, expr);
+  }
+  return "((" + expr + ") ? " + ToStringRaw(type, "*" + expr) + ": \"(null)\")";
+}
 
-const static std::unordered_map<std::string, TypeInfo> kTypeInfoMap = {
-    {"void", {"void", nullptr}},
-    {"boolean",
-     {
-         "bool",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(" << var_name << "? \"true\" : \"false\")";
-         },
-     }},
-    {"byte",
-     {
-         "int8_t",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(" << var_name << ")";
-         },
-     }},
-    {"char",
-     {
-         "char16_t",
-         [](CodeWriter& c, const string& var_name, bool isNdk) {
-           if (isNdk) {
-             c << "Json::Value(" << var_name << ")";
-           } else {
-             c << "Json::Value(std::string(android::String8(&" << var_name << ", 1)))";
-           }
-         },
-     }},
-    {"int",
-     {
-         "int32_t",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(" << var_name << ")";
-         },
-     }},
-    {"long",
-     {
-         "int64_t",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(static_cast<Json::Int64>(" << var_name << "))";
-         },
-     }},
-    {"float",
-     {
-         "float",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(" << var_name << ")";
-         },
-     }},
-    {"double",
-     {
-         "double",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(" << var_name << ")";
-         },
-     }},
-    {"String",
-     {
-         "std::string",
-         [](CodeWriter& c, const string& var_name, bool) {
-           c << "Json::Value(" << var_name << ")";
-         },
-     }}
-    // missing List, Map, ParcelFileDescriptor, IBinder
-};
+string ToStringVector(const AidlTypeSpecifier& element_type, const string& expr) {
+  return "[&](){ std::ostringstream o; o << \"[\"; bool first = true; for (const auto& v: " + expr +
+         ") { (void)v; if (first) first = false; else o << \", \"; o << " +
+         ToStringRaw(element_type, "v") + "; }; o << \"]\"; return o.str(); }()";
+}
 
-TypeInfo GetTypeInfo(const AidlTypeSpecifier& aidl) {
-  AIDL_FATAL_IF(!aidl.IsResolved(), aidl) << aidl.ToString();
-  const string& aidl_name = aidl.GetName();
+string ToStringNullableVector(const AidlTypeSpecifier& element_type, const string& expr) {
+  return "[&](){ if (!(" + expr +
+         ")) return std::string(\"(null)\"); std::ostringstream o; o << \"[\"; bool first = true; "
+         "for (const auto& v: *(" +
+         expr + ")) { (void)v; if (first) first = false; else o << \", \"; o << " +
+         ToStringNullable(element_type, "v") + "; }; o << \"]\"; return o.str(); }()";
+}
 
-  TypeInfo info;
-  if (AidlTypenames::IsBuiltinTypename(aidl_name)) {
-    auto it = kTypeInfoMap.find(aidl_name);
-    if (it != kTypeInfoMap.end()) {
-      info = it->second;
+string ToStringRaw(const AidlTypeSpecifier& type, const string& expr) {
+  if (AidlTypenames::IsBuiltinTypename(type.GetName())) {
+    if (AidlTypenames::IsPrimitiveTypename(type.GetName())) {
+      if (type.GetName() == "boolean") {
+        return "(" + expr + "?\"true\":\"false\")";
+      }
+      if (type.GetName() == "char") {
+        return "std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(" +
+               expr + ")";
+      }
+      return "std::to_string(" + expr + ")";
     }
-  }
-  // Missing interface and parcelable type
-  return info;
-}
-
-inline bool CanWriteLog(const TypeInfo& t) {
-  return t.cpp_name != "";
-}
-
-bool CanWriteLog(const AidlTypeSpecifier& aidl) {
-  return CanWriteLog(GetTypeInfo(aidl));
-}
-
-void WriteLogFor(CodeWriter& writer, const AidlTypeSpecifier& type, const std::string& name,
-                 bool isPointer, const std::string& log, bool isNdk) {
-  const TypeInfo info = GetTypeInfo(type);
-  if (!CanWriteLog(info)) {
-    return;
+    if (type.GetName() == "String") {
+      return "(std::ostringstream() << " + expr + ").str()";
+    }
+    // ""(empty string) for unsupported types
+    return "\"\"";
   }
 
-  const string var_object_expr = ((isPointer ? "*" : "")) + name;
+  const AidlDefinedType* defined_type = type.GetDefinedType();
+  AIDL_FATAL_IF(defined_type == nullptr, type);
+
+  if (defined_type->AsInterface()) {
+    // ""(empty string) for unsupported types
+    return "\"\"";
+  }
+  if (defined_type->AsEnumDeclaration()) {
+    const auto ns = Join(defined_type->GetSplitPackage(), "::");
+    return ns + "::toString(" + expr + ")";
+  }
+  return "_call_toString(" + expr + ")";
+}
+
+string ToString(const AidlTypeSpecifier& type, const string& expr) {
+  static const std::set<string> kNotSupported = {"Map", "IBinder", "ParcelFileDescriptor",
+                                                 "ParcelableHolder"};
+  if (kNotSupported.find(type.GetName()) != kNotSupported.end()) {
+    // ""(empty string) for unsupported types
+    return "\"\"";
+  }
+  if (type.IsArray() && type.IsNullable()) {
+    const auto& element_type = type.ArrayBase();
+    return ToStringNullableVector(element_type, expr);
+  }
+  if (type.GetName() == "List" && type.IsNullable()) {
+    const auto& element_type = *type.GetTypeParameters()[0];
+    return ToStringNullableVector(element_type, expr);
+  }
   if (type.IsArray()) {
-    writer << log << " = Json::Value(Json::arrayValue);\n";
-    writer << "for (const auto& v: " << var_object_expr << ") " << log << ".append(";
-    info.toJsonValueExpr(writer, "v", isNdk);
-    writer << ");";
-  } else {
-    writer << log << " = ";
-    info.toJsonValueExpr(writer, var_object_expr, isNdk);
-    writer << ";";
+    const auto& element_type = type.ArrayBase();
+    return ToStringVector(element_type, expr);
   }
-  writer << "\n";
+  if (type.GetName() == "List") {
+    const auto& element_type = *type.GetTypeParameters()[0];
+    return ToStringVector(element_type, expr);
+  }
+  if (type.IsNullable()) {
+    return ToStringNullable(type, expr);
+  }
+  return ToStringRaw(type, expr);
 }
 
-void WriteLogForArguments(CodeWriterPtr& writer, const AidlArgument& a, bool isServer,
-                          string logVarName, bool isNdk) {
-  if (!CanWriteLog(a.GetType())) {
-    return;
-  }
-  string logElementVarName = "_log_arg_element";
-  (*writer) << "{\n";
-  (*writer).Indent();
-  (*writer) << "Json::Value " << logElementVarName << "(Json::objectValue);\n";
-  string varName = isServer || isNdk ? BuildVarName(a) : a.GetName();
-  (*writer) << logElementVarName << "[\"name\"] = \"" << varName << "\";\n";
-
-  bool isPointer = a.IsOut() && !isServer;
-  WriteLogFor(*(writer.get()), a.GetType(), varName, isPointer, logElementVarName + "[\"value\"]",
-              isNdk);
-  (*writer) << logVarName << ".append(" << logElementVarName << ");\n";
-  (*writer) << "}\n";
-  (*writer).Dedent();
+void WriteLogForArgument(CodeWriter& w, const AidlArgument& a, bool is_server,
+                         const string& log_var, bool is_ndk) {
+  const string var_name = is_server || is_ndk ? BuildVarName(a) : a.GetName();
+  const bool is_pointer = a.IsOut() && !is_server;
+  const string value_expr = (is_pointer ? "*" : "") + var_name;
+  w << log_var
+    << ".emplace_back(\"" + var_name + "\", " + ToString(a.GetType(), value_expr) + ");\n";
 }
 
 const string GenLogBeforeExecute(const string className, const AidlMethod& method, bool isServer,
                                  bool isNdk) {
   string code;
   CodeWriterPtr writer = CodeWriter::ForString(&code);
-  (*writer) << "Json::Value _log_input_args(Json::arrayValue);\n";
+  (*writer) << className << "::TransactionLog _transaction_log;\n";
 
   (*writer) << "if (" << className << "::logFunc != nullptr) {\n";
   (*writer).Indent();
 
-  for (const auto& a : method.GetArguments()) {
-    if (a->IsIn()) {
-      WriteLogForArguments(writer, *a, isServer, "_log_input_args", isNdk);
-    }
+  for (const auto& a : method.GetInArguments()) {
+    WriteLogForArgument(*writer, *a, isServer, "_transaction_log.input_args", isNdk);
   }
 
   (*writer).Dedent();
@@ -260,95 +250,45 @@
 
   (*writer) << "if (" << className << "::logFunc != nullptr) {\n";
   (*writer).Indent();
-
-  // Write the log as a Json object. For example,
-  //
-  // Json log object for following interface description
-  //
-  // package foo.bar;
-  // interface IFoo {
-  //   String TestMethod(int arg1, inout String[] arg2, out double arg3);
-  // }
-  //
-  // would be:
-  //
-  // {
-  //   duration_ms: 100.42,
-  //   interface_name: "foo.bar.IFoo",
-  //   method_name: "TestMethod",
-  //   (proxy|stub)_address: "0x12345678",
-  //   input_args: [
-  //     {name: "arg1", value: 30,},
-  //     {name: "arg2", value: ["apple", "grape"],},
-  //   ],
-  //   output_args: [
-  //     {name: "arg2", value: ["mango", "banana"],},
-  //     {name: "arg3", value: "10.5",},
-  //   ],
-  //   _aidl_return: "ok",
-  //   binder_status: {
-  //     exception_code: -8,
-  //     exception_message: "Something wrong",
-  //     transaction_error: 0,
-  //     service_specific_error_code: -42,
-  //   },
-  // }
+  const auto address = (isNdk && isServer) ? "_aidl_impl.get()" : "static_cast<const void*>(this)";
   (*writer) << "auto _log_end = std::chrono::steady_clock::now();\n";
-  (*writer) << "Json::Value _log_transaction(Json::objectValue);\n";
-  (*writer) << "_log_transaction[\"duration_ms\"] = "
-            << "std::chrono::duration<double, std::milli>(_log_end - "
-               "_log_start).count();\n";
-  (*writer) << "_log_transaction[\"interface_name\"] = "
-            << "Json::Value(\"" << interface.GetCanonicalName() << "\");\n";
-  (*writer) << "_log_transaction[\"method_name\"] = "
-            << "Json::Value(\"" << method.GetName() << "\");\n";
+  (*writer) << "_transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end "
+               "- _log_start).count();\n";
+  (*writer) << "_transaction_log.interface_name = \"" << interface.GetCanonicalName() << "\";\n";
+  (*writer) << "_transaction_log.method_name = \"" << method.GetName() << "\";\n";
+  (*writer) << "_transaction_log.stub_address = " << (isServer ? address : "nullptr") << ";\n";
+  (*writer) << "_transaction_log.proxy_address = " << (isServer ? "nullptr" : address) << ";\n";
 
-  (*writer) << "_log_transaction[\"" << (isServer ? "stub_address" : "proxy_address") << "\"] = ";
-  (*writer) << "Json::Value("
-            << "(std::ostringstream() << "
-            << (isNdk && isServer ? "_aidl_impl" : "static_cast<const void*>(this)") << ").str()"
-            << ");\n";
-  (*writer) << "_log_transaction[\"input_args\"] = _log_input_args;\n";
-  (*writer) << "Json::Value _log_output_args(Json::arrayValue);\n";
-
-  (*writer) << "Json::Value _log_status(Json::objectValue);\n";
   if (isNdk) {
-    (*writer) << "_log_status[\"exception_code\"] = Json::Value(AStatus_getExceptionCode("
-              << statusVarName << ".get()));\n";
-    (*writer) << "_log_status[\"exception_message\"] = Json::Value(AStatus_getMessage("
-              << statusVarName << ".get()));\n";
-    (*writer) << "_log_status[\"transaction_error\"] = Json::Value(AStatus_getStatus("
-              << statusVarName << ".get()));\n";
-    (*writer) << "_log_status[\"service_specific_error_code\"] = "
-                 "Json::Value(AStatus_getServiceSpecificError("
-              << statusVarName << ".get()));\n";
+    (*writer) << "_transaction_log.exception_code = AStatus_getExceptionCode(" << statusVarName
+              << ".get());\n";
+    (*writer) << "_transaction_log.exception_message = AStatus_getMessage(" << statusVarName
+              << ".get());\n";
+    (*writer) << "_transaction_log.transaction_error = AStatus_getStatus(" << statusVarName
+              << ".get());\n";
+    (*writer) << "_transaction_log.service_specific_error_code = AStatus_getServiceSpecificError("
+              << statusVarName << ".get());\n";
   } else {
-    (*writer) << "_log_status[\"exception_code\"] = Json::Value(" << statusVarName
-              << ".exceptionCode());\n";
-    (*writer) << "_log_status[\"exception_message\"] = Json::Value(" << statusVarName
-              << ".exceptionMessage());\n";
-    (*writer) << "_log_status[\"transaction_error\"] = Json::Value(" << statusVarName
-              << ".transactionError());\n";
-    (*writer) << "_log_status[\"service_specific_error_code\"] = Json::Value(" << statusVarName
-              << ".serviceSpecificErrorCode());\n";
+    (*writer) << "_transaction_log.exception_code = " << statusVarName << ".exceptionCode();\n";
+    (*writer) << "_transaction_log.exception_message = " << statusVarName
+              << ".exceptionMessage();\n";
+    (*writer) << "_transaction_log.transaction_error = " << statusVarName
+              << ".transactionError();\n";
+    (*writer) << "_transaction_log.service_specific_error_code = " << statusVarName
+              << ".serviceSpecificErrorCode();\n";
   }
 
-  (*writer) << "_log_transaction[\"binder_status\"] = _log_status;\n";
-
   for (const auto& a : method.GetOutArguments()) {
-    WriteLogForArguments(writer, *a, isServer, "_log_output_args", isNdk);
+    WriteLogForArgument(*writer, *a, isServer, "_transaction_log.output_args", isNdk);
   }
 
-  (*writer) << "_log_transaction[\"output_args\"] = _log_output_args;\n";
-
   if (method.GetType().GetName() != "void") {
-    WriteLogFor(*(writer.get()), method.GetType(), returnVarName, !isServer,
-                "_log_transaction[\"" + returnVarName + "\"]", isNdk);
+    const string expr = (isServer ? "" : "*") + returnVarName;
+    (*writer) << "_transaction_log.result = " << ToString(method.GetType(), expr) << ";\n";
   }
 
-  // call the user-provided function with the Json object for the entire
-  // transaction
-  (*writer) << className << "::logFunc(_log_transaction);\n";
+  // call the user-provided function with the transaction log object
+  (*writer) << className << "::logFunc(_transaction_log);\n";
 
   (*writer).Dedent();
   (*writer) << "}\n";
@@ -367,8 +307,9 @@
   code << "#pragma clang diagnostic push\n";
   code << "#pragma clang diagnostic ignored \"-Wc++17-extensions\"\n";
   code << "template <>\n";
-  code << "constexpr inline std::array<" << fq_name << ", " << size << "> enum_values<" << fq_name
-       << "> = {\n";
+  code << "constexpr inline std::array<" << fq_name << ", " << size << ">";
+  GenerateDeprecated(code, enum_decl);
+  code << " enum_values<" << fq_name << "> = {\n";
   for (const auto& enumerator : enum_decl.GetEnumerators()) {
     code << "  " << fq_name << "::" << enumerator->GetName() << ",\n";
   }
@@ -377,7 +318,7 @@
   return code.str();
 }
 
-std::string TemplateDecl(const AidlStructuredParcelable& defined_type) {
+std::string TemplateDecl(const AidlParcelable& defined_type) {
   std::string decl = "";
   if (defined_type.IsGeneric()) {
     std::vector<std::string> template_params;
@@ -390,6 +331,269 @@
   return decl;
 }
 
+void GenerateParcelableComparisonOperators(CodeWriter& out, const AidlParcelable& parcelable) {
+  std::set<string> operators{"<", ">", "==", ">=", "<=", "!="};
+  bool is_empty = false;
+
+  auto comparable = [&](const string& prefix) {
+    vector<string> fields;
+    if (auto p = parcelable.AsStructuredParcelable(); p != nullptr) {
+      is_empty = p->GetFields().empty();
+      for (const auto& f : p->GetFields()) {
+        fields.push_back(prefix + f->GetName());
+      }
+      return "std::tie(" + Join(fields, ", ") + ")";
+    } else if (auto p = parcelable.AsUnionDeclaration(); p != nullptr) {
+      return prefix + "_value";
+    } else {
+      AIDL_FATAL(parcelable) << "Unknown paracelable type";
+    }
+  };
+
+  string lhs = comparable("");
+  string rhs = comparable("rhs.");
+  for (const auto& op : operators) {
+    out << "inline bool operator" << op << "(const " << parcelable.GetName() << "&"
+        << (is_empty ? "" : " rhs") << ") const {\n"
+        << "  return " << lhs << " " << op << " " << rhs << ";\n"
+        << "}\n";
+  }
+  out << "\n";
+}
+
+// Output may look like:
+// inline std::string toString() const {
+//   std::ostringstream os;
+//   os << "MyData{";
+//   os << "field1: " << field1;
+//   os << ", field2: " << v.field2;
+//   ...
+//   os << "}";
+//   return os.str();
+// }
+void GenerateToString(CodeWriter& out, const AidlStructuredParcelable& parcelable) {
+  out << kToStringHelper;
+  out << "inline std::string toString() const {\n";
+  out.Indent();
+  out << "std::ostringstream os;\n";
+  out << "os << \"" << parcelable.GetName() << "{\";\n";
+  bool first = true;
+  for (const auto& f : parcelable.GetFields()) {
+    if (first) {
+      out << "os << \"";
+      first = false;
+    } else {
+      out << "os << \", ";
+    }
+    out << f->GetName() << ": \" << " << ToString(f->GetType(), f->GetName()) << ";\n";
+  }
+  out << "os << \"}\";\n";
+  out << "return os.str();\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+// Output may look like:
+// inline std::string toString() const {
+//   std::ostringstream os;
+//   os << "MyData{";
+//   switch (v.getTag()) {
+//   case MyData::field: os << "field: " << v.get<MyData::field>(); break;
+//   ...
+//   }
+//   os << "}";
+//   return os.str();
+// }
+void GenerateToString(CodeWriter& out, const AidlUnionDecl& parcelable) {
+  out << kToStringHelper;
+  out << "inline std::string toString() const {\n";
+  out.Indent();
+  out << "std::ostringstream os;\n";
+  out << "os << \"" + parcelable.GetName() + "{\";\n";
+  out << "switch (getTag()) {\n";
+  for (const auto& f : parcelable.GetFields()) {
+    const string tag = f->GetName();
+    out << "case " << tag << ": os << \"" << tag << ": \" << "
+        << ToString(f->GetType(), "get<" + tag + ">()") << "; break;\n";
+  }
+  out << "}\n";
+  out << "os << \"}\";\n";
+  out << "return os.str();\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+std::string GetDeprecatedAttribute(const AidlCommentable& type) {
+  if (auto deprecated = FindDeprecated(type.GetComments()); deprecated.has_value()) {
+    if (deprecated->note.empty()) {
+      return "__attribute__((deprecated))";
+    }
+    return "__attribute__((deprecated(" + QuotedEscape(deprecated->note) + ")))";
+  }
+  return "";
+}
+
+const vector<string> UnionWriter::headers{
+    "cassert",      // __assert for logging
+    "type_traits",  // std::is_same_v
+    "utility",      // std::mode/forward for value
+    "variant",      // std::variant for value
+};
+
+void UnionWriter::PrivateFields(CodeWriter& out) const {
+  vector<string> field_types;
+  for (const auto& f : decl.GetFields()) {
+    field_types.push_back(name_of(f->GetType(), typenames));
+  }
+  out << "std::variant<" + Join(field_types, ", ") + "> _value;\n";
+}
+
+void UnionWriter::PublicFields(CodeWriter& out) const {
+  AidlTypeSpecifier tag_type(AIDL_LOCATION_HERE, "int", /* is_array= */ false,
+                             /* type_params= */ nullptr, Comments{});
+  tag_type.Resolve(typenames);
+
+  out << "enum Tag : " << name_of(tag_type, typenames) << " {\n";
+  bool is_first = true;
+  for (const auto& f : decl.GetFields()) {
+    out << "  " << f->GetName();
+    GenerateDeprecated(out, *f);
+    if (is_first) out << " = 0";
+    out << ",  // " << f->Signature() << ";\n";
+    is_first = false;
+  }
+  out << "};\n";
+
+  const auto& name = decl.GetName();
+
+  AIDL_FATAL_IF(decl.GetFields().empty(), decl) << "Union '" << name << "' is empty.";
+  const auto& first_field = decl.GetFields()[0];
+  const auto& default_name = first_field->GetName();
+  const auto& default_value =
+      name_of(first_field->GetType(), typenames) + "(" + first_field->ValueString(decorator) + ")";
+
+  auto tmpl = R"--(
+template<typename _Tp>
+static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, {name}>;
+
+{name}() : _value(std::in_place_index<{default_name}>, {default_value}) {{ }}
+{name}(const {name}&) = default;
+{name}({name}&&) = default;
+{name}& operator=(const {name}&) = default;
+{name}& operator=({name}&&) = default;
+
+template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+// NOLINTNEXTLINE(google-explicit-constructor)
+constexpr {name}(_Tp&& _arg)
+    : _value(std::forward<_Tp>(_arg)) {{}}
+
+template <typename... _Tp>
+constexpr explicit {name}(_Tp&&... _args)
+    : _value(std::forward<_Tp>(_args)...) {{}}
+
+template <Tag _tag, typename... _Tp>
+static {name} make(_Tp&&... _args) {{
+  return {name}(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+}}
+
+template <Tag _tag, typename _Tp, typename... _Up>
+static {name} make(std::initializer_list<_Tp> _il, _Up&&... _args) {{
+  return {name}(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+}}
+
+Tag getTag() const {{
+  return static_cast<Tag>(_value.index());
+}}
+
+template <Tag _tag>
+const auto& get() const {{
+  if (getTag() != _tag) {{ __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }}
+  return std::get<_tag>(_value);
+}}
+
+template <Tag _tag>
+auto& get() {{
+  if (getTag() != _tag) {{ __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }}
+  return std::get<_tag>(_value);
+}}
+
+template <Tag _tag, typename... _Tp>
+void set(_Tp&&... _args) {{
+  _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+}}
+
+)--";
+  out << fmt::format(tmpl, fmt::arg("name", name), fmt::arg("default_name", default_name),
+                     fmt::arg("default_value", default_value));
+}
+
+void UnionWriter::ReadFromParcel(CodeWriter& out, const ParcelWriterContext& ctx) const {
+  AidlTypeSpecifier tag_type(AIDL_LOCATION_HERE, "int", /* is_array= */ false,
+                             /* type_params= */ nullptr, Comments{});
+  tag_type.Resolve(typenames);
+
+  const string tag = "_aidl_tag";
+  const string value = "_aidl_value";
+  const string status = "_aidl_ret_status";
+
+  auto read_var = [&](const string& var, const AidlTypeSpecifier& type) {
+    out << fmt::format("{} {};\n", name_of(type, typenames), var);
+    out << fmt::format("if (({} = ", status);
+    ctx.read_func(out, var, type);
+    out << fmt::format(") != {}) return {};\n", ctx.status_ok, status);
+  };
+
+  out << fmt::format("{} {};\n", ctx.status_type, status);
+  read_var(tag, tag_type);
+  out << fmt::format("switch ({}) {{\n", tag);
+  for (const auto& variable : decl.GetFields()) {
+    out << fmt::format("case {}: {{\n", variable->GetName());
+    out.Indent();
+    const auto& type = variable->GetType();
+    read_var(value, type);
+    out << fmt::format("if constexpr (std::is_trivially_copyable_v<{}>) {{\n",
+                       name_of(type, typenames));
+    out.Indent();
+    out << fmt::format("set<{}>({});\n", variable->GetName(), value);
+    out.Dedent();
+    out << "} else {\n";
+    out.Indent();
+    // Even when the `if constexpr` is false, the compiler runs the tidy check for the
+    // next line, which doesn't make sense. Silence the check for the unreachable code.
+    out << "// NOLINTNEXTLINE(performance-move-const-arg)\n";
+    out << fmt::format("set<{}>(std::move({}));\n", variable->GetName(), value);
+    out.Dedent();
+    out << "}\n";
+    out << fmt::format("return {}; }}\n", ctx.status_ok);
+    out.Dedent();
+  }
+  out << "}\n";
+  out << fmt::format("return {};\n", ctx.status_bad);
+}
+
+void UnionWriter::WriteToParcel(CodeWriter& out, const ParcelWriterContext& ctx) const {
+  AidlTypeSpecifier tag_type(AIDL_LOCATION_HERE, "int", /* is_array= */ false,
+                             /* type_params= */ nullptr, Comments{});
+  tag_type.Resolve(typenames);
+
+  const string tag = "_aidl_tag";
+  const string value = "_aidl_value";
+  const string status = "_aidl_ret_status";
+
+  out << fmt::format("{} {} = ", ctx.status_type, status);
+  ctx.write_func(out, "getTag()", tag_type);
+  out << ";\n";
+  out << fmt::format("if ({} != {}) return {};\n", status, ctx.status_ok, status);
+  out << "switch (getTag()) {\n";
+  for (const auto& variable : decl.GetFields()) {
+    out << fmt::format("case {}: return ", variable->GetName());
+    ctx.write_func(out, "get<" + variable->GetName() + ">()", variable->GetType());
+    out << ";\n";
+  }
+  out << "}\n";
+  out << "__assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, \"can't reach here\");\n";
+}
+
 }  // namespace cpp
 }  // namespace aidl
 }  // namespace android
diff --git a/aidl_to_cpp_common.h b/aidl_to_cpp_common.h
index 2892f88..368e724 100644
--- a/aidl_to_cpp_common.h
+++ b/aidl_to_cpp_common.h
@@ -16,6 +16,7 @@
 
 #pragma once
 
+#include <functional>
 #include <string>
 #include <type_traits>
 
@@ -28,6 +29,11 @@
 namespace aidl {
 namespace cpp {
 
+// provides _call_toString(expr) which call expr.toString() if possible
+extern char kToStringHelper[];
+
+extern char kTransactionLogStruct[];
+
 // These roughly correspond to the various class names in the C++ hierarchy:
 enum class ClassNames {
   BASE,          // Foo (not a real class, but useful in some circumstances).
@@ -72,7 +78,44 @@
 
 std::string GenerateEnumValues(const AidlEnumDeclaration& enum_decl,
                                const std::vector<std::string>& enclosing_namespaces_of_enum_decl);
-std::string TemplateDecl(const AidlStructuredParcelable& defined_type);
+std::string TemplateDecl(const AidlParcelable& defined_type);
+
+void GenerateParcelableComparisonOperators(CodeWriter& out, const AidlParcelable& parcelable);
+
+void GenerateToString(CodeWriter& out, const AidlStructuredParcelable& parcelable);
+void GenerateToString(CodeWriter& out, const AidlUnionDecl& parcelable);
+
+std::string GetDeprecatedAttribute(const AidlCommentable& type);
+
+template <typename Stream>
+void GenerateDeprecated(Stream& out, const AidlCommentable& type) {
+  if (auto deprecated = GetDeprecatedAttribute(type); !deprecated.empty()) {
+    out << " " + deprecated;
+  }
+}
+
+struct ParcelWriterContext {
+  string status_type;
+  string status_ok;
+  string status_bad;
+  std::function<void(CodeWriter& out, const std::string& var, const AidlTypeSpecifier& type)>
+      read_func;
+  std::function<void(CodeWriter& out, const std::string& value, const AidlTypeSpecifier& type)>
+      write_func;
+};
+
+struct UnionWriter {
+  const AidlUnionDecl& decl;
+  const AidlTypenames& typenames;
+  const std::function<std::string(const AidlTypeSpecifier&, const AidlTypenames&)> name_of;
+  const ::ConstantValueDecorator& decorator;
+  static const std::vector<std::string> headers;
+
+  void PrivateFields(CodeWriter& out) const;
+  void PublicFields(CodeWriter& out) const;
+  void ReadFromParcel(CodeWriter& out, const ParcelWriterContext&) const;
+  void WriteToParcel(CodeWriter& out, const ParcelWriterContext&) const;
+};
 
 }  // namespace cpp
 }  // namespace aidl
diff --git a/aidl_to_java.cpp b/aidl_to_java.cpp
index 9bb9052..6030a35 100644
--- a/aidl_to_java.cpp
+++ b/aidl_to_java.cpp
@@ -39,10 +39,17 @@
 using std::vector;
 
 std::string ConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value) {
-  if (type.GetName() == "long" && !type.IsArray()) {
+  if (type.IsArray()) {
+    return raw_value;
+  }
+  if (type.GetName() == "long") {
     return raw_value + "L";
   }
-
+  if (auto defined_type = type.GetDefinedType(); defined_type) {
+    auto enum_type = defined_type->AsEnumDeclaration();
+    AIDL_FATAL_IF(!enum_type, type) << "Invalid type for \"" << raw_value << "\"";
+    return type.GetName() + "." + raw_value.substr(raw_value.find_last_of('.') + 1);
+  }
   return raw_value;
 };
 
@@ -264,18 +271,14 @@
        [](const CodeGeneratorContext& c) {
          if (c.type.IsGeneric()) {
            const string& contained_type = c.type.GetTypeParameters().at(0)->GetName();
-           if (AidlTypenames::IsBuiltinTypename(contained_type)) {
-             if (contained_type == "String") {
-               c.writer << c.parcel << ".writeStringList(" << c.var << ");\n";
-             } else if (contained_type == "IBinder") {
-               c.writer << c.parcel << ".writeBinderList(" << c.var << ");\n";
-             }
+           if (contained_type == "String") {
+             c.writer << c.parcel << ".writeStringList(" << c.var << ");\n";
+           } else if (contained_type == "IBinder") {
+             c.writer << c.parcel << ".writeBinderList(" << c.var << ");\n";
+           } else if (c.typenames.IsParcelable(contained_type)) {
+             c.writer << c.parcel << ".writeTypedList(" << c.var << ");\n";
            } else {
-             const AidlDefinedType* t = c.typenames.TryGetDefinedType(contained_type);
-             AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << contained_type;
-             if (t->AsParcelable() != nullptr) {
-               c.writer << c.parcel << ".writeTypedList(" << c.var << ");\n";
-             }
+             AIDL_FATAL(c.type) << "write: NOT IMPLEMENTED for " << contained_type;
            }
          } else {
            c.writer << c.parcel << ".writeList(" << c.var << ");\n";
@@ -492,20 +495,16 @@
        [](const CodeGeneratorContext& c) {
          if (c.type.IsGeneric()) {
            const string& contained_type = c.type.GetTypeParameters().at(0)->GetName();
-           if (AidlTypenames::IsBuiltinTypename(contained_type)) {
-             if (contained_type == "String") {
-               c.writer << c.var << " = " << c.parcel << ".createStringArrayList();\n";
-             } else if (contained_type == "IBinder") {
-               c.writer << c.var << " = " << c.parcel << ".createBinderArrayList();\n";
-             }
+           if (contained_type == "String") {
+             c.writer << c.var << " = " << c.parcel << ".createStringArrayList();\n";
+           } else if (contained_type == "IBinder") {
+             c.writer << c.var << " = " << c.parcel << ".createBinderArrayList();\n";
+           } else if (c.typenames.IsParcelable(contained_type)) {
+             c.writer << c.var << " = " << c.parcel << ".createTypedArrayList("
+                      << JavaNameOf(*(c.type.GetTypeParameters().at(0)), c.typenames)
+                      << ".CREATOR);\n";
            } else {
-             const AidlDefinedType* t = c.typenames.TryGetDefinedType(contained_type);
-             AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << contained_type;
-             if (t->AsParcelable() != nullptr) {
-               c.writer << c.var << " = " << c.parcel << ".createTypedArrayList("
-                        << JavaNameOf(*(c.type.GetTypeParameters().at(0)), c.typenames)
-                        << ".CREATOR);\n";
-             }
+             AIDL_FATAL(c.type) << "create: NOT IMPLEMENTED for " << contained_type;
            }
          } else {
            const string classloader = EnsureAndGetClassloader(const_cast<CodeGeneratorContext&>(c));
@@ -620,7 +619,7 @@
         c.writer << c.var << " = " << c.type.GetName() << ".Stub.asInterface(" << c.parcel
                  << ".readStrongBinder());\n";
       }
-    } else if (t->AsParcelable() != nullptr || t->AsStructuredParcelable() != nullptr) {
+    } else if (t->AsParcelable() != nullptr) {
       if (c.type.IsArray()) {
         c.writer << c.var << " = " << c.parcel << ".createTypedArray("
                  << JavaNameOf(c.type, c.typenames) << ".CREATOR);\n";
@@ -682,20 +681,16 @@
        [](const CodeGeneratorContext& c) {
          if (c.type.IsGeneric()) {
            const string& contained_type = c.type.GetTypeParameters().at(0)->GetName();
-           if (AidlTypenames::IsBuiltinTypename(contained_type)) {
-             if (contained_type == "String") {
-               c.writer << c.parcel << ".readStringList(" << c.var << ");\n";
-             } else if (contained_type == "IBinder") {
-               c.writer << c.parcel << ".readBinderList(" << c.var << ");\n";
-             }
+           if (contained_type == "String") {
+             c.writer << c.parcel << ".readStringList(" << c.var << ");\n";
+           } else if (contained_type == "IBinder") {
+             c.writer << c.parcel << ".readBinderList(" << c.var << ");\n";
+           } else if (c.typenames.IsParcelable(contained_type)) {
+             c.writer << c.parcel << ".readTypedList(" << c.var << ", "
+                      << JavaNameOf(*(c.type.GetTypeParameters().at(0)), c.typenames)
+                      << ".CREATOR);\n";
            } else {
-             const AidlDefinedType* t = c.typenames.TryGetDefinedType(contained_type);
-             AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << contained_type;
-             if (t->AsParcelable() != nullptr) {
-               c.writer << c.parcel << ".readTypedList(" << c.var << ", "
-                        << JavaNameOf(*(c.type.GetTypeParameters().at(0)), c.typenames)
-                        << ".CREATOR);\n";
-             }
+             AIDL_FATAL(c.type) << "read: NOT IMPLEMENTED for " << contained_type;
            }
          } else {
            const string classloader = EnsureAndGetClassloader(const_cast<CodeGeneratorContext&>(c));
@@ -762,7 +757,7 @@
   } else {
     const AidlDefinedType* t = c.typenames.TryGetDefinedType(c.type.GetName());
     AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << c.type.GetName();
-    if (t->AsParcelable() != nullptr) {
+    if (t->AsParcelable() != nullptr || t->AsUnionDeclaration() != nullptr) {
       if (c.type.IsArray()) {
         c.writer << c.parcel << ".readTypedArray(" << c.var << ", " << c.type.GetName()
                  << ".CREATOR);\n";
@@ -780,8 +775,6 @@
 
 void ToStringFor(const CodeGeneratorContext& c) {
   if (c.type.IsArray()) {
-    // Arrays can be null
-    c.writer << c.var << " == null ? \"null\" : ";
     c.writer << "java.util.Arrays.toString(" << c.var << ")";
     return;
   }
@@ -816,7 +809,7 @@
   // that they are actually user-defined types.
   AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type";
   if (t->AsInterface() != nullptr || t->AsParcelable() != nullptr) {
-    c.writer << c.var << ".toString()";
+    c.writer << "java.util.Objects.toString(" << c.var << ")";
     return;
   }
 
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index c4b1aeb..9d1b794 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -70,10 +70,21 @@
 };
 
 std::string ConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value) {
+  if (type.IsArray()) {
+    return raw_value;
+  }
+
   if (type.GetName() == "long" && !type.IsArray()) {
     return raw_value + "L";
   }
 
+  if (auto defined_type = type.GetDefinedType(); defined_type) {
+    auto enum_type = defined_type->AsEnumDeclaration();
+    AIDL_FATAL_IF(!enum_type, type) << "Invalid type for \"" << raw_value << "\"";
+    return NdkFullClassName(*enum_type, cpp::ClassNames::RAW) +
+           "::" + raw_value.substr(raw_value.find_last_of('.') + 1);
+  }
+
   return raw_value;
 };
 
@@ -322,6 +333,19 @@
          }),
          .nullable_array = nullptr,
      }},
+    {"ParcelableHolder",
+     TypeInfo{
+         .raw =
+             TypeInfo::Aspect{
+                 .cpp_name = "::ndk::AParcelableHolder",
+                 .value_is_cheap = false,
+                 .read_func = StandardRead("::ndk::AParcel_readParcelable"),
+                 .write_func = StandardWrite("::ndk::AParcel_writeParcelable"),
+             },
+         .array = nullptr,
+         .nullable = nullptr,
+         .nullable_array = nullptr,
+     }},
 };
 
 static TypeInfo::Aspect GetTypeAspect(const AidlTypenames& types, const AidlTypeSpecifier& aidl) {
diff --git a/aidl_to_rust.cpp b/aidl_to_rust.cpp
index 61dceee..dd1751c 100644
--- a/aidl_to_rust.cpp
+++ b/aidl_to_rust.cpp
@@ -37,6 +37,8 @@
 namespace rust {
 
 namespace {
+std::string GetRawRustName(const AidlTypeSpecifier& type);
+
 std::string ConstantValueDecoratorInternal(const AidlTypeSpecifier& type,
                                            const std::string& raw_value, bool by_ref) {
   if (type.IsArray()) {
@@ -64,6 +66,12 @@
     return raw_value + ".into()";
   }
 
+  if (auto defined_type = type.GetDefinedType(); defined_type) {
+    auto enum_type = defined_type->AsEnumDeclaration();
+    AIDL_FATAL_IF(!enum_type, type) << "Invalid type for \"" << raw_value << "\"";
+    return GetRawRustName(type) + "::" + raw_value.substr(raw_value.find_last_of('.') + 1);
+  }
+
   return raw_value;
 }
 
@@ -96,8 +104,7 @@
   };
 
   // If the type is an array/List<T>, get the inner element type
-  AIDL_FATAL_IF(
-      type.IsGeneric() && (type.GetName() != "List" || type.GetTypeParameters().size() != 1), type);
+  AIDL_FATAL_IF(typenames.IsList(type) && type.GetTypeParameters().size() != 1, type);
   const auto& element_type = type.IsGeneric() ? (*type.GetTypeParameters().at(0)) : type;
   const string& element_type_name = element_type.GetName();
   if (m.find(element_type_name) != m.end()) {
@@ -150,7 +157,7 @@
 std::string RustNameOf(const AidlTypeSpecifier& type, const AidlTypenames& typenames,
                        StorageMode mode) {
   std::string rust_name;
-  if (type.IsArray() || type.IsGeneric()) {
+  if (type.IsArray() || typenames.IsList(type)) {
     StorageMode element_mode;
     if (mode == StorageMode::OUT_ARGUMENT || mode == StorageMode::DEFAULT_VALUE) {
       // Elements need to have Default for resize_out_vec()
@@ -210,7 +217,7 @@
 
   const bool isEnum = definedType && definedType->AsEnumDeclaration() != nullptr;
   const bool isPrimitive = AidlTypenames::IsPrimitiveTypename(typeName);
-  if (typeName == "String" || arg.GetType().IsArray() || arg.GetType().IsGeneric()) {
+  if (typeName == "String" || arg.GetType().IsArray() || typenames.IsList(arg.GetType())) {
     return StorageMode::UNSIZED_ARGUMENT;
   } else if (!(isPrimitive || isEnum)) {
     return StorageMode::IN_ARGUMENT;
@@ -286,7 +293,7 @@
 }
 
 bool TypeHasDefault(const AidlTypeSpecifier& type, const AidlTypenames& typenames) {
-  if (type.IsArray() || type.IsGeneric()) {
+  if (type.IsArray() || typenames.IsList(type)) {
     return true;
   }
 
diff --git a/aidl_typenames.cpp b/aidl_typenames.cpp
index 5e5cdbd..109f99a 100644
--- a/aidl_typenames.cpp
+++ b/aidl_typenames.cpp
@@ -131,6 +131,17 @@
   return true;
 }
 
+const AidlDocument* AidlTypenames::GetDocumentFor(const AidlDefinedType* type) const {
+  for (const auto& doc : AllDocuments()) {
+    for (const auto& defined_type : doc->DefinedTypes()) {
+      if (defined_type.get() == type) {
+        return doc.get();
+      }
+    }
+  }
+  return nullptr;
+}
+
 const AidlDocument& AidlTypenames::MainDocument() const {
   AIDL_FATAL_IF(documents_.size() == 0, AIDL_LOCATION_HERE) << "Main document doesn't exist";
   return *(documents_[0]);
@@ -157,6 +168,16 @@
   return kPrimitiveTypes.find(type_name) != kPrimitiveTypes.end();
 }
 
+bool AidlTypenames::IsParcelable(const string& type_name) const {
+  if (IsBuiltinTypename(type_name)) {
+    return type_name == "ParcelableHolder" || type_name == "ParcelFileDescriptor";
+  }
+  if (auto defined_type = TryGetDefinedType(type_name); defined_type) {
+    return defined_type->AsParcelable() != nullptr;
+  }
+  return false;
+}
+
 const AidlDefinedType* AidlTypenames::TryGetDefinedType(const string& type_name) const {
   return TryGetDefinedTypeImpl(type_name).type;
 }
@@ -205,15 +226,15 @@
   if (IsBuiltinTypename(type_name)) {
     auto found = kJavaLikeTypeToAidlType.find(type_name);
     if (found != kJavaLikeTypeToAidlType.end()) {
-      return {found->second, true};
+      return {found->second, true, nullptr};
     }
-    return {type_name, true};
+    return {type_name, true, nullptr};
   }
   const AidlDefinedType* defined_type = TryGetDefinedType(type_name);
   if (defined_type != nullptr) {
-    return {defined_type->GetCanonicalName(), true};
+    return {defined_type->GetCanonicalName(), true, defined_type};
   } else {
-    return {type_name, false};
+    return {type_name, false, nullptr};
   }
 }
 
@@ -269,16 +290,30 @@
 }
 
 // Only T[], List, Map, ParcelFileDescriptor and mutable Parcelable can be an out parameter.
-bool AidlTypenames::CanBeOutParameter(const AidlTypeSpecifier& type) const {
+// Returns pair of
+//  - bool: tells if the type can be an out/inout parameter
+//  - string: the aspect of the type which decides whether the type can be "out" or not.
+pair<bool, string> AidlTypenames::CanBeOutParameter(const AidlTypeSpecifier& type) const {
   const string& name = type.GetName();
-  if (IsBuiltinTypename(name) || GetEnumDeclaration(type)) {
-    return type.IsArray() || type.GetName() == "List" || type.GetName() == "Map" ||
-           type.GetName() == "ParcelFileDescriptor";
+  if (type.IsArray()) return {true, "array"};
+
+  if (IsBuiltinTypename(name)) {
+    if (name == "List" || name == "Map" || name == "ParcelFileDescriptor") {
+      return {true, name};
+    }
+    return {false, name};
   }
-  const AidlDefinedType* t = TryGetDefinedType(type.GetName());
-  AIDL_FATAL_IF(t == nullptr, type) << "Unrecognized type: '" << type.GetName() << "'";
+
+  const AidlDefinedType* t = TryGetDefinedType(name);
+  AIDL_FATAL_IF(t == nullptr, type) << "Unrecognized type: '" << name << "'";
+
   // An 'out' field is passed as an argument, so it doesn't make sense if it is immutable.
-  return t->AsParcelable() != nullptr && !t->IsJavaOnlyImmutable();
+  if (t->AsParcelable() != nullptr) {
+    if (t->IsJavaOnlyImmutable()) return {false, "@JavaOnlyImmutable"};
+    return {true, "parcelable/union"};
+  }
+
+  return {false, t->GetPreprocessDeclarationName()};
 }
 
 const AidlEnumDeclaration* AidlTypenames::GetEnumDeclaration(const AidlTypeSpecifier& type) const {
@@ -299,6 +334,15 @@
   return nullptr;
 }
 
+const AidlParcelable* AidlTypenames::GetParcelable(const AidlTypeSpecifier& type) const {
+  if (auto defined_type = TryGetDefinedType(type.GetName()); defined_type != nullptr) {
+    if (auto parcelable = defined_type->AsParcelable(); parcelable != nullptr) {
+      return parcelable;
+    }
+  }
+  return nullptr;
+}
+
 void AidlTypenames::IterateTypes(const std::function<void(const AidlDefinedType&)>& body) const {
   for (const auto& kv : defined_types_) {
     body(*kv.second);
@@ -308,5 +352,21 @@
   }
 }
 
+bool AidlTypenames::Autofill() const {
+  bool success = true;
+  IterateTypes([&](const AidlDefinedType& type) {
+    // BackingType is filled in for all known enums, including imported enums,
+    // because other types that may use enums, such as Interface or
+    // StructuredParcelable, need to know the enum BackingType when
+    // generating code.
+    if (auto enum_decl = const_cast<AidlDefinedType&>(type).AsEnumDeclaration(); enum_decl) {
+      if (!enum_decl->Autofill(*this)) {
+        success = false;
+      }
+    }
+  });
+  return success;
+}
+
 }  // namespace aidl
 }  // namespace android
diff --git a/aidl_typenames.h b/aidl_typenames.h
index 469de4b..9ba5745 100644
--- a/aidl_typenames.h
+++ b/aidl_typenames.h
@@ -18,12 +18,14 @@
 #include <functional>
 #include <map>
 #include <memory>
+#include <optional>
 #include <set>
 #include <string>
 #include <utility>
 #include <vector>
 
 using std::map;
+using std::optional;
 using std::pair;
 using std::set;
 using std::string;
@@ -33,6 +35,7 @@
 class AidlDefinedType;
 class AidlEnumDeclaration;
 class AidlInterface;
+class AidlParcelable;
 class AidlTypeSpecifier;
 class AidlDocument;
 
@@ -54,20 +57,23 @@
  public:
   AidlTypenames() = default;
   bool AddDocument(std::unique_ptr<AidlDocument> doc);
+  const AidlDocument* GetDocumentFor(const AidlDefinedType* type) const;
   const std::vector<std::unique_ptr<AidlDocument>>& AllDocuments() const { return documents_; }
   const AidlDocument& MainDocument() const;
   bool AddPreprocessedType(unique_ptr<AidlDefinedType> type);
   static bool IsBuiltinTypename(const string& type_name);
   static bool IsPrimitiveTypename(const string& type_name);
+  bool IsParcelable(const string& type_name) const;
   const AidlDefinedType* TryGetDefinedType(const string& type_name) const;
   std::vector<AidlDefinedType*> AllDefinedTypes() const;
 
   struct ResolvedTypename {
     std::string canonical_name;
     bool is_resolved;
+    const AidlDefinedType* defined_type;
   };
   ResolvedTypename ResolveTypename(const string& type_name) const;
-  bool CanBeOutParameter(const AidlTypeSpecifier& type) const;
+  pair<bool, string> CanBeOutParameter(const AidlTypeSpecifier& type) const;
   bool CanBeJavaOnlyImmutable(const AidlTypeSpecifier& type) const;
   bool CanBeFixedSize(const AidlTypeSpecifier& type) const;
   static bool IsList(const AidlTypeSpecifier& type);
@@ -79,8 +85,13 @@
   // Returns the AidlInterface of the given type, or nullptr if the type
   // is not an AidlInterface;
   const AidlInterface* GetInterface(const AidlTypeSpecifier& type) const;
+  // Returns the AidlParcelable of the given type, or nullptr if the type
+  // is not an AidlParcelable;
+  const AidlParcelable* GetParcelable(const AidlTypeSpecifier& type) const;
   // Iterates over all defined and then preprocessed types
   void IterateTypes(const std::function<void(const AidlDefinedType&)>& body) const;
+  // Fixes AST after type/ref resolution before validation
+  bool Autofill() const;
 
  private:
   struct DefinedImplResult {
@@ -90,7 +101,7 @@
     const bool from_preprocessed;
   };
   DefinedImplResult TryGetDefinedTypeImpl(const string& type_name) const;
-  map<string, const AidlDefinedType*> defined_types_;
+  map<string, AidlDefinedType*> defined_types_;
   map<string, unique_ptr<AidlDefinedType>> preprocessed_types_;
   std::vector<std::unique_ptr<AidlDocument>> documents_;
 };
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 0f2f7e6..6d67b7d 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -14,20 +14,24 @@
  * limitations under the License.
  */
 
+#include "aidl.h"
+
+#include <android-base/format.h>
+#include <android-base/stringprintf.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <map>
 #include <memory>
 #include <set>
 #include <string>
 #include <vector>
 
-#include <android-base/stringprintf.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include "aidl.h"
 #include "aidl_checkapi.h"
 #include "aidl_language.h"
 #include "aidl_to_cpp.h"
 #include "aidl_to_java.h"
+#include "comments.h"
 #include "logging.h"
 #include "options.h"
 #include "tests/fake_io_delegate.h"
@@ -35,10 +39,12 @@
 using android::aidl::internals::parse_preprocessed_file;
 using android::aidl::test::FakeIoDelegate;
 using android::base::StringPrintf;
+using std::map;
 using std::set;
 using std::string;
 using std::unique_ptr;
 using std::vector;
+using testing::HasSubstr;
 using testing::TestParamInfo;
 using testing::internal::CaptureStderr;
 using testing::internal::GetCapturedStderr;
@@ -73,113 +79,6 @@
 p/Foo.aidl :
 )";
 
-const char kExpectedJavaParcelableOutputContests[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-@android.annotation.Hide
-public class Rect implements android.os.Parcelable
-{
-  // Comment
-
-  @android.annotation.Hide
-  public int x = 5;
-
-  @android.annotation.Hide
-  @android.compat.annotation.UnsupportedAppUsage(expectedSignature = "dummy", implicitMember = "dummy", maxTargetSdk = 28, publicAlternatives = "dummy", trackingBug = 42L, overrideSourcePosition="Rect.aidl:7:1:10:14")
-  public int y = 0;
-
-  public android.os.ParcelFileDescriptor fd;
-  public static final android.os.Parcelable.Creator<Rect> CREATOR = new android.os.Parcelable.Creator<Rect>() {
-    @Override
-    public Rect createFromParcel(android.os.Parcel _aidl_source) {
-      Rect _aidl_out = new Rect();
-      _aidl_out.readFromParcel(_aidl_source);
-      return _aidl_out;
-    }
-    @Override
-    public Rect[] newArray(int _aidl_size) {
-      return new Rect[_aidl_size];
-    }
-  };
-  @Override public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)
-  {
-    int _aidl_start_pos = _aidl_parcel.dataPosition();
-    _aidl_parcel.writeInt(0);
-    _aidl_parcel.writeInt(x);
-    _aidl_parcel.writeInt(y);
-    if ((fd!=null)) {
-      _aidl_parcel.writeInt(1);
-      fd.writeToParcel(_aidl_parcel, 0);
-    }
-    else {
-      _aidl_parcel.writeInt(0);
-    }
-    int _aidl_end_pos = _aidl_parcel.dataPosition();
-    _aidl_parcel.setDataPosition(_aidl_start_pos);
-    _aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
-    _aidl_parcel.setDataPosition(_aidl_end_pos);
-  }
-  public final void readFromParcel(android.os.Parcel _aidl_parcel)
-  {
-    int _aidl_start_pos = _aidl_parcel.dataPosition();
-    int _aidl_parcelable_size = _aidl_parcel.readInt();
-    try {
-      if (_aidl_parcelable_size < 0) return;
-      x = _aidl_parcel.readInt();
-      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
-      y = _aidl_parcel.readInt();
-      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
-      if ((0!=_aidl_parcel.readInt())) {
-        fd = android.os.ParcelFileDescriptor.CREATOR.createFromParcel(_aidl_parcel);
-      }
-      else {
-        fd = null;
-      }
-      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
-    } finally {
-      if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {
-        throw new android.os.BadParcelableException("Overflow in the size of parcelable");
-      }
-      _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
-    }
-  }
-  @Override public int describeContents()
-  {
-    return 0;
-  }
-}
-)";
-
-// clang-format off
-const char kExpectedCppHeaderOutput[] =
-    R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <optional>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-#include <vector>
-
-class IFoo : public ::android::IInterface {
-public:
-  DECLARE_META_INTERFACE(Foo)
-  virtual ::android::binder::Status foo(::std::optional<::std::vector<::std::optional<::android::String16>>>* _aidl_return) = 0;
-};  // class IFoo
-class IFooDefault : public IFoo {
-public:
-  ::android::IBinder* onAsBinder() override {
-    return nullptr;
-  }
-  ::android::binder::Status foo(::std::optional<::std::vector<::std::optional<::android::String16>>>*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-};  // class IFooDefault
-)";
-// clang-format on
-
 }  // namespace
 
 class AidlTest : public ::testing::TestWithParam<Options::Language> {
@@ -190,7 +89,7 @@
     io_delegate_.SetFileContents(path, contents);
     vector<string> args;
     args.emplace_back("aidl");
-    args.emplace_back("--lang=" + Options::LanguageToString(lang));
+    args.emplace_back("--lang=" + to_string(lang));
     for (const string& s : additional_arguments) {
       args.emplace_back(s);
     }
@@ -235,7 +134,7 @@
                          testing::Values(Options::Language::CPP, Options::Language::JAVA,
                                          Options::Language::NDK, Options::Language::RUST),
                          [](const testing::TestParamInfo<Options::Language>& info) {
-                           return Options::LanguageToString(info.param);
+                           return to_string(info.param);
                          });
 
 TEST_P(AidlTest, AcceptMissingPackage) {
@@ -246,6 +145,42 @@
   EXPECT_NE(nullptr, Parse("IFoo.aidl", "interface IFoo { } // foo", typenames_, GetLanguage()));
 }
 
+TEST_P(AidlTest, InterfaceRequiresCorrectPath) {
+  const string expected_stderr =
+      "ERROR: a/Foo.aidl:1.11-21: IBar should be declared in a file called a/IBar.aidl\n";
+  const std::string file_contents = "package a; interface IBar {}";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", file_contents, typenames_, GetLanguage()));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr()) << file_contents;
+}
+
+TEST_P(AidlTest, ParcelableRequiresCorrectPath) {
+  const string expected_stderr =
+      "ERROR: a/Foo.aidl:1.11-21: Bar should be declared in a file called a/Bar.aidl\n";
+  const std::string file_contents = "package a; interface Bar {}";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", file_contents, typenames_, GetLanguage()));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr()) << file_contents;
+}
+
+TEST_P(AidlTest, UnstructuredParcelableRequiresCorrectPath) {
+  const string expected_stderr =
+      "ERROR: a/Foo.aidl:1.22-26: Bar should be declared in a file called a/Bar.aidl\n";
+  const std::string file_contents = "package a; parcelable Bar cpp_header \"anything.h\";";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", file_contents, typenames_, GetLanguage()));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr()) << file_contents;
+}
+
+TEST_P(AidlTest, EnumRequiresCorrectPath) {
+  const string expected_stderr =
+      "ERROR: a/Foo.aidl:1.16-20: Bar should be declared in a file called a/Bar.aidl\n";
+  const std::string file_contents = "package a; enum Bar { A, }";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", file_contents, typenames_, GetLanguage()));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr()) << file_contents;
+}
+
 TEST_P(AidlTest, RejectsArraysOfBinders) {
   import_paths_.emplace("");
   io_delegate_.SetFileContents("bar/IBar.aidl",
@@ -269,7 +204,8 @@
 TEST_P(AidlTest, RejectOutParametersForIBinder) {
   const string interface_ibinder = "package a; interface IBaz { void f(out IBinder bar); }";
   const string expected_ibinder_stderr =
-      "ERROR: a/IBaz.aidl:1.47-51: 'out IBinder bar' can only be an in parameter.\n";
+      "ERROR: a/IBaz.aidl:1.47-51: 'bar' can't be an out parameter because IBinder can only be an "
+      "in parameter.\n";
   CaptureStderr();
   EXPECT_EQ(nullptr, Parse("a/IBaz.aidl", interface_ibinder, typenames_, GetLanguage()));
   EXPECT_EQ(expected_ibinder_stderr, GetCapturedStderr());
@@ -330,13 +266,22 @@
 
 TEST_P(AidlTest, RejectsDuplicatedFieldNames) {
   const string method = "package a; parcelable Foo { int a; String a; }";
-  const string expected_stderr =
-      "ERROR: a/Foo.aidl:1.22-26: The parcelable 'Foo' has duplicate field name 'a'\n";
+  const string expected_stderr = "ERROR: a/Foo.aidl:1.42-44: 'Foo' has duplicate field name 'a'\n";
   CaptureStderr();
   EXPECT_EQ(nullptr, Parse("a/Foo.aidl", method, typenames_, GetLanguage()));
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_P(AidlTest, RejectsRepeatedAnnotations) {
+  const string method = R"(@Hide @Hide parcelable Foo {})";
+  const string expected_stderr =
+      "ERROR: Foo.aidl:1.23-27: 'Hide' is repeated, but not allowed. Previous location: "
+      "Foo.aidl:1.1-6\n";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("Foo.aidl", method, typenames_, GetLanguage()));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
 TEST_P(AidlTest, RejectsDuplicatedAnnotationParams) {
   const string method = "package a; interface IFoo { @UnsupportedAppUsage(foo=1, foo=2)void f(); }";
   const string expected_stderr = "ERROR: a/IFoo.aidl:1.56-62: Trying to redefine parameter foo.\n";
@@ -348,50 +293,36 @@
 TEST_P(AidlTest, RejectUnsupportedInterfaceAnnotations) {
   AidlError error;
   const string method = "package a; @nullable interface IFoo { int f(); }";
-  const string expected_stderr =
-      "ERROR: a/IFoo.aidl:1.21-31: 'nullable' is not a supported annotation for this node. "
-      "It must be one of: Hide, UnsupportedAppUsage, VintfStability, JavaPassthrough, Descriptor\n";
   CaptureStderr();
   EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage(), &error));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("@nullable is not available."));
   EXPECT_EQ(AidlError::BAD_TYPE, error);
 }
 
 TEST_P(AidlTest, RejectUnsupportedTypeAnnotations) {
   AidlError error;
   const string method = "package a; interface IFoo { @JavaOnlyStableParcelable int f(); }";
-  const string expected_stderr =
-      "ERROR: a/IFoo.aidl:1.54-58: 'JavaOnlyStableParcelable' is not a supported annotation "
-      "for this node. It must be one of: Hide, UnsupportedAppUsage, nullable, utf8InCpp, JavaPassthrough\n";
   CaptureStderr();
   EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage(), &error));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("@JavaOnlyStableParcelable is not available."));
   EXPECT_EQ(AidlError::BAD_TYPE, error);
 }
 
 TEST_P(AidlTest, RejectUnsupportedParcelableAnnotations) {
   AidlError error;
   const string method = "package a; @nullable parcelable IFoo cpp_header \"IFoo.h\";";
-  const string expected_stderr =
-      "ERROR: a/Foo.aidl:1.32-37: 'nullable' is not a supported annotation for this node. "
-      "It must be one of: Hide, JavaOnlyStableParcelable, UnsupportedAppUsage, VintfStability, "
-      "JavaPassthrough, JavaOnlyImmutable\n";
   CaptureStderr();
-  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", method, typenames_, GetLanguage(), &error));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+  EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage(), &error));
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("@nullable is not available."));
   EXPECT_EQ(AidlError::BAD_TYPE, error);
 }
 
 TEST_P(AidlTest, RejectUnsupportedParcelableDefineAnnotations) {
   AidlError error;
-  const string method = "package a; @nullable parcelable Foo { String a; String b; }";
-  const string expected_stderr =
-      "ERROR: a/Foo.aidl:1.32-36: 'nullable' is not a supported annotation for this node. "
-      "It must be one of: Hide, UnsupportedAppUsage, VintfStability, JavaPassthrough, JavaDebug, "
-      "JavaOnlyImmutable, FixedSize, RustDerive\n";
+  const string method = "package a; @nullable parcelable IFoo { String a; String b; }";
   CaptureStderr();
-  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", method, typenames_, GetLanguage(), &error));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+  EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage(), &error));
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("@nullable is not available."));
   EXPECT_EQ(AidlError::BAD_TYPE, error);
 }
 
@@ -508,46 +439,137 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
-TEST_F(AidlTest, ParsesJavaDebugAnnotation) {
-  io_delegate_.SetFileContents("a/IFoo.aidl", R"(package a;
-    @JavaDebug parcelable IFoo { int a; float b; })");
-  Options java_options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
+TEST_F(AidlTest, ParcelableSupportJavaDeriveToString) {
+  io_delegate_.SetFileContents("a/Foo.aidl", R"(package a;
+    @JavaDerive(toString=true) parcelable Foo { int a; float b; })");
+  Options java_options = Options::From("aidl --lang=java -o out a/Foo.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
 
   string java_out;
-  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/IFoo.java", &java_out));
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &java_out));
   EXPECT_THAT(java_out, testing::HasSubstr("public String toString() {"));
 
   // Other backends shouldn't be bothered
-  Options cpp_options = Options::From("aidl --lang=cpp -o out -h out a/IFoo.aidl");
+  Options cpp_options = Options::From("aidl --lang=cpp -o out -h out a/Foo.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(cpp_options, io_delegate_));
 
-  Options ndk_options = Options::From("aidl --lang=ndk -o out -h out a/IFoo.aidl");
+  Options ndk_options = Options::From("aidl --lang=ndk -o out -h out a/Foo.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(ndk_options, io_delegate_));
 }
 
-TEST_F(AidlTest, RejectsJavaDebugAnnotation) {
+TEST_F(AidlTest, UnionSupportJavaDeriveToString) {
+  io_delegate_.SetFileContents("a/Foo.aidl", R"(package a;
+    @JavaDerive(toString=true) union Foo { int a; int[] b; })");
+  CaptureStderr();
+  Options java_options = Options::From("aidl --lang=java -o out a/Foo.aidl");
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+
+  const string expected_to_string_method = R"--(
+  @Override
+  public String toString() {
+    switch (_tag) {
+    case a: return "a.Foo.a(" + (getA()) + ")";
+    case b: return "a.Foo.b(" + (java.util.Arrays.toString(getB())) + ")";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+)--";
+
+  string java_out;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &java_out));
+  EXPECT_THAT(java_out, testing::HasSubstr(expected_to_string_method));
+}
+
+TEST_F(AidlTest, ParcelableSupportJavaDeriveEquals) {
+  io_delegate_.SetFileContents("a/Foo.aidl", R"(package a;
+    @JavaDerive(equals=true) parcelable Foo { int a; float b; })");
+  CaptureStderr();
+  Options java_options = Options::From("aidl --lang=java -o out a/Foo.aidl");
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+
+  const std::string expected = R"--(
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) return true;
+    if (other == null) return false;
+    if (!(other instanceof Foo)) return false;
+    Foo that = (Foo)other;
+    if (!java.util.Objects.deepEquals(a, that.a)) return false;
+    if (!java.util.Objects.deepEquals(b, that.b)) return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return java.util.Arrays.deepHashCode(java.util.Arrays.asList(a, b).toArray());
+  }
+)--";
+
+  string java_out;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &java_out));
+  EXPECT_THAT(java_out, testing::HasSubstr(expected));
+}
+
+TEST_F(AidlTest, UnionSupportJavaDeriveEquals) {
+  io_delegate_.SetFileContents("a/Foo.aidl", R"(package a;
+    @JavaDerive(equals=true) union Foo { int a; int[] b; })");
+  CaptureStderr();
+  Options java_options = Options::From("aidl --lang=java -o out a/Foo.aidl");
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+
+  const std::string expected = R"--(
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) return true;
+    if (other == null) return false;
+    if (!(other instanceof Foo)) return false;
+    Foo that = (Foo)other;
+    if (_tag != that._tag) return false;
+    if (!java.util.Objects.deepEquals(_value, that._value)) return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return java.util.Arrays.deepHashCode(java.util.Arrays.asList(_tag, _value).toArray());
+  }
+)--";
+
+  string java_out;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &java_out));
+  EXPECT_THAT(java_out, testing::HasSubstr(expected));
+}
+
+TEST_F(AidlTest, RejectsJavaDeriveAnnotation) {
   {
-    io_delegate_.SetFileContents("a/IFoo.aidl", "package a; @JavaDebug interface IFoo{}");
-    Options java_options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
+    io_delegate_.SetFileContents("a/Foo.aidl",
+                                 "package a; @JavaDerive(blah=true) parcelable Foo{}");
+    Options java_options = Options::From("aidl --lang=java -o out a/Foo.aidl");
     CaptureStderr();
     EXPECT_NE(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
     const std::string expected_stderr =
-        "ERROR: a/IFoo.aidl:1.22-32: 'JavaDebug' is not a supported annotation for this node. "
-        "It must be one of: Hide, UnsupportedAppUsage, VintfStability, JavaPassthrough, "
-        "Descriptor\n";
-    EXPECT_EQ(expected_stderr, GetCapturedStderr());
+        "ERROR: a/Foo.aidl:1.11-34: Parameter blah not supported for annotation JavaDerive.";
+    EXPECT_THAT(GetCapturedStderr(),
+                HasSubstr("Parameter blah not supported for annotation JavaDerive."));
   }
 
   {
-    io_delegate_.SetFileContents("a/IFoo.aidl", "package a; @JavaDebug enum IFoo { A=1, }");
+    io_delegate_.SetFileContents("a/IFoo.aidl", "package a; @JavaDerive interface IFoo{}");
     Options java_options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
     CaptureStderr();
     EXPECT_NE(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
-    const std::string expected_stderr =
-        "ERROR: a/IFoo.aidl:1.27-32: 'JavaDebug' is not a supported annotation for this node. "
-        "It must be one of: Backing, Hide, VintfStability, JavaPassthrough\n";
-    EXPECT_EQ(expected_stderr, GetCapturedStderr());
+    EXPECT_THAT(GetCapturedStderr(), HasSubstr("@JavaDerive is not available."));
+  }
+
+  {
+    io_delegate_.SetFileContents("a/IFoo.aidl", "package a; @JavaDerive enum IFoo { A=1, }");
+    Options java_options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
+    CaptureStderr();
+    EXPECT_NE(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
+    EXPECT_THAT(GetCapturedStderr(), HasSubstr("@JavaDerive is not available."));
   }
 }
 
@@ -598,19 +620,48 @@
 
 TEST_P(AidlTest, WritesComments) {
   string foo_interface =
-      "package a; /* foo */ interface IFoo {"
-      "  /* i */ int i();"
-      "  /* j */ @nullable String j();"
-      "  /* k */ @UnsupportedAppUsage oneway void k(int a); }";
+      R"(package a;
+        /* foo */
+        interface IFoo {
+          /* i */
+          int i();
+          // j
+          @nullable String j();
+          // k1
+          /* k2 */
+          @UnsupportedAppUsage oneway void k(int a);
+        })";
 
+  CaptureStderr();
   auto parse_result = Parse("a/IFoo.aidl", foo_interface, typenames_, GetLanguage());
   EXPECT_NE(nullptr, parse_result);
-  EXPECT_EQ("/* foo */", parse_result->GetComments());
+  EXPECT_EQ("", GetCapturedStderr());
+
+  EXPECT_EQ((Comments{{"/* foo */"}}), parse_result->GetComments());
 
   const AidlInterface* interface = parse_result->AsInterface();
-  EXPECT_EQ("/* i */", interface->GetMethods()[0]->GetComments());
-  EXPECT_EQ("/* j */", interface->GetMethods()[1]->GetComments());
-  EXPECT_EQ("/* k */", interface->GetMethods()[2]->GetComments());
+  EXPECT_EQ((Comments{{"/* i */"}}), interface->GetMethods()[0]->GetComments());
+  EXPECT_EQ((Comments{{"// j\n"}}), interface->GetMethods()[1]->GetComments());
+  EXPECT_EQ((Comments{{"// k1\n"}, {"/* k2 */"}}), interface->GetMethods()[2]->GetComments());
+}
+
+TEST_P(AidlTest, CppHeaderCanBeIdentifierAsWell) {
+  io_delegate_.SetFileContents("p/cpp_header.aidl",
+                               R"(package p;
+         parcelable cpp_header cpp_header "bar/header";)");
+  import_paths_.emplace("");
+  const string input_path = "p/IFoo.aidl";
+  const string input = R"(package p;
+                          import p.cpp_header;
+                          interface IFoo {
+                            // get bar
+                            cpp_header get();
+                          })";
+
+  auto parse_result = Parse(input_path, input, typenames_, GetLanguage());
+  EXPECT_NE(nullptr, parse_result);
+  const AidlInterface* interface = parse_result->AsInterface();
+  EXPECT_EQ((Comments{{"// get bar\n"}}), interface->GetMethods()[0]->GetComments());
 }
 
 TEST_F(AidlTest, ParsesPreprocessedFile) {
@@ -646,7 +697,7 @@
   EXPECT_TRUE(typenames_.ResolveTypename("one.IBar").is_resolved);
   EXPECT_TRUE(typenames_.ResolveTypename("another.IBar").is_resolved);
   // But if we request just "IBar" we should get our imported one.
-  AidlTypeSpecifier ambiguous_type(AIDL_LOCATION_HERE, "IBar", false, nullptr, "");
+  AidlTypeSpecifier ambiguous_type(AIDL_LOCATION_HERE, "IBar", false, nullptr, {});
   ambiguous_type.Resolve(typenames_);
   EXPECT_EQ("one.IBar", ambiguous_type.GetName());
 }
@@ -668,7 +719,7 @@
   EXPECT_TRUE(typenames_.ResolveTypename("one.IBar").is_resolved);
   EXPECT_TRUE(typenames_.ResolveTypename("another.IBar").is_resolved);
   // But if we request just "IBar" we should get our imported one.
-  AidlTypeSpecifier ambiguous_type(AIDL_LOCATION_HERE, "IBar", false, nullptr, "");
+  AidlTypeSpecifier ambiguous_type(AIDL_LOCATION_HERE, "IBar", false, nullptr, {});
   ambiguous_type.Resolve(typenames_);
   EXPECT_EQ("one.IBar", ambiguous_type.GetName());
 }
@@ -693,49 +744,154 @@
   EXPECT_EQ("parcelable p.Outer.Inner;\ninterface one.IBar;\n", output);
 }
 
-TEST_F(AidlTest, JavaParcelableOutput) {
-  io_delegate_.SetFileContents(
-      "Rect.aidl",
-      "@Hide\n"
-      "parcelable Rect {\n"
-      "  // Comment\n"
-      "  @Hide\n"
-      "  int x=5;\n"
-      "  @Hide\n"
-      "  @UnsupportedAppUsage(maxTargetSdk = 28, trackingBug = 42, implicitMember = \"dummy\", "
-      "expectedSignature = \"dummy\", publicAlternatives = \"d\" \n + \"u\" + \n \"m\" \n + \"m\" "
-      "+ \"y\")\n"
-      "  int y;\n"
-      "  ParcelFileDescriptor fd;\n"
-      "}");
+TEST_P(AidlTest, SupportDeprecated) {
+  struct TestCase {
+    std::string output_file;
+    std::string annotation;
+  };
 
-  vector<string> args{"aidl", "Rect.aidl"};
-  Options options = Options::From(args);
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  auto CheckDeprecated = [&](const std::string& filename, const std::string& contents,
+                             std::vector<std::pair<Options::Language, TestCase>> expectations) {
+    io_delegate_.SetFileContents(filename, contents);
 
-  string output;
-  EXPECT_TRUE(io_delegate_.GetWrittenContents("Rect.java", &output));
-  EXPECT_EQ(kExpectedJavaParcelableOutputContests, output);
-}
+    auto options = Options::From("aidl --lang=" + to_string(GetLanguage()) + " " + filename +
+                                 " --out=out --header_out=out");
+    EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+    for (const auto& [lang, test_case] : expectations) {
+      if (lang != GetLanguage()) continue;
+      string output;
+      EXPECT_TRUE(io_delegate_.GetWrittenContents(test_case.output_file, &output))
+          << base::Join(io_delegate_.ListOutputFiles(), ",");
+      EXPECT_THAT(output, HasSubstr(test_case.annotation));
+    }
+  };
 
-TEST_F(AidlTest, CppHeaderIncludes) {
-  io_delegate_.SetFileContents("IFoo.aidl",
-                               "interface IFoo {\n"
-                               "  @nullable List<String> foo();\n"
-                               "}");
+  // Emit escaped string for notes
+  CheckDeprecated(
+      "IFoo.aidl",
+      R"(interface IFoo {
+           /**
+            * @note asdf
+            * @deprecated a really long deprecation message
+            *
+            *    which is really long
+            * @param foo bar
+            */
+           List<String> foo();
+        })",
+      {
+          {Options::Language::JAVA, {"out/IFoo.java", "@Deprecated"}},
+          {Options::Language::CPP,
+           {"out/IFoo.h",
+            R"(__attribute__((deprecated("a really long deprecation message which is really long"))))"}},
+          {Options::Language::NDK,
+           {"out/aidl/IFoo.h",
+            R"(__attribute__((deprecated("a really long deprecation message which is really long"))))"}},
+          {Options::Language::RUST,
+           {"out/IFoo.rs",
+            R"(#[deprecated = "a really long deprecation message which is really long"])"}},
+      });
 
-  vector<string> args{"aidl", "--lang=cpp", "IFoo.aidl"};
-  Options options = Options::From(args);
-  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
-  std::vector<std::string> empty;
-  EXPECT_EQ(empty, io_delegate_.ListFiles(""));
-  EXPECT_EQ(empty, io_delegate_.ListFiles("/"));
-  EXPECT_EQ(empty, io_delegate_.ListFiles("out"));
+  // In AIDL @deprecated can be in block comments as well as javadoc style
+  CheckDeprecated(
+      "IFoo.aidl",
+      "interface IFoo {\n"
+      "  /* @deprecated use bar() */\n"
+      "  List<String> foo();\n"
+      "}",
+      {
+          {Options::Language::JAVA, {"out/IFoo.java", "@Deprecated"}},
+          {Options::Language::JAVA, {"out/IFoo.java", "/** @deprecated use bar() */"}},
+          {Options::Language::CPP, {"out/IFoo.h", "__attribute__((deprecated(\"use bar()\")))"}},
+          {Options::Language::NDK,
+           {"out/aidl/IFoo.h", "__attribute__((deprecated(\"use bar()\")))"}},
+          {Options::Language::RUST, {"out/IFoo.rs", "#[deprecated = \"use bar()\"]"}},
+      });
 
-  // Make sure the optional and String16.h includes are added
-  string output;
-  EXPECT_TRUE(io_delegate_.GetWrittenContents("IFoo.h", &output));
-  EXPECT_EQ(kExpectedCppHeaderOutput, output);
+  // but not in line comments
+  auto parsed = Parse("IFoo.aidl", "// @deprecated\ninterface IFoo {}", typenames_, GetLanguage());
+  EXPECT_FALSE(parsed->IsDeprecated());
+
+  // parcelable
+  CheckDeprecated("Foo.aidl",
+                  "parcelable Foo {\n"
+                  "  /** @deprecated use bar*/\n"
+                  "  int foo = 0;\n"
+                  "}",
+                  {
+                      {Options::Language::JAVA, {"out/Foo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::RUST, {"out/Foo.rs", "#[deprecated"}},
+                  });
+
+  // interface constants
+  CheckDeprecated("IFoo.aidl",
+                  "interface IFoo {\n"
+                  "  /** @deprecated use bar*/\n"
+                  "  const int FOO = 0;\n"
+                  "}",
+                  {
+                      {Options::Language::JAVA, {"out/IFoo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/IFoo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/IFoo.h", "__attribute__((deprecated"}},
+                      {Options::Language::RUST, {"out/IFoo.rs", "#[deprecated"}},
+                  });
+
+  // union fields
+  CheckDeprecated("Foo.aidl",
+                  "union Foo {\n"
+                  "  int bar = 0;\n"
+                  "  /** @deprecated use bar*/\n"
+                  "  int foo;\n"
+                  "}",
+                  {
+                      {Options::Language::JAVA, {"out/Foo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::RUST, {"out/Foo.rs", "#[deprecated"}},
+                  });
+
+  CheckDeprecated("Foo.aidl",
+                  "/** @deprecated use Bar */\n"
+                  "parcelable Foo {}",
+                  {
+                      {Options::Language::JAVA, {"out/Foo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::RUST, {"out/Foo.rs", "#[deprecated"}},
+                  });
+
+  CheckDeprecated("Foo.aidl",
+                  "/** @deprecated use Bar */\n"
+                  "union Foo { int foo = 0; }",
+                  {
+                      {Options::Language::JAVA, {"out/Foo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::RUST, {"out/Foo.rs", "#[deprecated"}},
+                  });
+
+  CheckDeprecated("IFoo.aidl",
+                  "/** @deprecated use IBar */\n"
+                  "interface IFoo {}",
+                  {
+                      {Options::Language::JAVA, {"out/IFoo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/IFoo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/IFoo.h", "__attribute__((deprecated"}},
+                      {Options::Language::RUST, {"out/IFoo.rs", "#[deprecated"}},
+                  });
+
+  CheckDeprecated("Foo.aidl",
+                  "/** @deprecated use IBar */\n"
+                  "enum Foo { FOO }",
+                  {
+                      {Options::Language::JAVA, {"out/Foo.java", "@Deprecated"}},
+                      {Options::Language::CPP, {"out/Foo.h", "__attribute__((deprecated"}},
+                      {Options::Language::NDK, {"out/aidl/Foo.h", "__attribute__((deprecated"}},
+                      // TODO(b/177860423) support "deprecated" in Rust enum
+                      // {Options::Language::RUST, {"out/Foo.rs", "#[deprecated"}},
+                  });
 }
 
 TEST_P(AidlTest, RequireOuterClass) {
@@ -832,6 +988,55 @@
   EXPECT_EQ(AidlError::BAD_TYPE, error);
 }
 
+TEST_P(AidlTest, FailOnTooBigConstant) {
+  AidlError error;
+  const string expected_stderr =
+      "ERROR: p/IFoo.aidl:3.48-52: Invalid type specifier for an int32 literal: byte\n";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
+                           R"(package p;
+                      interface IFoo {
+                        const byte type2small = 256;
+                      }
+                   )",
+                           typenames_, GetLanguage(), &error));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+  EXPECT_EQ(AidlError::BAD_TYPE, error);
+}
+
+TEST_F(AidlTest, BoolConstantsEvaluatesToIntegers) {
+  io_delegate_.SetFileContents("a/Foo.aidl", "package a; parcelable Foo { const int y = true; }");
+  CaptureStderr();
+  auto options = Options::From("aidl --lang java -o out a/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &code));
+  EXPECT_THAT(code, testing::HasSubstr("public static final int y = 1;"));
+}
+
+TEST_F(AidlTest, AidlConstantValue_EvaluatedValue) {
+  using Ptr = unique_ptr<AidlConstantValue>;
+  const AidlLocation& loc = AIDL_LOCATION_HERE;
+
+  EXPECT_EQ('c', Ptr(AidlConstantValue::Character(loc, 'c'))->EvaluatedValue<char>());
+  EXPECT_EQ("abc", Ptr(AidlConstantValue::String(loc, "\"abc\""))->EvaluatedValue<string>());
+  EXPECT_FLOAT_EQ(1.0f, Ptr(AidlConstantValue::Floating(loc, "1.0f"))->EvaluatedValue<float>());
+  EXPECT_EQ(true, Ptr(AidlConstantValue::Boolean(loc, true))->EvaluatedValue<bool>());
+
+  AidlBinaryConstExpression one_plus_one(loc, Ptr(AidlConstantValue::Integral(loc, "1")), "+",
+                                         Ptr(AidlConstantValue::Integral(loc, "1")));
+  EXPECT_EQ(2, one_plus_one.EvaluatedValue<int32_t>());
+
+  auto values = unique_ptr<vector<Ptr>>{new vector<Ptr>};
+  values->emplace_back(AidlConstantValue::String(loc, "\"hello\""));
+  values->emplace_back(AidlConstantValue::String(loc, "\"world\""));
+  vector<string> expected{"hello", "world"};
+  EXPECT_EQ(
+      expected,
+      Ptr(AidlConstantValue::Array(loc, std::move(values)))->EvaluatedValue<vector<string>>());
+}
+
 TEST_P(AidlTest, FailOnManyDefinedTypes) {
   AidlError error;
   const string expected_stderr =
@@ -965,7 +1170,7 @@
 
   EXPECT_TRUE(typenames_.ResolveTypename("p.Outer.Inner").is_resolved);
   // C++ uses "::" instead of "." to refer to a inner class.
-  AidlTypeSpecifier nested_type(AIDL_LOCATION_HERE, "p.Outer.Inner", false, nullptr, "");
+  AidlTypeSpecifier nested_type(AIDL_LOCATION_HERE, "p.Outer.Inner", false, nullptr, {});
   EXPECT_EQ("::p::Outer::Inner", cpp::CppNameOf(nested_type, typenames_));
 }
 
@@ -979,7 +1184,7 @@
   auto parse_result = Parse(input_path, input, typenames_, GetLanguage());
   EXPECT_NE(nullptr, parse_result);
   EXPECT_TRUE(typenames_.ResolveTypename("p.Bar").is_resolved);
-  AidlTypeSpecifier native_type(AIDL_LOCATION_HERE, "p.Bar", false, nullptr, "");
+  AidlTypeSpecifier native_type(AIDL_LOCATION_HERE, "p.Bar", false, nullptr, {});
   native_type.Resolve(typenames_);
 
   EXPECT_EQ("p.Bar", java::InstantiableJavaSignatureOf(native_type, typenames_));
@@ -1073,49 +1278,6 @@
   EXPECT_FALSE(io_delegate_.GetWrittenContents(options.OutputFile(), &output_file_contents));
 }
 
-// TODO(b/136048684)
-TEST_P(AidlTest, PrimitiveList) {
-  const string primitive_interface =
-      "package a; interface IFoo {\n"
-      "  List<int> foo(); }";
-  string expected_stderr;
-  switch (GetLanguage()) {
-    case Options::Language::CPP:
-      expected_stderr =
-          "ERROR: a/IFoo.aidl:2.1-7: List<int> is not supported. List in cpp supports only "
-          "String and IBinder.\n";
-      break;
-    case Options::Language::JAVA:
-      expected_stderr =
-          "ERROR: a/IFoo.aidl:2.1-7: List<int> is not supported. List in Java supports only "
-          "String, IBinder, and ParcelFileDescriptor.\n";
-      break;
-    case Options::Language::NDK:
-      expected_stderr =
-          "ERROR: a/IFoo.aidl:2.1-7: A generic type cannot have any primitive type parameters.\n";
-      break;
-    case Options::Language::RUST:
-      expected_stderr =
-          "ERROR: a/IFoo.aidl:2.1-7: A generic type cannot have any primitive type parameters.\n";
-      break;
-    default:
-      AIDL_FATAL(AIDL_LOCATION_HERE)
-          << "Unexpected Options::Language enumerator: " << static_cast<size_t>(GetLanguage());
-  }
-  CaptureStderr();
-  AidlTypenames tn1;
-  EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", primitive_interface, tn1, GetLanguage()));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
-
-  string primitive_parcelable =
-      "package a; parcelable IFoo {\n"
-      "  List<int> foo;}";
-  CaptureStderr();
-  AidlTypenames tn2;
-  EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", primitive_parcelable, tn2, GetLanguage()));
-  EXPECT_EQ(expected_stderr, GetCapturedStderr());
-}
-
 TEST_P(AidlTest, RejectsListArray) {
   const string expected_stderr = "ERROR: a/Foo.aidl:2.1-7: List[] is not supported.\n";
   const string list_array_parcelable =
@@ -1165,10 +1327,10 @@
       "  ParcelableHolder extension;\n"
       "  ParcelableHolder extension2;\n"
       "}";
-  if (GetLanguage() == Options::Language::NDK || GetLanguage() == Options::Language::RUST) {
+  if (GetLanguage() == Options::Language::RUST) {
     EXPECT_EQ(nullptr, Parse("a/Data.aidl", extendable_parcelable, typenames_, GetLanguage()));
     EXPECT_EQ(
-        "ERROR: a/Data.aidl:2.1-19: The NDK and Rust backend does not support ParcelableHolder "
+        "ERROR: a/Data.aidl:2.1-19: The Rust backend does not support ParcelableHolder "
         "yet.\n",
         GetCapturedStderr());
   } else {
@@ -1185,9 +1347,10 @@
   EXPECT_EQ(nullptr,
             Parse("a/IFoo.aidl", parcelableholder_return_interface, typenames_, GetLanguage()));
 
-  if (GetLanguage() == Options::Language::NDK || GetLanguage() == Options::Language::RUST) {
+  if (GetLanguage() == Options::Language::RUST) {
     EXPECT_EQ(
-        "ERROR: a/IFoo.aidl:2.1-19: The NDK and Rust backend does not support ParcelableHolder "
+        "ERROR: a/IFoo.aidl:2.19-23: ParcelableHolder cannot be a return type\n"
+        "ERROR: a/IFoo.aidl:2.1-19: The Rust backend does not support ParcelableHolder "
         "yet.\n",
         GetCapturedStderr());
     return;
@@ -1205,9 +1368,10 @@
   EXPECT_EQ(nullptr,
             Parse("a/IFoo.aidl", extendable_parcelable_arg_interface, typenames_, GetLanguage()));
 
-  if (GetLanguage() == Options::Language::NDK || GetLanguage() == Options::Language::RUST) {
+  if (GetLanguage() == Options::Language::RUST) {
     EXPECT_EQ(
-        "ERROR: a/IFoo.aidl:2.14-31: The NDK and Rust backend does not support ParcelableHolder "
+        "ERROR: a/IFoo.aidl:2.31-34: ParcelableHolder cannot be an argument type\n"
+        "ERROR: a/IFoo.aidl:2.14-31: The Rust backend does not support ParcelableHolder "
         "yet.\n",
         GetCapturedStderr());
     return;
@@ -1216,20 +1380,74 @@
             GetCapturedStderr());
 }
 
+TEST_P(AidlTest, RejectNullableParcelableHolderField) {
+  io_delegate_.SetFileContents("Foo.aidl", "parcelable Foo { @nullable ParcelableHolder ext; }");
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
+  const string expected_stderr = "ERROR: Foo.aidl:1.27-44: ParcelableHolder cannot be nullable.\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  if (GetLanguage() == Options::Language::RUST) {
+    EXPECT_EQ(
+        "ERROR: Foo.aidl:1.27-44: ParcelableHolder cannot be nullable.\n"
+        "ERROR: Foo.aidl:1.27-44: The Rust backend does not support ParcelableHolder "
+        "yet.\n",
+        GetCapturedStderr());
+    return;
+  }
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_P(AidlTest, ParcelablesWithConstants) {
+  io_delegate_.SetFileContents("Foo.aidl", "parcelable Foo { const int BIT = 0x1 << 3; }");
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+}
+
+TEST_P(AidlTest, UnionWithConstants) {
+  io_delegate_.SetFileContents("Foo.aidl", "union Foo { const int BIT = 0x1 << 3; int n; }");
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+}
+
+TEST_F(AidlTest, ConstantsWithAnnotations) {
+  io_delegate_.SetFileContents("IFoo.aidl",
+                               "interface IFoo {\n"
+                               " @JavaPassthrough(annotation=\"@Foo\")\n"
+                               " const @JavaPassthrough(annotation=\"@Bar\") int FOO = 0;\n"
+                               "}");
+  Options options = Options::From("aidl IFoo.aidl --lang=java -o out");
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/IFoo.java", &code));
+  EXPECT_THAT(code, HasSubstr("@Foo\n"));
+  EXPECT_THAT(code, HasSubstr("@Bar\n"));
+}
+
 TEST_F(AidlTest, ApiDump) {
   io_delegate_.SetFileContents(
       "foo/bar/IFoo.aidl",
       "package foo.bar;\n"
       "import foo.bar.Data;\n"
-      "// comment @hide\n"
+      "// commented /* @hide */\n"
       "interface IFoo {\n"
-      "    /* @hide */\n"
-      "    int foo(out int[] a, String b, boolean c, inout List<String>  d);\n"
-      "    int foo2(@utf8InCpp String x, inout List<String>  y);\n"
+      "    /* @hide applied \n"
+      "       @deprecated use foo2 */\n"
+      "    int foo(out int[] a, String b, boolean c, inout List<String> d);\n"
+      "    int foo2(@utf8InCpp String x, inout List<String> y);\n"
       "    IFoo foo3(IFoo foo);\n"
       "    Data getData();\n"
-      "    // @hide\n"
+      "    // @hide not applied\n"
+      "    /** blahblah\n"
+      "        @deprecated\n"
+      "          reason why... */\n"
       "    const int A = 1;\n"
+      "    // @deprecated tags in line comments are ignored\n"
       "    const String STR = \"Hello\";\n"
       "}\n");
   io_delegate_.SetFileContents("foo/bar/Data.aidl",
@@ -1241,11 +1459,9 @@
                                "   int x = 10;\n"
                                "   // @hide\n"
                                "   int y;\n"
-                               "   IFoo foo;\n"
-                               "   List<IFoo> a;\n"
                                "   /*@hide2*/\n"
-                               "   List<foo.bar.IFoo> b;\n"
-                               "   // It should be @hide property\n"
+                               "   IFoo foo;\n"
+                               "   // Ignore @hide property in line comment\n"
                                "   @nullable String[] c;\n"
                                "}\n");
   io_delegate_.SetFileContents("api.aidl", "");
@@ -1256,35 +1472,38 @@
   ASSERT_TRUE(result);
   string actual;
   EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/IFoo.aidl", &actual));
-  EXPECT_EQ(actual, string(kPreamble).append(R"(package foo.bar;
-/* @hide */
+  EXPECT_EQ(string(kPreamble).append(R"(package foo.bar;
 interface IFoo {
-  /* @hide */
+  /**
+   * @hide
+   * @deprecated use foo2
+   */
   int foo(out int[] a, String b, boolean c, inout List<String> d);
   int foo2(@utf8InCpp String x, inout List<String> y);
   foo.bar.IFoo foo3(foo.bar.IFoo foo);
   foo.bar.Data getData();
-  /* @hide */
+  /**
+   * @deprecated reason why...
+   */
   const int A = 1;
   const String STR = "Hello";
 }
-)"));
+)"),
+            actual);
 
   EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/Data.aidl", &actual));
-  EXPECT_EQ(actual, string(kPreamble).append(R"(package foo.bar;
-/* @hide */
+  EXPECT_EQ(string(kPreamble).append(R"(package foo.bar;
+/**
+ * @hide
+ */
 parcelable Data {
-  /* @hide */
   int x = 10;
-  /* @hide */
   int y;
   foo.bar.IFoo foo;
-  List<foo.bar.IFoo> a;
-  List<foo.bar.IFoo> b;
-  /* @hide */
   @nullable String[] c;
 }
-)"));
+)"),
+            actual);
 }
 
 TEST_F(AidlTest, ApiDumpWithManualIds) {
@@ -1332,9 +1551,84 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_F(AidlTest, ApiDumpConstWithAnnotation) {
+  io_delegate_.SetFileContents("foo/bar/IFoo.aidl",
+                               "package foo.bar;\n"
+                               "interface IFoo {\n"
+                               "    @utf8InCpp String foo();\n"
+                               "    const @utf8InCpp String bar = \"bar\";\n"
+                               "}\n");
+
+  vector<string> args = {"aidl", "--dumpapi", "-o dump", "foo/bar/IFoo.aidl"};
+  Options options = Options::From(args);
+  CaptureStderr();
+  EXPECT_TRUE(dump_api(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string actual;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/IFoo.aidl", &actual));
+  EXPECT_EQ(string(kPreamble).append(R"(package foo.bar;
+interface IFoo {
+  @utf8InCpp String foo();
+  const @utf8InCpp String bar = "bar";
+}
+)"),
+            actual);
+}
+
+TEST_F(AidlTest, ApiDumpWithEnums) {
+  io_delegate_.SetFileContents("foo/bar/Enum.aidl",
+                               "package foo.bar;\n"
+                               "enum Enum {\n"
+                               "    FOO,\n"
+                               "    BAR = FOO + 1,\n"
+                               "}\n");
+
+  vector<string> args = {"aidl", "--dumpapi", "-I . ", "-o dump", "foo/bar/Enum.aidl"};
+  Options options = Options::From(args);
+  CaptureStderr();
+  EXPECT_TRUE(dump_api(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string actual;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/Enum.aidl", &actual));
+  EXPECT_EQ(string(kPreamble).append("package foo.bar;\n"
+                                     "enum Enum {\n"
+                                     "  FOO = 0,\n"
+                                     "  BAR = 1,\n"
+                                     "}\n"),
+            actual);
+}
+
+TEST_F(AidlTest, ApiDumpWithEnumDefaultValues) {
+  io_delegate_.SetFileContents("foo/bar/Enum.aidl",
+                               "package foo.bar;\n"
+                               "enum Enum {\n"
+                               "    FOO,\n"
+                               "}\n");
+  io_delegate_.SetFileContents("foo/bar/Foo.aidl",
+                               "package foo.bar;\n"
+                               "import foo.bar.Enum;\n"
+                               "parcelable Foo {\n"
+                               "    Enum e = Enum.FOO;\n"
+                               "}\n");
+
+  vector<string> args = {"aidl", "--dumpapi", "-I . ", "-o dump", "foo/bar/Foo.aidl"};
+  Options options = Options::From(args);
+  CaptureStderr();
+  EXPECT_TRUE(dump_api(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string actual;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/Foo.aidl", &actual));
+  EXPECT_EQ(string(kPreamble).append("package foo.bar;\n"
+                                     "parcelable Foo {\n"
+                                     "  foo.bar.Enum e = foo.bar.Enum.FOO;\n"
+                                     "}\n"),
+            actual);
+}
+
 TEST_F(AidlTest, CheckNumGenericTypeSecifier) {
   const string expected_list_stderr =
-      "ERROR: p/IFoo.aidl:1.37-41: List must have only one type parameter.\n";
+      "ERROR: p/IFoo.aidl:1.37-41: List can only have one type parameter, but got: "
+      "'List<String,String>'\n";
   const string expected_map_stderr =
       "ERROR: p/IFoo.aidl:1.37-40: Map must have 0 or 2 type parameters, but got 'Map<String>'\n";
   Options options = Options::From("aidl p/IFoo.aidl IFoo.java");
@@ -1600,6 +1894,19 @@
   EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
 }
 
+TEST_F(AidlTest, CheckApiForEquality) {
+  CaptureStderr();
+  Options options = Options::From("aidl --checkapi=equal old new");
+
+  io_delegate_.SetFileContents("old/p/IFoo.aidl",
+                               "package p; interface IFoo{ @utf8InCpp @nullable String foo();}");
+  io_delegate_.SetFileContents("new/p/IFoo.aidl",
+                               "package p; interface IFoo{ @utf8InCpp String foo();}");
+
+  EXPECT_FALSE(::android::aidl::check_api(options, io_delegate_));
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("+  @utf8InCpp String foo();"));
+}
+
 TEST_F(AidlTest, DifferentOrderAnnotationsInCheckAPI) {
   Options options = Options::From("aidl --checkapi old new");
   io_delegate_.SetFileContents("old/p/IFoo.aidl",
@@ -1618,6 +1925,18 @@
   EXPECT_TRUE(::android::aidl::check_api(options, io_delegate_));
 }
 
+TEST_F(AidlTest, CheckApi_EnumFieldsWithDefaultValues) {
+  Options options = Options::From("aidl --checkapi old new");
+  const string foo_definition = "package p; parcelable Foo{ p.Enum e = p.Enum.FOO; }";
+  const string enum_definition = "package p; enum Enum { FOO }";
+  io_delegate_.SetFileContents("old/p/Foo.aidl", foo_definition);
+  io_delegate_.SetFileContents("old/p/Enum.aidl", enum_definition);
+  io_delegate_.SetFileContents("new/p/Foo.aidl", foo_definition);
+  io_delegate_.SetFileContents("new/p/Enum.aidl", enum_definition);
+
+  EXPECT_TRUE(::android::aidl::check_api(options, io_delegate_));
+}
+
 class AidlTestCompatibleChanges : public AidlTest {
  protected:
   Options options_ = Options::From("aidl --checkapi old new");
@@ -1705,6 +2024,21 @@
   EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
 }
 
+TEST_F(AidlTestCompatibleChanges, NewUnionField) {
+  io_delegate_.SetFileContents("old/p/Union.aidl",
+                               "package p;"
+                               "union Union {"
+                               "  String foo;"
+                               "}");
+  io_delegate_.SetFileContents("new/p/Union.aidl",
+                               "package p;"
+                               "union Union {"
+                               "  String foo;"
+                               "  int num;"
+                               "}");
+  EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
 TEST_F(AidlTestCompatibleChanges, NewPackage) {
   io_delegate_.SetFileContents("old/p/IFoo.aidl",
                                "package p;"
@@ -1773,6 +2107,53 @@
   EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
 }
 
+TEST_F(AidlTestCompatibleChanges, ReorderedAnnatations) {
+  io_delegate_.SetFileContents("old/p/Foo.aidl",
+                               "package p;"
+                               "@JavaPassthrough(annotation=\"Alice\")"
+                               "@JavaPassthrough(annotation=\"Bob\")"
+                               "parcelable Foo {}");
+  io_delegate_.SetFileContents("new/p/Foo.aidl",
+                               "package p;"
+                               "@JavaPassthrough(annotation=\"Bob\")"
+                               "@JavaPassthrough(annotation=\"Alice\")"
+                               "parcelable Foo {}");
+  EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
+TEST_F(AidlTestCompatibleChanges, OkayToDeprecate) {
+  io_delegate_.SetFileContents("old/p/Foo.aidl",
+                               "package p;"
+                               "parcelable Foo {}");
+  io_delegate_.SetFileContents("new/p/Foo.aidl",
+                               "package p;"
+                               "@JavaPassthrough(annotation=\"@Deprecated\")"
+                               "parcelable Foo {}");
+  EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
+TEST_F(AidlTestCompatibleChanges, NewFieldOfNewType) {
+  io_delegate_.SetFileContents("old/p/Data.aidl",
+                               "package p;"
+                               "parcelable Data {"
+                               "  int num;"
+                               "}");
+  io_delegate_.SetFileContents(
+      "new/p/Data.aidl",
+      "package p;"
+      "parcelable Data {"
+      "  int num;"
+      "  p.Enum e;"  // this is considered as valid since 0(enum default) is valid for "Enum" type
+      "}");
+  io_delegate_.SetFileContents("new/p/Enum.aidl",
+                               "package p;"
+                               "enum Enum {"
+                               "  FOO = 0,"
+                               "  BAR = 1,"
+                               "}");
+  EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
 class AidlTestIncompatibleChanges : public AidlTest {
  protected:
   Options options_ = Options::From("aidl --checkapi old new");
@@ -1875,6 +2256,56 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_F(AidlTestIncompatibleChanges, NewFieldWithNoDefault) {
+  const string expected_stderr =
+      "ERROR: new/p/Data.aidl:1.46-50: Field 'str' does not have a useful default in some "
+      "backends. Please either provide a default value for this field or mark the field as "
+      "@nullable. This value or a null value will be used automatically when an old version of "
+      "this parcelable is sent to a process which understands a new version of this parcelable. In "
+      "order to make sure your code continues to be backwards compatible, make sure the default or "
+      "null value does not cause a semantic change to this parcelable.\n";
+  io_delegate_.SetFileContents("old/p/Data.aidl",
+                               "package p;"
+                               "parcelable Data {"
+                               "  int num;"
+                               "}");
+  io_delegate_.SetFileContents("new/p/Data.aidl",
+                               "package p;"
+                               "parcelable Data {"
+                               "  int num;"
+                               "  String str;"
+                               "}");
+  CaptureStderr();
+  EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, NewFieldWithNonZeroEnum) {
+  const string expected_stderr =
+      "ERROR: new/p/Data.aidl:1.46-48: Field 'e' of enum 'Enum' can't be initialized as '0'. "
+      "Please make sure 'Enum' has '0' as a valid value.\n";
+  io_delegate_.SetFileContents("old/p/Data.aidl",
+                               "package p;"
+                               "parcelable Data {"
+                               "  int num;"
+                               "}");
+  io_delegate_.SetFileContents("new/p/Data.aidl",
+                               "package p;"
+                               "parcelable Data {"
+                               "  int num;"
+                               "  p.Enum e;"
+                               "}");
+  io_delegate_.SetFileContents("new/p/Enum.aidl",
+                               "package p;"
+                               "enum Enum {"
+                               "  FOO = 1,"
+                               "  BAR = 2,"
+                               "}");
+  CaptureStderr();
+  EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
 TEST_F(AidlTestIncompatibleChanges, RemovedEnumerator) {
   const string expected_stderr =
       "ERROR: new/p/Enum.aidl:1.15-20: Removed enumerator from p.Enum: FOO\n";
@@ -1894,6 +2325,25 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_F(AidlTestIncompatibleChanges, RemovedUnionField) {
+  const string expected_stderr =
+      "ERROR: new/p/Union.aidl:1.16-22: Number of fields in p.Union is reduced from 2 to 1.\n";
+  io_delegate_.SetFileContents("old/p/Union.aidl",
+                               "package p;"
+                               "union Union {"
+                               "  String str;"
+                               "  int num;"
+                               "}");
+  io_delegate_.SetFileContents("new/p/Union.aidl",
+                               "package p;"
+                               "union Union {"
+                               "  String str;"
+                               "}");
+  CaptureStderr();
+  EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
 TEST_F(AidlTestIncompatibleChanges, RenamedMethod) {
   const string expected_stderr =
       "ERROR: old/p/IFoo.aidl:1.61-65: Removed or changed method: p.IFoo.bar(String)\n";
@@ -2056,9 +2506,48 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_F(AidlTestIncompatibleChanges, ChangedBackingTypeOfEnum) {
+  const string expected_stderr =
+      "ERROR: new/p/Foo.aidl:1.11-32: Type changed: byte to long.\n"
+      "ERROR: new/p/Foo.aidl:1.36-40: Changed backing types.\n";
+  io_delegate_.SetFileContents("old/p/Foo.aidl",
+                               "package p;"
+                               "@Backing(type=\"byte\")"
+                               "enum Foo {"
+                               " FOO, BAR,"
+                               "}");
+  io_delegate_.SetFileContents("new/p/Foo.aidl",
+                               "package p;"
+                               "@Backing(type=\"long\")"
+                               "enum Foo {"
+                               " FOO, BAR,"
+                               "}");
+  CaptureStderr();
+  EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, ChangedAnnatationParams) {
+  const string expected_stderr =
+      "ERROR: new/p/Foo.aidl:1.55-59: Changed annotations: @JavaPassthrough(annotation=\"Alice\") "
+      "to @JavaPassthrough(annotation=\"Bob\")\n";
+  io_delegate_.SetFileContents("old/p/Foo.aidl",
+                               "package p;"
+                               "@JavaPassthrough(annotation=\"Alice\")"
+                               "parcelable Foo {}");
+  io_delegate_.SetFileContents("new/p/Foo.aidl",
+                               "package p;"
+                               "@JavaPassthrough(annotation=\"Bob\")"
+                               "parcelable Foo {}");
+
+  CaptureStderr();
+  EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
 TEST_F(AidlTestIncompatibleChanges, AddedParcelableAnnotation) {
   const string expected_stderr =
-      "ERROR: new/p/Foo.aidl:1.47-51: Changed annotations: (empty) to @JavaOnlyStableParcelable\n";
+      "ERROR: new/p/Foo.aidl:1.32-36: Changed annotations: (empty) to @FixedSize\n";
   io_delegate_.SetFileContents("old/p/Foo.aidl",
                                "package p;"
                                "parcelable Foo {"
@@ -2066,7 +2555,7 @@
                                "}");
   io_delegate_.SetFileContents("new/p/Foo.aidl",
                                "package p;"
-                               "@JavaOnlyStableParcelable parcelable Foo {"
+                               "@FixedSize parcelable Foo {"
                                "  int A;"
                                "}");
   CaptureStderr();
@@ -2076,10 +2565,10 @@
 
 TEST_F(AidlTestIncompatibleChanges, RemovedParcelableAnnotation) {
   const string expected_stderr =
-      "ERROR: new/p/Foo.aidl:1.21-25: Changed annotations: @JavaOnlyStableParcelable to (empty)\n";
+      "ERROR: new/p/Foo.aidl:1.21-25: Changed annotations: @FixedSize to (empty)\n";
   io_delegate_.SetFileContents("old/p/Foo.aidl",
                                "package p;"
-                               "@JavaOnlyStableParcelable parcelable Foo {"
+                               "@FixedSize parcelable Foo {"
                                "  int A;"
                                "}");
   io_delegate_.SetFileContents("new/p/Foo.aidl",
@@ -2184,8 +2673,7 @@
                                "  int isFixedSize;"
                                "}");
   io_delegate_.SetFileContents("Bar.aidl", "parcelable Bar { int a; }");
-  Options options =
-      Options::From("aidl Foo.aidl -I . --lang=" + Options::LanguageToString(GetLanguage()));
+  Options options = Options::From("aidl Foo.aidl -I . --lang=" + to_string(GetLanguage()));
 
   CaptureStderr();
   EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
@@ -2198,8 +2686,7 @@
   io_delegate_.SetFileContents("Foo.aidl", "@FixedSize parcelable Foo { int a; Bar b; }");
   io_delegate_.SetFileContents("Bar.aidl", "@FixedSize parcelable Bar { Val c; }");
   io_delegate_.SetFileContents("Val.aidl", "enum Val { A, B, }");
-  Options options =
-      Options::From("aidl Foo.aidl -I . --lang=" + Options::LanguageToString(GetLanguage()));
+  Options options = Options::From("aidl Foo.aidl -I . --lang=" + to_string(GetLanguage()));
 
   CaptureStderr();
   EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
@@ -2378,32 +2865,53 @@
 }
 
 TEST_F(AidlTest, ParseJavaPassthroughAnnotation) {
-  io_delegate_.SetFileContents("a/IFoo.aidl", R"(package a;
-    @JavaPassthrough(annotation="@com.android.Alice(arg=com.android.Alice.Value.A) ")
+  io_delegate_.SetFileContents("a/IFoo.aidl", R"--(package a;
+    import a.MyEnum;
+    @JavaPassthrough(annotation="@com.android.Alice(arg=com.android.Alice.Value.A)")
+    @JavaPassthrough(annotation="@com.android.AliceTwo")
     interface IFoo {
         @JavaPassthrough(annotation="@com.android.Bob")
-        void foo(@JavaPassthrough(annotation="@com.android.Cat") int x);
+        void foo(@JavaPassthrough(annotation="@com.android.Cat") int x, MyEnum y);
         const @JavaPassthrough(annotation="@com.android.David") int A = 3;
-    })");
+    })--");
+  // JavaPassthrough should work with other types as well (e.g. enum)
+  io_delegate_.SetFileContents("a/MyEnum.aidl", R"--(package a;
+    @JavaPassthrough(annotation="@com.android.Alice(arg=com.android.Alice.Value.A)")
+    @JavaPassthrough(annotation="@com.android.AliceTwo")
+    @Backing(type="byte")
+    enum MyEnum {
+      a, b, c
+    })--");
 
-  Options java_options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
+  Options java_options = Options::From("aidl -I . --lang=java -o out a/IFoo.aidl a/MyEnum.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
 
   string java_out;
   EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/IFoo.java", &java_out));
-  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Alice(arg=com.android.Alice.Value.A)"));
-  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Bob"));
-  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Cat"));
-  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.David"));
+  // type-decl-level annotations with newline at the end
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Alice(arg=com.android.Alice.Value.A)\n"));
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.AliceTwo\n"));
+  // member-decl-level annotations with newline at the end
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Bob\n"));
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.David\n"));
+  // inline annotations with space at the end
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Cat "));
+
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/MyEnum.java", &java_out));
+  // type-decl-level annotations with newline at the end
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.Alice(arg=com.android.Alice.Value.A)\n"));
+  EXPECT_THAT(java_out, testing::HasSubstr("@com.android.AliceTwo\n"));
 
   // Other backends shouldn't be bothered
-  Options cpp_options = Options::From("aidl --lang=cpp -o out -h out a/IFoo.aidl");
+  Options cpp_options =
+      Options::From("aidl -I . --lang=cpp -o out -h out a/IFoo.aidl a/MyEnum.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(cpp_options, io_delegate_));
 
-  Options ndk_options = Options::From("aidl --lang=ndk -o out -h out a/IFoo.aidl");
+  Options ndk_options =
+      Options::From("aidl -I . --lang=ndk -o out -h out a/IFoo.aidl a/MyEnum.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(ndk_options, io_delegate_));
 
-  Options rust_options = Options::From("aidl --lang=rust -o out a/IFoo.aidl");
+  Options rust_options = Options::From("aidl -I . --lang=rust -o out a/IFoo.aidl a/MyEnum.aidl");
   EXPECT_EQ(0, ::android::aidl::compile_aidl(rust_options, io_delegate_));
 }
 
@@ -2533,8 +3041,7 @@
 TEST_P(AidlTest, FailOnOutOfBoundsAutofilledEnum) {
   AidlError error;
   const string expected_stderr =
-      "ERROR: p/TestEnum.aidl:3.35-44: Invalid type specifier for an int32 "
-      "literal: byte\n"
+      "ERROR: p/TestEnum.aidl:5.1-36: Invalid type specifier for an int32 literal: byte\n"
       "ERROR: p/TestEnum.aidl:5.1-36: Enumerator type differs from enum backing type.\n";
   CaptureStderr();
   EXPECT_EQ(nullptr, Parse("p/TestEnum.aidl",
@@ -2554,8 +3061,6 @@
   AidlError error;
   const string expected_stderr =
       "ERROR: p/TestEnum.aidl:2.1-51: Parameter foo not supported for annotation Backing. It must "
-      "be one of: type\n"
-      "ERROR: p/TestEnum.aidl:2.1-51: Parameter foo not supported for annotation Backing. It must "
       "be one of: type\n";
   CaptureStderr();
   EXPECT_EQ(nullptr, Parse("p/TestEnum.aidl",
@@ -2571,7 +3076,14 @@
   EXPECT_EQ(AidlError::BAD_TYPE, error);
 }
 
-TEST_P(AidlTest, SupportJavaOnlyImmutableAnnotation) {
+TEST_P(AidlTest, BackingAnnotationRequireTypeParameter) {
+  const string expected_stderr = "ERROR: Enum.aidl:1.1-9: Missing 'type' on @Backing.\n";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("Enum.aidl", "@Backing enum Enum { FOO }", typenames_, GetLanguage()));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, SupportJavaOnlyImmutableAnnotation) {
   io_delegate_.SetFileContents("Foo.aidl",
                                "@JavaOnlyImmutable parcelable Foo { int a; Bar b; List<Bar> c; "
                                "Map<String, Baz> d; Bar[] e; }");
@@ -2582,52 +3094,235 @@
   EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
 }
 
-TEST_P(AidlTest, RejectMutableParcelableFromJavaOnlyImmutableParcelable) {
+TEST_F(AidlTest, RejectMutableParcelableFromJavaOnlyImmutableParcelable) {
   io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable parcelable Foo { Bar bar; }");
   io_delegate_.SetFileContents("Bar.aidl", "parcelable Bar { String a; }");
+  string expected_error =
+      "ERROR: Foo.aidl:1.40-44: The @JavaOnlyImmutable 'Foo' has a non-immutable field "
+      "named 'bar'.\n";
+  CaptureStderr();
   Options options = Options::From("aidl --lang=java Foo.aidl -I .");
   EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_error, GetCapturedStderr());
 }
 
-TEST_P(AidlTest, ImmtuableParcelableCannotBeInOut) {
+TEST_F(AidlTest, RejectMutableParcelableFromJavaOnlyImmutableUnion) {
+  io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable union Foo { Bar bar; }");
+  io_delegate_.SetFileContents("Bar.aidl", "parcelable Bar { String a; }");
+  string expected_error =
+      "ERROR: Foo.aidl:1.35-39: The @JavaOnlyImmutable 'Foo' has a non-immutable field "
+      "named 'bar'.\n";
+  CaptureStderr();
+  Options options = Options::From("aidl --lang=java Foo.aidl -I .");
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_error, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, ImmutableParcelableCannotBeInOut) {
   io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable parcelable Foo { int a; }");
-  io_delegate_.SetFileContents("IBar.aidl", "interface IBar { void my(inout Foo); }");
+  io_delegate_.SetFileContents("IBar.aidl", "interface IBar { void my(inout Foo foo); }");
+  string expected_error =
+      "ERROR: IBar.aidl:1.35-39: 'foo' can't be an inout parameter because @JavaOnlyImmutable can "
+      "only be an in parameter.\n";
+  CaptureStderr();
   Options options = Options::From("aidl --lang=java IBar.aidl -I .");
   EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_error, GetCapturedStderr());
 }
 
-TEST_P(AidlTest, ImmtuableParcelableCannotBeOut) {
+TEST_F(AidlTest, ImmutableParcelableCannotBeOut) {
   io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable parcelable Foo { int a; }");
-  io_delegate_.SetFileContents("IBar.aidl", "interface IBar { void my(out Foo); }");
+  io_delegate_.SetFileContents("IBar.aidl", "interface IBar { void my(out Foo foo); }");
+  string expected_error =
+      "ERROR: IBar.aidl:1.33-37: 'foo' can't be an out parameter because @JavaOnlyImmutable can "
+      "only be an in parameter.\n";
+  CaptureStderr();
   Options options = Options::From("aidl --lang=java IBar.aidl -I .");
   EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_error, GetCapturedStderr());
 }
 
-TEST_P(AidlTest, ImmtuableParcelableFieldNameRestriction) {
+TEST_F(AidlTest, ImmutableParcelableFieldNameRestriction) {
   io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable parcelable Foo { int a; int A; }");
   Options options = Options::From("aidl --lang=java Foo.aidl");
   const string expected_stderr =
-      "ERROR: Foo.aidl:1.30-34: The parcelable 'Foo' has duplicate field name 'A' after "
-      "capitalizing the first letter\n";
+      "ERROR: Foo.aidl:1.47-49: 'Foo' has duplicate field name 'A' after capitalizing the first "
+      "letter\n";
   CaptureStderr();
   EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_P(AidlTest, UnionInUnion) {
+  import_paths_.insert(".");
+  io_delegate_.SetFileContents("Bar.aidl", "union Bar { int n = 42; long l; }");
+  CaptureStderr();
+  EXPECT_NE(nullptr, Parse("Foo.aidl", "union Foo { Bar b; int n; }", typenames_, GetLanguage()));
+  EXPECT_THAT("", GetCapturedStderr());
+}
+
+TEST_P(AidlTest, UnionRejectsEmptyDecl) {
+  const string method = "package a; union Foo {}";
+  const string expected_stderr = "ERROR: a/Foo.aidl:1.17-21: The union 'Foo' has no fields.\n";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", method, typenames_, GetLanguage()));
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_stderr));
+}
+
+TEST_P(AidlTest, UnionRejectsParcelableHolder) {
+  const string method = "package a; union Foo { ParcelableHolder x; }";
+  const string expected_stderr =
+      "ERROR: a/Foo.aidl:1.40-42: A union can't have a member of ParcelableHolder 'x'\n";
+  CaptureStderr();
+  EXPECT_EQ(nullptr, Parse("a/Foo.aidl", method, typenames_, GetLanguage()));
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_stderr));
+}
+
+TEST_P(AidlTest, UnionRejectsFirstEnumWithNoDefaults) {
+  import_paths_.insert(".");
+  io_delegate_.SetFileContents("a/Enum.aidl", "package a; enum Enum { FOO, BAR }");
+  const string expected_err = "The union's first member should have a useful default value.";
+  CaptureStderr();
+  EXPECT_EQ(nullptr,
+            Parse("a/Foo.aidl", "package a; union Foo { a.Enum e; }", typenames_, GetLanguage()));
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_err));
+}
+
 TEST_P(AidlTest, GenericStructuredParcelable) {
   io_delegate_.SetFileContents("Foo.aidl", "parcelable Foo<T, U> { int a; int A; }");
-  Options options =
-      Options::From("aidl Foo.aidl --lang=" + Options::LanguageToString(GetLanguage()));
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
   const string expected_stderr = "";
   CaptureStderr();
   EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_F(AidlTest, GenericStructuredParcelableWithStringConstants_Cpp) {
+  io_delegate_.SetFileContents("Foo.aidl",
+                               "parcelable Foo<T, U> { int a; const String s = \"\"; }");
+  Options options =
+      Options::From("aidl Foo.aidl --lang=" + to_string(Options::Language::CPP) + " -o out -h out");
+  const string expected_stderr = "";
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/Foo.h", &code));
+  EXPECT_THAT(code, testing::HasSubstr(R"--(template <typename T, typename U>
+const ::android::String16& Foo<T,U>::s() {
+  static const ::android::String16 value(::android::String16(""));
+  return value;
+})--"));
+}
+
+TEST_F(AidlTest, GenericStructuredParcelableWithStringConstants_Ndk) {
+  io_delegate_.SetFileContents("Foo.aidl",
+                               "parcelable Foo<T, U> { int a; const String s = \"\"; }");
+  Options options =
+      Options::From("aidl Foo.aidl --lang=" + to_string(Options::Language::NDK) + " -o out -h out");
+  const string expected_stderr = "";
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/aidl/Foo.h", &code));
+  EXPECT_THAT(code, testing::HasSubstr(R"--(template <typename T, typename U>
+const char* Foo<T, U>::s = "";
+)--"));
+}
+
+TEST_F(AidlTest, NestedTypeArgs) {
+  io_delegate_.SetFileContents("a/Bar.aidl", "package a; parcelable Bar<A> { }");
+  io_delegate_.SetFileContents("a/Baz.aidl", "package a; parcelable Baz<A, B> { }");
+
+  io_delegate_.SetFileContents("a/Foo.aidl",
+                               "package a; import a.Bar; import a.Baz; parcelable Foo { "
+                               "Baz<Bar<Bar<String[]>>[], Bar<String>> barss; }");
+  Options options = Options::From("aidl a/Foo.aidl -I . -o out --lang=java");
+  const string expected_stderr = "";
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &code));
+  EXPECT_THAT(code,
+              testing::HasSubstr(
+                  "a.Baz<a.Bar<a.Bar<java.lang.String[]>>[],a.Bar<java.lang.String>> barss;"));
+}
+
+TEST_F(AidlTest, DoubleArrayError) {
+  io_delegate_.SetFileContents("a/Bar.aidl", "package a; parcelable Bar { String[][] a; }");
+
+  Options options = Options::From("aidl a/Bar.aidl -I . -o out --lang=java");
+  const string expected_stderr =
+      "ERROR: a/Bar.aidl:1.28-37: Can only have one dimensional arrays.\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, DoubleGenericError) {
+  io_delegate_.SetFileContents("a/Bar.aidl",
+                               "package a; parcelable Bar { List<String><String> a; }");
+
+  Options options = Options::From("aidl a/Bar.aidl -I . -o out --lang=java");
+  const string expected_stderr =
+      "ERROR: a/Bar.aidl:1.28-33: Can only specify one set of type parameters.\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, ArrayBeforeGenericError) {
+  io_delegate_.SetFileContents("a/Bar.aidl", "package a; parcelable Bar { List[]<String> a; }");
+
+  Options options = Options::From("aidl a/Bar.aidl -I . -o out --lang=java");
+  const string expected_stderr =
+      "ERROR: a/Bar.aidl:1.28-33: Must specify type parameters (<>) before array ([]).\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+struct GenericAidlTest : ::testing::Test {
+  FakeIoDelegate io_delegate_;
+  void Compile(string cmd) {
+    io_delegate_.SetFileContents("Foo.aidl", "parcelable Foo { Bar<Baz<Qux>> x; }");
+    io_delegate_.SetFileContents("Bar.aidl", "parcelable Bar<T> {  }");
+    io_delegate_.SetFileContents("Baz.aidl", "parcelable Baz<T> {  }");
+    io_delegate_.SetFileContents("Qux.aidl", "parcelable Qux {  }");
+
+    Options options = Options::From(cmd);
+    CaptureStderr();
+    EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+    EXPECT_EQ("", GetCapturedStderr());
+  }
+};
+
+TEST_F(GenericAidlTest, ImportGenericParameterTypesCPP) {
+  Compile("aidl Foo.aidl --lang=cpp -I . -o out -h out");
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/Foo.h", &code));
+  EXPECT_THAT(code, testing::HasSubstr("#include <Bar.h>"));
+  EXPECT_THAT(code, testing::HasSubstr("#include <Baz.h>"));
+  EXPECT_THAT(code, testing::HasSubstr("#include <Qux.h>"));
+}
+
+TEST_F(GenericAidlTest, ImportGenericParameterTypesNDK) {
+  Compile("aidl Foo.aidl --lang=ndk -I . -o out -h out");
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/aidl/Foo.h", &code));
+  EXPECT_THAT(code, testing::HasSubstr("#include <aidl/Bar.h>"));
+  EXPECT_THAT(code, testing::HasSubstr("#include <aidl/Baz.h>"));
+  EXPECT_THAT(code, testing::HasSubstr("#include <aidl/Qux.h>"));
+}
+
 TEST_P(AidlTest, RejectGenericStructuredParcelabelRepeatedParam) {
   io_delegate_.SetFileContents("Foo.aidl", "parcelable Foo<T,T> { int a; int A; }");
-  Options options =
-      Options::From("aidl Foo.aidl --lang=" + Options::LanguageToString(GetLanguage()));
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
   const string expected_stderr =
       "ERROR: Foo.aidl:1.11-15: Every type parameter should be unique.\n";
   CaptureStderr();
@@ -2637,13 +3332,527 @@
 
 TEST_P(AidlTest, RejectGenericStructuredParcelableField) {
   io_delegate_.SetFileContents("Foo.aidl", "parcelable Foo<T,T> { T a; int A; }");
-  Options options =
-      Options::From("aidl Foo.aidl --lang=" + Options::LanguageToString(GetLanguage()));
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
   const string expected_stderr = "ERROR: Foo.aidl:1.22-24: Failed to resolve 'T'\n";
   CaptureStderr();
   EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_P(AidlTest, LongCommentWithinConstExpression) {
+  io_delegate_.SetFileContents("Foo.aidl", "enum Foo { FOO = (1 << 1) /* comment */ | 0x0 }");
+  Options options = Options::From("aidl Foo.aidl --lang=" + to_string(GetLanguage()));
+  CaptureStderr();
+  EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+}
+
+TEST_F(AidlTest, RejectUntypdeListAndMapInUnion) {
+  io_delegate_.SetFileContents("a/Foo.aidl", "package a; union Foo { List l; Map m; }");
+  Options options = Options::From("aidl a/Foo.aidl --lang=java -o out");
+  std::string expectedErr =
+      "ERROR: a/Foo.aidl:1.28-30: "
+      "Encountered an untyped List or Map. The use of untyped List/Map is "
+      "prohibited because it is not guaranteed that the objects in the list are recognizable in "
+      "the receiving side. Consider switching to an array or a generic List/Map.\n"
+      "ERROR: a/Foo.aidl:1.35-37: "
+      "Encountered an untyped List or Map. The use of untyped List/Map is "
+      "prohibited because it is not guaranteed that the objects in the list are recognizable in "
+      "the receiving side. Consider switching to an array or a generic List/Map.\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expectedErr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, RejectUntypdeListAndMapInUnstructuredParcelable) {
+  io_delegate_.SetFileContents("a/Foo.aidl", "package a; parcelable Foo { List l; Map m; }");
+  Options options = Options::From("aidl a/Foo.aidl --lang=java -o out");
+  std::string expectedErr =
+      "ERROR: a/Foo.aidl:1.33-35: "
+      "Encountered an untyped List or Map. The use of untyped List/Map is "
+      "prohibited because it is not guaranteed that the objects in the list are recognizable in "
+      "the receiving side. Consider switching to an array or a generic List/Map.\n"
+      "ERROR: a/Foo.aidl:1.40-42: "
+      "Encountered an untyped List or Map. The use of untyped List/Map is "
+      "prohibited because it is not guaranteed that the objects in the list are recognizable in "
+      "the receiving side. Consider switching to an array or a generic List/Map.\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expectedErr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, RejectNestedUntypedListAndMap) {
+  io_delegate_.SetFileContents("a/Bar.aidl", "package a; parcelable Bar<T>;");
+  io_delegate_.SetFileContents(
+      "a/Foo.aidl", "package a; import a.Bar; parcelable Foo { Bar<List> a; Bar<Map> b; }");
+  Options options = Options::From("aidl a/Foo.aidl -I . --lang=java -o out");
+  std::string expectedErr =
+      "ERROR: a/Foo.aidl:1.52-54: "
+      "Encountered an untyped List or Map. The use of untyped List/Map is "
+      "prohibited because it is not guaranteed that the objects in the list are recognizable in "
+      "the receiving side. Consider switching to an array or a generic List/Map.\n"
+      "ERROR: a/Foo.aidl:1.64-66: "
+      "Encountered an untyped List or Map. The use of untyped List/Map is "
+      "prohibited because it is not guaranteed that the objects in the list are recognizable in "
+      "the receiving side. Consider switching to an array or a generic List/Map.\n";
+  CaptureStderr();
+  EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(expectedErr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, EnumWithDefaults_Java) {
+  io_delegate_.SetFileContents("a/p/Enum.aidl", "package p; enum Enum { FOO, BAR }");
+  io_delegate_.SetFileContents("a/p/Foo.aidl", R"(
+package p;
+import p.Enum;
+parcelable Foo {
+  Enum e = Enum.BAR;
+})");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang java -o out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/p/Foo.java", &code));
+  EXPECT_THAT(code, testing::HasSubstr("byte e = p.Enum.BAR"));
+}
+
+TEST_F(AidlTest, EnumWithDefaults_Cpp) {
+  io_delegate_.SetFileContents("a/p/Enum.aidl", "package p; enum Enum { FOO, BAR }");
+  io_delegate_.SetFileContents("a/p/Foo.aidl", R"(
+package p;
+import p.Enum;
+parcelable Foo {
+  Enum e = Enum.BAR;
+})");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang cpp -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/p/Foo.h", &code));
+  EXPECT_THAT(code, testing::HasSubstr("::p::Enum e = ::p::Enum(::p::Enum::BAR);"));
+}
+
+TEST_F(AidlTest, EnumWithDefaults_Ndk) {
+  io_delegate_.SetFileContents("a/p/Enum.aidl", "package p; enum Enum { FOO, BAR }");
+  io_delegate_.SetFileContents("a/p/Foo.aidl", R"(
+package p;
+import p.Enum;
+parcelable Foo {
+  Enum e = Enum.BAR;
+})");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/aidl/p/Foo.h", &code));
+  EXPECT_THAT(code, testing::HasSubstr("::aidl::p::Enum e = ::aidl::p::Enum::BAR;"));
+}
+
+TEST_F(AidlTest, EnumWithDefaults_Rust) {
+  io_delegate_.SetFileContents("a/p/Enum.aidl", "package p; enum Enum { FOO, BAR }");
+  io_delegate_.SetFileContents("a/p/Foo.aidl", R"(
+package p;
+import p.Enum;
+parcelable Foo {
+  int  n = 42;
+  Enum e = Enum.BAR;
+})");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang rust -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/p/Foo.rs", &code));
+  EXPECT_THAT(code, testing::HasSubstr(R"(
+  fn default() -> Self {
+    Self {
+      n: 42,
+      e: crate::mangled::_1_p_4_Enum::BAR,
+    }
+  })"));
+}
+
+TEST_P(AidlTest, EnumeratorIsConstantValue_DefaultValue) {
+  import_paths_.insert("a");
+  io_delegate_.SetFileContents("a/p/Enum.aidl", "package p; enum Enum { FOO = 1, BAR = 2}");
+  CaptureStderr();
+  const AidlDefinedType* type = Parse("a/p/Foo.aidl", R"(
+package p;
+import p.Enum;
+parcelable Foo {
+  int e = Enum.FOO | Enum.BAR;
+})",
+                                      typenames_, GetLanguage());
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+  EXPECT_TRUE(type);
+  const auto& fields = type->AsStructuredParcelable()->GetFields();
+  EXPECT_EQ("int e = 3", fields[0]->ToString());
+}
+
+TEST_P(AidlTest, EnumeratorIsConstantValue_CanDefineOtherEnumerator) {
+  CaptureStderr();
+  const AidlDefinedType* type = Parse("a/p/Foo.aidl", R"(
+@Backing(type="int")
+enum Foo {
+      STANDARD_SHIFT = 16,
+      STANDARD_BT709 = 1 << STANDARD_SHIFT,
+      STANDARD_BT601_625 = 2 << STANDARD_SHIFT,
+}
+)",
+                                      typenames_, GetLanguage());
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+  EXPECT_TRUE(type);
+  const auto& enum_type = type->AsEnumDeclaration();
+  string code;
+  enum_type->Dump(CodeWriter::ForString(&code).get());
+  EXPECT_EQ(R"--(@Backing(type="int")
+enum Foo {
+  STANDARD_SHIFT = 16,
+  STANDARD_BT709 = 65536,
+  STANDARD_BT601_625 = 131072,
+}
+)--",
+            code);
+}
+
+TEST_F(AidlTest, EnumDefaultShouldBeEnumerators) {
+  io_delegate_.SetFileContents("a/p/Enum.aidl", "package p; enum Enum { FOO = 1, BAR = 2}");
+  io_delegate_.SetFileContents("a/p/Foo.aidl", R"(
+package p;
+import p.Enum;
+parcelable Foo {
+  Enum e = Enum.FOO | Enum.BAR;
+})");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang java -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("ERROR: a/p/Foo.aidl:5.11-20: Invalid value (Enum.FOO|Enum.BAR) for enum p.Enum\n",
+            err);
+}
+
+TEST_P(AidlTest, DefaultWithEmptyArray) {
+  io_delegate_.SetFileContents("a/p/Foo.aidl", "package p; parcelable Foo { p.Bar[] bars = {}; }");
+  io_delegate_.SetFileContents("a/p/Bar.aidl", "package p; parcelable Bar { }");
+  CaptureStderr();
+  auto options =
+      Options::From("aidl -I a --lang " + to_string(GetLanguage()) + " -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+}
+
+TEST_P(AidlTest, RejectRefsInAnnotation) {
+  io_delegate_.SetFileContents("a/p/IFoo.aidl",
+                               "package p; interface IFoo {\n"
+                               "  const String ANNOTATION = \"@Annotation\";\n"
+                               "  @JavaPassthrough(annotation=ANNOTATION) void foo();\n"
+                               "}");
+  CaptureStderr();
+  auto options =
+      Options::From("aidl --lang " + to_string(GetLanguage()) + " -o out -h out a/p/IFoo.aidl");
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ(
+      "ERROR: a/p/IFoo.aidl:3.31-41: Value must be a constant expression but contains reference to "
+      "ANNOTATION.\n",
+      err);
+}
+
+TEST_F(AidlTest, DefaultWithEnumValues) {
+  io_delegate_.SetFileContents(
+      "a/p/Foo.aidl",
+      "package p; import p.Bar; parcelable Foo { Bar[] bars = { Bar.FOO, Bar.FOO }; }");
+  io_delegate_.SetFileContents("a/p/Bar.aidl", "package p; enum Bar { FOO, BAR }");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("", err);
+  string code;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("out/aidl/p/Foo.h", &code));
+  EXPECT_THAT(
+      code, testing::HasSubstr(
+                "std::vector<::aidl::p::Bar> bars = {::aidl::p::Bar::FOO, ::aidl::p::Bar::FOO};"));
+}
+
+TEST_F(AidlTest, RejectsCircularReferencingEnumerators) {
+  io_delegate_.SetFileContents("a/p/Foo.aidl", "package p; enum Foo { A = B, B }");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ(
+      "ERROR: a/p/Foo.aidl:1.26-28: Found a circular reference: B -> A -> B\n"
+      "ERROR: a/p/Foo.aidl:1.29-31: Found a circular reference: A -> B -> A\n",
+      err);
+}
+
+TEST_F(AidlTest, RejectsCircularReferencingConsts) {
+  io_delegate_.SetFileContents("a/p/Foo.aidl",
+                               "package p; parcelable Foo { const int A = A + 1; }");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  auto err = GetCapturedStderr();
+  EXPECT_EQ("ERROR: a/p/Foo.aidl:1.42-44: Found a circular reference: A -> A\n", err);
+}
+
+TEST_F(AidlTest, RecursiveReferences) {
+  io_delegate_.SetFileContents("a/p/Foo.aidl",
+                               "package p; parcelable Foo { const int A = p.Bar.A + 1; }");
+  io_delegate_.SetFileContents("a/p/Bar.aidl",
+                               "package p; parcelable Bar { const int A = p.Baz.A + 1; }");
+  io_delegate_.SetFileContents("a/p/Baz.aidl", "package p; parcelable Baz { const int A = 1; }");
+  CaptureStderr();
+  auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+}
+
+TEST_P(AidlTest, UnknownConstReference) {
+  io_delegate_.SetFileContents("Foo.aidl", " parcelable Foo { UnknownType field = UNKNOWN_REF; }");
+  auto options =
+      Options::From("aidl --lang " + to_string(GetLanguage()) + " -o out -h out Foo.aidl");
+  const string err =
+      "ERROR: Foo.aidl:1.18-30: Failed to resolve 'UnknownType'\n"
+      "ERROR: Foo.aidl:1.38-50: Can't find UNKNOWN_REF in Foo\n"
+      "ERROR: Foo.aidl:1.38-50: Unknown reference 'UNKNOWN_REF'\n";
+  CaptureStderr();
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ(err, GetCapturedStderr());
+}
+
+TEST_P(AidlTest, JavaCompatibleBuiltinTypes) {
+  string contents = R"(
+import android.os.IBinder;
+import android.os.IInterface;
+interface IFoo {}
+  )";
+  EXPECT_NE(nullptr, Parse("IFoo.aidl", contents, typenames_, GetLanguage()));
+}
+
+TEST_P(AidlTest, WarningInterfaceName) {
+  io_delegate_.SetFileContents("p/Foo.aidl", "interface Foo {}");
+  auto options = Options::From("aidl --lang " + to_string(GetLanguage()) +
+                               " -Weverything -o out -h out p/Foo.aidl");
+  CaptureStderr();
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("WARNING: p/Foo.aidl:1.1-10: Interface names should start with I. [-Winterface-name]\n",
+            GetCapturedStderr());
+}
+
+TEST_P(AidlTest, ErrorInterfaceName) {
+  io_delegate_.SetFileContents("p/Foo.aidl", "interface Foo {}");
+  auto options = Options::From("aidl --lang " + to_string(GetLanguage()) +
+                               " -Weverything -Werror -o out -h out p/Foo.aidl");
+  CaptureStderr();
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("ERROR: p/Foo.aidl:1.1-10: Interface names should start with I. [-Winterface-name]\n",
+            GetCapturedStderr());
+}
+
+TEST_F(AidlTest, FormatCommentsForJava) {
+  using android::aidl::FormatCommentsForJava;
+
+  struct TestCase {
+    vector<Comment> comments;
+    string formatted;
+  };
+  vector<TestCase> testcases = {
+      {{}, ""},
+      {{{"// line comments\n"}}, "// line comments\n"},
+      {{{"// @hide \n"}}, "// @hide \n"},
+      // Transform the last block comment as Javadoc.
+      {{{"/*\n"
+         " * Hello, world!\n"
+         " */"}},
+       "/**\n"
+       " * Hello, world!\n"
+       " */"},
+      {{{"/* @hide */"}}, "/** @hide */"},
+      {{{"/**\n"
+         "   @param foo ...\n"
+         "*/"}},
+       "/**\n"
+       "   @param foo ...\n"
+       "*/"},
+      {{{"/* @hide */"}, {"/* @hide */"}}, "/* @hide *//** @hide */"},
+      {{{"/* @deprecated first */"}, {"/* @deprecated second */"}},
+       "/* @deprecated first *//** @deprecated second */"},
+      {{{"/* @deprecated */"}, {"/** @param foo */"}}, "/* @deprecated *//** @param foo */"},
+      // Line comments are printed as they are
+      {{{"/* @deprecated */"}, {"// line comments\n"}}, "/* @deprecated */// line comments\n"},
+  };
+  for (const auto& [input, formatted] : testcases) {
+    EXPECT_EQ(formatted, FormatCommentsForJava(input));
+  }
+}
+
+TEST_F(AidlTest, HideIsNotForArgs) {
+  io_delegate_.SetFileContents("IFoo.aidl",
+                               "interface IFoo {\n"
+                               "  void foo(in @Hide int x);\n"
+                               "}");
+  auto options = Options::From("aidl --lang=java IFoo.aidl");
+  CaptureStderr();
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("@Hide is not available"));
+}
+
+TEST_F(AidlTest, SuppressWarningsIsNotForArgs) {
+  io_delegate_.SetFileContents(
+      "IFoo.aidl",
+      "interface IFoo {\n"
+      "  void foo(in @SuppressWarnings(value=\"inout-parameter\") int x);\n"
+      "}");
+  auto options = Options::From("aidl --lang=java IFoo.aidl");
+  CaptureStderr();
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_THAT(GetCapturedStderr(), HasSubstr("@SuppressWarnings is not available"));
+}
+
+struct TypeParam {
+  string kind;
+  string literal;
+};
+
+const TypeParam kTypeParams[] = {
+    {"primitive", "int"},   {"String", "String"},
+    {"IBinder", "IBinder"}, {"ParcelFileDescriptor", "ParcelFileDescriptor"},
+    {"parcelable", "Foo"},  {"enum", "a.Enum"},
+    {"union", "a.Union"},   {"interface", "a.IBar"},
+};
+
+const std::map<std::string, std::string> kListSupportExpectations = {
+    {"cpp_primitive", "A generic type cannot have any primitive type parameters."},
+    {"java_primitive", "A generic type cannot have any primitive type parameters."},
+    {"ndk_primitive", "A generic type cannot have any primitive type parameters."},
+    {"rust_primitive", "A generic type cannot have any primitive type parameters."},
+    {"cpp_String", ""},
+    {"java_String", ""},
+    {"ndk_String", ""},
+    {"rust_String", ""},
+    {"cpp_IBinder", ""},
+    {"java_IBinder", ""},
+    {"ndk_IBinder", "List<IBinder> is not supported. List in NDK doesn't support IBinder."},
+    {"rust_IBinder", ""},
+    {"cpp_ParcelFileDescriptor", ""},
+    {"java_ParcelFileDescriptor", ""},
+    {"ndk_ParcelFileDescriptor", ""},
+    {"rust_ParcelFileDescriptor", ""},
+    {"cpp_interface", "List<a.IBar> is not supported."},
+    {"java_interface", "List<a.IBar> is not supported."},
+    {"ndk_interface", "List<a.IBar> is not supported."},
+    {"rust_interface", "List<a.IBar> is not supported."},
+    {"cpp_parcelable", ""},
+    {"java_parcelable", ""},
+    {"ndk_parcelable", ""},
+    {"rust_parcelable", ""},
+    {"cpp_enum", "A generic type cannot have any primitive type parameters."},
+    {"java_enum", "A generic type cannot have any primitive type parameters."},
+    {"ndk_enum", "A generic type cannot have any primitive type parameters."},
+    {"rust_enum", "A generic type cannot have any primitive type parameters."},
+    {"cpp_union", ""},
+    {"java_union", ""},
+    {"ndk_union", ""},
+    {"rust_union", ""},
+};
+
+const std::map<std::string, std::string> kArraySupportExpectations = {
+    {"cpp_primitive", ""},
+    {"java_primitive", ""},
+    {"ndk_primitive", ""},
+    {"rust_primitive", ""},
+    {"cpp_String", ""},
+    {"java_String", ""},
+    {"ndk_String", ""},
+    {"rust_String", ""},
+    {"cpp_IBinder", ""},
+    {"java_IBinder", ""},
+    {"ndk_IBinder", "The ndk backend does not support array of IBinder"},
+    {"rust_IBinder", "The rust backend does not support array of IBinder"},
+    {"cpp_ParcelFileDescriptor", ""},
+    {"java_ParcelFileDescriptor", ""},
+    {"ndk_ParcelFileDescriptor", ""},
+    {"rust_ParcelFileDescriptor", ""},
+    {"cpp_interface", "Binder type cannot be an array"},
+    {"java_interface", "Binder type cannot be an array"},
+    {"ndk_interface", "Binder type cannot be an array"},
+    {"rust_interface", "Binder type cannot be an array"},
+    {"cpp_parcelable", ""},
+    {"java_parcelable", ""},
+    {"ndk_parcelable", ""},
+    {"rust_parcelable", ""},
+    {"cpp_enum", ""},
+    {"java_enum", ""},
+    {"ndk_enum", ""},
+    {"rust_enum", ""},
+    {"cpp_union", ""},
+    {"java_union", ""},
+    {"ndk_union", ""},
+    {"rust_union", ""},
+};
+
+class AidlTypeParamTest : public testing::TestWithParam<std::tuple<Options::Language, TypeParam>> {
+ public:
+  void Run(const std::string& generic_type_decl,
+           const std::map<std::string, std::string>& expectations) {
+    const auto& param = GetParam();
+    const auto& lang = to_string(std::get<0>(param));
+    const auto& kind = std::get<1>(param).kind;
+
+    FakeIoDelegate io;
+    io.SetFileContents("a/IBar.aidl", "package a; interface IBar { }");
+    io.SetFileContents("a/Enum.aidl", "package a; enum Enum { A }");
+    io.SetFileContents("a/Union.aidl", "package a; union Union { int a; }");
+    std::string decl = fmt::format(generic_type_decl, std::get<1>(param).literal);
+    io.SetFileContents("a/Foo.aidl", "package a; parcelable Foo { " + decl + " f; }");
+
+    const auto options =
+        Options::From(fmt::format("aidl -I . --lang={} a/Foo.aidl -o out -h out", lang));
+    CaptureStderr();
+    compile_aidl(options, io);
+    auto it = expectations.find(lang + "_" + kind);
+    EXPECT_TRUE(it != expectations.end());
+    const string err = GetCapturedStderr();
+    if (it->second.empty()) {
+      EXPECT_EQ("", err);
+    } else {
+      EXPECT_THAT(err, testing::HasSubstr(it->second));
+    }
+  }
+};
+
+INSTANTIATE_TEST_SUITE_P(
+    AidlTestSuite, AidlTypeParamTest,
+    testing::Combine(testing::Values(Options::Language::CPP, Options::Language::JAVA,
+                                     Options::Language::NDK, Options::Language::RUST),
+                     testing::ValuesIn(kTypeParams)),
+    [](const testing::TestParamInfo<std::tuple<Options::Language, TypeParam>>& info) {
+      return to_string(std::get<0>(info.param)) + "_" + std::get<1>(info.param).kind;
+    });
+
+TEST_P(AidlTypeParamTest, ListSupportedTypes) {
+  Run("List<{}>", kListSupportExpectations);
+}
+
+TEST_P(AidlTypeParamTest, ArraySupportedTypes) {
+  Run("{}[]", kArraySupportExpectations);
+}
+
 }  // namespace aidl
 }  // namespace android
diff --git a/ast_cpp.cpp b/ast_cpp.cpp
index 63f16b0..39af24c 100644
--- a/ast_cpp.cpp
+++ b/ast_cpp.cpp
@@ -18,6 +18,8 @@
 
 #include <algorithm>
 
+#include <android-base/strings.h>
+
 #include "code_writer.h"
 #include "logging.h"
 
@@ -42,15 +44,17 @@
 }
 
 ClassDecl::ClassDecl(const std::string& name, const std::string& parent,
-                     const std::vector<std::string>& template_params)
-    : name_(name), parent_(parent), template_params_(template_params) {}
+                     const std::vector<std::string>& template_params, const std::string& attributes)
+    : name_(name), parent_(parent), attributes_(attributes), template_params_(template_params) {}
 
 ClassDecl::ClassDecl(const std::string& name, const std::string& parent,
                      const std::vector<std::string>& template_params,
                      std::vector<unique_ptr<Declaration>> public_members,
-                     std::vector<unique_ptr<Declaration>> private_members)
+                     std::vector<unique_ptr<Declaration>> private_members,
+                     const std::string& attributes)
     : name_(name),
       parent_(parent),
+      attributes_(attributes),
       template_params_(template_params),
       public_members_(std::move(public_members)),
       private_members_(std::move(private_members)) {}
@@ -59,7 +63,11 @@
   if (!template_params_.empty())
     to->Write("template <typename %s>\n", base::Join(template_params_, ", typename ").c_str());
 
-  to->Write("class %s ", name_.c_str());
+  to->Write("class");
+  if (!attributes_.empty()) {
+    to->Write(" %s", attributes_.c_str());
+  }
+  to->Write(" %s ", name_.c_str());
 
   if (parent_.length() > 0) to->Write(": public %s ", parent_.c_str());
 
@@ -90,18 +98,21 @@
   private_members_.push_back(std::move(member));
 }
 
-Enum::EnumField::EnumField(const string& k, const string& v)
-    : key(k),
-      value(v) {}
+Enum::EnumField::EnumField(const string& k, const string& v, const string& a)
+    : key(k), value(v), attribute(a) {}
 
-Enum::Enum(const string& name, const string& base_type, bool is_class)
-    : enum_name_(name), underlying_type_(base_type), is_class_(is_class) {}
+Enum::Enum(const string& name, const string& base_type, bool is_class,
+           const std::string& attributes)
+    : enum_name_(name), underlying_type_(base_type), attributes_(attributes), is_class_(is_class) {}
 
 void Enum::Write(CodeWriter* to) const {
   to->Write("enum ");
   if (is_class_) {
     to->Write("class ");
   }
+  if (!attributes_.empty()) {
+    to->Write("%s ", attributes_.c_str());
+  }
   if (underlying_type_.empty()) {
     to->Write("%s {\n", enum_name_.c_str());
   } else {
@@ -109,18 +120,21 @@
   }
   to->Indent();
   for (const auto& field : fields_) {
-    if (field.value.empty()) {
-      to->Write("%s,\n", field.key.c_str());
-    } else {
-      to->Write("%s = %s,\n", field.key.c_str(), field.value.c_str());
+    to->Write("%s", field.key.c_str());
+    if (!field.attribute.empty()) {
+      to->Write(" %s", field.attribute.c_str());
     }
+    if (!field.value.empty()) {
+      to->Write(" = %s", field.value.c_str());
+    }
+    to->Write(",\n");
   }
   to->Dedent();
   to->Write("};\n");
 }
 
-void Enum::AddValue(const string& key, const string& value) {
-  fields_.emplace_back(key, value);
+void Enum::AddValue(const string& key, const string& value, const string& attribute) {
+  fields_.emplace_back(key, value, attribute);
 }
 
 ArgList::ArgList(const std::string& single_argument)
@@ -188,15 +202,15 @@
   to->Write("\n");
 }
 
-MethodDecl::MethodDecl(const std::string& return_type,
-                       const std::string& name,
-                       ArgList&& arg_list)
-    : MethodDecl(return_type, name, std::move(arg_list), 0u) {}
+MethodDecl::MethodDecl(const std::string& return_type, const std::string& name, ArgList&& arg_list,
+                       const std::string& attributes)
+    : MethodDecl(return_type, name, std::move(arg_list), 0u, attributes) {}
 
 MethodDecl::MethodDecl(const std::string& return_type, const std::string& name, ArgList&& arg_list,
-                       uint32_t modifiers)
+                       uint32_t modifiers, const std::string& attributes)
     : return_type_(return_type),
       name_(name),
+      attributes_(attributes),
       arguments_(std::move(arg_list)),
       is_const_(modifiers & IS_CONST),
       is_virtual_(modifiers & IS_VIRTUAL),
@@ -224,6 +238,8 @@
 
   if (is_final_) to->Write(" final");
 
+  if (!attributes_.empty()) to->Write(" %s", attributes_.c_str());
+
   if (is_pure_virtual_)
     to->Write(" = 0");
 
diff --git a/ast_cpp.h b/ast_cpp.h
index 9890f27..ca5105c 100644
--- a/ast_cpp.h
+++ b/ast_cpp.h
@@ -64,11 +64,12 @@
 class ClassDecl : public Declaration {
  public:
   ClassDecl(const std::string& name, const std::string& parent,
-            const std::vector<std::string>& template_params);
+            const std::vector<std::string>& template_params, const std::string& attributes = "");
   ClassDecl(const std::string& name, const std::string& parent,
             const std::vector<std::string>& template_params,
             std::vector<std::unique_ptr<Declaration>> public_members,
-            std::vector<std::unique_ptr<Declaration>> private_members);
+            std::vector<std::unique_ptr<Declaration>> private_members,
+            const std::string& attributes = "");
   virtual ~ClassDecl() = default;
 
   void Write(CodeWriter* to) const override;
@@ -79,6 +80,7 @@
  private:
   std::string name_;
   std::string parent_;
+  std::string attributes_;
   std::vector<std::string> template_params_;
   std::vector<std::unique_ptr<Declaration>> public_members_;
   std::vector<std::unique_ptr<Declaration>> private_members_;
@@ -86,23 +88,27 @@
 
 class Enum : public Declaration {
  public:
-  Enum(const std::string& name, const std::string& base_type, bool is_class);
+  Enum(const std::string& name, const std::string& base_type, bool is_class,
+       const std::string& attributes = "");
   virtual ~Enum() = default;
 
   bool HasValues() const { return !fields_.empty(); }
   void Write(CodeWriter* to) const override;
 
-  void AddValue(const std::string& key, const std::string& value);
+  void AddValue(const std::string& key, const std::string& value,
+                const std::string& attribute = "");
 
  private:
   struct EnumField {
-    EnumField(const std::string& k, const std::string& v);
+    EnumField(const std::string& k, const std::string& v, const std::string& a);
     const std::string key;
     const std::string value;
+    const std::string attribute;
   };
 
   std::string enum_name_;
   std::string underlying_type_;
+  std::string attributes_;
   bool is_class_;
   std::vector<EnumField> fields_;
 };  // class Enum
@@ -169,13 +175,10 @@
     IS_FINAL = 1 << 5,
   };
 
-  MethodDecl(const std::string& return_type,
-             const std::string& name,
-             ArgList&& arg_list);
-  MethodDecl(const std::string& return_type,
-             const std::string& name,
-             ArgList&& arg_list,
-             uint32_t modifiers);
+  MethodDecl(const std::string& return_type, const std::string& name, ArgList&& arg_list,
+             const std::string& attributes = "");
+  MethodDecl(const std::string& return_type, const std::string& name, ArgList&& arg_list,
+             uint32_t modifiers, const std::string& attributes = "");
   virtual ~MethodDecl() = default;
 
   void Write(CodeWriter* to) const override;
@@ -183,6 +186,7 @@
  private:
   const std::string return_type_;
   const std::string name_;
+  const std::string attributes_;
   const ArgList arguments_;
   bool is_const_ = false;
   bool is_virtual_ = false;
diff --git a/ast_java.cpp b/ast_java.cpp
index 8604bc2..066624e 100644
--- a/ast_java.cpp
+++ b/ast_java.cpp
@@ -37,6 +37,11 @@
   return str;
 }
 
+void WriteComment(CodeWriter* to, const std::string& comment) {
+  to->Write("%s", comment.c_str());
+  if (!comment.empty() && comment.back() != '\n') to->Write("\n");
+}
+
 void WriteModifiers(CodeWriter* to, int mod, int mask) {
   int m = mod & mask;
 
@@ -78,9 +83,7 @@
 Field::Field(int m, std::shared_ptr<Variable> v) : ClassElement(), modifiers(m), variable(v) {}
 
 void Field::Write(CodeWriter* to) const {
-  if (this->comment.length() != 0) {
-    to->Write("%s\n", this->comment.c_str());
-  }
+  WriteComment(to, comment);
   for (const auto& a : this->annotations) {
     to->Write("%s\n", a.c_str());
   }
@@ -329,9 +332,7 @@
 void Method::Write(CodeWriter* to) const {
   size_t N, i;
 
-  if (this->comment.length() != 0) {
-    to->Write("%s\n", this->comment.c_str());
-  }
+  WriteComment(to, comment);
 
   for (const auto& a : this->annotations) {
     to->Write("%s\n", a.c_str());
@@ -381,9 +382,7 @@
 void Class::Write(CodeWriter* to) const {
   size_t N, i;
 
-  if (this->comment.length() != 0) {
-    to->Write("%s\n", this->comment.c_str());
-  }
+  WriteComment(to, comment);
   for (const auto& a : this->annotations) {
     to->Write("%s\n", a.c_str());
   }
diff --git a/build/Android.bp b/build/Android.bp
index a9c0f31..31edf56 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -29,6 +29,13 @@
     srcs: [
         "aidl_interface.go",
         "properties.go",
+        "aidl_api.go",
+        "aidl_gen_rule.go",
+        "aidl_interface_backends.go",
+        "aidl_interface_metadata_singleton.go",
+        "aidl_mapping.go",
+        "aidl_rust_source_provider.go",
+        "aidl_utils.go",
     ],
     testSrcs: [
         "aidl_test.go",
@@ -42,16 +49,13 @@
 }
 
 // These configurations are inherited by all aidl-gen modules
-
+// TODO(b/146436251): default isn't applied because the module is created
+// in PreArchMutators, when import behavior becomes explicit, the logic can
+// be moved back to LoadHook, and then default can be applied as well.
 cc_defaults {
     name: "aidl-cpp-module-defaults",
     // TODO(b/31559095): remove when host bionic is available
     defaults: ["libbinder_ndk_host_user"],
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wextra-semi",
-    ],
 }
 
 java_defaults {
@@ -175,3 +179,44 @@
         "tests_3/EmptyInterface.aidl",
     ],
 }
+
+// These test that a parcel imported from A->B->C will have the required dependencies to link in
+// all backends (C++ backends need to link direclty against the constructor of the parcelable
+// in order to work)
+aidl_interface {
+    name: "tests_transitive_parcel.a",
+    srcs: [ "tests_transitive_parcel/a/*.aidl" ],
+    imports: [
+        "tests_transitive_parcel.b",
+        "tests_transitive_parcel.c",
+    ],
+    unstable: true,
+    backend: {
+        rust: {
+            enabled: true,
+        },
+    },
+}
+
+aidl_interface {
+    name: "tests_transitive_parcel.b",
+    srcs: [ "tests_transitive_parcel/b/*.aidl" ],
+    imports: [ "tests_transitive_parcel.c" ],
+    unstable: true,
+    backend: {
+        rust: {
+            enabled: true,
+        },
+    },
+}
+
+aidl_interface {
+    name: "tests_transitive_parcel.c",
+    srcs: [ "tests_transitive_parcel/c/*.aidl" ],
+    unstable: true,
+    backend: {
+        rust: {
+            enabled: true,
+        },
+    },
+}
diff --git a/build/aidl_api.go b/build/aidl_api.go
new file mode 100644
index 0000000..2a45d3b
--- /dev/null
+++ b/build/aidl_api.go
@@ -0,0 +1,374 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+
+	"fmt"
+	"io"
+	"path/filepath"
+	"strconv"
+	"strings"
+
+	"github.com/google/blueprint"
+	"github.com/google/blueprint/proptools"
+)
+
+var (
+	aidlDumpApiRule = pctx.StaticRule("aidlDumpApiRule", blueprint.RuleParams{
+		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
+			`${aidlCmd} --dumpapi --structured ${imports} ${optionalFlags} --out ${outDir} ${in} && ` +
+			`(cd ${outDir} && find ./ -name "*.aidl" -print0 | LC_ALL=C sort -z | xargs -0 sha1sum && echo ${latestVersion}) | sha1sum | cut -d " " -f 1 > ${hashFile} `,
+		CommandDeps: []string{"${aidlCmd}"},
+	}, "optionalFlags", "imports", "outDir", "hashFile", "latestVersion")
+
+	aidlCheckApiRule = pctx.StaticRule("aidlCheckApiRule", blueprint.RuleParams{
+		Command: `(${aidlCmd} ${optionalFlags} --checkapi=${checkApiLevel} ${old} ${new} && touch ${out}) || ` +
+			`(cat ${messageFile} && exit 1)`,
+		CommandDeps: []string{"${aidlCmd}"},
+		Description: "AIDL CHECK API: ${new} against ${old}",
+	}, "optionalFlags", "old", "new", "messageFile", "checkApiLevel")
+
+	aidlVerifyHashRule = pctx.StaticRule("aidlVerifyHashRule", blueprint.RuleParams{
+		Command: `if [ $$(cd '${apiDir}' && { find ./ -name "*.aidl" -print0 | LC_ALL=C sort -z | xargs -0 sha1sum && echo ${version}; } | sha1sum | cut -d " " -f 1) = $$(read -r <'${hashFile}' hash extra; printf %s $$hash) ]; then ` +
+			`touch ${out}; else cat '${messageFile}' && exit 1; fi`,
+		Description: "Verify ${apiDir} files have not been modified",
+	}, "apiDir", "version", "messageFile", "hashFile")
+)
+
+type aidlApiProperties struct {
+	BaseName  string
+	Srcs      []string `android:"path"`
+	AidlRoot  string   // base directory for the input aidl file
+	Stability *string
+	Imports   []string
+	Versions  []string
+}
+
+type aidlApi struct {
+	android.ModuleBase
+
+	properties aidlApiProperties
+
+	// for triggering api check for version X against version X-1
+	checkApiTimestamps android.WritablePaths
+
+	// for triggering updating current API
+	updateApiTimestamp android.WritablePath
+
+	// for triggering check that files have not been modified
+	checkHashTimestamps android.WritablePaths
+
+	// for triggering freezing API as the new version
+	freezeApiTimestamp android.WritablePath
+}
+
+func (m *aidlApi) apiDir() string {
+	return filepath.Join(aidlApiDir, m.properties.BaseName)
+}
+
+// `m <iface>-freeze-api` will freeze ToT as this version
+func (m *aidlApi) nextVersion() string {
+	return nextVersion(m.properties.Versions)
+}
+
+type apiDump struct {
+	dir      android.Path
+	files    android.Paths
+	hashFile android.OptionalPath
+}
+
+func (m *aidlApi) createApiDumpFromSource(ctx android.ModuleContext) apiDump {
+	srcs, imports := getPaths(ctx, m.properties.Srcs)
+
+	if ctx.Failed() {
+		return apiDump{}
+	}
+
+	var importPaths []string
+	importPaths = append(importPaths, imports...)
+	ctx.VisitDirectDeps(func(dep android.Module) {
+		if importedAidl, ok := dep.(*aidlInterface); ok {
+			importPaths = append(importPaths, importedAidl.properties.Full_import_paths...)
+		}
+	})
+
+	var apiDir android.WritablePath
+	var apiFiles android.WritablePaths
+	var hashFile android.WritablePath
+
+	apiDir = android.PathForModuleOut(ctx, "dump")
+	aidlRoot := android.PathForModuleSrc(ctx, m.properties.AidlRoot)
+	for _, src := range srcs {
+		baseDir := getBaseDir(ctx, src, aidlRoot)
+		relPath, _ := filepath.Rel(baseDir, src.String())
+		outFile := android.PathForModuleOut(ctx, "dump", relPath)
+		apiFiles = append(apiFiles, outFile)
+	}
+	hashFile = android.PathForModuleOut(ctx, "dump", ".hash")
+	latestVersion := "latest-version"
+	if len(m.properties.Versions) >= 1 {
+		latestVersion = m.properties.Versions[len(m.properties.Versions)-1]
+	}
+
+	var optionalFlags []string
+	if m.properties.Stability != nil {
+		optionalFlags = append(optionalFlags, "--stability", *m.properties.Stability)
+	}
+
+	ctx.Build(pctx, android.BuildParams{
+		Rule:    aidlDumpApiRule,
+		Outputs: append(apiFiles, hashFile),
+		Inputs:  srcs,
+		Args: map[string]string{
+			"optionalFlags": strings.Join(optionalFlags, " "),
+			"imports":       strings.Join(wrap("-I", importPaths, ""), " "),
+			"outDir":        apiDir.String(),
+			"hashFile":      hashFile.String(),
+			"latestVersion": latestVersion,
+		},
+	})
+	return apiDump{apiDir, apiFiles.Paths(), android.OptionalPathForPath(hashFile)}
+}
+
+func (m *aidlApi) makeApiDumpAsVersion(ctx android.ModuleContext, dump apiDump, version string) android.WritablePath {
+	timestampFile := android.PathForModuleOut(ctx, "updateapi_"+version+".timestamp")
+
+	modulePath := android.PathForModuleSrc(ctx).String()
+
+	targetDir := filepath.Join(modulePath, m.apiDir(), version)
+	rb := android.NewRuleBuilder(pctx, ctx)
+	// Wipe the target directory and then copy the API dump into the directory
+	rb.Command().Text("mkdir -p " + targetDir)
+	rb.Command().Text("rm -rf " + targetDir + "/*")
+	if version != currentVersion {
+		rb.Command().Text("cp -rf " + dump.dir.String() + "/. " + targetDir).Implicits(dump.files)
+		// If this is making a new frozen (i.e. non-current) version of the interface,
+		// modify Android.bp file to add the new version to the 'versions' property.
+		rb.Command().BuiltTool("bpmodify").
+			Text("-w -m " + m.properties.BaseName).
+			Text("-parameter versions -a " + version).
+			Text(android.PathForModuleSrc(ctx, "Android.bp").String())
+	} else {
+		// In this case (unfrozen interface), don't copy .hash
+		rb.Command().Text("cp -rf " + dump.dir.String() + "/* " + targetDir).Implicits(dump.files)
+	}
+	rb.Command().Text("touch").Output(timestampFile)
+
+	rb.Build("dump_aidl_api"+m.properties.BaseName+"_"+version,
+		"Making AIDL API of "+m.properties.BaseName+" as version "+version)
+	return timestampFile
+}
+
+func (m *aidlApi) checkApi(ctx android.ModuleContext, oldDump, newDump apiDump, checkApiLevel string, messageFile android.Path) android.WritablePath {
+	newVersion := newDump.dir.Base()
+	timestampFile := android.PathForModuleOut(ctx, "checkapi_"+newVersion+".timestamp")
+
+	var optionalFlags []string
+	if m.properties.Stability != nil {
+		optionalFlags = append(optionalFlags, "--stability", *m.properties.Stability)
+	}
+
+	var implicits android.Paths
+	implicits = append(implicits, oldDump.files...)
+	implicits = append(implicits, newDump.files...)
+	implicits = append(implicits, messageFile)
+	ctx.Build(pctx, android.BuildParams{
+		Rule:      aidlCheckApiRule,
+		Implicits: implicits,
+		Output:    timestampFile,
+		Args: map[string]string{
+			"optionalFlags": strings.Join(optionalFlags, " "),
+			"old":           oldDump.dir.String(),
+			"new":           newDump.dir.String(),
+			"messageFile":   messageFile.String(),
+			"checkApiLevel": checkApiLevel,
+		},
+	})
+	return timestampFile
+}
+
+func (m *aidlApi) checkCompatibility(ctx android.ModuleContext, oldDump, newDump apiDump) android.WritablePath {
+	messageFile := android.PathForSource(ctx, "system/tools/aidl/build/message_check_compatibility.txt")
+	return m.checkApi(ctx, oldDump, newDump, "compatible", messageFile)
+}
+
+func (m *aidlApi) checkEquality(ctx android.ModuleContext, oldDump apiDump, newDump apiDump) android.WritablePath {
+	// Use different messages depending on whether platform SDK is finalized or not.
+	// In case when it is finalized, we should never allow updating the already frozen API.
+	// If it's not finalized, we let users to update the current version by invoking
+	// `m <name>-update-api`.
+	messageFile := android.PathForSource(ctx, "system/tools/aidl/build/message_check_equality.txt")
+	sdkIsFinal := !ctx.Config().DefaultAppTargetSdk(ctx).IsPreview()
+	if sdkIsFinal {
+		messageFile = android.PathForSource(ctx, "system/tools/aidl/build/message_check_equality_release.txt")
+	}
+	formattedMessageFile := android.PathForModuleOut(ctx, "message_check_equality.txt")
+	rb := android.NewRuleBuilder(pctx, ctx)
+	rb.Command().Text("sed").Flag(" s/%s/" + m.properties.BaseName + "/g ").Input(messageFile).Text(" > ").Output(formattedMessageFile)
+	rb.Build("format_message_"+m.properties.BaseName, "")
+
+	var implicits android.Paths
+	implicits = append(implicits, oldDump.files...)
+	implicits = append(implicits, newDump.files...)
+	implicits = append(implicits, formattedMessageFile)
+	return m.checkApi(ctx, oldDump, newDump, "equal", formattedMessageFile)
+}
+
+func (m *aidlApi) checkIntegrity(ctx android.ModuleContext, dump apiDump) android.WritablePath {
+	version := dump.dir.Base()
+	timestampFile := android.PathForModuleOut(ctx, "checkhash_"+version+".timestamp")
+	messageFile := android.PathForSource(ctx, "system/tools/aidl/build/message_check_integrity.txt")
+
+	i, _ := strconv.Atoi(version)
+	if i == 1 {
+		version = "latest-version"
+	} else {
+		version = strconv.Itoa(i - 1)
+	}
+
+	var implicits android.Paths
+	implicits = append(implicits, dump.files...)
+	implicits = append(implicits, dump.hashFile.Path())
+	implicits = append(implicits, messageFile)
+	ctx.Build(pctx, android.BuildParams{
+		Rule:      aidlVerifyHashRule,
+		Implicits: implicits,
+		Output:    timestampFile,
+		Args: map[string]string{
+			"apiDir":      dump.dir.String(),
+			"version":     version,
+			"hashFile":    dump.hashFile.Path().String(),
+			"messageFile": messageFile.String(),
+		},
+	})
+	return timestampFile
+}
+
+func (m *aidlApi) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+	// An API dump is created from source and it is compared against the API dump of the
+	// 'current' (yet-to-be-finalized) version. By checking this we enforce that any change in
+	// the AIDL interface is gated by the AIDL API review even before the interface is frozen as
+	// a new version.
+	totApiDump := m.createApiDumpFromSource(ctx)
+	currentApiDir := android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), currentVersion)
+	var currentApiDump apiDump
+	if currentApiDir.Valid() {
+		currentApiDump = apiDump{
+			dir:      currentApiDir.Path(),
+			files:    ctx.Glob(filepath.Join(currentApiDir.Path().String(), "**/*.aidl"), nil),
+			hashFile: android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), currentVersion, ".hash"),
+		}
+		checked := m.checkEquality(ctx, currentApiDump, totApiDump)
+		m.checkApiTimestamps = append(m.checkApiTimestamps, checked)
+	} else {
+		// The "current" directory might not exist, in case when the interface is first created.
+		// Instruct user to create one by executing `m <name>-update-api`.
+		rb := android.NewRuleBuilder(pctx, ctx)
+		ifaceName := m.properties.BaseName
+		rb.Command().Text(fmt.Sprintf(`echo "API dump for the current version of AIDL interface %s does not exist."`, ifaceName))
+		rb.Command().Text(fmt.Sprintf(`echo Run "m %s-update-api", or add "unstable: true" to the build rule `+
+			`for the interface if it does not need to be versioned`, ifaceName))
+		// This file will never be created. Otherwise, the build will pass simply by running 'm; m'.
+		alwaysChecked := android.PathForModuleOut(ctx, "checkapi_current.timestamp")
+		rb.Command().Text("false").ImplicitOutput(alwaysChecked)
+		rb.Build("check_current_aidl_api", "")
+		m.checkApiTimestamps = append(m.checkApiTimestamps, alwaysChecked)
+	}
+
+	// Also check that version X is backwards compatible with version X-1.
+	// "current" is checked against the latest version.
+	var dumps []apiDump
+	for _, ver := range m.properties.Versions {
+		apiDir := filepath.Join(ctx.ModuleDir(), m.apiDir(), ver)
+		apiDirPath := android.ExistentPathForSource(ctx, apiDir)
+		if apiDirPath.Valid() {
+			dumps = append(dumps, apiDump{
+				dir:      apiDirPath.Path(),
+				files:    ctx.Glob(filepath.Join(apiDirPath.String(), "**/*.aidl"), nil),
+				hashFile: android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), ver, ".hash"),
+			})
+		} else if ctx.Config().AllowMissingDependencies() {
+			ctx.AddMissingDependencies([]string{apiDir})
+		} else {
+			ctx.ModuleErrorf("API version %s path %s does not exist", ver, apiDir)
+		}
+	}
+	if currentApiDir.Valid() {
+		dumps = append(dumps, currentApiDump)
+	}
+	for i, _ := range dumps {
+		if dumps[i].hashFile.Valid() {
+			checkHashTimestamp := m.checkIntegrity(ctx, dumps[i])
+			m.checkHashTimestamps = append(m.checkHashTimestamps, checkHashTimestamp)
+		}
+
+		if i == 0 {
+			continue
+		}
+		checked := m.checkCompatibility(ctx, dumps[i-1], dumps[i])
+		m.checkApiTimestamps = append(m.checkApiTimestamps, checked)
+	}
+
+	// API dump from source is updated to the 'current' version. Triggered by `m <name>-update-api`
+	m.updateApiTimestamp = m.makeApiDumpAsVersion(ctx, totApiDump, currentVersion)
+
+	// API dump from source is frozen as the next stable version. Triggered by `m <name>-freeze-api`
+	nextVersion := m.nextVersion()
+	m.freezeApiTimestamp = m.makeApiDumpAsVersion(ctx, totApiDump, nextVersion)
+}
+
+func (m *aidlApi) AndroidMk() android.AndroidMkData {
+	return android.AndroidMkData{
+		Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+			android.WriteAndroidMkData(w, data)
+			targetName := m.properties.BaseName + "-freeze-api"
+			fmt.Fprintln(w, ".PHONY:", targetName)
+			fmt.Fprintln(w, targetName+":", m.freezeApiTimestamp.String())
+
+			targetName = m.properties.BaseName + "-update-api"
+			fmt.Fprintln(w, ".PHONY:", targetName)
+			fmt.Fprintln(w, targetName+":", m.updateApiTimestamp.String())
+		},
+	}
+}
+
+func (m *aidlApi) DepsMutator(ctx android.BottomUpMutatorContext) {
+	ctx.AddDependency(ctx.Module(), nil, wrap("", m.properties.Imports, aidlInterfaceSuffix)...)
+}
+
+func aidlApiFactory() android.Module {
+	m := &aidlApi{}
+	m.AddProperties(&m.properties)
+	android.InitAndroidModule(m)
+	return m
+}
+
+func addApiModule(mctx android.LoadHookContext, i *aidlInterface) string {
+	apiModule := i.ModuleBase.Name() + aidlApiSuffix
+	srcs, aidlRoot := i.srcsForVersion(mctx, i.nextVersion())
+	mctx.CreateModule(aidlApiFactory, &nameProperties{
+		Name: proptools.StringPtr(apiModule),
+	}, &aidlApiProperties{
+		BaseName:  i.ModuleBase.Name(),
+		Srcs:      srcs,
+		AidlRoot:  aidlRoot,
+		Stability: i.properties.Stability,
+		Imports:   concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
+		Versions:  i.properties.Versions,
+	})
+	return apiModule
+}
diff --git a/build/aidl_api/test-piece-1/current/some_package/IFoo.aidl b/build/aidl_api/test-piece-1/current/some_package/IFoo.aidl
index c18d258..71d1bf2 100644
--- a/build/aidl_api/test-piece-1/current/some_package/IFoo.aidl
+++ b/build/aidl_api/test-piece-1/current/some_package/IFoo.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-piece-1/current/some_package/Thing.aidl b/build/aidl_api/test-piece-1/current/some_package/Thing.aidl
index 366799e..90c5720 100644
--- a/build/aidl_api/test-piece-1/current/some_package/Thing.aidl
+++ b/build/aidl_api/test-piece-1/current/some_package/Thing.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-piece-1/current/some_package/sub_package/IFoo.aidl b/build/aidl_api/test-piece-1/current/some_package/sub_package/IFoo.aidl
index e0fefbc..4cd970a 100644
--- a/build/aidl_api/test-piece-1/current/some_package/sub_package/IFoo.aidl
+++ b/build/aidl_api/test-piece-1/current/some_package/sub_package/IFoo.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-piece-1/current/some_package/sub_package/SubThing.aidl b/build/aidl_api/test-piece-1/current/some_package/sub_package/SubThing.aidl
index e7e6692..bff0008 100644
--- a/build/aidl_api/test-piece-1/current/some_package/sub_package/SubThing.aidl
+++ b/build/aidl_api/test-piece-1/current/some_package/sub_package/SubThing.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-piece-2/current/INoPackage.aidl b/build/aidl_api/test-piece-2/current/INoPackage.aidl
index 28cc69a..b7c150f 100644
--- a/build/aidl_api/test-piece-2/current/INoPackage.aidl
+++ b/build/aidl_api/test-piece-2/current/INoPackage.aidl
@@ -1,3 +1,36 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
 interface INoPackage {
   void CanYouDealWithThisBar(in some_package.IBar bar);
 }
diff --git a/build/aidl_api/test-piece-2/current/some_package/IBar.aidl b/build/aidl_api/test-piece-2/current/some_package/IBar.aidl
index 61ad15a..b60c537 100644
--- a/build/aidl_api/test-piece-2/current/some_package/IBar.aidl
+++ b/build/aidl_api/test-piece-2/current/some_package/IBar.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-piece-3/current/other_package/IBaz.aidl b/build/aidl_api/test-piece-3/current/other_package/IBaz.aidl
index 2c94ade..bc3d50c 100644
--- a/build/aidl_api/test-piece-3/current/other_package/IBaz.aidl
+++ b/build/aidl_api/test-piece-3/current/other_package/IBaz.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-piece-4/current/another_package/IFaz.aidl b/build/aidl_api/test-piece-4/current/another_package/IFaz.aidl
index 0ed5c4a..35e17f5 100644
--- a/build/aidl_api/test-piece-4/current/another_package/IFaz.aidl
+++ b/build/aidl_api/test-piece-4/current/another_package/IFaz.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_api/test-root-package/current/test_package/IBaz.aidl b/build/aidl_api/test-root-package/current/test_package/IBaz.aidl
index fbc1a14..356851a 100644
--- a/build/aidl_api/test-root-package/current/test_package/IBaz.aidl
+++ b/build/aidl_api/test-root-package/current/test_package/IBaz.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go
new file mode 100644
index 0000000..d4950f3
--- /dev/null
+++ b/build/aidl_gen_rule.go
@@ -0,0 +1,292 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+	"android/soong/genrule"
+
+	"path/filepath"
+	"strings"
+
+	"github.com/google/blueprint"
+	"github.com/google/blueprint/pathtools"
+	"github.com/google/blueprint/proptools"
+)
+
+var (
+	aidlDirPrepareRule = pctx.StaticRule("aidlDirPrepareRule", blueprint.RuleParams{
+		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
+			`touch ${out} # ${in}`,
+		Description: "create ${out}",
+	}, "outDir")
+
+	aidlCppRule = pctx.StaticRule("aidlCppRule", blueprint.RuleParams{
+		Command: `mkdir -p "${headerDir}" && ` +
+			`${aidlCmd} --lang=${lang} ${optionalFlags} --structured --ninja -d ${out}.d ` +
+			`-h ${headerDir} -o ${outDir} ${imports} ${in}`,
+		Depfile:     "${out}.d",
+		Deps:        blueprint.DepsGCC,
+		CommandDeps: []string{"${aidlCmd}"},
+		Description: "AIDL ${lang} ${in}",
+	}, "imports", "lang", "headerDir", "outDir", "optionalFlags")
+
+	aidlJavaRule = pctx.StaticRule("aidlJavaRule", blueprint.RuleParams{
+		Command: `${aidlCmd} --lang=java ${optionalFlags} --structured --ninja -d ${out}.d ` +
+			`-o ${outDir} ${imports} ${in}`,
+		Depfile:     "${out}.d",
+		Deps:        blueprint.DepsGCC,
+		CommandDeps: []string{"${aidlCmd}"},
+		Description: "AIDL Java ${in}",
+	}, "imports", "outDir", "optionalFlags")
+
+	aidlRustRule = pctx.StaticRule("aidlRustRule", blueprint.RuleParams{
+		Command: `${aidlCmd} --lang=rust ${optionalFlags} --structured --ninja -d ${out}.d ` +
+			`-o ${outDir} ${imports} ${in}`,
+		Depfile:     "${out}.d",
+		Deps:        blueprint.DepsGCC,
+		CommandDeps: []string{"${aidlCmd}"},
+		Description: "AIDL Rust ${in}",
+	}, "imports", "outDir", "optionalFlags")
+)
+
+type aidlGenProperties struct {
+	Srcs       []string `android:"path"`
+	AidlRoot   string   // base directory for the input aidl file
+	Imports    []string
+	Stability  *string
+	Lang       string // target language [java|cpp|ndk|rust]
+	BaseName   string
+	GenLog     bool
+	Version    string
+	GenTrace   bool
+	Unstable   *bool
+	Visibility []string
+	Flags      []string
+}
+
+type aidlGenRule struct {
+	android.ModuleBase
+
+	properties aidlGenProperties
+
+	implicitInputs android.Paths
+	importFlags    string
+
+	// TODO(b/149952131): always have a hash file
+	hashFile android.Path
+
+	genOutDir     android.ModuleGenPath
+	genHeaderDir  android.ModuleGenPath
+	genHeaderDeps android.Paths
+	genOutputs    android.WritablePaths
+}
+
+var _ android.SourceFileProducer = (*aidlGenRule)(nil)
+var _ genrule.SourceFileGenerator = (*aidlGenRule)(nil)
+
+func (g *aidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+	srcs, imports := getPaths(ctx, g.properties.Srcs)
+
+	if ctx.Failed() {
+		return
+	}
+
+	genDirTimestamp := android.PathForModuleGen(ctx, "timestamp")
+	g.implicitInputs = append(g.implicitInputs, genDirTimestamp)
+
+	var importPaths []string
+	importPaths = append(importPaths, imports...)
+	ctx.VisitDirectDeps(func(dep android.Module) {
+		if importedAidl, ok := dep.(*aidlInterface); ok {
+			importPaths = append(importPaths, importedAidl.properties.Full_import_paths...)
+		} else if api, ok := dep.(*aidlApi); ok {
+			// When compiling an AIDL interface, also make sure that each
+			// version of the interface is compatible with its previous version
+			for _, path := range api.checkApiTimestamps {
+				g.implicitInputs = append(g.implicitInputs, path)
+			}
+			for _, path := range api.checkHashTimestamps {
+				g.implicitInputs = append(g.implicitInputs, path)
+			}
+		}
+	})
+	g.importFlags = strings.Join(wrap("-I", importPaths, ""), " ")
+
+	g.genOutDir = android.PathForModuleGen(ctx)
+	g.genHeaderDir = android.PathForModuleGen(ctx, "include")
+	for _, src := range srcs {
+		outFile, headers := g.generateBuildActionsForSingleAidl(ctx, src)
+		g.genOutputs = append(g.genOutputs, outFile)
+		g.genHeaderDeps = append(g.genHeaderDeps, headers...)
+	}
+
+	// This is to clean genOutDir before generating any file
+	ctx.Build(pctx, android.BuildParams{
+		Rule:   aidlDirPrepareRule,
+		Inputs: srcs,
+		Output: genDirTimestamp,
+		Args: map[string]string{
+			"outDir": g.genOutDir.String(),
+		},
+	})
+}
+
+func (g *aidlGenRule) generateBuildActionsForSingleAidl(ctx android.ModuleContext, src android.Path) (android.WritablePath, android.Paths) {
+	baseDir := getBaseDir(ctx, src, android.PathForModuleSrc(ctx, g.properties.AidlRoot))
+
+	var ext string
+	if g.properties.Lang == langJava {
+		ext = "java"
+	} else if g.properties.Lang == langRust {
+		ext = "rs"
+	} else {
+		ext = "cpp"
+	}
+	relPath, _ := filepath.Rel(baseDir, src.String())
+	outFile := android.PathForModuleGen(ctx, pathtools.ReplaceExtension(relPath, ext))
+	implicits := g.implicitInputs
+
+	optionalFlags := append([]string{}, g.properties.Flags...)
+	if g.properties.Version != "" {
+		optionalFlags = append(optionalFlags, "--version "+g.properties.Version)
+
+		hash := "notfrozen"
+		if !strings.HasPrefix(baseDir, ctx.Config().BuildDir()) {
+			hashFile := android.ExistentPathForSource(ctx, baseDir, ".hash")
+			if hashFile.Valid() {
+				hash = "$$(read -r <" + hashFile.Path().String() + " hash extra; printf '%s' \"$$hash\")"
+				implicits = append(implicits, hashFile.Path())
+
+				g.hashFile = hashFile.Path()
+			}
+		}
+		optionalFlags = append(optionalFlags, "--hash "+hash)
+	}
+	if g.properties.GenTrace {
+		optionalFlags = append(optionalFlags, "-t")
+	}
+	if g.properties.Stability != nil {
+		optionalFlags = append(optionalFlags, "--stability", *g.properties.Stability)
+	}
+
+	var headers android.WritablePaths
+	if g.properties.Lang == langJava {
+		ctx.Build(pctx, android.BuildParams{
+			Rule:      aidlJavaRule,
+			Input:     src,
+			Implicits: implicits,
+			Output:    outFile,
+			Args: map[string]string{
+				"imports":       g.importFlags,
+				"outDir":        g.genOutDir.String(),
+				"optionalFlags": strings.Join(optionalFlags, " "),
+			},
+		})
+	} else if g.properties.Lang == langRust {
+		ctx.Build(pctx, android.BuildParams{
+			Rule:      aidlRustRule,
+			Input:     src,
+			Implicits: implicits,
+			Output:    outFile,
+			Args: map[string]string{
+				"imports":       g.importFlags,
+				"outDir":        g.genOutDir.String(),
+				"optionalFlags": strings.Join(optionalFlags, " "),
+			},
+		})
+	} else {
+		typeName := strings.TrimSuffix(filepath.Base(relPath), ".aidl")
+		packagePath := filepath.Dir(relPath)
+		baseName := typeName
+		// TODO(b/111362593): aidl_to_cpp_common.cpp uses heuristics to figure out if
+		//   an interface name has a leading I. Those same heuristics have been
+		//   moved here.
+		if len(baseName) >= 2 && baseName[0] == 'I' &&
+			strings.ToUpper(baseName)[1] == baseName[1] {
+			baseName = strings.TrimPrefix(typeName, "I")
+		}
+
+		prefix := ""
+		if g.properties.Lang == langNdk || g.properties.Lang == langNdkPlatform {
+			prefix = "aidl"
+		}
+
+		headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath,
+			typeName+".h"))
+		headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath,
+			"Bp"+baseName+".h"))
+		headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath,
+			"Bn"+baseName+".h"))
+
+		if g.properties.GenLog {
+			optionalFlags = append(optionalFlags, "--log")
+		}
+
+		aidlLang := g.properties.Lang
+		if aidlLang == langNdkPlatform {
+			aidlLang = "ndk"
+		}
+
+		ctx.Build(pctx, android.BuildParams{
+			Rule:            aidlCppRule,
+			Input:           src,
+			Implicits:       implicits,
+			Output:          outFile,
+			ImplicitOutputs: headers,
+			Args: map[string]string{
+				"imports":       g.importFlags,
+				"lang":          aidlLang,
+				"headerDir":     g.genHeaderDir.String(),
+				"outDir":        g.genOutDir.String(),
+				"optionalFlags": strings.Join(optionalFlags, " "),
+			},
+		})
+	}
+
+	return outFile, headers.Paths()
+}
+
+func (g *aidlGenRule) GeneratedSourceFiles() android.Paths {
+	return g.genOutputs.Paths()
+}
+
+func (g *aidlGenRule) Srcs() android.Paths {
+	return g.genOutputs.Paths()
+}
+
+func (g *aidlGenRule) GeneratedDeps() android.Paths {
+	return g.genHeaderDeps
+}
+
+func (g *aidlGenRule) GeneratedHeaderDirs() android.Paths {
+	return android.Paths{g.genHeaderDir}
+}
+
+func (g *aidlGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
+	ctx.AddDependency(ctx.Module(), nil, wrap("", g.properties.Imports, aidlInterfaceSuffix)...)
+	if !proptools.Bool(g.properties.Unstable) {
+		ctx.AddDependency(ctx.Module(), nil, g.properties.BaseName+aidlApiSuffix)
+	}
+
+	ctx.AddReverseDependency(ctx.Module(), nil, aidlMetadataSingletonName)
+}
+
+func aidlGenFactory() android.Module {
+	g := &aidlGenRule{}
+	g.AddProperties(&g.properties)
+	android.InitAndroidModule(g)
+	return g
+}
diff --git a/build/aidl_interface.go b/build/aidl_interface.go
index bfbeb45..a0b22c0 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -17,20 +17,17 @@
 import (
 	"android/soong/android"
 	"android/soong/cc"
-	"android/soong/genrule"
 	"android/soong/java"
 	"android/soong/phony"
 	"android/soong/rust"
 
 	"fmt"
-	"io"
 	"path/filepath"
+	"sort"
 	"strconv"
 	"strings"
 	"sync"
 
-	"github.com/google/blueprint"
-	"github.com/google/blueprint/pathtools"
 	"github.com/google/blueprint/proptools"
 )
 
@@ -51,105 +48,6 @@
 
 var (
 	pctx = android.NewPackageContext("android/aidl")
-
-	aidlDirPrepareRule = pctx.StaticRule("aidlDirPrepareRule", blueprint.RuleParams{
-		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
-			`touch ${out} # ${in}`,
-		Description: "create ${out}",
-	}, "outDir")
-
-	aidlCppRule = pctx.StaticRule("aidlCppRule", blueprint.RuleParams{
-		Command: `mkdir -p "${headerDir}" && ` +
-			`${aidlCmd} --lang=${lang} ${optionalFlags} --structured --ninja -d ${out}.d ` +
-			`-h ${headerDir} -o ${outDir} ${imports} ${in}`,
-		Depfile:     "${out}.d",
-		Deps:        blueprint.DepsGCC,
-		CommandDeps: []string{"${aidlCmd}"},
-		Description: "AIDL ${lang} ${in}",
-	}, "imports", "lang", "headerDir", "outDir", "optionalFlags")
-
-	aidlJavaRule = pctx.StaticRule("aidlJavaRule", blueprint.RuleParams{
-		Command: `${aidlCmd} --lang=java ${optionalFlags} --structured --ninja -d ${out}.d ` +
-			`-o ${outDir} ${imports} ${in}`,
-		Depfile:     "${out}.d",
-		Deps:        blueprint.DepsGCC,
-		CommandDeps: []string{"${aidlCmd}"},
-		Description: "AIDL Java ${in}",
-	}, "imports", "outDir", "optionalFlags")
-
-	aidlRustRule = pctx.StaticRule("aidlRustRule", blueprint.RuleParams{
-		Command: `${aidlCmd} --lang=rust ${optionalFlags} --structured --ninja -d ${out}.d ` +
-			`-o ${outDir} ${imports} ${in}`,
-		Depfile:     "${out}.d",
-		Deps:        blueprint.DepsGCC,
-		CommandDeps: []string{"${aidlCmd}"},
-		Description: "AIDL Rust ${in}",
-	}, "imports", "outDir", "optionalFlags")
-
-	aidlDumpApiRule = pctx.StaticRule("aidlDumpApiRule", blueprint.RuleParams{
-		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
-			`${aidlCmd} --dumpapi --structured ${imports} ${optionalFlags} --out ${outDir} ${in} && ` +
-			`(cd ${outDir} && find ./ -name "*.aidl" -print0 | LC_ALL=C sort -z | xargs -0 sha1sum && echo ${latestVersion}) | sha1sum | cut -d " " -f 1 > ${hashFile} `,
-		CommandDeps: []string{"${aidlCmd}"},
-	}, "optionalFlags", "imports", "outDir", "hashFile", "latestVersion")
-
-	aidlMetadataRule = pctx.StaticRule("aidlMetadataRule", blueprint.RuleParams{
-		Command: `rm -f ${out} && { ` +
-			`echo '{' && ` +
-			`echo "\"name\": \"${name}\"," && ` +
-			`echo "\"stability\": \"${stability}\"," && ` +
-			`echo "\"types\": [${types}]," && ` +
-			`echo "\"hashes\": [${hashes}]" && ` +
-			`echo '}' ` +
-			`;} >> ${out}`,
-		Description: "AIDL metadata: ${out}",
-	}, "name", "stability", "types", "hashes")
-
-	aidlDumpMappingsRule = pctx.StaticRule("aidlDumpMappingsRule", blueprint.RuleParams{
-		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
-			`${aidlCmd} --apimapping ${outDir}/intermediate.txt ${in} ${imports} && ` +
-			`${aidlToJniCmd} ${outDir}/intermediate.txt ${out}`,
-		CommandDeps: []string{"${aidlCmd}"},
-	}, "imports", "outDir")
-
-	aidlCheckApiRule = pctx.StaticRule("aidlCheckApiRule", blueprint.RuleParams{
-		Command: `(${aidlCmd} ${optionalFlags} --checkapi ${old} ${new} && touch ${out}) || ` +
-			`(cat ${messageFile} && exit 1)`,
-		CommandDeps: []string{"${aidlCmd}"},
-		Description: "AIDL CHECK API: ${new} against ${old}",
-	}, "optionalFlags", "old", "new", "messageFile")
-
-	aidlDiffApiRule = pctx.StaticRule("aidlDiffApiRule", blueprint.RuleParams{
-		Command: `if diff -r -B -I '//.*' -x '${hashFile}' '${old}' '${new}'; then touch '${out}'; else ` +
-			`cat '${messageFile}' && exit 1; fi`,
-		Description: "Check equality of ${new} and ${old}",
-	}, "old", "new", "hashFile", "messageFile")
-
-	aidlVerifyHashRule = pctx.StaticRule("aidlVerifyHashRule", blueprint.RuleParams{
-		Command: `if [ $$(cd '${apiDir}' && { find ./ -name "*.aidl" -print0 | LC_ALL=C sort -z | xargs -0 sha1sum && echo ${version}; } | sha1sum | cut -d " " -f 1) = $$(read -r <'${hashFile}' hash extra; printf %s $$hash) ]; then ` +
-			`touch ${out}; else cat '${messageFile}' && exit 1; fi`,
-		Description: "Verify ${apiDir} files have not been modified",
-	}, "apiDir", "version", "messageFile", "hashFile")
-
-	aidlRustGlueRule = pctx.StaticRule("aidlRustGlueRule", blueprint.RuleParams{
-		Command:     `${aidlRustGlueCmd} ${out} ${root} ${in} ${imports}`,
-		CommandDeps: []string{"${aidlRustGlueCmd}"},
-	}, "root", "imports")
-
-	joinJsonObjectsToArrayRule = pctx.StaticRule("joinJsonObjectsToArrayRule", blueprint.RuleParams{
-		Rspfile:        "$out.rsp",
-		RspfileContent: "$files",
-		Command: "rm -rf ${out} && " +
-			// Start the output array with an opening bracket.
-			"echo '[' >> ${out} && " +
-			// Append each input file and a comma to the output.
-			"for file in $$(cat ${out}.rsp); do " +
-			"cat $$file >> ${out}; echo ',' >> ${out}; " +
-			"done && " +
-			// Remove the last comma, replacing it with the closing bracket.
-			"sed -i '$$d' ${out} && echo ']' >> ${out}",
-		Description: "Joining JSON objects into array ${out}",
-	}, "files")
 )
 
 func init() {
@@ -157,15 +55,23 @@
 	pctx.SourcePathVariable("aidlToJniCmd", "system/tools/aidl/build/aidl_to_jni.py")
 	pctx.SourcePathVariable("aidlRustGlueCmd", "system/tools/aidl/build/aidl_rust_glue.py")
 	android.RegisterModuleType("aidl_interface", aidlInterfaceFactory)
-	android.RegisterModuleType("aidl_mapping", aidlMappingFactory)
-	android.RegisterMakeVarsProvider(pctx, allAidlInterfacesMakeVars)
-	android.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
+	android.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
+		ctx.BottomUp("checkImports", checkImports).Parallel()
+		ctx.TopDown("createAidlInterface", createAidlInterfaceMutator).Parallel()
+	})
 	android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
 		ctx.BottomUp("checkUnstableModule", checkUnstableModuleMutator).Parallel()
+		ctx.BottomUp("recordVersions", recordVersions).Parallel()
 		ctx.BottomUp("checkDuplicatedVersions", checkDuplicatedVersions).Parallel()
 	})
 }
 
+func createAidlInterfaceMutator(mctx android.TopDownMutatorContext) {
+	if g, ok := mctx.Module().(*aidlImplementationGenerator); ok {
+		g.GenerateImplementation(mctx)
+	}
+}
+
 func checkUnstableModuleMutator(mctx android.BottomUpMutatorContext) {
 	mctx.VisitDirectDepsIf(func(m android.Module) bool {
 		return android.InList(m.Name(), *unstableModules(mctx.Config()))
@@ -183,15 +89,24 @@
 	})
 }
 
-func checkDuplicatedVersions(mctx android.BottomUpMutatorContext) {
+func recordVersions(mctx android.BottomUpMutatorContext) {
 	switch mctx.Module().(type) {
 	case *java.Library:
 	case *cc.Module:
 	case *rust.Module:
+	case *aidlGenRule:
 	default:
 		return
 	}
 
+	isAidlModule := false // whether this module is from an AIDL interface
+	for _, i := range *aidlInterfaces(mctx.Config()) {
+		if android.InList(mctx.ModuleName(), i.internalModuleNames) {
+			isAidlModule = true
+			break
+		}
+	}
+
 	// First, gather all the AIDL interfaces modules that are directly or indirectly
 	// depended on by this module
 	myAidlDeps := make(map[DepInfo]bool)
@@ -200,16 +115,40 @@
 		case *java.Library:
 		case *cc.Module:
 		case *rust.Module:
+		case *aidlGenRule:
+			// Dependencies to the source module is tracked only when it's from a client
+			// module, i.e. not from an AIDL-generated stub library
+			if isAidlModule {
+				return
+			}
 		default:
 			return
 		}
 		depName := mctx.OtherModuleName(dep)
-		// If this module dgpends on one of the aidl interface module, record it
+		isSource := strings.HasSuffix(depName, "-source")
+		depName = strings.TrimSuffix(depName, "-source")
+		// If this module depends on one of the aidl interface module, record it
 		for _, i := range *aidlInterfaces(mctx.Config()) {
 			if android.InList(depName, i.internalModuleNames) {
 				ifaceName := i.ModuleBase.Name()
 				verLang := depName[len(ifaceName):]
-				myAidlDeps[DepInfo{ifaceName, verLang}] = true
+
+				// TODO(b/150578172) remove those modules when every module specify its version.
+				if i.hasVersion() {
+					if strings.HasPrefix(verLang, "-unstable") {
+						verLang = "-V" + i.nextVersion() + strings.TrimPrefix(verLang, "-unstable")
+					} else if !strings.HasPrefix(verLang, "-V") {
+						verLang = "-V" + i.latestVersion() + verLang
+					}
+				} else {
+					verLang = strings.TrimPrefix(verLang, "-unstable")
+					if !proptools.Bool(i.properties.Unstable) {
+						if !strings.HasPrefix(verLang, "-V1") {
+							verLang = "-V1" + verLang
+						}
+					}
+				}
+				myAidlDeps[DepInfo{ifaceName, verLang, isSource}] = true
 				break
 			}
 		}
@@ -238,44 +177,61 @@
 	aidlDepsMutex.Lock()
 	aidlDeps(mctx.Config())[mctx.Module()] = list
 	aidlDepsMutex.Unlock()
+}
+
+func checkDuplicatedVersions(mctx android.BottomUpMutatorContext) {
+	switch mctx.Module().(type) {
+	case *java.Library:
+	case *cc.Module:
+	case *rust.Module:
+	case *aidlGenRule:
+	default:
+		return
+	}
+
+	aidlDepsMutex.RLock()
+	myAidlDeps := aidlDeps(mctx.Config())[mctx.Module()]
+	aidlDepsMutex.RUnlock()
+	if myAidlDeps == nil || len(myAidlDeps) == 0 {
+		return // This should be the usual case
+	}
 
 	// Lastly, report an error if there is any duplicated versions of the same interface * lang
 	for _, lang := range []string{langJava, langCpp, langNdk, langNdkPlatform} {
-		// interfaceName -> list of module names for the interface
-		versionsOf := make(map[string][]string)
-		for dep := range myAidlDeps {
+		// interfaceName -> verLang -> list of module names
+		versionsOf := make(map[string]map[string][]string)
+		for _, dep := range myAidlDeps {
 			if !strings.HasSuffix(dep.verLang, lang) {
 				continue
 			}
 			versions := versionsOf[dep.ifaceName]
-			versions = append(versions, dep.ifaceName+dep.verLang)
-			if len(versions) >= 2 {
-				mctx.ModuleErrorf("multiple versions of aidl_interface %s (backend:%s) are used: %v",
-					dep.ifaceName, lang, versions)
+			if versions == nil {
+				versions = make(map[string][]string)
+				versionsOf[dep.ifaceName] = versions
 			}
-			versionsOf[dep.ifaceName] = versions
+			versions[dep.verLang] = append(versions[dep.verLang], dep.moduleName())
+		}
+
+		for _, versions := range versionsOf {
+			if len(versions) >= 2 {
+				var violators []string
+				for _, modules := range versions {
+					violators = append(violators, modules...)
+				}
+				violators = android.SortedUniqueStrings(violators)
+				mctx.ModuleErrorf("depends on multiple versions of the same aidl_interface: %s", strings.Join(violators, ", "))
+				mctx.WalkDeps(func(child android.Module, parent android.Module) bool {
+					if android.InList(child.Name(), violators) {
+						mctx.ModuleErrorf("Dependency path: %s", mctx.GetPathString(true))
+						return false
+					}
+					return true
+				})
+			}
 		}
 	}
 }
 
-// wrap(p, a, s) = [p + v + s for v in a]
-func wrap(prefix string, strs []string, suffix string) []string {
-	ret := make([]string, len(strs))
-	for i, v := range strs {
-		ret[i] = prefix + v + suffix
-	}
-	return ret
-}
-
-// concat(a...) = sum((i for i in a), [])
-func concat(sstrs ...[]string) []string {
-	var ret []string
-	for _, v := range sstrs {
-		ret = append(ret, v...)
-	}
-	return ret
-}
-
 func getPaths(ctx android.ModuleContext, rawSrcs []string) (paths android.Paths, imports []string) {
 	srcs := android.PathsForModuleSrc(ctx, rawSrcs)
 
@@ -305,578 +261,6 @@
 		!strings.HasPrefix(path, "../") && !strings.HasPrefix(path, "/")
 }
 
-type aidlGenProperties struct {
-	Srcs       []string `android:"path"`
-	AidlRoot   string   // base directory for the input aidl file
-	Imports    []string
-	Stability  *string
-	Lang       string // target language [java|cpp|ndk|rust]
-	BaseName   string
-	GenLog     bool
-	Version    string
-	GenTrace   bool
-	Unstable   *bool
-	Visibility []string
-}
-
-type aidlGenRule struct {
-	android.ModuleBase
-
-	properties aidlGenProperties
-
-	implicitInputs android.Paths
-	importFlags    string
-
-	// TODO(b/149952131): always have a hash file
-	hashFile android.Path
-
-	genOutDir     android.ModuleGenPath
-	genHeaderDir  android.ModuleGenPath
-	genHeaderDeps android.Paths
-	genOutputs    android.WritablePaths
-}
-
-var _ android.SourceFileProducer = (*aidlGenRule)(nil)
-var _ genrule.SourceFileGenerator = (*aidlGenRule)(nil)
-
-func (g *aidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	srcs, imports := getPaths(ctx, g.properties.Srcs)
-
-	if ctx.Failed() {
-		return
-	}
-
-	genDirTimestamp := android.PathForModuleGen(ctx, "timestamp")
-	g.implicitInputs = append(g.implicitInputs, genDirTimestamp)
-
-	var importPaths []string
-	importPaths = append(importPaths, imports...)
-	ctx.VisitDirectDeps(func(dep android.Module) {
-		if importedAidl, ok := dep.(*aidlInterface); ok {
-			importPaths = append(importPaths, importedAidl.properties.Full_import_paths...)
-		} else if api, ok := dep.(*aidlApi); ok {
-			// When compiling an AIDL interface, also make sure that each
-			// version of the interface is compatible with its previous version
-			for _, path := range api.checkApiTimestamps {
-				g.implicitInputs = append(g.implicitInputs, path)
-			}
-			for _, path := range api.checkHashTimestamps {
-				g.implicitInputs = append(g.implicitInputs, path)
-			}
-		}
-	})
-	g.importFlags = strings.Join(wrap("-I", importPaths, ""), " ")
-
-	g.genOutDir = android.PathForModuleGen(ctx)
-	g.genHeaderDir = android.PathForModuleGen(ctx, "include")
-	for _, src := range srcs {
-		outFile, headers := g.generateBuildActionsForSingleAidl(ctx, src)
-		g.genOutputs = append(g.genOutputs, outFile)
-		g.genHeaderDeps = append(g.genHeaderDeps, headers...)
-	}
-
-	// This is to clean genOutDir before generating any file
-	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   aidlDirPrepareRule,
-		Inputs: srcs,
-		Output: genDirTimestamp,
-		Args: map[string]string{
-			"outDir": g.genOutDir.String(),
-		},
-	})
-}
-
-// baseDir is the directory where the package name starts. e.g. For an AIDL fil
-// mymodule/aidl_src/com/android/IFoo.aidl, baseDir is mymodule/aidl_src given that the package name is
-// com.android. The build system however don't know the package name without actually reading the AIDL file.
-// Therefore, we rely on the user to correctly set the base directory via following two methods:
-// 1) via the 'path' property of filegroup or
-// 2) via `local_include_dir' of the aidl_interface module.
-func getBaseDir(ctx android.ModuleContext, src android.Path, aidlRoot android.Path) string {
-	// By default, we try to get 1) by reading Rel() of the input path.
-	baseDir := strings.TrimSuffix(src.String(), src.Rel())
-	// However, if 2) is set and it's more specific (i.e. deeper) than 1), we use 2).
-	if strings.HasPrefix(aidlRoot.String(), baseDir) {
-		baseDir = aidlRoot.String()
-	}
-	return baseDir
-}
-
-func (g *aidlGenRule) generateBuildActionsForSingleAidl(ctx android.ModuleContext, src android.Path) (android.WritablePath, android.Paths) {
-	baseDir := getBaseDir(ctx, src, android.PathForModuleSrc(ctx, g.properties.AidlRoot))
-
-	var ext string
-	if g.properties.Lang == langJava {
-		ext = "java"
-	} else if g.properties.Lang == langRust {
-		ext = "rs"
-	} else {
-		ext = "cpp"
-	}
-	relPath, _ := filepath.Rel(baseDir, src.String())
-	outFile := android.PathForModuleGen(ctx, pathtools.ReplaceExtension(relPath, ext))
-	implicits := g.implicitInputs
-
-	var optionalFlags []string
-	if g.properties.Version != "" {
-		optionalFlags = append(optionalFlags, "--version "+g.properties.Version)
-
-		hash := "notfrozen"
-		if !strings.HasPrefix(baseDir, ctx.Config().BuildDir()) {
-			hashFile := android.ExistentPathForSource(ctx, baseDir, ".hash")
-			if hashFile.Valid() {
-				hash = "$$(read -r <" + hashFile.Path().String() + " hash extra; printf '%s' \"$$hash\")"
-				implicits = append(implicits, hashFile.Path())
-
-				g.hashFile = hashFile.Path()
-			}
-		}
-		optionalFlags = append(optionalFlags, "--hash "+hash)
-	}
-	if g.properties.GenTrace {
-		optionalFlags = append(optionalFlags, "-t")
-	}
-	if g.properties.Stability != nil {
-		optionalFlags = append(optionalFlags, "--stability", *g.properties.Stability)
-	}
-
-	var headers android.WritablePaths
-	if g.properties.Lang == langJava {
-		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-			Rule:      aidlJavaRule,
-			Input:     src,
-			Implicits: implicits,
-			Output:    outFile,
-			Args: map[string]string{
-				"imports":       g.importFlags,
-				"outDir":        g.genOutDir.String(),
-				"optionalFlags": strings.Join(optionalFlags, " "),
-			},
-		})
-	} else if g.properties.Lang == langRust {
-		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-			Rule:      aidlRustRule,
-			Input:     src,
-			Implicits: implicits,
-			Output:    outFile,
-			Args: map[string]string{
-				"imports":       g.importFlags,
-				"outDir":        g.genOutDir.String(),
-				"optionalFlags": strings.Join(optionalFlags, " "),
-			},
-		})
-	} else {
-		typeName := strings.TrimSuffix(filepath.Base(relPath), ".aidl")
-		packagePath := filepath.Dir(relPath)
-		baseName := typeName
-		// TODO(b/111362593): aidl_to_cpp_common.cpp uses heuristics to figure out if
-		//   an interface name has a leading I. Those same heuristics have been
-		//   moved here.
-		if len(baseName) >= 2 && baseName[0] == 'I' &&
-			strings.ToUpper(baseName)[1] == baseName[1] {
-			baseName = strings.TrimPrefix(typeName, "I")
-		}
-
-		prefix := ""
-		if g.properties.Lang == langNdk || g.properties.Lang == langNdkPlatform {
-			prefix = "aidl"
-		}
-
-		headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath,
-			typeName+".h"))
-		headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath,
-			"Bp"+baseName+".h"))
-		headers = append(headers, g.genHeaderDir.Join(ctx, prefix, packagePath,
-			"Bn"+baseName+".h"))
-
-		if g.properties.GenLog {
-			optionalFlags = append(optionalFlags, "--log")
-		}
-
-		aidlLang := g.properties.Lang
-		if aidlLang == langNdkPlatform {
-			aidlLang = "ndk"
-		}
-
-		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-			Rule:            aidlCppRule,
-			Input:           src,
-			Implicits:       implicits,
-			Output:          outFile,
-			ImplicitOutputs: headers,
-			Args: map[string]string{
-				"imports":       g.importFlags,
-				"lang":          aidlLang,
-				"headerDir":     g.genHeaderDir.String(),
-				"outDir":        g.genOutDir.String(),
-				"optionalFlags": strings.Join(optionalFlags, " "),
-			},
-		})
-	}
-
-	return outFile, headers.Paths()
-}
-
-func (g *aidlGenRule) GeneratedSourceFiles() android.Paths {
-	return g.genOutputs.Paths()
-}
-
-func (g *aidlGenRule) Srcs() android.Paths {
-	return g.genOutputs.Paths()
-}
-
-func (g *aidlGenRule) GeneratedDeps() android.Paths {
-	return g.genHeaderDeps
-}
-
-func (g *aidlGenRule) GeneratedHeaderDirs() android.Paths {
-	return android.Paths{g.genHeaderDir}
-}
-
-func (g *aidlGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
-	ctx.AddDependency(ctx.Module(), nil, wrap("", g.properties.Imports, aidlInterfaceSuffix)...)
-	if !proptools.Bool(g.properties.Unstable) {
-		ctx.AddDependency(ctx.Module(), nil, g.properties.BaseName+aidlApiSuffix)
-	}
-
-	ctx.AddReverseDependency(ctx.Module(), nil, aidlMetadataSingletonName)
-}
-
-func aidlGenFactory() android.Module {
-	g := &aidlGenRule{}
-	g.AddProperties(&g.properties)
-	android.InitAndroidModule(g)
-	return g
-}
-
-type aidlApiProperties struct {
-	BaseName  string
-	Srcs      []string `android:"path"`
-	AidlRoot  string   // base directory for the input aidl file
-	Stability *string
-	Imports   []string
-	Versions  []string
-}
-
-type aidlApi struct {
-	android.ModuleBase
-
-	properties aidlApiProperties
-
-	// for triggering api check for version X against version X-1
-	checkApiTimestamps android.WritablePaths
-
-	// for triggering updating current API
-	updateApiTimestamp android.WritablePath
-
-	// for triggering check that files have not been modified
-	checkHashTimestamps android.WritablePaths
-
-	// for triggering freezing API as the new version
-	freezeApiTimestamp android.WritablePath
-}
-
-func (m *aidlApi) apiDir() string {
-	return filepath.Join(aidlApiDir, m.properties.BaseName)
-}
-
-// `m <iface>-freeze-api` will freeze ToT as this version
-func (m *aidlApi) nextVersion(ctx android.ModuleContext) string {
-	if len(m.properties.Versions) == 0 {
-		return "1"
-	} else {
-		latestVersion := m.properties.Versions[len(m.properties.Versions)-1]
-
-		i, err := strconv.Atoi(latestVersion)
-		if err != nil {
-			panic(err)
-		}
-
-		return strconv.Itoa(i + 1)
-	}
-}
-
-type apiDump struct {
-	dir      android.Path
-	files    android.Paths
-	hashFile android.OptionalPath
-}
-
-func (m *aidlApi) createApiDumpFromSource(ctx android.ModuleContext) apiDump {
-	srcs, imports := getPaths(ctx, m.properties.Srcs)
-
-	if ctx.Failed() {
-		return apiDump{}
-	}
-
-	var importPaths []string
-	importPaths = append(importPaths, imports...)
-	ctx.VisitDirectDeps(func(dep android.Module) {
-		if importedAidl, ok := dep.(*aidlInterface); ok {
-			importPaths = append(importPaths, importedAidl.properties.Full_import_paths...)
-		}
-	})
-
-	var apiDir android.WritablePath
-	var apiFiles android.WritablePaths
-	var hashFile android.WritablePath
-
-	apiDir = android.PathForModuleOut(ctx, "dump")
-	aidlRoot := android.PathForModuleSrc(ctx, m.properties.AidlRoot)
-	for _, src := range srcs {
-		baseDir := getBaseDir(ctx, src, aidlRoot)
-		relPath, _ := filepath.Rel(baseDir, src.String())
-		outFile := android.PathForModuleOut(ctx, "dump", relPath)
-		apiFiles = append(apiFiles, outFile)
-	}
-	hashFile = android.PathForModuleOut(ctx, "dump", ".hash")
-	latestVersion := "latest-version"
-	if len(m.properties.Versions) >= 1 {
-		latestVersion = m.properties.Versions[len(m.properties.Versions)-1]
-	}
-
-	var optionalFlags []string
-	if m.properties.Stability != nil {
-		optionalFlags = append(optionalFlags, "--stability", *m.properties.Stability)
-	}
-
-	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:    aidlDumpApiRule,
-		Outputs: append(apiFiles, hashFile),
-		Inputs:  srcs,
-		Args: map[string]string{
-			"optionalFlags": strings.Join(optionalFlags, " "),
-			"imports":       strings.Join(wrap("-I", importPaths, ""), " "),
-			"outDir":        apiDir.String(),
-			"hashFile":      hashFile.String(),
-			"latestVersion": latestVersion,
-		},
-	})
-	return apiDump{apiDir, apiFiles.Paths(), android.OptionalPathForPath(hashFile)}
-}
-
-func (m *aidlApi) makeApiDumpAsVersion(ctx android.ModuleContext, dump apiDump, version string) android.WritablePath {
-	timestampFile := android.PathForModuleOut(ctx, "updateapi_"+version+".timestamp")
-
-	modulePath := android.PathForModuleSrc(ctx).String()
-
-	targetDir := filepath.Join(modulePath, m.apiDir(), version)
-	rb := android.NewRuleBuilder()
-	// Wipe the target directory and then copy the API dump into the directory
-	rb.Command().Text("mkdir -p " + targetDir)
-	rb.Command().Text("rm -rf " + targetDir + "/*")
-	if version != currentVersion {
-		rb.Command().Text("cp -rf " + dump.dir.String() + "/. " + targetDir).Implicits(dump.files)
-		// If this is making a new frozen (i.e. non-current) version of the interface,
-		// modify Android.bp file to add the new version to the 'versions' property.
-		rb.Command().BuiltTool(ctx, "bpmodify").
-			Text("-w -m " + m.properties.BaseName).
-			Text("-parameter versions -a " + version).
-			Text(android.PathForModuleSrc(ctx, "Android.bp").String())
-	} else {
-		// In this case (unfrozen interface), don't copy .hash
-		rb.Command().Text("cp -rf " + dump.dir.String() + "/* " + targetDir).Implicits(dump.files)
-	}
-	rb.Command().Text("touch").Output(timestampFile)
-
-	rb.Build(pctx, ctx, "dump_aidl_api"+m.properties.BaseName+"_"+version,
-		"Making AIDL API of "+m.properties.BaseName+" as version "+version)
-	return timestampFile
-}
-
-func (m *aidlApi) checkCompatibility(ctx android.ModuleContext, oldDump apiDump, newDump apiDump) android.WritablePath {
-	newVersion := newDump.dir.Base()
-	timestampFile := android.PathForModuleOut(ctx, "checkapi_"+newVersion+".timestamp")
-	messageFile := android.PathForSource(ctx, "system/tools/aidl/build/message_check_compatibility.txt")
-
-	var optionalFlags []string
-	if m.properties.Stability != nil {
-		optionalFlags = append(optionalFlags, "--stability", *m.properties.Stability)
-	}
-
-	var implicits android.Paths
-	implicits = append(implicits, oldDump.files...)
-	implicits = append(implicits, newDump.files...)
-	implicits = append(implicits, messageFile)
-	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:      aidlCheckApiRule,
-		Implicits: implicits,
-		Output:    timestampFile,
-		Args: map[string]string{
-			"optionalFlags": strings.Join(optionalFlags, " "),
-			"old":           oldDump.dir.String(),
-			"new":           newDump.dir.String(),
-			"messageFile":   messageFile.String(),
-		},
-	})
-	return timestampFile
-}
-
-func (m *aidlApi) checkEquality(ctx android.ModuleContext, oldDump apiDump, newDump apiDump) android.WritablePath {
-	newVersion := newDump.dir.Base()
-	timestampFile := android.PathForModuleOut(ctx, "checkapi_"+newVersion+".timestamp")
-
-	// Use different messages depending on whether platform SDK is finalized or not.
-	// In case when it is finalized, we should never allow updating the already frozen API.
-	// If it's not finalized, we let users to update the current version by invoking
-	// `m <name>-update-api`.
-	messageFile := android.PathForSource(ctx, "system/tools/aidl/build/message_check_equality.txt")
-	sdkIsFinal := !ctx.Config().DefaultAppTargetSdk(ctx).IsPreview()
-	if sdkIsFinal {
-		messageFile = android.PathForSource(ctx, "system/tools/aidl/build/message_check_equality_release.txt")
-	}
-	formattedMessageFile := android.PathForModuleOut(ctx, "message_check_equality.txt")
-	rb := android.NewRuleBuilder()
-	rb.Command().Text("sed").Flag(" s/%s/" + m.properties.BaseName + "/g ").Input(messageFile).Text(" > ").Output(formattedMessageFile)
-	rb.Build(pctx, ctx, "format_message_"+m.properties.BaseName, "")
-
-	var implicits android.Paths
-	implicits = append(implicits, oldDump.files...)
-	implicits = append(implicits, newDump.files...)
-	implicits = append(implicits, formattedMessageFile)
-	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:      aidlDiffApiRule,
-		Implicits: implicits,
-		Output:    timestampFile,
-		Args: map[string]string{
-			"old":         oldDump.dir.String(),
-			"new":         newDump.dir.String(),
-			"hashFile":    newDump.hashFile.Path().Base(),
-			"messageFile": formattedMessageFile.String(),
-		},
-	})
-	return timestampFile
-}
-
-func (m *aidlApi) checkIntegrity(ctx android.ModuleContext, dump apiDump) android.WritablePath {
-	version := dump.dir.Base()
-	timestampFile := android.PathForModuleOut(ctx, "checkhash_"+version+".timestamp")
-	messageFile := android.PathForSource(ctx, "system/tools/aidl/build/message_check_integrity.txt")
-
-	i, _ := strconv.Atoi(version)
-	if i == 1 {
-		version = "latest-version"
-	} else {
-		version = strconv.Itoa(i - 1)
-	}
-
-	var implicits android.Paths
-	implicits = append(implicits, dump.files...)
-	implicits = append(implicits, dump.hashFile.Path())
-	implicits = append(implicits, messageFile)
-	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:      aidlVerifyHashRule,
-		Implicits: implicits,
-		Output:    timestampFile,
-		Args: map[string]string{
-			"apiDir":      dump.dir.String(),
-			"version":     version,
-			"hashFile":    dump.hashFile.Path().String(),
-			"messageFile": messageFile.String(),
-		},
-	})
-	return timestampFile
-}
-
-func (m *aidlApi) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	// An API dump is created from source and it is compared against the API dump of the
-	// 'current' (yet-to-be-finalized) version. By checking this we enforce that any change in
-	// the AIDL interface is gated by the AIDL API review even before the interface is frozen as
-	// a new version.
-	totApiDump := m.createApiDumpFromSource(ctx)
-	currentApiDir := android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), currentVersion)
-	var currentApiDump apiDump
-	if currentApiDir.Valid() {
-		currentApiDump = apiDump{
-			dir:      currentApiDir.Path(),
-			files:    ctx.Glob(filepath.Join(currentApiDir.Path().String(), "**/*.aidl"), nil),
-			hashFile: android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), currentVersion, ".hash"),
-		}
-		checked := m.checkEquality(ctx, currentApiDump, totApiDump)
-		m.checkApiTimestamps = append(m.checkApiTimestamps, checked)
-	} else {
-		// The "current" directory might not exist, in case when the interface is first created.
-		// Instruct user to create one by executing `m <name>-update-api`.
-		rb := android.NewRuleBuilder()
-		ifaceName := m.properties.BaseName
-		rb.Command().Text(fmt.Sprintf(`echo "API dump for the current version of AIDL interface %s does not exist."`, ifaceName))
-		rb.Command().Text(fmt.Sprintf(`echo Run "m %s-update-api", or add "unstable: true" to the build rule `+
-			`for the interface if it does not need to be versioned`, ifaceName))
-		// This file will never be created. Otherwise, the build will pass simply by running 'm; m'.
-		alwaysChecked := android.PathForModuleOut(ctx, "checkapi_current.timestamp")
-		rb.Command().Text("false").ImplicitOutput(alwaysChecked)
-		rb.Build(pctx, ctx, "check_current_aidl_api", "")
-		m.checkApiTimestamps = append(m.checkApiTimestamps, alwaysChecked)
-	}
-
-	// Also check that version X is backwards compatible with version X-1.
-	// "current" is checked against the latest version.
-	var dumps []apiDump
-	for _, ver := range m.properties.Versions {
-		apiDir := filepath.Join(ctx.ModuleDir(), m.apiDir(), ver)
-		apiDirPath := android.ExistentPathForSource(ctx, apiDir)
-		if apiDirPath.Valid() {
-			dumps = append(dumps, apiDump{
-				dir:      apiDirPath.Path(),
-				files:    ctx.Glob(filepath.Join(apiDirPath.String(), "**/*.aidl"), nil),
-				hashFile: android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), ver, ".hash"),
-			})
-		} else if ctx.Config().AllowMissingDependencies() {
-			ctx.AddMissingDependencies([]string{apiDir})
-		} else {
-			ctx.ModuleErrorf("API version %s path %s does not exist", ver, apiDir)
-		}
-	}
-	if currentApiDir.Valid() {
-		dumps = append(dumps, currentApiDump)
-	}
-	for i, _ := range dumps {
-		if dumps[i].hashFile.Valid() {
-			checkHashTimestamp := m.checkIntegrity(ctx, dumps[i])
-			m.checkHashTimestamps = append(m.checkHashTimestamps, checkHashTimestamp)
-		}
-
-		if i == 0 {
-			continue
-		}
-		checked := m.checkCompatibility(ctx, dumps[i-1], dumps[i])
-		m.checkApiTimestamps = append(m.checkApiTimestamps, checked)
-	}
-
-	// API dump from source is updated to the 'current' version. Triggered by `m <name>-update-api`
-	m.updateApiTimestamp = m.makeApiDumpAsVersion(ctx, totApiDump, currentVersion)
-
-	// API dump from source is frozen as the next stable version. Triggered by `m <name>-freeze-api`
-	nextVersion := m.nextVersion(ctx)
-	m.freezeApiTimestamp = m.makeApiDumpAsVersion(ctx, totApiDump, nextVersion)
-}
-
-func (m *aidlApi) AndroidMk() android.AndroidMkData {
-	return android.AndroidMkData{
-		Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
-			android.WriteAndroidMkData(w, data)
-			targetName := m.properties.BaseName + "-freeze-api"
-			fmt.Fprintln(w, ".PHONY:", targetName)
-			fmt.Fprintln(w, targetName+":", m.freezeApiTimestamp.String())
-
-			targetName = m.properties.BaseName + "-update-api"
-			fmt.Fprintln(w, ".PHONY:", targetName)
-			fmt.Fprintln(w, targetName+":", m.updateApiTimestamp.String())
-		},
-	}
-}
-
-func (m *aidlApi) DepsMutator(ctx android.BottomUpMutatorContext) {
-	ctx.AddDependency(ctx.Module(), nil, wrap("", m.properties.Imports, aidlInterfaceSuffix)...)
-}
-
-func aidlApiFactory() android.Module {
-	m := &aidlApi{}
-	m.AddProperties(&m.properties)
-	android.InitAndroidModule(m)
-	return m
-}
-
 type CommonBackendProperties struct {
 	// Whether to generate code in the corresponding backend.
 	// Default: true
@@ -887,6 +271,11 @@
 	// For native modules, the property needs to be set when a module is a part of mainline modules(APEX).
 	// Forwarded to generated java/native module.
 	Min_sdk_version *string
+
+	// Determines whether the generated source files are available or not. When set to true,
+	// the source files can be added to `srcs` property via `:<ifacename>-<backend>-source`,
+	// e.g., ":myaidl-java-source"
+	Srcs_available *bool
 }
 
 type CommonNativeBackendProperties struct {
@@ -904,9 +293,25 @@
 	// Vndk properties for C++/NDK libraries only (preferred to use backend-specific settings)
 	cc.VndkProperties
 
+	// How to interpret VNDK options. We only want one library in the VNDK (not multiple
+	// versions, since this would be a waste of space/unclear, and ultimately we want all
+	// code in a given release to be updated to use a specific version). By default, this
+	// puts either the latest stable version of the library or, if there is no stable
+	// version, the unstable version of the library in the VNDK. When using this field,
+	// explicitly set it to one of the values in the 'versions' field to put that version
+	// in the VNDK or set it to the next version (1 higher than this) to mean the version
+	// that will be frozen in the next update.
+	Vndk_use_version *string
+
 	// Whether the library can be installed on the vendor image.
 	Vendor_available *bool
 
+	// Whether the library can be installed on the odm image.
+	Odm_available *bool
+
+	// Whether the library can be installed on the product image.
+	Product_available *bool
+
 	// Whether the library can be loaded multiple times into the same process
 	Double_loadable *bool
 
@@ -968,6 +373,14 @@
 		// (for apps) and "<name>-ndk_platform" (for platform usage).
 		Ndk struct {
 			CommonNativeBackendProperties
+
+			// Currently, all ndk-supported interfaces generate two variants:
+			// - ndk - for apps to use, against an NDK
+			// - ndk_platform - for the platform to use
+			//
+			// This adds an option to disable the 'ndk' variant in cases where APIs
+			// only available in the platform version work.
+			Apps_enabled *bool
 		}
 		// Backend of the compiler generating code for Rust clients.
 		// When enabled, this creates a target called "<name>-rust".
@@ -979,6 +392,9 @@
 	// Marks that this interface does not need to be stable. When set to true, the build system
 	// doesn't create the API dump and require it to be updated. Default is false.
 	Unstable *bool
+
+	// Optional flags to be passed to the AIDL compiler. e.g. "-Weverything"
+	Flags []string
 }
 
 type aidlInterface struct {
@@ -1007,6 +423,14 @@
 	return i.properties.Backend.Ndk.Enabled == nil || *i.properties.Backend.Ndk.Enabled
 }
 
+func (i *aidlInterface) shouldGenerateAppNdkBackend() bool {
+	if !i.shouldGenerateNdkBackend() {
+		return false
+	}
+	// explicitly true if not specified to give early warning to devs
+	return i.properties.Backend.Ndk.Apps_enabled == nil || *i.properties.Backend.Ndk.Apps_enabled
+}
+
 func (i *aidlInterface) shouldGenerateRustBackend() bool {
 	return i.properties.Backend.Rust.Enabled != nil && *i.properties.Backend.Rust.Enabled
 }
@@ -1025,32 +449,37 @@
 	*unstableModules = append(*unstableModules, moduleName)
 }
 
-func (i *aidlInterface) checkImports(mctx android.BaseModuleContext) {
-	for _, anImport := range i.properties.Imports {
-		other := lookupInterface(anImport, mctx.Config())
+func checkImports(mctx android.BottomUpMutatorContext) {
+	if i, ok := mctx.Module().(*aidlInterface); ok {
+		for _, anImport := range i.properties.Imports {
+			other := lookupInterface(anImport, mctx.Config())
 
-		if other == nil {
-			mctx.PropertyErrorf("imports", "Import does not exist: "+anImport)
-		}
+			if other == nil {
+				if mctx.Config().AllowMissingDependencies() {
+					continue
+				}
+				mctx.PropertyErrorf("imports", "Import does not exist: "+anImport)
+			}
 
-		if i.shouldGenerateJavaBackend() && !other.shouldGenerateJavaBackend() {
-			mctx.PropertyErrorf("backend.java.enabled",
-				"Java backend not enabled in the imported AIDL interface %q", anImport)
-		}
+			if i.shouldGenerateJavaBackend() && !other.shouldGenerateJavaBackend() {
+				mctx.PropertyErrorf("backend.java.enabled",
+					"Java backend not enabled in the imported AIDL interface %q", anImport)
+			}
 
-		if i.shouldGenerateCppBackend() && !other.shouldGenerateCppBackend() {
-			mctx.PropertyErrorf("backend.cpp.enabled",
-				"C++ backend not enabled in the imported AIDL interface %q", anImport)
-		}
+			if i.shouldGenerateCppBackend() && !other.shouldGenerateCppBackend() {
+				mctx.PropertyErrorf("backend.cpp.enabled",
+					"C++ backend not enabled in the imported AIDL interface %q", anImport)
+			}
 
-		if i.shouldGenerateNdkBackend() && !other.shouldGenerateNdkBackend() {
-			mctx.PropertyErrorf("backend.ndk.enabled",
-				"NDK backend not enabled in the imported AIDL interface %q", anImport)
-		}
+			if i.shouldGenerateNdkBackend() && !other.shouldGenerateNdkBackend() {
+				mctx.PropertyErrorf("backend.ndk.enabled",
+					"NDK backend not enabled in the imported AIDL interface %q", anImport)
+			}
 
-		if i.shouldGenerateRustBackend() && !other.shouldGenerateRustBackend() {
-			mctx.PropertyErrorf("backend.rust.enabled",
-				"Rust backend not enabled in the imported AIDL interface %q", anImport)
+			if i.shouldGenerateRustBackend() && !other.shouldGenerateRustBackend() {
+				mctx.PropertyErrorf("backend.rust.enabled",
+					"Rust backend not enabled in the imported AIDL interface %q", anImport)
+			}
 		}
 	}
 }
@@ -1081,27 +510,66 @@
 	}
 }
 func (i *aidlInterface) checkVersions(mctx android.LoadHookContext) {
+	versions := make(map[string]bool)
+	intVersions := make([]int, 0, len(i.properties.Versions))
 	for _, ver := range i.properties.Versions {
-		_, err := strconv.Atoi(ver)
+		if _, dup := versions[ver]; dup {
+			mctx.PropertyErrorf("versions", "duplicate found", ver)
+			continue
+		}
+		versions[ver] = true
+		n, err := strconv.Atoi(ver)
 		if err != nil {
 			mctx.PropertyErrorf("versions", "%q is not an integer", ver)
 			continue
 		}
+		if n <= 0 {
+			mctx.PropertyErrorf("versions", "should be > 0, but is %v", ver)
+			continue
+		}
+		intVersions = append(intVersions, n)
+
+	}
+	if !mctx.Failed() && !sort.IntsAreSorted(intVersions) {
+		mctx.PropertyErrorf("versions", "should be sorted, but is %v", i.properties.Versions)
 	}
 }
-
-func (i *aidlInterface) currentVersion(ctx android.LoadHookContext) string {
-	if !i.hasVersion() {
-		return ""
-	} else {
-		ver := i.latestVersion()
-		i, err := strconv.Atoi(ver)
-		if err != nil {
-			panic(err)
-		}
-
-		return strconv.Itoa(i + 1)
+func (i *aidlInterface) checkVndkUseVersion(mctx android.LoadHookContext) {
+	if i.properties.Vndk_use_version == nil {
+		return
 	}
+	if !i.hasVersion() {
+		mctx.PropertyErrorf("vndk_use_version", "This does not make sense when no 'versions' are specified.")
+
+	}
+	if *i.properties.Vndk_use_version == i.nextVersion() {
+		return
+	}
+	for _, ver := range i.properties.Versions {
+		if *i.properties.Vndk_use_version == ver {
+			return
+		}
+	}
+	mctx.PropertyErrorf("vndk_use_version", "Specified version %q does not exist", *i.properties.Vndk_use_version)
+}
+
+func (i *aidlInterface) nextVersion() string {
+	if proptools.Bool(i.properties.Unstable) {
+		return ""
+	}
+	return nextVersion(i.properties.Versions)
+}
+
+func nextVersion(versions []string) string {
+	if len(versions) == 0 {
+		return "1"
+	}
+	ver := versions[len(versions)-1]
+	i, err := strconv.Atoi(ver)
+	if err != nil {
+		panic(err)
+	}
+	return strconv.Itoa(i + 1)
 }
 
 func (i *aidlInterface) latestVersion() string {
@@ -1110,84 +578,11 @@
 	}
 	return i.properties.Versions[len(i.properties.Versions)-1]
 }
-func (i *aidlInterface) isLatestVersion(version string) bool {
-	if !i.hasVersion() {
-		return true
-	}
-	return version == i.latestVersion()
-}
+
 func (i *aidlInterface) hasVersion() bool {
 	return len(i.properties.Versions) > 0
 }
 
-// This function returns module name with version. Assume that there is foo of which latest version is 2
-// Version -> Module name
-// "1"->foo-V1
-// "2"->foo-V2
-// "3"(unfrozen)->foo-unstable
-// ""-> foo
-// "unstable" -> foo-unstable
-func (i *aidlInterface) versionedName(ctx android.LoadHookContext, version string) string {
-	name := i.ModuleBase.Name()
-	if version == "" {
-		return name
-	}
-	if version == i.currentVersion(ctx) || version == unstableVersion {
-		return name + "-" + unstableVersion
-	}
-	return name + "-V" + version
-}
-
-// This function returns C++ artifact's name. Mostly, it returns same as versionedName(),
-// But, it returns different value only if it is the case below.
-// Assume that there is foo of which latest version is 2
-// foo-unstable -> foo-V3
-// foo -> foo-V2 (latest frozen version)
-// Assume that there is bar of which version hasn't been defined yet.
-// bar -> bar
-// bar-unstable -> bar-V1
-func (i *aidlInterface) cppOutputName(version string) string {
-	name := i.ModuleBase.Name()
-	if i.hasVersion() && version == unstableVersion {
-		panic("A versioned module's output name in C++ must not contain 'unstable'")
-	}
-	// If the module doesn't have version, it returns with version(-V1) only if 'version' is unstable,
-	// otherwise, it returns the name without version.
-	if !i.hasVersion() {
-		// TODO(b/150578172): Use "-V1" as 'unstable' when the build system supports it, or remove it altogether later.
-		if version == "" {
-			return name
-		}
-		// latestVersion() always returns "0"
-		i, err := strconv.Atoi(i.latestVersion())
-		if err != nil {
-			panic(err)
-		}
-		return name + "-V" + strconv.Itoa(i+1)
-	}
-	if version == "" {
-		version = i.latestVersion()
-	}
-	return name + "-V" + version
-}
-
-func (i *aidlInterface) srcsForVersion(mctx android.LoadHookContext, version string) (srcs []string, aidlRoot string) {
-	if version == i.currentVersion(mctx) {
-		return i.properties.Srcs, i.properties.Local_include_dir
-	} else {
-		aidlRoot = filepath.Join(aidlApiDir, i.ModuleBase.Name(), version)
-		full_paths, err := mctx.GlobWithDeps(filepath.Join(mctx.ModuleDir(), aidlRoot, "**/*.aidl"), nil)
-		if err != nil {
-			panic(err)
-		}
-		for _, path := range full_paths {
-			// Here, we need path local to the module
-			srcs = append(srcs, strings.TrimPrefix(path, mctx.ModuleDir()+"/"))
-		}
-		return srcs, aidlRoot
-	}
-}
-
 func aidlInterfaceHook(mctx android.LoadHookContext, i *aidlInterface) {
 	if !isRelativePath(i.properties.Local_include_dir) {
 		mctx.PropertyErrorf("local_include_dir", "must be relative path: "+i.properties.Local_include_dir)
@@ -1201,6 +596,7 @@
 	i.gatherInterface(mctx)
 	i.checkStability(mctx)
 	i.checkVersions(mctx)
+	i.checkVndkUseVersion(mctx)
 	i.checkGenTrace(mctx)
 
 	if mctx.Failed() {
@@ -1208,96 +604,46 @@
 	}
 
 	var libs []string
-
-	currentVersion := i.currentVersion(mctx)
-
-	versionsForCpp := make([]string, len(i.properties.Versions))
-
 	sdkIsFinal := !mctx.Config().DefaultAppTargetSdk(mctx).IsPreview()
 
+	unstable := proptools.Bool(i.properties.Unstable)
+
+	if unstable {
+		if i.hasVersion() {
+			mctx.PropertyErrorf("versions", "cannot have versions for an unstable interface")
+			return
+		}
+	}
 	needToCheckUnstableVersion := sdkIsFinal && i.hasVersion() && i.Owner() == ""
-	copy(versionsForCpp, i.properties.Versions)
-	if i.hasVersion() {
-		// In C++ library, AIDL doesn't create the module of which name is with latest version,
-		// instead of it, there is a module without version.
-		versionsForCpp[len(i.properties.Versions)-1] = ""
-	}
-	if i.shouldGenerateCppBackend() {
-		unstableLib := addCppLibrary(mctx, i, currentVersion, langCpp)
-		if !i.hasVersion() {
-			libs = append(libs, addCppLibrary(mctx, i, unstableVersion, langCpp))
+	versions := i.properties.Versions
+	nextVersion := i.nextVersion()
+	shouldGenerateLangBackendMap := map[string]bool{
+		langCpp:         i.shouldGenerateCppBackend(),
+		langNdk:         i.shouldGenerateAppNdkBackend(),
+		langNdkPlatform: i.shouldGenerateNdkBackend(),
+		langJava:        i.shouldGenerateJavaBackend(),
+		langRust:        i.shouldGenerateRustBackend()}
+	for lang, shouldGenerate := range shouldGenerateLangBackendMap {
+		if !shouldGenerate {
+			continue
 		}
-		if needToCheckUnstableVersion {
-			addUnstableModule(mctx, unstableLib)
+		libs = append(libs, addLibrary(mctx, i, nextVersion, lang))
+		if !unstable && needToCheckUnstableVersion {
+			addUnstableModule(mctx, libs[len(libs)-1])
 		}
-		libs = append(libs, unstableLib)
-		for _, version := range versionsForCpp {
-			libs = append(libs, addCppLibrary(mctx, i, version, langCpp))
+		for _, version := range versions {
+			libs = append(libs, addLibrary(mctx, i, version, lang))
 		}
-	}
-
-	if i.shouldGenerateNdkBackend() {
-		{
-			unstableLib := addCppLibrary(mctx, i, currentVersion, langNdk)
-			if !i.hasVersion() {
-				libs = append(libs, addCppLibrary(mctx, i, unstableVersion, langNdk))
+		// TODO(b/150578172) remove those modules when every module specify its version.
+		if !sdkIsFinal {
+			if !unstable {
+				libs = append(libs, addLibrary(mctx, i, "", lang))
 			}
-			if needToCheckUnstableVersion {
-				addUnstableModule(mctx, unstableLib)
-			}
-			libs = append(libs, unstableLib)
-			for _, version := range versionsForCpp {
-				libs = append(libs, addCppLibrary(mctx, i, version, langNdk))
-			}
-		}
-		{
-			// TODO(b/121157555): combine with '-ndk' variant
-			unstableLib := addCppLibrary(mctx, i, currentVersion, langNdkPlatform)
-			if !i.hasVersion() {
-				libs = append(libs, addCppLibrary(mctx, i, unstableVersion, langNdkPlatform))
-			}
-			if needToCheckUnstableVersion {
-				addUnstableModule(mctx, unstableLib)
-			}
-			libs = append(libs, unstableLib)
-			for _, version := range versionsForCpp {
-				libs = append(libs, addCppLibrary(mctx, i, version, langNdkPlatform))
-			}
-		}
-	}
-	versionsForJava := i.properties.Versions
-	if i.hasVersion() {
-		versionsForJava = append(i.properties.Versions, "")
-	}
-	if i.shouldGenerateJavaBackend() {
-		unstableLib := addJavaLibrary(mctx, i, currentVersion)
-		if !i.hasVersion() {
-			libs = append(libs, addJavaLibrary(mctx, i, unstableVersion))
-		}
-		if needToCheckUnstableVersion {
-			addUnstableModule(mctx, unstableLib)
-		}
-		libs = append(libs, unstableLib)
-		for _, version := range versionsForJava {
-			libs = append(libs, addJavaLibrary(mctx, i, version))
-		}
-	}
-
-	if i.shouldGenerateRustBackend() {
-		unstableLib := addRustLibrary(mctx, i, currentVersion)
-		if needToCheckUnstableVersion {
-			addUnstableModule(mctx, unstableLib)
-		}
-		libs = append(libs, unstableLib)
-		for _, version := range versionsForCpp {
-			addRustLibrary(mctx, i, version)
+			libs = append(libs, addLibrary(mctx, i, unstableVersion, lang))
 		}
 	}
 
 	if proptools.Bool(i.properties.Unstable) {
-		if i.hasVersion() {
-			mctx.PropertyErrorf("versions", "cannot have versions for an unstable interface")
-		}
 		apiDirRoot := filepath.Join(aidlApiDir, i.ModuleBase.Name())
 		aidlDumps, _ := mctx.GlobWithDeps(filepath.Join(mctx.ModuleDir(), apiDirRoot, "**/*.aidl"), nil)
 		if len(aidlDumps) != 0 {
@@ -1308,7 +654,6 @@
 			mctx.ModuleErrorf("unstable:true and stability:%q cannot happen at the same time", i.properties.Stability)
 		}
 	} else {
-		sdkIsFinal := !mctx.Config().DefaultAppTargetSdk(mctx).IsPreview()
 		if sdkIsFinal && !i.hasVersion() && i.Owner() == "" {
 			mctx.PropertyErrorf("versions", "must be set (need to be frozen) when \"unstable\" is false, PLATFORM_VERSION_CODENAME is REL, and \"owner\" property is missing.")
 		}
@@ -1329,398 +674,42 @@
 	i.internalModuleNames = libs
 }
 
-// This function returns actual version which is used by AIDL compiler from version for a module name.
-// A 'version' has to be either empty(for a non-versioned module) or a version number(for a versioned module).
-// A 'versionForModuleName' has to be either
-//  - empty: the latest version(unstable)
-//  - "unstable": the same as above, only for non-versioned module.
-//  - a version number
-func (i *aidlInterface) normalizeVersion(versionForModuleName string) string {
-	if i.hasVersion() && versionForModuleName == "" {
-		return i.latestVersion()
-	}
-	if versionForModuleName == unstableVersion {
-		if i.hasVersion() {
-			panic("An interface with versions must not have a module of which name is 'unstable'.")
+// srcsVisibility gives the value for the `visibility` property of the source gen module for the
+// language backend `lang`. By default, the source gen module is not visible to the clients of
+// aidl_interface (because it's an impl detail), but when `backend.<backend>.srcs_available` is set
+// to true, the source gen module follows the visibility of the aidl_interface module.
+func srcsVisibility(mctx android.LoadHookContext, lang string) []string {
+	if a, ok := mctx.Module().(*aidlInterface); !ok {
+		panic(fmt.Errorf("%q is not aidl_interface", mctx.Module().String()))
+	} else {
+		var prop *bool
+		switch lang {
+		case langCpp:
+			prop = a.properties.Backend.Cpp.Srcs_available
+		case langJava:
+			prop = a.properties.Backend.Java.Srcs_available
+		case langNdk, langNdkPlatform:
+			prop = a.properties.Backend.Ndk.Srcs_available
+		case langRust:
+			prop = a.properties.Backend.Rust.Srcs_available
+		default:
+			panic(fmt.Errorf("unsupported language backend %q\n", lang))
 		}
-		return ""
+		if proptools.Bool(prop) {
+			// Returning nil so that the visibility of the source module defaults to the
+			// the package-level default visibility. This way, the source module gets
+			// the same visibility as the library modules.
+			return nil
+		}
 	}
-	return versionForModuleName
-}
-
-func (i *aidlInterface) getImportPostfix(mctx android.LoadHookContext, version string, lang string) string {
-	if version == i.currentVersion(mctx) {
-		return "-" + unstableVersion + "-" + lang
-	}
-	return "-" + lang
-}
-
-func defaultVisibility(mctx android.LoadHookContext) []string {
 	return []string{
 		"//" + mctx.ModuleDir(),
-		// system/tools/aidl/build is always added because aidl_metadata_json in the directory has
-		// dependencies to all aidl_interface modules.
+		// system/tools/aidl/build is always added because aidl_metadata_json in the
+		// directory has dependencies to all aidl_interface modules.
 		"//system/tools/aidl/build",
 	}
 }
 
-func addCppLibrary(mctx android.LoadHookContext, i *aidlInterface, versionForModuleName string, lang string) string {
-	cppSourceGen := i.versionedName(mctx, versionForModuleName) + "-" + lang + "-source"
-	cppModuleGen := i.versionedName(mctx, versionForModuleName) + "-" + lang
-	cppOutputGen := i.cppOutputName(versionForModuleName) + "-" + lang
-	version := i.normalizeVersion(versionForModuleName)
-	srcs, aidlRoot := i.srcsForVersion(mctx, version)
-	if len(srcs) == 0 {
-		// This can happen when the version is about to be frozen; the version
-		// directory is created but API dump hasn't been copied there.
-		// Don't create a library for the yet-to-be-frozen version.
-		return ""
-	}
-
-	var overrideVndkProperties cc.VndkProperties
-
-	// For an interface with no versions, this is the ToT interface,
-	// especially, choose the module of which 'versionForModuleName' is 'unstable' to have only one version per an interface in VNDK.
-	// For an interface w/ versions, this is that latest stable version.
-	canBeTargetForVndk := (!i.hasVersion() && versionForModuleName == unstableVersion) || (i.hasVersion() && version == i.latestVersion())
-	if !canBeTargetForVndk {
-		// We only want the VNDK to include the latest interface. For interfaces in
-		// development, they will be frozen, so we put their latest version in the
-		// VNDK. For interfaces which are already frozen, we put their latest version
-		// in the VNDK, and when that version is frozen, the version in the VNDK can
-		// be updated. Otherwise, we remove this library from the VNDK, to avoid adding
-		// multiple versions of the same library to the VNDK.
-		overrideVndkProperties.Vndk.Enabled = proptools.BoolPtr(false)
-		overrideVndkProperties.Vndk.Support_system_process = proptools.BoolPtr(false)
-	}
-
-	var commonProperties *CommonNativeBackendProperties
-	if lang == langCpp {
-		commonProperties = &i.properties.Backend.Cpp.CommonNativeBackendProperties
-	} else if lang == langNdk || lang == langNdkPlatform {
-		commonProperties = &i.properties.Backend.Ndk.CommonNativeBackendProperties
-	}
-
-	genLog := proptools.Bool(commonProperties.Gen_log)
-	genTrace := proptools.Bool(i.properties.Gen_trace)
-
-	mctx.CreateModule(aidlGenFactory, &nameProperties{
-		Name: proptools.StringPtr(cppSourceGen),
-	}, &aidlGenProperties{
-		Srcs:       srcs,
-		AidlRoot:   aidlRoot,
-		Imports:    concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
-		Stability:  i.properties.Stability,
-		Lang:       lang,
-		BaseName:   i.ModuleBase.Name(),
-		GenLog:     genLog,
-		Version:    version,
-		GenTrace:   genTrace,
-		Unstable:   i.properties.Unstable,
-		Visibility: defaultVisibility(mctx),
-	})
-	importPostfix := i.getImportPostfix(mctx, version, lang)
-
-	importExportDependencies := wrap("", i.properties.Imports, importPostfix)
-	var sharedLibDependency []string
-	var libJSONCppDependency []string
-	var staticLibDependency []string
-	var headerLibs []string
-	var sdkVersion *string
-	var minSdkVersion *string
-	var stl *string
-	var cpp_std *string
-	var hostSupported *bool
-	var addCflags []string
-
-	if lang == langCpp {
-		importExportDependencies = append(importExportDependencies, "libbinder", "libutils")
-		if genLog {
-			libJSONCppDependency = []string{"libjsoncpp"}
-		}
-		if genTrace {
-			sharedLibDependency = append(sharedLibDependency, "libcutils")
-		}
-		hostSupported = i.properties.Host_supported
-		minSdkVersion = i.properties.Backend.Cpp.Min_sdk_version
-	} else if lang == langNdk {
-		importExportDependencies = append(importExportDependencies, "libbinder_ndk")
-		if genLog {
-			staticLibDependency = []string{"libjsoncpp_ndk"}
-		}
-		if genTrace {
-			sharedLibDependency = append(sharedLibDependency, "libandroid")
-		}
-		sdkVersion = proptools.StringPtr("current")
-		stl = proptools.StringPtr("c++_shared")
-		minSdkVersion = i.properties.Backend.Ndk.Min_sdk_version
-	} else if lang == langNdkPlatform {
-		importExportDependencies = append(importExportDependencies, "libbinder_ndk")
-		if genLog {
-			libJSONCppDependency = []string{"libjsoncpp"}
-		}
-		if genTrace {
-			headerLibs = append(headerLibs, "libandroid_aidltrace")
-			sharedLibDependency = append(sharedLibDependency, "libcutils")
-		}
-		hostSupported = i.properties.Host_supported
-		addCflags = append(addCflags, "-DBINDER_STABILITY_SUPPORT")
-		minSdkVersion = i.properties.Backend.Ndk.Min_sdk_version
-	} else {
-		panic("Unrecognized language: " + lang)
-	}
-
-	vendorAvailable := i.properties.Vendor_available
-	if lang == langCpp && "vintf" == proptools.String(i.properties.Stability) {
-		// Vendors cannot use the libbinder (cpp) backend of AIDL in a way that is stable.
-		// So, in order to prevent accidental usage of these library by vendor, forcibly
-		// disabling this version of the library.
-		//
-		// It may be the case in the future that we will want to enable this (if some generic
-		// helper should be used by both libbinder vendor things using /dev/vndbinder as well
-		// as those things using /dev/binder + libbinder_ndk to talk to stable interfaces).
-		vendorAvailable = proptools.BoolPtr(false)
-	}
-
-	if lang == langNdk {
-		// TODO(b/121157555): when the NDK variant is its own variant, these wouldn't interact,
-		// but we can't create a vendor version of an NDK variant
-		//
-		// nil (unspecified) is used instead of false so that this can't conflict with
-		// 'vendor: true', for instance.
-		vendorAvailable = nil
-		overrideVndkProperties.Vndk.Enabled = proptools.BoolPtr(false)
-		overrideVndkProperties.Vndk.Support_system_process = proptools.BoolPtr(false)
-	}
-
-	mctx.CreateModule(cc.LibraryFactory, &ccProperties{
-		Name:                      proptools.StringPtr(cppModuleGen),
-		Vendor_available:          vendorAvailable,
-		Host_supported:            hostSupported,
-		Defaults:                  []string{"aidl-cpp-module-defaults"},
-		Double_loadable:           i.properties.Double_loadable,
-		Generated_sources:         []string{cppSourceGen},
-		Generated_headers:         []string{cppSourceGen},
-		Export_generated_headers:  []string{cppSourceGen},
-		Static:                    staticLib{Whole_static_libs: libJSONCppDependency},
-		Shared:                    sharedLib{Shared_libs: libJSONCppDependency, Export_shared_lib_headers: libJSONCppDependency},
-		Static_libs:               staticLibDependency,
-		Shared_libs:               append(importExportDependencies, sharedLibDependency...),
-		Header_libs:               headerLibs,
-		Export_shared_lib_headers: importExportDependencies,
-		Sdk_version:               sdkVersion,
-		Stl:                       stl,
-		Cpp_std:                   cpp_std,
-		Cflags:                    append(addCflags, "-Wextra", "-Wall", "-Werror"),
-		Stem:                      proptools.StringPtr(cppOutputGen),
-		Apex_available:            commonProperties.Apex_available,
-		Min_sdk_version:           minSdkVersion,
-		UseApexNameMacro:          true,
-	}, &i.properties.VndkProperties, &commonProperties.VndkProperties, &overrideVndkProperties)
-
-	return cppModuleGen
-}
-
-func addJavaLibrary(mctx android.LoadHookContext, i *aidlInterface, versionForModuleName string) string {
-	javaSourceGen := i.versionedName(mctx, versionForModuleName) + "-java-source"
-	javaModuleGen := i.versionedName(mctx, versionForModuleName) + "-java"
-	version := i.normalizeVersion(versionForModuleName)
-	srcs, aidlRoot := i.srcsForVersion(mctx, version)
-	if len(srcs) == 0 {
-		// This can happen when the version is about to be frozen; the version
-		// directory is created but API dump hasn't been copied there.
-		// Don't create a library for the yet-to-be-frozen version.
-		return ""
-	}
-
-	sdkVersion := i.properties.Backend.Java.Sdk_version
-	if !proptools.Bool(i.properties.Backend.Java.Platform_apis) && sdkVersion == nil {
-		// platform apis requires no default
-		sdkVersion = proptools.StringPtr("system_current")
-	}
-
-	mctx.CreateModule(aidlGenFactory, &nameProperties{
-		Name: proptools.StringPtr(javaSourceGen),
-	}, &aidlGenProperties{
-		Srcs:       srcs,
-		AidlRoot:   aidlRoot,
-		Imports:    concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
-		Stability:  i.properties.Stability,
-		Lang:       langJava,
-		BaseName:   i.ModuleBase.Name(),
-		Version:    version,
-		GenTrace:   proptools.Bool(i.properties.Gen_trace),
-		Unstable:   i.properties.Unstable,
-		Visibility: defaultVisibility(mctx),
-	})
-
-	importPostfix := i.getImportPostfix(mctx, version, langJava)
-	mctx.CreateModule(java.LibraryFactory, &javaProperties{
-		Name:            proptools.StringPtr(javaModuleGen),
-		Installable:     proptools.BoolPtr(true),
-		Defaults:        []string{"aidl-java-module-defaults"},
-		Sdk_version:     sdkVersion,
-		Platform_apis:   i.properties.Backend.Java.Platform_apis,
-		Static_libs:     wrap("", i.properties.Imports, importPostfix),
-		Srcs:            []string{":" + javaSourceGen},
-		Apex_available:  i.properties.Backend.Java.Apex_available,
-		Min_sdk_version: i.properties.Backend.Java.Min_sdk_version,
-	})
-
-	return javaModuleGen
-}
-
-type aidlRustSourceProviderProperties struct {
-	SourceGen string `android:"path"`
-	Imports   []string
-}
-
-type aidlRustSourceProvider struct {
-	*rust.BaseSourceProvider
-
-	properties aidlRustSourceProviderProperties
-}
-
-func (sp *aidlRustSourceProvider) GenerateSource(ctx rust.ModuleContext, deps rust.PathDeps) android.Path {
-	sourceStem := proptools.String(sp.BaseSourceProvider.Properties.Source_stem)
-	topLevelOutputFile := android.PathForModuleOut(ctx, sourceStem+".rs")
-	srcPaths := android.PathsForModuleSrc(ctx, []string{sp.properties.SourceGen})
-
-	// Find the gen directory for the source module
-	aidlGenModule, _ := ctx.GetDirectDep(android.SrcIsModule(sp.properties.SourceGen))
-	srcGenDir := aidlGenModule.(*aidlGenRule).genOutDir
-
-	// In Rust, we import our dependency crates into `mangled`:
-	//   use dependency::mangled::*;
-	// so we can use the crate:: Rust path prefix to refer to
-	// both crate-local and imported paths (from dependencies)
-	importFlags := make([]string, len(sp.properties.Imports))
-	for i, dep := range sp.properties.Imports {
-		importFlags[i] = "-I" + fixRustName(dep)
-	}
-
-	// In Rust, we need to do some extra post-processing:
-	// emit a top-level foo.rs that includes all the generated .rs
-	// files verbatim ("glued" together). The generated glue file
-	// replicates the AIDL package hierarchy from the input
-	// .aidl files in two ways:
-	//   * 1:1 mapping in the crate::aidl namespace, used by downstream users
-	//   * mangled in the crate::mangled namespace, used internally
-	//     to resolve AIDL package paths between dependencies
-	ctx.Build(pctx, android.BuildParams{
-		Rule:   aidlRustGlueRule,
-		Inputs: srcPaths,
-		Output: topLevelOutputFile,
-		Args: map[string]string{
-			"root":    srcGenDir.String(),
-			"imports": strings.Join(importFlags, " "),
-		},
-	})
-
-	sp.BaseSourceProvider.OutputFile = topLevelOutputFile
-	return topLevelOutputFile
-}
-
-func (sp *aidlRustSourceProvider) SourceProviderProps() []interface{} {
-	return append(sp.BaseSourceProvider.SourceProviderProps(),
-		&sp.properties)
-}
-
-func (sp *aidlRustSourceProvider) SourceProviderDeps(ctx rust.DepsContext, deps rust.Deps) rust.Deps {
-	deps = sp.BaseSourceProvider.SourceProviderDeps(ctx, deps)
-	deps.Rustlibs = append(deps.Rustlibs, "libbinder_rs", "liblazy_static")
-	deps.Rustlibs = append(deps.Rustlibs, wrap("", sp.properties.Imports, "-rust")...)
-	return deps
-}
-
-func (sp *aidlRustSourceProvider) AndroidMk(ctx rust.AndroidMkContext, ret *android.AndroidMkData) {
-	ctx.SubAndroidMk(ret, sp.BaseSourceProvider)
-	ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
-		fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
-	})
-}
-
-func aidlRustLibraryFactory() android.Module {
-	sourceProvider := &aidlRustSourceProvider{
-		BaseSourceProvider: rust.NewSourceProvider(),
-		properties:         aidlRustSourceProviderProperties{},
-	}
-
-	module := rust.NewSourceProviderModule(android.HostAndDeviceSupported, sourceProvider, true)
-	return module.Init()
-}
-
-func fixRustName(name string) string {
-	return strings.Map(func(r rune) rune {
-		switch r {
-		case '-', '.':
-			return '_'
-		default:
-			return r
-		}
-	}, name)
-}
-
-func addRustLibrary(mctx android.LoadHookContext, i *aidlInterface, versionForModuleName string) string {
-	rustSourceGen := i.versionedName(mctx, versionForModuleName) + "-rust-source"
-	rustModuleGen := i.versionedName(mctx, versionForModuleName) + "-rust"
-	version := i.normalizeVersion(versionForModuleName)
-	srcs, aidlRoot := i.srcsForVersion(mctx, version)
-	if len(srcs) == 0 {
-		// This can happen when the version is about to be frozen; the version
-		// directory is created but API dump hasn't been copied there.
-		// Don't create a library for the yet-to-be-frozen version.
-		return ""
-	}
-
-	mctx.CreateModule(aidlGenFactory, &nameProperties{
-		Name: proptools.StringPtr(rustSourceGen),
-	}, &aidlGenProperties{
-		Srcs:       srcs,
-		AidlRoot:   aidlRoot,
-		Imports:    concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
-		Stability:  i.properties.Stability,
-		Lang:       langRust,
-		BaseName:   i.ModuleBase.Name(),
-		Version:    version,
-		Unstable:   i.properties.Unstable,
-		Visibility: defaultVisibility(mctx),
-	})
-
-	versionedRustName := fixRustName(i.versionedName(mctx, versionForModuleName))
-
-	mctx.CreateModule(aidlRustLibraryFactory, &rustProperties{
-		Name:           proptools.StringPtr(rustModuleGen),
-		Crate_name:     versionedRustName,
-		Stem:           proptools.StringPtr("lib" + versionedRustName),
-		Defaults:       []string{"aidl-rust-module-defaults"},
-		Host_supported: i.properties.Host_supported,
-	}, &rust.SourceProviderProperties{
-		Source_stem: proptools.StringPtr(versionedRustName),
-	}, &aidlRustSourceProviderProperties{
-		SourceGen: ":" + rustSourceGen,
-		Imports:   i.properties.Imports,
-	})
-
-	return rustModuleGen
-}
-
-func addApiModule(mctx android.LoadHookContext, i *aidlInterface) string {
-	apiModule := i.ModuleBase.Name() + aidlApiSuffix
-	srcs, aidlRoot := i.srcsForVersion(mctx, i.currentVersion(mctx))
-	mctx.CreateModule(aidlApiFactory, &nameProperties{
-		Name: proptools.StringPtr(apiModule),
-	}, &aidlApiProperties{
-		BaseName:  i.ModuleBase.Name(),
-		Srcs:      srcs,
-		AidlRoot:  aidlRoot,
-		Stability: i.properties.Stability,
-		Imports:   concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
-		Versions:  i.properties.Versions,
-	})
-	return apiModule
-}
-
 func (i *aidlInterface) Name() string {
 	return i.ModuleBase.Name() + aidlInterfaceSuffix
 }
@@ -1734,8 +723,6 @@
 	}
 }
 func (i *aidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) {
-	i.checkImports(ctx)
-
 	ctx.AddReverseDependency(ctx.Module(), nil, aidlMetadataSingletonName)
 }
 
@@ -1763,6 +750,15 @@
 type DepInfo struct {
 	ifaceName string
 	verLang   string
+	isSource  bool
+}
+
+func (d DepInfo) moduleName() string {
+	name := d.ifaceName + d.verLang
+	if d.isSource {
+		name += "-source"
+	}
+	return name
 }
 
 func aidlDeps(config android.Config) map[android.Module][]DepInfo {
@@ -1787,165 +783,3 @@
 	}
 	return nil
 }
-
-func aidlInterfacesMetadataSingletonFactory() android.Module {
-	i := &aidlInterfacesMetadataSingleton{}
-	android.InitAndroidModule(i)
-	return i
-}
-
-type aidlInterfacesMetadataSingleton struct {
-	android.ModuleBase
-
-	metadataPath android.OutputPath
-}
-
-var _ android.OutputFileProducer = (*aidlInterfacesMetadataSingleton)(nil)
-
-func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	if m.Name() != aidlMetadataSingletonName {
-		ctx.PropertyErrorf("name", "must be %s", aidlMetadataSingletonName)
-		return
-	}
-
-	type ModuleInfo struct {
-		Stability     string
-		ComputedTypes []string
-		HashFiles     []string
-	}
-
-	// name -> ModuleInfo
-	moduleInfos := map[string]ModuleInfo{}
-	ctx.VisitDirectDeps(func(m android.Module) {
-		if !m.ExportedToMake() {
-			return
-		}
-
-		switch t := m.(type) {
-		case *aidlInterface:
-			info := moduleInfos[t.ModuleBase.Name()]
-			info.Stability = proptools.StringDefault(t.properties.Stability, "")
-			info.ComputedTypes = t.computedTypes
-			moduleInfos[t.ModuleBase.Name()] = info
-		case *aidlGenRule:
-			info := moduleInfos[t.properties.BaseName]
-			if t.hashFile != nil {
-				info.HashFiles = append(info.HashFiles, t.hashFile.String())
-			}
-			moduleInfos[t.properties.BaseName] = info
-		default:
-			panic(fmt.Sprintf("Unrecognized module type: %v", t))
-		}
-
-	})
-
-	var metadataOutputs android.Paths
-	for name, info := range moduleInfos {
-		metadataPath := android.PathForModuleOut(ctx, "metadata_"+name)
-		metadataOutputs = append(metadataOutputs, metadataPath)
-
-		// There is one aidlGenRule per-version per-backend. If we had
-		// objects per version and sub-objects per backend, we could
-		// avoid needing to filter out duplicates.
-		info.HashFiles = android.FirstUniqueStrings(info.HashFiles)
-
-		implicits := android.PathsForSource(ctx, info.HashFiles)
-
-		ctx.Build(pctx, android.BuildParams{
-			Rule:      aidlMetadataRule,
-			Implicits: implicits,
-			Output:    metadataPath,
-			Args: map[string]string{
-				"name":      name,
-				"stability": info.Stability,
-				"types":     strings.Join(wrap(`\"`, info.ComputedTypes, `\"`), ", "),
-				"hashes": strings.Join(
-					wrap(`\"$$(read -r < `,
-						info.HashFiles,
-						` hash extra; printf '%s' $$hash)\"`), ", "),
-			},
-		})
-	}
-
-	m.metadataPath = android.PathForModuleOut(ctx, "aidl_metadata.json").OutputPath
-
-	ctx.Build(pctx, android.BuildParams{
-		Rule:   joinJsonObjectsToArrayRule,
-		Inputs: metadataOutputs,
-		Output: m.metadataPath,
-		Args: map[string]string{
-			"files": strings.Join(metadataOutputs.Strings(), " "),
-		},
-	})
-}
-
-func (m *aidlInterfacesMetadataSingleton) OutputFiles(tag string) (android.Paths, error) {
-	if tag != "" {
-		return nil, fmt.Errorf("unsupported tag %q", tag)
-	}
-
-	return android.Paths{m.metadataPath}, nil
-}
-
-type aidlMappingProperties struct {
-	// Source file of this prebuilt.
-	Srcs   []string `android:"path"`
-	Output string
-}
-
-type aidlMapping struct {
-	android.ModuleBase
-	properties     aidlMappingProperties
-	outputFilePath android.WritablePath
-}
-
-func (s *aidlMapping) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
-func (s *aidlMapping) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	srcs, imports := getPaths(ctx, s.properties.Srcs)
-
-	s.outputFilePath = android.PathForModuleOut(ctx, s.properties.Output)
-	outDir := android.PathForModuleGen(ctx)
-	ctx.Build(pctx, android.BuildParams{
-		Rule:   aidlDumpMappingsRule,
-		Inputs: srcs,
-		Output: s.outputFilePath,
-		Args: map[string]string{
-			"imports": android.JoinWithPrefix(imports, " -I"),
-			"outDir":  outDir.String(),
-		},
-	})
-}
-
-func InitAidlMappingModule(s *aidlMapping) {
-	s.AddProperties(&s.properties)
-}
-
-func aidlMappingFactory() android.Module {
-	module := &aidlMapping{}
-	InitAidlMappingModule(module)
-	android.InitAndroidModule(module)
-	return module
-}
-
-func (m *aidlMapping) AndroidMk() android.AndroidMkData {
-	return android.AndroidMkData{
-		Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
-			android.WriteAndroidMkData(w, data)
-			targetName := m.Name()
-			fmt.Fprintln(w, ".PHONY:", targetName)
-			fmt.Fprintln(w, targetName+":", m.outputFilePath.String())
-		},
-	}
-}
-
-func allAidlInterfacesMakeVars(ctx android.MakeVarsContext) {
-	names := []string{}
-	ctx.VisitAllModules(func(module android.Module) {
-		if ai, ok := module.(*aidlInterface); ok {
-			names = append(names, ai.BaseModuleName())
-		}
-	})
-	ctx.Strict("ALL_AIDL_INTERFACES", strings.Join(names, " "))
-}
diff --git a/build/aidl_interface_backends.go b/build/aidl_interface_backends.go
new file mode 100644
index 0000000..8c85c2a
--- /dev/null
+++ b/build/aidl_interface_backends.go
@@ -0,0 +1,469 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+	"android/soong/cc"
+	"android/soong/java"
+	"android/soong/rust"
+
+	"path/filepath"
+	"strings"
+
+	"github.com/google/blueprint/proptools"
+)
+
+func addLibrary(mctx android.LoadHookContext, i *aidlInterface, version string, lang string) string {
+	if lang == langJava {
+		return addJavaLibrary(mctx, i, version)
+	} else if lang == langRust {
+		return addRustLibrary(mctx, i, version)
+	}
+	return addCppLibrary(mctx, i, version, lang)
+}
+
+func addCppLibrary(mctx android.LoadHookContext, i *aidlInterface, version string, lang string) string {
+	cppSourceGen := i.versionedName(version) + "-" + lang + "-source"
+	cppModuleGen := i.versionedName(version) + "-" + lang
+
+	srcs, aidlRoot := i.srcsForVersion(mctx, version)
+	if len(srcs) == 0 {
+		// This can happen when the version is about to be frozen; the version
+		// directory is created but API dump hasn't been copied there.
+		// Don't create a library for the yet-to-be-frozen version.
+		return ""
+	}
+
+	var overrideVndkProperties cc.VndkProperties
+
+	if !i.isModuleForVndk(version) {
+		// We only want the VNDK to include the latest interface. For interfaces in
+		// development, they will be frozen, so we put their latest version in the
+		// VNDK. For interfaces which are already frozen, we put their latest version
+		// in the VNDK, and when that version is frozen, the version in the VNDK can
+		// be updated. Otherwise, we remove this library from the VNDK, to avoid adding
+		// multiple versions of the same library to the VNDK.
+		overrideVndkProperties.Vndk.Enabled = proptools.BoolPtr(false)
+		overrideVndkProperties.Vndk.Support_system_process = proptools.BoolPtr(false)
+	}
+
+	var commonProperties *CommonNativeBackendProperties
+	if lang == langCpp {
+		commonProperties = &i.properties.Backend.Cpp.CommonNativeBackendProperties
+	} else if lang == langNdk || lang == langNdkPlatform {
+		commonProperties = &i.properties.Backend.Ndk.CommonNativeBackendProperties
+	}
+
+	genLog := proptools.Bool(commonProperties.Gen_log)
+	genTrace := proptools.Bool(i.properties.Gen_trace)
+
+	mctx.CreateModule(aidlGenFactory, &nameProperties{
+		Name: proptools.StringPtr(cppSourceGen),
+	}, &aidlGenProperties{
+		Srcs:       srcs,
+		AidlRoot:   aidlRoot,
+		Imports:    concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
+		Stability:  i.properties.Stability,
+		Lang:       lang,
+		BaseName:   i.ModuleBase.Name(),
+		GenLog:     genLog,
+		Version:    i.versionForAidlGenRule(version),
+		GenTrace:   genTrace,
+		Unstable:   i.properties.Unstable,
+		Visibility: srcsVisibility(mctx, lang),
+		Flags:      i.properties.Flags,
+	})
+
+	importExportDependencies := []string{}
+	var sharedLibDependency []string
+	var headerLibs []string
+	var sdkVersion *string
+	var minSdkVersion *string
+	var stl *string
+	var cpp_std *string
+	var hostSupported *bool
+	var addCflags []string
+
+	if lang == langCpp {
+		importExportDependencies = append(importExportDependencies, "libbinder", "libutils")
+		if genTrace {
+			sharedLibDependency = append(sharedLibDependency, "libcutils")
+		}
+		hostSupported = i.properties.Host_supported
+		minSdkVersion = i.properties.Backend.Cpp.Min_sdk_version
+	} else if lang == langNdk {
+		importExportDependencies = append(importExportDependencies, "libbinder_ndk")
+		if genTrace {
+			sharedLibDependency = append(sharedLibDependency, "libandroid")
+		}
+		sdkVersion = proptools.StringPtr("current")
+		stl = proptools.StringPtr("c++_shared")
+		minSdkVersion = i.properties.Backend.Ndk.Min_sdk_version
+	} else if lang == langNdkPlatform {
+		importExportDependencies = append(importExportDependencies, "libbinder_ndk")
+		if genTrace {
+			headerLibs = append(headerLibs, "libandroid_aidltrace")
+			sharedLibDependency = append(sharedLibDependency, "libcutils")
+		}
+		hostSupported = i.properties.Host_supported
+		addCflags = append(addCflags, "-DBINDER_STABILITY_SUPPORT")
+		minSdkVersion = i.properties.Backend.Ndk.Min_sdk_version
+	} else {
+		panic("Unrecognized language: " + lang)
+	}
+
+	vendorAvailable := i.properties.Vendor_available
+	odmAvailable := i.properties.Odm_available
+	productAvailable := i.properties.Product_available
+	if lang == langCpp {
+		// Vendor and product modules cannot use the libbinder (cpp) backend of AIDL in a
+		// way that is stable. So, in order to prevent accidental usage of these library by
+		// vendor and product forcibly disabling this version of the library.
+		//
+		// It may be the case in the future that we will want to enable this (if some generic
+		// helper should be used by both libbinder vendor things using /dev/vndbinder as well
+		// as those things using /dev/binder + libbinder_ndk to talk to stable interfaces).
+		if "vintf" == proptools.String(i.properties.Stability) {
+			overrideVndkProperties.Vndk.Private = proptools.BoolPtr(true)
+		}
+		// As libbinder is not available for the product processes, we must not create
+		// product variant for the aidl_interface
+		productAvailable = nil
+	}
+
+	if lang == langNdk {
+		// TODO(b/121157555): when the NDK variant is its own variant, these wouldn't interact,
+		// but we can't create a vendor or product version of an NDK variant
+		//
+		// nil (unspecified) is used instead of false so that this can't conflict with
+		// 'vendor: true', for instance.
+		vendorAvailable = nil
+		odmAvailable = nil
+		productAvailable = nil
+		overrideVndkProperties.Vndk.Enabled = proptools.BoolPtr(false)
+		overrideVndkProperties.Vndk.Support_system_process = proptools.BoolPtr(false)
+	}
+
+	mctx.CreateModule(aidlImplementationGeneratorFactory, &nameProperties{
+		Name: proptools.StringPtr(cppModuleGen + "-generator"),
+	}, &aidlImplementationGeneratorProperties{
+		Lang:              lang,
+		AidlInterfaceName: i.ModuleBase.Name(),
+		Version:           version,
+		ModuleProperties: []interface{}{
+			&ccProperties{
+				Name:                      proptools.StringPtr(cppModuleGen),
+				Vendor_available:          vendorAvailable,
+				Odm_available:             odmAvailable,
+				Product_available:         productAvailable,
+				Host_supported:            hostSupported,
+				Defaults:                  []string{"aidl-cpp-module-defaults"},
+				Double_loadable:           i.properties.Double_loadable,
+				Generated_sources:         []string{cppSourceGen},
+				Generated_headers:         []string{cppSourceGen},
+				Export_generated_headers:  []string{cppSourceGen},
+				Shared_libs:               append(importExportDependencies, sharedLibDependency...),
+				Header_libs:               headerLibs,
+				Export_shared_lib_headers: importExportDependencies,
+				Sdk_version:               sdkVersion,
+				Stl:                       stl,
+				Cpp_std:                   cpp_std,
+				Cflags:                    append(addCflags, "-Wextra", "-Wall", "-Werror", "-Wextra-semi"),
+				Apex_available:            commonProperties.Apex_available,
+				Min_sdk_version:           minSdkVersion,
+				UseApexNameMacro:          true,
+				Target: ccTargetProperties{
+					// Currently necessary for host builds
+					// TODO(b/31559095): bionic on host should define this
+					// TODO(b/146436251): default isn't applied because the module is created
+					// in PreArchMutators, when import behavior becomes explicit, the logic can
+					// be moved back to LoadHook
+					Host: hostProperties{Cflags: []string{
+						"-D__INTRODUCED_IN(n)=",
+						"-D__assert(a,b,c)=",
+						// We want all the APIs to be available on the host.
+						"-D__ANDROID_API__=10000"}},
+					Darwin: perTargetProperties{Enabled: proptools.BoolPtr(false)}},
+				Tidy: proptools.BoolPtr(true),
+				// Do the tidy check only for the generated headers
+				Tidy_flags:            []string{"--header-filter=" + android.PathForOutput(mctx).String() + ".*"},
+				Tidy_checks_as_errors: []string{"*"},
+			}, &i.properties.VndkProperties,
+			&commonProperties.VndkProperties,
+			&overrideVndkProperties,
+		},
+	})
+
+	return cppModuleGen
+}
+
+func addJavaLibrary(mctx android.LoadHookContext, i *aidlInterface, version string) string {
+	javaSourceGen := i.versionedName(version) + "-java-source"
+	javaModuleGen := i.versionedName(version) + "-java"
+	srcs, aidlRoot := i.srcsForVersion(mctx, version)
+	if len(srcs) == 0 {
+		// This can happen when the version is about to be frozen; the version
+		// directory is created but API dump hasn't been copied there.
+		// Don't create a library for the yet-to-be-frozen version.
+		return ""
+	}
+
+	sdkVersion := i.properties.Backend.Java.Sdk_version
+	if !proptools.Bool(i.properties.Backend.Java.Platform_apis) && sdkVersion == nil {
+		// platform apis requires no default
+		sdkVersion = proptools.StringPtr("system_current")
+	}
+
+	mctx.CreateModule(aidlGenFactory, &nameProperties{
+		Name: proptools.StringPtr(javaSourceGen),
+	}, &aidlGenProperties{
+		Srcs:       srcs,
+		AidlRoot:   aidlRoot,
+		Imports:    concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
+		Stability:  i.properties.Stability,
+		Lang:       langJava,
+		BaseName:   i.ModuleBase.Name(),
+		Version:    i.versionForAidlGenRule(version),
+		GenTrace:   proptools.Bool(i.properties.Gen_trace),
+		Unstable:   i.properties.Unstable,
+		Visibility: srcsVisibility(mctx, langJava),
+		Flags:      i.properties.Flags,
+	})
+
+	mctx.CreateModule(aidlImplementationGeneratorFactory, &nameProperties{
+		Name: proptools.StringPtr(javaModuleGen + "-generator"),
+	}, &aidlImplementationGeneratorProperties{
+		Lang:              langJava,
+		AidlInterfaceName: i.ModuleBase.Name(),
+		Version:           version,
+		ModuleProperties: []interface{}{&javaProperties{
+			Name:            proptools.StringPtr(javaModuleGen),
+			Installable:     proptools.BoolPtr(true),
+			Defaults:        []string{"aidl-java-module-defaults"},
+			Sdk_version:     sdkVersion,
+			Platform_apis:   i.properties.Backend.Java.Platform_apis,
+			Srcs:            []string{":" + javaSourceGen},
+			Apex_available:  i.properties.Backend.Java.Apex_available,
+			Min_sdk_version: i.properties.Backend.Java.Min_sdk_version,
+		}},
+	})
+
+	return javaModuleGen
+}
+
+func addRustLibrary(mctx android.LoadHookContext, i *aidlInterface, version string) string {
+	rustSourceGen := i.versionedName(version) + "-rust-source"
+	rustModuleGen := i.versionedName(version) + "-rust"
+	srcs, aidlRoot := i.srcsForVersion(mctx, version)
+	if len(srcs) == 0 {
+		// This can happen when the version is about to be frozen; the version
+		// directory is created but API dump hasn't been copied there.
+		// Don't create a library for the yet-to-be-frozen version.
+		return ""
+	}
+
+	mctx.CreateModule(aidlGenFactory, &nameProperties{
+		Name: proptools.StringPtr(rustSourceGen),
+	}, &aidlGenProperties{
+		Srcs:       srcs,
+		AidlRoot:   aidlRoot,
+		Imports:    concat(i.properties.Imports, []string{i.ModuleBase.Name()}),
+		Stability:  i.properties.Stability,
+		Lang:       langRust,
+		BaseName:   i.ModuleBase.Name(),
+		Version:    i.versionForAidlGenRule(version),
+		Unstable:   i.properties.Unstable,
+		Visibility: srcsVisibility(mctx, langRust),
+		Flags:      i.properties.Flags,
+	})
+
+	versionedRustName := fixRustName(i.versionedName(version))
+	rustCrateName := fixRustName(i.ModuleBase.Name())
+
+	mctx.CreateModule(aidlRustLibraryFactory, &rustProperties{
+		Name:           proptools.StringPtr(rustModuleGen),
+		Crate_name:     rustCrateName,
+		Stem:           proptools.StringPtr("lib" + versionedRustName),
+		Defaults:       []string{"aidl-rust-module-defaults"},
+		Host_supported: i.properties.Host_supported,
+		Target:         rustTargetProperties{Darwin: perTargetProperties{Enabled: proptools.BoolPtr(false)}},
+	}, &rust.SourceProviderProperties{
+		Source_stem: proptools.StringPtr(versionedRustName),
+	}, &aidlRustSourceProviderProperties{
+		SourceGen:         rustSourceGen,
+		Imports:           i.properties.Imports,
+		Version:           version,
+		AidlInterfaceName: i.ModuleBase.Name(),
+	})
+
+	return rustModuleGen
+}
+
+// This function returns module name with version. Assume that there is foo of which latest version is 2
+// Version -> Module name
+// "1"->foo-V1
+// "2"->foo-V2
+// "3"->foo-V3
+// And assume that there is 'bar' which is an 'unstable' interface.
+// ""->bar
+func (i *aidlInterface) versionedName(version string) string {
+	name := i.ModuleBase.Name()
+	// TODO(b/150578172) remove exception when every module specify its version.
+	if version == "" {
+		return name
+	} else if version == unstableVersion {
+		return name + "-" + unstableVersion
+	}
+	return name + "-V" + version
+}
+
+func (i *aidlInterface) srcsForVersion(mctx android.LoadHookContext, version string) (srcs []string, aidlRoot string) {
+	// TODO(b/150578172) remove exception when every module specify its version.
+	version = i.normalizeVersion(version)
+	if version == i.nextVersion() {
+		return i.properties.Srcs, i.properties.Local_include_dir
+	} else {
+		aidlRoot = filepath.Join(aidlApiDir, i.ModuleBase.Name(), version)
+		full_paths, err := mctx.GlobWithDeps(filepath.Join(mctx.ModuleDir(), aidlRoot, "**/*.aidl"), nil)
+		if err != nil {
+			panic(err)
+		}
+		for _, path := range full_paths {
+			// Here, we need path local to the module
+			srcs = append(srcs, strings.TrimPrefix(path, mctx.ModuleDir()+"/"))
+		}
+		return srcs, aidlRoot
+	}
+}
+
+func (i *aidlInterface) versionForAidlGenRule(version string) string {
+	if !i.hasVersion() {
+		return ""
+	}
+	// TODO(b/150578172) remove exception when every module specify its version.
+	if version == "" {
+		return i.latestVersion()
+	}
+	if version == unstableVersion {
+		return i.nextVersion()
+	}
+	return version
+}
+
+func (i *aidlInterface) isModuleForVndk(version string) bool {
+	// TODO(b/150578172) remove exception when every module specify its version.
+	version = i.normalizeVersion(version)
+
+	if i.properties.Vndk_use_version != nil {
+		if !i.hasVersion() {
+			panic("does not make sense, vndk_use_version specififed")
+		}
+		// Will be exactly one of the version numbers
+		return version == *i.properties.Vndk_use_version
+	}
+
+	// For an interface with no versions, this is the ToT interface.
+	if !i.hasVersion() {
+		return version == i.nextVersion()
+	}
+
+	return version == i.latestVersion()
+}
+
+// importing aidl_interface's version  | imported aidl_interface | imported aidl_interface's version
+// --------------------------------------------------------------------------------------------------
+// whatever                            | unstable                | unstable version
+// ToT version(including unstable)     | whatever                | ToT version(unstable if unstable)
+// otherwise                           | whatever                | the latest stable version
+// TODO(b/146436251) Make import field specify the explicit version which it wants to import.
+func (i *aidlInterface) getImportWithVersion(version string, anImport string, config android.Config) string {
+	// TODO(b/150578172) remove exception when every module specify its version.
+	version = i.normalizeVersion(version)
+
+	other := lookupInterface(anImport, config)
+	if proptools.Bool(other.properties.Unstable) {
+		return anImport
+	}
+	if version == i.nextVersion() || !other.hasVersion() {
+		return other.versionedName(other.nextVersion())
+	}
+	return other.versionedName(other.latestVersion())
+}
+
+// TODO(b/150578172) remove exception when every module specify its version.
+func (i *aidlInterface) normalizeVersion(version string) string {
+	if version == "" {
+		if i.hasVersion() {
+			return i.latestVersion()
+		} else if !proptools.Bool(i.properties.Unstable) {
+			return i.nextVersion()
+		}
+	} else if version == unstableVersion {
+		return i.nextVersion()
+	}
+	return version
+}
+
+func aidlImplementationGeneratorFactory() android.Module {
+	g := &aidlImplementationGenerator{}
+	g.AddProperties(&g.properties)
+	android.InitAndroidModule(g)
+	return g
+}
+
+type aidlImplementationGenerator struct {
+	android.ModuleBase
+	properties aidlImplementationGeneratorProperties
+}
+
+type aidlImplementationGeneratorProperties struct {
+	Lang              string
+	AidlInterfaceName string
+	Version           string
+	ModuleProperties  []interface{}
+}
+
+func (g *aidlImplementationGenerator) DepsMutator(ctx android.BottomUpMutatorContext) {
+}
+
+func (g *aidlImplementationGenerator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+}
+
+func (g *aidlImplementationGenerator) GenerateImplementation(ctx android.TopDownMutatorContext) {
+	i := lookupInterface(g.properties.AidlInterfaceName, ctx.Config())
+	version := g.properties.Version
+	lang := g.properties.Lang
+	if g.properties.Lang == langJava {
+		imports := make([]string, len(i.properties.Imports))
+		for idx, anImport := range i.properties.Imports {
+			imports[idx] = i.getImportWithVersion(version, anImport, ctx.Config()) + "-" + langJava
+		}
+		if p, ok := g.properties.ModuleProperties[0].(*javaProperties); ok {
+			p.Static_libs = imports
+		}
+		ctx.CreateModule(java.LibraryFactory, g.properties.ModuleProperties...)
+	} else {
+		imports := make([]string, len(i.properties.Imports))
+		for idx, anImport := range i.properties.Imports {
+			imports[idx] = i.getImportWithVersion(version, anImport, ctx.Config()) + "-" + lang
+		}
+		if p, ok := g.properties.ModuleProperties[0].(*ccProperties); ok {
+			p.Shared_libs = append(p.Shared_libs, imports...)
+			p.Export_shared_lib_headers = append(p.Export_shared_lib_headers, imports...)
+		}
+		ctx.CreateModule(cc.LibraryFactory, g.properties.ModuleProperties...)
+	}
+}
diff --git a/build/aidl_interface_metadata_singleton.go b/build/aidl_interface_metadata_singleton.go
new file mode 100644
index 0000000..8d4f4fc
--- /dev/null
+++ b/build/aidl_interface_metadata_singleton.go
@@ -0,0 +1,156 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+
+	"fmt"
+	"strings"
+
+	"github.com/google/blueprint"
+	"github.com/google/blueprint/proptools"
+)
+
+var (
+	aidlMetadataRule = pctx.StaticRule("aidlMetadataRule", blueprint.RuleParams{
+		Command: `rm -f ${out} && { ` +
+			`echo '{' && ` +
+			`echo "\"name\": \"${name}\"," && ` +
+			`echo "\"stability\": \"${stability}\"," && ` +
+			`echo "\"types\": [${types}]," && ` +
+			`echo "\"hashes\": [${hashes}]" && ` +
+			`echo '}' ` +
+			`;} >> ${out}`,
+		Description: "AIDL metadata: ${out}",
+	}, "name", "stability", "types", "hashes")
+
+	joinJsonObjectsToArrayRule = pctx.StaticRule("joinJsonObjectsToArrayRule", blueprint.RuleParams{
+		Rspfile:        "$out.rsp",
+		RspfileContent: "$files",
+		Command: "rm -rf ${out} && " +
+			// Start the output array with an opening bracket.
+			"echo '[' >> ${out} && " +
+			// Append each input file and a comma to the output.
+			"for file in $$(cat ${out}.rsp); do " +
+			"cat $$file >> ${out}; echo ',' >> ${out}; " +
+			"done && " +
+			// Remove the last comma, replacing it with the closing bracket.
+			"sed -i '$$d' ${out} && echo ']' >> ${out}",
+		Description: "Joining JSON objects into array ${out}",
+	}, "files")
+)
+
+func init() {
+	android.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
+}
+
+func aidlInterfacesMetadataSingletonFactory() android.Module {
+	i := &aidlInterfacesMetadataSingleton{}
+	android.InitAndroidModule(i)
+	return i
+}
+
+type aidlInterfacesMetadataSingleton struct {
+	android.ModuleBase
+
+	metadataPath android.OutputPath
+}
+
+var _ android.OutputFileProducer = (*aidlInterfacesMetadataSingleton)(nil)
+
+func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+	if m.Name() != aidlMetadataSingletonName {
+		ctx.PropertyErrorf("name", "must be %s", aidlMetadataSingletonName)
+		return
+	}
+
+	type ModuleInfo struct {
+		Stability     string
+		ComputedTypes []string
+		HashFiles     []string
+	}
+
+	// name -> ModuleInfo
+	moduleInfos := map[string]ModuleInfo{}
+	ctx.VisitDirectDeps(func(m android.Module) {
+		if !m.ExportedToMake() {
+			return
+		}
+
+		switch t := m.(type) {
+		case *aidlInterface:
+			info := moduleInfos[t.ModuleBase.Name()]
+			info.Stability = proptools.StringDefault(t.properties.Stability, "")
+			info.ComputedTypes = t.computedTypes
+			moduleInfos[t.ModuleBase.Name()] = info
+		case *aidlGenRule:
+			info := moduleInfos[t.properties.BaseName]
+			if t.hashFile != nil {
+				info.HashFiles = append(info.HashFiles, t.hashFile.String())
+			}
+			moduleInfos[t.properties.BaseName] = info
+		}
+
+	})
+
+	var metadataOutputs android.Paths
+	for _, name := range android.SortedStringKeys(moduleInfos) {
+		info := moduleInfos[name]
+		metadataPath := android.PathForModuleOut(ctx, "metadata_"+name)
+		metadataOutputs = append(metadataOutputs, metadataPath)
+
+		// There is one aidlGenRule per-version per-backend. If we had
+		// objects per version and sub-objects per backend, we could
+		// avoid needing to filter out duplicates.
+		info.HashFiles = android.FirstUniqueStrings(info.HashFiles)
+
+		implicits := android.PathsForSource(ctx, info.HashFiles)
+
+		ctx.Build(pctx, android.BuildParams{
+			Rule:      aidlMetadataRule,
+			Implicits: implicits,
+			Output:    metadataPath,
+			Args: map[string]string{
+				"name":      name,
+				"stability": info.Stability,
+				"types":     strings.Join(wrap(`\"`, info.ComputedTypes, `\"`), ", "),
+				"hashes": strings.Join(
+					wrap(`\"$$(read -r < `,
+						info.HashFiles,
+						` hash extra; printf '%s' $$hash)\"`), ", "),
+			},
+		})
+	}
+
+	m.metadataPath = android.PathForModuleOut(ctx, "aidl_metadata.json").OutputPath
+
+	ctx.Build(pctx, android.BuildParams{
+		Rule:   joinJsonObjectsToArrayRule,
+		Inputs: metadataOutputs,
+		Output: m.metadataPath,
+		Args: map[string]string{
+			"files": strings.Join(metadataOutputs.Strings(), " "),
+		},
+	})
+}
+
+func (m *aidlInterfacesMetadataSingleton) OutputFiles(tag string) (android.Paths, error) {
+	if tag != "" {
+		return nil, fmt.Errorf("unsupported tag %q", tag)
+	}
+
+	return android.Paths{m.metadataPath}, nil
+}
diff --git a/build/aidl_mapping.go b/build/aidl_mapping.go
new file mode 100644
index 0000000..b48e61e
--- /dev/null
+++ b/build/aidl_mapping.go
@@ -0,0 +1,102 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+
+	"fmt"
+	"io"
+	"strings"
+
+	"github.com/google/blueprint"
+)
+
+var (
+	aidlDumpMappingsRule = pctx.StaticRule("aidlDumpMappingsRule", blueprint.RuleParams{
+		Command: `rm -rf "${outDir}" && mkdir -p "${outDir}" && ` +
+			`${aidlCmd} --apimapping ${outDir}/intermediate.txt ${in} ${imports} && ` +
+			`${aidlToJniCmd} ${outDir}/intermediate.txt ${out}`,
+		CommandDeps: []string{"${aidlCmd}"},
+	}, "imports", "outDir")
+)
+
+func init() {
+	android.RegisterModuleType("aidl_mapping", aidlMappingFactory)
+	android.RegisterMakeVarsProvider(pctx, allAidlInterfacesMakeVars)
+}
+
+type aidlMappingProperties struct {
+	// Source file of this prebuilt.
+	Srcs   []string `android:"path"`
+	Output string
+}
+
+type aidlMapping struct {
+	android.ModuleBase
+	properties     aidlMappingProperties
+	outputFilePath android.WritablePath
+}
+
+func (s *aidlMapping) DepsMutator(ctx android.BottomUpMutatorContext) {
+}
+
+func (s *aidlMapping) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+	srcs, imports := getPaths(ctx, s.properties.Srcs)
+
+	s.outputFilePath = android.PathForModuleOut(ctx, s.properties.Output)
+	outDir := android.PathForModuleGen(ctx)
+	ctx.Build(pctx, android.BuildParams{
+		Rule:   aidlDumpMappingsRule,
+		Inputs: srcs,
+		Output: s.outputFilePath,
+		Args: map[string]string{
+			"imports": android.JoinWithPrefix(imports, " -I"),
+			"outDir":  outDir.String(),
+		},
+	})
+}
+
+func InitAidlMappingModule(s *aidlMapping) {
+	s.AddProperties(&s.properties)
+}
+
+func aidlMappingFactory() android.Module {
+	module := &aidlMapping{}
+	InitAidlMappingModule(module)
+	android.InitAndroidModule(module)
+	return module
+}
+
+func (m *aidlMapping) AndroidMk() android.AndroidMkData {
+	return android.AndroidMkData{
+		Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+			android.WriteAndroidMkData(w, data)
+			targetName := m.Name()
+			fmt.Fprintln(w, ".PHONY:", targetName)
+			fmt.Fprintln(w, targetName+":", m.outputFilePath.String())
+		},
+	}
+}
+
+func allAidlInterfacesMakeVars(ctx android.MakeVarsContext) {
+	names := []string{}
+	ctx.VisitAllModules(func(module android.Module) {
+		if ai, ok := module.(*aidlInterface); ok {
+			names = append(names, ai.BaseModuleName())
+		}
+	})
+	ctx.Strict("ALL_AIDL_INTERFACES", strings.Join(names, " "))
+}
diff --git a/build/aidl_rust_glue.py b/build/aidl_rust_glue.py
index 86bbdd0..ef31c3b 100755
--- a/build/aidl_rust_glue.py
+++ b/build/aidl_rust_glue.py
@@ -73,11 +73,6 @@
   with open(output, "w") as lib_rs_file:
     lib_rs_file.write("#![allow(non_snake_case)]\n")
     lib_rs_file.write("#![allow(missing_docs)]\n")
-    # Disable clippy error for `FIRST_CALL_TRANSACTION + 0`
-    lib_rs_file.write("#![allow(clippy::identity_op)]\n")
-    # Disable clippy error for extra zeroes on floating-point numbers
-    lib_rs_file.write("#![allow(clippy::excessive_precision)]\n")
-    lib_rs_file.write("#![allow(clippy::too_many_arguments)]\n")
     lib_rs_file.write("pub use binder::public_api as binder;\n")
 
     lib_rs_file.write("pub mod aidl {\n")
@@ -95,7 +90,7 @@
   parser.add_argument('output', help='Path to output .rs file')
   parser.add_argument('root', help='Common ancestor of all input files')
   parser.add_argument('inputs', nargs='+', help='Input .rs files')
-  parser.add_argument('-I', '--import', nargs='*', dest='imports',
+  parser.add_argument('-I', '--import', action='append', dest='imports',
                       default=[], help='Crates to import')
 
   args = parser.parse_args()
diff --git a/build/aidl_rust_source_provider.go b/build/aidl_rust_source_provider.go
new file mode 100644
index 0000000..7759045
--- /dev/null
+++ b/build/aidl_rust_source_provider.go
@@ -0,0 +1,127 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+	"android/soong/rust"
+
+	"strings"
+
+	"github.com/google/blueprint"
+	"github.com/google/blueprint/proptools"
+)
+
+var (
+	aidlRustGlueRule = pctx.StaticRule("aidlRustGlueRule", blueprint.RuleParams{
+		Command:     `${aidlRustGlueCmd} ${out} ${root} ${in} ${imports}`,
+		CommandDeps: []string{"${aidlRustGlueCmd}"},
+	}, "root", "imports")
+)
+
+type aidlRustSourceProviderProperties struct {
+	SourceGen         string `android:"path"`
+	Imports           []string
+	Version           string
+	AidlInterfaceName string
+}
+
+type aidlRustSourceProvider struct {
+	*rust.BaseSourceProvider
+
+	properties aidlRustSourceProviderProperties
+}
+
+var aidlRustSourceTag = struct {
+	blueprint.DependencyTag
+}{}
+
+func (sp *aidlRustSourceProvider) GenerateSource(ctx rust.ModuleContext, _ rust.PathDeps) android.Path {
+	sourceStem := proptools.String(sp.BaseSourceProvider.Properties.Source_stem)
+	topLevelOutputFile := android.PathForModuleOut(ctx, sourceStem+".rs")
+
+	aidlGenModule := ctx.GetDirectDepWithTag(sp.properties.SourceGen, aidlRustSourceTag)
+	// Find the gen directory for the source module
+	srcGenDir := aidlGenModule.(*aidlGenRule).genOutDir
+	srcPaths := aidlGenModule.(*aidlGenRule).genOutputs.Paths()
+
+	// In Rust, we import our dependency crates into `mangled`:
+	//   use dependency::mangled::*;
+	// so we can use the crate:: Rust path prefix to refer to
+	// both crate-local and imported paths (from dependencies)
+	importFlags := make([]string, len(sp.properties.Imports))
+	for i, dep := range sp.properties.Imports {
+		importFlags[i] = "-I" + fixRustName(dep)
+	}
+
+	// In Rust, we need to do some extra post-processing:
+	// emit a top-level foo.rs that includes all the generated .rs
+	// files verbatim ("glued" together). The generated glue file
+	// replicates the AIDL package hierarchy from the input
+	// .aidl files in two ways:
+	//   * 1:1 mapping in the crate::aidl namespace, used by downstream users
+	//   * mangled in the crate::mangled namespace, used internally
+	//     to resolve AIDL package paths between dependencies
+	ctx.Build(pctx, android.BuildParams{
+		Rule:   aidlRustGlueRule,
+		Inputs: srcPaths,
+		Output: topLevelOutputFile,
+		Args: map[string]string{
+			"root":    srcGenDir.String(),
+			"imports": strings.Join(importFlags, " "),
+		},
+	})
+
+	sp.BaseSourceProvider.OutputFiles = android.Paths{topLevelOutputFile}
+	return topLevelOutputFile
+}
+
+func (sp *aidlRustSourceProvider) SourceProviderProps() []interface{} {
+	return append(sp.BaseSourceProvider.SourceProviderProps(),
+		&sp.properties)
+}
+
+func (sp *aidlRustSourceProvider) SourceProviderDeps(ctx rust.DepsContext, deps rust.Deps) rust.Deps {
+	deps = sp.BaseSourceProvider.SourceProviderDeps(ctx, deps)
+	deps.Rustlibs = append(deps.Rustlibs, "libbinder_rs", "liblazy_static")
+	ai := lookupInterface(sp.properties.AidlInterfaceName, ctx.Config())
+	for _, dep := range sp.properties.Imports {
+		deps.Rustlibs = append(deps.Rustlibs, ai.getImportWithVersion(sp.properties.Version, dep, ctx.Config())+"-"+langRust)
+	}
+
+	// Add a depencency to the source module (*-rust-source) directly via `ctx` because
+	// the source module is specific to aidlRustSourceProvider and we don't want the rust module
+	// to know about it.
+	ctx.AddDependency(ctx.Module(), aidlRustSourceTag, sp.properties.SourceGen)
+
+	return deps
+}
+
+func (sp *aidlRustSourceProvider) AndroidMk(ctx rust.AndroidMkContext, ret *android.AndroidMkEntries) {
+	ctx.SubAndroidMk(ret, sp.BaseSourceProvider)
+	ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) {
+		entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
+	})
+}
+
+func aidlRustLibraryFactory() android.Module {
+	sourceProvider := &aidlRustSourceProvider{
+		BaseSourceProvider: rust.NewSourceProvider(),
+		properties:         aidlRustSourceProviderProperties{},
+	}
+
+	module := rust.NewSourceProviderModule(android.HostAndDeviceSupported, sourceProvider, false)
+	return module.Init()
+}
diff --git a/build/aidl_test.go b/build/aidl_test.go
index e0386f8..4e165e3 100644
--- a/build/aidl_test.go
+++ b/build/aidl_test.go
@@ -15,6 +15,7 @@
 package aidl
 
 import (
+	"fmt"
 	"io/ioutil"
 	"os"
 	"path/filepath"
@@ -79,6 +80,9 @@
 	bp = bp + java.GatherRequiredDepsForTest()
 	bp = bp + cc.GatherRequiredDepsForTest(android.Android)
 	bp = bp + `
+		package {
+			default_visibility: ["//visibility:public"],
+		}
 		java_defaults {
 			name: "aidl-java-module-defaults",
 		}
@@ -170,26 +174,32 @@
 		c(tempFS, config)
 	}
 
-	ctx := android.NewTestArchContext()
+	ctx := android.NewTestArchContext(config)
+	android.RegisterPackageBuildComponents(ctx)
+	ctx.PreArchMutators(android.RegisterVisibilityRuleChecker)
+
 	cc.RegisterRequiredBuildComponentsForTest(ctx)
+	java.RegisterRequiredBuildComponentsForTest(ctx)
 	ctx.RegisterModuleType("aidl_interface", aidlInterfaceFactory)
 	ctx.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
-	ctx.RegisterModuleType("android_app", java.AndroidAppFactory)
-	ctx.RegisterModuleType("java_defaults", func() android.Module {
-		return java.DefaultsFactory()
-	})
 	ctx.RegisterModuleType("rust_defaults", func() android.Module {
 		return rust.DefaultsFactory()
 	})
 	ctx.RegisterModuleType("rust_library", rust.RustLibraryFactory)
-	ctx.RegisterModuleType("java_library_static", java.LibraryStaticFactory)
-	ctx.RegisterModuleType("java_library", java.LibraryFactory)
-	ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory)
 
 	ctx.RegisterModuleType("apex", apex.BundleFactory)
 	ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
 
 	ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
+	ctx.PreArchMutators(android.RegisterVisibilityRuleGatherer)
+
+	ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
+		ctx.BottomUp("checkImports", checkImports)
+		ctx.TopDown("createAidlInterface", createAidlInterfaceMutator)
+	})
+
+	ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
+
 	ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
 		ctx.BottomUp("rust_libraries", rust.LibraryMutator).Parallel()
 		ctx.BottomUp("rust_stdlinkage", rust.LibstdMutator).Parallel()
@@ -200,9 +210,10 @@
 	ctx.PostDepsMutators(apex.RegisterPostDepsMutators)
 	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
 		ctx.BottomUp("checkUnstableModule", checkUnstableModuleMutator).Parallel()
+		ctx.BottomUp("recordVersions", recordVersions).Parallel()
 		ctx.BottomUp("checkDuplicatedVersions", checkDuplicatedVersions).Parallel()
 	})
-	ctx.Register(config)
+	ctx.Register()
 
 	return ctx, config
 }
@@ -210,7 +221,7 @@
 func testAidl(t *testing.T, bp string, customizers ...testCustomizer) (*android.TestContext, android.Config) {
 	t.Helper()
 	ctx, config := _testAidl(t, bp, customizers...)
-	_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
+	_, errs := ctx.ParseBlueprintsFiles("Android.bp")
 	android.FailIfErrored(t, errs)
 	_, errs = ctx.PrepareBuildActions(config)
 	android.FailIfErrored(t, errs)
@@ -220,7 +231,7 @@
 func testAidlError(t *testing.T, pattern, bp string, customizers ...testCustomizer) {
 	t.Helper()
 	ctx, config := _testAidl(t, bp, customizers...)
-	_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
+	_, errs := ctx.ParseBlueprintsFiles("Android.bp")
 	if len(errs) > 0 {
 		android.FailIfNoMatchingErrors(t, pattern, errs)
 		return
@@ -235,6 +246,7 @@
 
 // asserts that there are expected module regardless of variants
 func assertModulesExists(t *testing.T, ctx *android.TestContext, names ...string) {
+	t.Helper()
 	missing := []string{}
 	for _, name := range names {
 		variants := ctx.ModuleVariantsForTests(name)
@@ -252,6 +264,23 @@
 	}
 }
 
+func assertContains(t *testing.T, actual, expected string) {
+	t.Helper()
+	if !strings.Contains(actual, expected) {
+		t.Errorf("%q is not found in %q.", expected, actual)
+	}
+}
+
+func assertListContains(t *testing.T, actual []string, expected string) {
+	t.Helper()
+	for _, a := range actual {
+		if strings.Contains(a, expected) {
+			return
+		}
+	}
+	t.Errorf("%q is not found in %v.", expected, actual)
+}
+
 // Vintf module must have versions in release version
 func TestVintfWithoutVersionInRelease(t *testing.T) {
 	vintfWithoutVersionBp := `
@@ -271,7 +300,7 @@
 	testAidlError(t, expectedError, vintfWithoutVersionBp, setReleaseEnv())
 
 	ctx, _ := testAidl(t, vintfWithoutVersionBp)
-	assertModulesExists(t, ctx, "foo-java", "foo-rust", "foo-cpp", "foo-ndk", "foo-ndk_platform")
+	assertModulesExists(t, ctx, "foo-V1-java", "foo-V1-rust", "foo-V1-cpp", "foo-V1-ndk", "foo-V1-ndk_platform")
 }
 
 // Check if using unstable version in release cause an error.
@@ -288,10 +317,10 @@
 	}
 	java_library {
 		name: "bar",
-		libs: ["foo-unstable-java"],
+		libs: ["foo-V2-java"],
 	}`
 
-	expectedError := `unstable-java is disallowed in release version because it is unstable.`
+	expectedError := `foo-V2-java is disallowed in release version because it is unstable.`
 	testAidlError(t, expectedError, unstableVersionUsageInJavaBp, setReleaseEnv(), withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
 	}))
@@ -313,7 +342,7 @@
 	}
 	java_library {
 		name: "bar",
-		libs: ["foo-java"],
+		libs: ["foo-V1-java"],
 	}`
 
 	testAidl(t, stableVersionUsageInJavaBp, setReleaseEnv(), withFiles(map[string][]byte{
@@ -337,7 +366,7 @@
 
 	java_library {
 		name: "bar",
-		libs: ["foo-java"],
+		libs: ["foo-V1-java"],
 	}`
 
 	expectedError := `"foo_interface": versions: must be set \(need to be frozen\) when "unstable" is false, PLATFORM_VERSION_CODENAME is REL, and "owner" property is missing.`
@@ -430,7 +459,7 @@
 		}
 	`)
 
-	assertModulesExists(t, ctx, "foo-java", "foo-rust", "foo-cpp", "foo-ndk", "foo-ndk_platform")
+	assertModulesExists(t, ctx, "foo-V1-java", "foo-V1-rust", "foo-V1-cpp", "foo-V1-ndk", "foo-V1-ndk_platform")
 }
 
 func TestCreatesModulesWithFrozenVersions(t *testing.T) {
@@ -471,15 +500,75 @@
 		"aidl_api/foo/1/foo.1.aidl": nil,
 	}))
 
-	// For alias for the latest frozen version (=1)
-	assertModulesExists(t, ctx, "foo-java", "foo-rust", "foo-cpp", "foo-ndk", "foo-ndk_platform")
-
 	// For frozen version "1"
-	// Note that it is not yet implemented to generate native modules for latest frozen version
-	assertModulesExists(t, ctx, "foo-V1-java")
+	assertModulesExists(t, ctx, "foo-V1-java", "foo-V1-rust", "foo-V1-cpp", "foo-V1-ndk", "foo-V1-ndk_platform")
 
 	// For ToT (current)
-	assertModulesExists(t, ctx, "foo-unstable-java", "foo-unstable-rust", "foo-unstable-cpp", "foo-unstable-ndk", "foo-unstable-ndk_platform")
+	assertModulesExists(t, ctx, "foo-V2-java", "foo-V2-rust", "foo-V2-cpp", "foo-V2-ndk", "foo-V2-ndk_platform")
+}
+
+func TestErrorsWithUnsortedVersions(t *testing.T) {
+	testAidlError(t, `versions: should be sorted`, `
+		aidl_interface {
+			name: "foo",
+			srcs: [
+				"IFoo.aidl",
+			],
+			versions: [
+				"2",
+				"1",
+			],
+			backend: {
+				rust: {
+					enabled: true,
+				},
+			},
+		}
+	`)
+}
+
+func TestErrorsWithDuplicateVersions(t *testing.T) {
+	testAidlError(t, `versions: duplicate`, `
+		aidl_interface {
+			name: "foo",
+			srcs: [
+				"IFoo.aidl",
+			],
+			versions: [
+				"1",
+				"1",
+			],
+		}
+	`)
+}
+
+func TestErrorsWithNonPositiveVersions(t *testing.T) {
+	testAidlError(t, `versions: should be > 0`, `
+		aidl_interface {
+			name: "foo",
+			srcs: [
+				"IFoo.aidl",
+			],
+			versions: [
+				"-1",
+				"1",
+			],
+		}
+	`)
+}
+
+func TestErrorsWithNonIntegerVersions(t *testing.T) {
+	testAidlError(t, `versions: "first" is not an integer`, `
+		aidl_interface {
+			name: "foo",
+			srcs: [
+				"IFoo.aidl",
+			],
+			versions: [
+				"first",
+			],
+		}
+	`)
 }
 
 const (
@@ -519,13 +608,11 @@
 			},
 		}
 	`)
-	// It's the only exception, <name>-<backend> generates the artifact of which name is <name>-<backend>,
-	// if it doesn't have a version.
-	assertOutput("foo-java", androidVariant, "foo-java.jar")
+	// Even though there is no version, generated modules have version(V1) unless it isn't an unstable interface.
+	assertOutput("foo-V1-java", androidVariant, "foo-V1-java.jar")
 
-	assertOutput("foo-cpp", nativeVariant, "foo-cpp.so")
-	assertOutput("foo-unstable-cpp", nativeVariant, "foo-V1-cpp.so")
-	assertOutput("foo-rust", nativeRustVariant, "libfoo.dylib.so")
+	assertOutput("foo-V1-cpp", nativeVariant, "foo-V1-cpp.so")
+	assertOutput("foo-V1-rust", nativeRustVariant, "libfoo_V1.dylib.so")
 
 	// With versions: "1", "2"
 	ctx, _ = testAidl(t, `
@@ -549,9 +636,9 @@
 	}))
 
 	// alias for the latest frozen version (=2)
-	assertOutput("foo-java", androidVariant, "foo-java.jar")
-	assertOutput("foo-cpp", nativeVariant, "foo-V2-cpp.so")
-	assertOutput("foo-rust", nativeRustVariant, "libfoo.dylib.so")
+	assertOutput("foo-V2-java", androidVariant, "foo-V2-java.jar")
+	assertOutput("foo-V2-cpp", nativeVariant, "foo-V2-cpp.so")
+	assertOutput("foo-V2-rust", nativeRustVariant, "libfoo_V2.dylib.so")
 
 	// frozen "1"
 	assertOutput("foo-V1-java", androidVariant, "foo-V1-java.jar")
@@ -559,45 +646,13 @@
 	assertOutput("foo-V1-rust", nativeRustVariant, "libfoo_V1.dylib.so")
 
 	// tot
-	assertOutput("foo-unstable-java", androidVariant, "foo-unstable-java.jar")
-	assertOutput("foo-unstable-cpp", nativeVariant, "foo-V3-cpp.so")
-	assertOutput("foo-unstable-rust", nativeRustVariant, "libfoo_unstable.dylib.so")
+	assertOutput("foo-V3-java", androidVariant, "foo-V3-java.jar")
+	assertOutput("foo-V3-cpp", nativeVariant, "foo-V3-cpp.so")
+	assertOutput("foo-V3-rust", nativeRustVariant, "libfoo_V3.dylib.so")
 
 	// skip ndk/ndk_platform since they follow the same rule with cpp
 }
 
-func TestGenLogForNativeBackendRequiresJson(t *testing.T) {
-	testAidlError(t, `"foo-cpp" depends on .*"libjsoncpp"`, `
-		aidl_interface {
-			name: "foo",
-			srcs: [
-				"IFoo.aidl",
-			],
-			backend: {
-				cpp: {
-					gen_log: true,
-				},
-			},
-		}
-	`)
-	testAidl(t, `
-		aidl_interface {
-			name: "foo",
-			srcs: [
-				"IFoo.aidl",
-			],
-			backend: {
-				cpp: {
-					gen_log: true,
-				},
-			},
-		}
-		cc_library {
-			name: "libjsoncpp",
-		}
-	`)
-}
-
 func TestImports(t *testing.T) {
 	testAidlError(t, `Import does not exist:`, `
 		aidl_interface {
@@ -685,16 +740,16 @@
 		}
 	`)
 
-	ldRule := ctx.ModuleForTests("foo-cpp", nativeVariant).Rule("ld")
+	ldRule := ctx.ModuleForTests("foo-V1-cpp", nativeVariant).Rule("ld")
 	libFlags := ldRule.Args["libFlags"]
-	libBar := filepath.Join("bar.1-unstable-cpp", nativeVariant, "bar.1-V1-cpp.so")
+	libBar := filepath.Join("bar.1-V1-cpp", nativeVariant, "bar.1-V1-cpp.so")
 	if !strings.Contains(libFlags, libBar) {
 		t.Errorf("%q is not found in %q", libBar, libFlags)
 	}
 
-	rustcRule := ctx.ModuleForTests("foo-rust", nativeRustVariant).Rule("rustc")
+	rustcRule := ctx.ModuleForTests("foo-V1-rust", nativeRustVariant).Rule("rustc")
 	libFlags = rustcRule.Args["libFlags"]
-	libBar = filepath.Join(buildDir, ".intermediates", "bar.1-rust", nativeRustVariant, "libbar_1.dylib.so")
+	libBar = filepath.Join(buildDir, ".intermediates", "bar.1-V1-rust", nativeRustVariant, "libbar_1_V1.dylib.so")
 	libBarFlag := "--extern bar_1=" + libBar
 	if !strings.Contains(libFlags, libBarFlag) {
 		t.Errorf("%q is not found in %q", libBarFlag, libFlags)
@@ -702,9 +757,9 @@
 }
 
 func TestDuplicatedVersions(t *testing.T) {
-	// foo depends on myiface-ndk (v2) via direct dep and also on
+	// foo depends on myiface-V2-ndk via direct dep and also on
 	// myiface-V1-ndk via indirect dep. This should be prohibited.
-	testAidlError(t, `multiple versions of aidl_interface myiface \(backend:ndk\) are used`, `
+	testAidlError(t, `depends on multiple versions of the same aidl_interface: myiface-V1-ndk, myiface-V2-ndk`, `
 		aidl_interface {
 			name: "myiface",
 			srcs: ["IFoo.aidl"],
@@ -713,7 +768,7 @@
 
 		cc_library {
 			name: "foo",
-			shared_libs: ["myiface-ndk", "bar"],
+			shared_libs: ["myiface-V2-ndk", "bar"],
 		}
 
 		cc_library {
@@ -727,7 +782,7 @@
 		"aidl_api/myiface/2/myiface.2.aidl": nil,
 		"aidl_api/myiface/2/.hash":          nil,
 	}))
-	testAidlError(t, `multiple versions of aidl_interface myiface \(backend:ndk\) are used`, `
+	testAidlError(t, `depends on multiple versions of the same aidl_interface: myiface-V1-ndk, myiface-V2-ndk`, `
 		aidl_interface {
 			name: "myiface",
 			srcs: ["IFoo.aidl"],
@@ -742,7 +797,63 @@
 
 		cc_library {
 			name: "foobar",
-			shared_libs: ["myiface-ndk", "myiface2-ndk"],
+			shared_libs: ["myiface-V1-ndk", "myiface2-V1-ndk"],
+		}
+
+	`, withFiles(map[string][]byte{
+		"aidl_api/myiface/1/myiface.1.aidl": nil,
+		"aidl_api/myiface/1/.hash":          nil,
+	}))
+	testAidlError(t, `depends on multiple versions of the same aidl_interface: myiface-V1-ndk-source, myiface-V2-ndk`, `
+		aidl_interface {
+			name: "myiface",
+			srcs: ["IFoo.aidl"],
+			versions: ["1"],
+			backend: {
+				ndk: {
+					srcs_available: true,
+				},
+			},
+		}
+
+		aidl_interface {
+			name: "myiface2",
+			srcs: ["IBar.aidl"],
+			imports: ["myiface"]
+		}
+
+		cc_library {
+			name: "foobar",
+			srcs: [":myiface-V1-ndk-source"],
+			shared_libs: ["myiface2-V1-ndk"],
+		}
+
+	`, withFiles(map[string][]byte{
+		"aidl_api/myiface/1/myiface.1.aidl": nil,
+		"aidl_api/myiface/1/.hash":          nil,
+	}))
+	testAidl(t, `
+		aidl_interface {
+			name: "myiface",
+			srcs: ["IFoo.aidl"],
+			versions: ["1"],
+			backend: {
+				ndk: {
+					srcs_available: true,
+				},
+			},
+		}
+
+		aidl_interface {
+			name: "myiface2",
+			srcs: ["IBar.aidl"],
+			imports: ["myiface"]
+		}
+
+		cc_library {
+			name: "foobar",
+			srcs: [":myiface-V2-ndk-source"],
+			shared_libs: ["myiface2-V1-ndk"],
 		}
 
 	`, withFiles(map[string][]byte{
@@ -764,7 +875,7 @@
 
 		cc_library {
 			name: "foobar",
-			shared_libs: ["myiface-unstable-ndk", "myiface2-ndk"],
+			shared_libs: ["myiface-V2-ndk", "myiface2-V1-ndk"],
 		}
 
 	`, withFiles(map[string][]byte{
@@ -779,6 +890,7 @@
 			name: "myiface",
 			srcs: ["IFoo.aidl"],
 			vendor_available: true,
+			product_available: true,
 			unstable: true,
 			vndk: {
 				enabled: true,
@@ -789,6 +901,7 @@
 		aidl_interface {
 			name: "myiface",
 			vendor_available: true,
+			product_available: true,
 			srcs: ["IFoo.aidl"],
 			vndk: {
 				enabled: true,
@@ -799,6 +912,7 @@
 		aidl_interface {
 			name: "myiface",
 			vendor_available: true,
+			product_available: true,
 			srcs: ["IFoo.aidl"],
 			stability: "vintf",
 			vndk: {
@@ -822,7 +936,7 @@
 		apex {
 			name: "myapex",
 			key: "myapex.key",
-			native_shared_libs: ["myiface-ndk_platform"],
+			native_shared_libs: ["myiface-V1-ndk_platform"],
 		}
 		apex_key {
 			name: "myapex.key",
@@ -833,15 +947,86 @@
 		"system/sepolicy/apex/myapex-file_contexts": nil,
 	}))
 
-	assertContains := func(t *testing.T, actual, expected string) {
-		t.Helper()
-		if !strings.Contains(actual, expected) {
-			t.Errorf("%q is not found in %q.", expected, actual)
-		}
-	}
-
-	ccRule := ctx.ModuleForTests("myiface-ndk_platform", "android_arm64_armv8-a_static_myapex").Rule("cc")
+	ccRule := ctx.ModuleForTests("myiface-V1-ndk_platform", "android_arm64_armv8-a_static_myapex").Rule("cc")
 	assertContains(t, ccRule.Args["cFlags"], "-D__ANDROID_APEX__")
 	assertContains(t, ccRule.Args["cFlags"], "-D__ANDROID_APEX_NAME__='\"myapex\"'")
 	assertContains(t, ccRule.Args["cFlags"], "-D__ANDROID_APEX_MYAPEX__")
 }
+
+func TestSrcsAvailable(t *testing.T) {
+	bp := `
+		aidl_interface {
+			name: "myiface",
+			srcs: ["IFoo.aidl"],
+			backend: {
+				java: {
+					srcs_available: %s,
+				},
+				cpp: {
+					srcs_available: %s,
+				},
+			},
+		}
+	`
+	customizer := withFiles(map[string][]byte{
+		"otherpackage/Android.bp": []byte(`
+			java_library {
+				name: "javalib",
+				srcs: [":myiface-V1-java-source"],
+			}
+			cc_library_shared {
+				name: "cclib",
+				srcs: [":myiface-V1-cpp-source"],
+			}
+		`),
+	})
+	ctx, _ := testAidl(t, fmt.Sprintf(bp, "true", "true"), customizer)
+	javaInputs := ctx.ModuleForTests("javalib", "android_common").Rule("javac").Inputs.Strings()
+	assertListContains(t, javaInputs, "myiface-V1-java-source/gen/IFoo.java")
+	ccInput := ctx.ModuleForTests("cclib", "android_arm64_armv8-a_shared").Rule("cc").Input.String()
+	assertContains(t, ccInput, "myiface-V1-cpp-source/gen/IFoo.cpp")
+
+	testAidlError(t, `depends on //.:myiface-V1-java-source which is not visible to this module`,
+		fmt.Sprintf(bp, "false", "true"), customizer)
+	testAidlError(t, `depends on //.:myiface-V1-cpp-source which is not visible to this module`,
+		fmt.Sprintf(bp, "true", "false"), customizer)
+}
+
+func TestRustDuplicateNames(t *testing.T) {
+	testAidl(t, `
+		aidl_interface {
+			name: "myiface",
+			srcs: ["dir/a/Foo.aidl", "dir/b/Foo.aidl"],
+			backend: {
+				rust: {
+					enabled: true,
+				},
+			},
+		}
+	`)
+}
+
+func TestAidlFlags(t *testing.T) {
+	ctx, _ := testAidl(t, `
+		aidl_interface {
+			name: "myiface",
+			srcs: ["a/Foo.aidl", "b/Bar.aidl"],
+			flags: ["-Weverything", "-Werror"],
+			backend: { rust: { enabled: true }}
+		}
+	`)
+	for module, outputs := range map[string][]string{
+		"myiface-V1-cpp-source":  {"a/Foo.h", "b/Bar.h"},
+		"myiface-V1-java-source": {"a/Foo.java", "b/Bar.java"},
+		"myiface-V1-ndk-source":  {"aidl/a/Foo.h", "aidl/b/Bar.h"},
+		"myiface-V1-rust-source": {"a/Foo.rs", "b/Bar.rs"},
+	} {
+		for _, output := range outputs {
+			t.Run(module+"/"+output, func(t *testing.T) {
+				params := ctx.ModuleForTests(module, "").Output(output)
+				assertContains(t, params.Args["optionalFlags"], "-Weverything")
+				assertContains(t, params.Args["optionalFlags"], "-Werror")
+			})
+		}
+	}
+}
diff --git a/build/aidl_utils.go b/build/aidl_utils.go
new file mode 100644
index 0000000..4ea073b
--- /dev/null
+++ b/build/aidl_utils.go
@@ -0,0 +1,65 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package aidl
+
+import (
+	"android/soong/android"
+	"strings"
+)
+
+// wrap(p, a, s) = [p + v + s for v in a]
+func wrap(prefix string, strs []string, suffix string) []string {
+	ret := make([]string, len(strs))
+	for i, v := range strs {
+		ret[i] = prefix + v + suffix
+	}
+	return ret
+}
+
+// concat(a...) = sum((i for i in a), [])
+func concat(sstrs ...[]string) []string {
+	var ret []string
+	for _, v := range sstrs {
+		ret = append(ret, v...)
+	}
+	return ret
+}
+
+// baseDir is the directory where the package name starts. e.g. For an AIDL fil
+// mymodule/aidl_src/com/android/IFoo.aidl, baseDir is mymodule/aidl_src given that the package name is
+// com.android. The build system however don't know the package name without actually reading the AIDL file.
+// Therefore, we rely on the user to correctly set the base directory via following two methods:
+// 1) via the 'path' property of filegroup or
+// 2) via `local_include_dir' of the aidl_interface module.
+func getBaseDir(ctx android.ModuleContext, src android.Path, aidlRoot android.Path) string {
+	// By default, we try to get 1) by reading Rel() of the input path.
+	baseDir := strings.TrimSuffix(src.String(), src.Rel())
+	// However, if 2) is set and it's more specific (i.e. deeper) than 1), we use 2).
+	if strings.HasPrefix(aidlRoot.String(), baseDir) {
+		baseDir = aidlRoot.String()
+	}
+	return baseDir
+}
+
+func fixRustName(name string) string {
+	return strings.Map(func(r rune) rune {
+		switch r {
+		case '-', '.':
+			return '_'
+		default:
+			return r
+		}
+	}, name)
+}
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 05a01b4..9c9f358 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -7,7 +7,7 @@
     installable: false,
 
     native_shared_libs: [
-        "test-piece-1-ndk_platform",
+        "test-piece-1-V3-ndk_platform",
     ],
 }
 
diff --git a/build/properties.go b/build/properties.go
index a260801..fea4974 100644
--- a/build/properties.go
+++ b/build/properties.go
@@ -17,26 +17,34 @@
 type nameProperties struct {
 	Name *string
 }
-type staticLib struct {
-	Whole_static_libs []string
+
+type hostProperties struct {
+	Cflags []string
+}
+type perTargetProperties struct {
+	Enabled *bool
 }
 
-type sharedLib struct {
-	Shared_libs               []string
-	Export_shared_lib_headers []string
+type ccTargetProperties struct {
+	Host   hostProperties
+	Darwin perTargetProperties
 }
+
+type rustTargetProperties struct {
+	Darwin perTargetProperties
+}
+
 type ccProperties struct {
 	Name                      *string
 	Owner                     *string
 	Defaults                  []string
 	Double_loadable           *bool
 	Vendor_available          *bool
+	Odm_available             *bool
+	Product_available         *bool
 	Host_supported            *bool
 	Generated_sources         []string
 	Generated_headers         []string
-	Shared                    sharedLib
-	Static                    staticLib
-	Static_libs               []string
 	Shared_libs               []string
 	Export_shared_lib_headers []string
 	Export_generated_headers  []string
@@ -49,6 +57,10 @@
 	Apex_available            []string
 	Min_sdk_version           *string
 	UseApexNameMacro          bool
+	Target                    ccTargetProperties
+	Tidy                      *bool
+	Tidy_flags                []string
+	Tidy_checks_as_errors     []string
 }
 
 type javaProperties struct {
@@ -73,6 +85,7 @@
 	Srcs           []string
 	Rustlibs       []string
 	Stem           *string
+	Target         rustTargetProperties
 }
 
 type phonyProperties struct {
diff --git a/tests/java_app/src/android/aidl/tests/TestFailException.java b/build/tests_transitive_parcel/a/IA.aidl
similarity index 65%
copy from tests/java_app/src/android/aidl/tests/TestFailException.java
copy to build/tests_transitive_parcel/a/IA.aidl
index de000fa..ff097f0 100644
--- a/tests/java_app/src/android/aidl/tests/TestFailException.java
+++ b/build/tests_transitive_parcel/a/IA.aidl
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2016, The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,11 +14,10 @@
  * limitations under the License.
  */
 
-package android.aidl.tests;
+package tests_transitive_parcel.a;
 
-public class TestFailException extends Exception {
-    public TestFailException(String message) {
-        super(message);
-    }
+import tests_transitive_parcel.b.B;
+
+interface IA {
+    B getB();
 }
-
diff --git a/tests/java_app/src/android/aidl/tests/TestFailException.java b/build/tests_transitive_parcel/b/B.aidl
similarity index 65%
copy from tests/java_app/src/android/aidl/tests/TestFailException.java
copy to build/tests_transitive_parcel/b/B.aidl
index de000fa..3468d30 100644
--- a/tests/java_app/src/android/aidl/tests/TestFailException.java
+++ b/build/tests_transitive_parcel/b/B.aidl
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2016, The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package android.aidl.tests;
+package tests_transitive_parcel.b;
 
-public class TestFailException extends Exception {
-    public TestFailException(String message) {
-        super(message);
-    }
+import tests_transitive_parcel.c.C;
+
+parcelable B {
+    int i;
+    C c;
 }
-
diff --git a/tests/java_app/src/android/aidl/tests/TestFailException.java b/build/tests_transitive_parcel/c/C.aidl
similarity index 65%
copy from tests/java_app/src/android/aidl/tests/TestFailException.java
copy to build/tests_transitive_parcel/c/C.aidl
index de000fa..697a9f1 100644
--- a/tests/java_app/src/android/aidl/tests/TestFailException.java
+++ b/build/tests_transitive_parcel/c/C.aidl
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2016, The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,11 +14,8 @@
  * limitations under the License.
  */
 
-package android.aidl.tests;
+package tests_transitive_parcel.c;
 
-public class TestFailException extends Exception {
-    public TestFailException(String message) {
-        super(message);
-    }
+parcelable C {
+    int i;
 }
-
diff --git a/code_writer.cpp b/code_writer.cpp
index 447b91f..773a598 100644
--- a/code_writer.cpp
+++ b/code_writer.cpp
@@ -21,6 +21,7 @@
 #include <fstream>
 #include <iostream>
 #include <sstream>
+#include <unordered_map>
 #include <vector>
 
 #include <android-base/stringprintf.h>
@@ -132,5 +133,23 @@
   return CodeWriterPtr(new StringCodeWriter(buf));
 }
 
+std::string QuotedEscape(const std::string& str) {
+  std::string result;
+  result += '"';
+  static const std::unordered_map<char, std::string> escape = {
+      {'"', "\\\""}, {'\\', "\\\\"}, {'\n', "\\n"}, {'\r', "\\r"}, {'\t', "\\t"}, {'\v', "\\v"},
+  };
+  for (auto c : str) {
+    auto it = escape.find(c);
+    if (it != escape.end()) {
+      result += it->second;
+    } else {
+      result += c;
+    }
+  }
+  result += '"';
+  return result;
+}
+
 }  // namespace aidl
 }  // namespace android
diff --git a/code_writer.h b/code_writer.h
index 469cd5f..7501385 100644
--- a/code_writer.h
+++ b/code_writer.h
@@ -16,11 +16,13 @@
 
 #pragma once
 
+#include <stdio.h>
+
+#include <functional>
 #include <memory>
 #include <ostream>
 #include <string>
-
-#include <stdio.h>
+#include <utility>
 
 namespace android {
 namespace aidl {
@@ -57,5 +59,7 @@
   bool start_of_line_ {true};
 };
 
+std::string QuotedEscape(const std::string& str);
+
 }  // namespace aidl
 }  // namespace android
diff --git a/code_writer_unittest.cpp b/code_writer_unittest.cpp
index 9cf462c..76a2af5 100644
--- a/code_writer_unittest.cpp
+++ b/code_writer_unittest.cpp
@@ -44,5 +44,17 @@
   EXPECT_EQ(str, "Write this and that");
 }
 
+TEST(CodeWriterTest, WorksWithNonAscii) {
+  // Due to b/174366536(basic_stringbuf implicit-conversion), the following snippet crashes
+  //   std::stringstream s;
+  //   s << "ê°€";
+  std::string str;
+  CodeWriterPtr ptr = CodeWriter::ForString(&str);
+  CodeWriter& writer = *ptr;
+  writer << "ê°€";
+  writer.Close();
+  EXPECT_EQ(str, "ê°€");
+}
+
 }  // namespace aidl
 }  // namespace android
diff --git a/comments.cpp b/comments.cpp
new file mode 100644
index 0000000..afbdc8f
--- /dev/null
+++ b/comments.cpp
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "comments.h"
+
+#include <android-base/result.h>
+#include <android-base/strings.h>
+
+#include <optional>
+#include <regex>
+#include <string>
+#include <vector>
+
+#include "logging.h"
+
+using android::base::EndsWith;
+using android::base::Error;
+using android::base::Join;
+using android::base::Result;
+using android::base::Split;
+using android::base::StartsWith;
+using android::base::Trim;
+
+namespace android {
+namespace aidl {
+
+namespace {
+
+static const std::string_view kLineCommentBegin = "//";
+static const std::string_view kBlockCommentBegin = "/*";
+static const std::string_view kBlockCommentEnd = "*/";
+static const std::string_view kDocCommentBegin = "/**";
+static const std::string kTagDeprecated = "@deprecated";
+static const std::regex kTagHideRegex{"@hide\\b"};
+
+std::string ConsumePrefix(const std::string& s, std::string_view prefix) {
+  AIDL_FATAL_IF(!StartsWith(s, prefix), AIDL_LOCATION_HERE)
+      << "'" << s << "' has no prefix '" << prefix << "'";
+  return s.substr(prefix.size());
+}
+
+std::string ConsumeSuffix(const std::string& s, std::string_view suffix) {
+  AIDL_FATAL_IF(!EndsWith(s, suffix), AIDL_LOCATION_HERE);
+  return s.substr(0, s.size() - suffix.size());
+}
+
+struct BlockTag {
+  std::string name;
+  std::string description;
+};
+
+// Removes comment markers: //, /*, */, optional leading "*" in block comments
+// - keeps leading spaces, but trims trailing spaces
+// - keeps empty lines
+std::vector<std::string> TrimmedLines(const Comment& c) {
+  if (c.type == Comment::Type::LINE) {
+    return std::vector{ConsumePrefix(c.body, kLineCommentBegin)};
+  }
+
+  std::string stripped = ConsumeSuffix(ConsumePrefix(c.body, kBlockCommentBegin), kBlockCommentEnd);
+
+  std::vector<std::string> lines;
+  bool found_first_line = false;
+
+  for (auto& line : Split(stripped, "\n")) {
+    // Delete prefixes like "    * ", "   *", or "    ".
+    size_t idx = 0;
+    for (; idx < line.size() && isspace(line[idx]); idx++)
+      ;
+    if (idx < line.size() && line[idx] == '*') idx++;
+    if (idx < line.size() && line[idx] == ' ') idx++;
+
+    const std::string& sanitized_line = line.substr(idx);
+    size_t i = sanitized_line.size();
+    for (; i > 0 && isspace(sanitized_line[i - 1]); i--)
+      ;
+
+    // Either the size is 0 or everything was whitespace.
+    bool is_empty_line = i == 0;
+
+    found_first_line = found_first_line || !is_empty_line;
+    if (!found_first_line) continue;
+
+    // if is_empty_line, i == 0 so substr == ""
+    lines.push_back(sanitized_line.substr(0, i));
+  }
+  // remove trailing empty lines
+  while (!lines.empty() && Trim(lines.back()).empty()) {
+    lines.pop_back();
+  }
+  return lines;
+}
+
+// Parses a block comment and returns block tags in the comment.
+std::vector<BlockTag> BlockTags(const Comment& c) {
+  AIDL_FATAL_IF(c.type != Comment::Type::BLOCK, AIDL_LOCATION_HERE);
+
+  std::vector<BlockTag> tags;
+
+  // current tag and paragraph
+  std::string tag;
+  std::vector<std::string> paragraph;
+
+  auto end_paragraph = [&]() {
+    if (tag.empty()) {
+      paragraph.clear();
+      return;
+    }
+    // paragraph lines are trimed at both ends
+    tags.push_back({tag, Join(paragraph, " ")});
+    tag.clear();
+    paragraph.clear();
+  };
+
+  for (const auto& line : TrimmedLines(c)) {
+    size_t idx = 0;
+    // skip leading spaces
+    for (; idx < line.size() && isspace(line[idx]); idx++)
+      ;
+
+    if (idx == line.size()) {
+      // skip empty lines
+    } else if (line[idx] == '@') {
+      // end the current paragraph before reading a new block tag (+ description paragraph)
+      end_paragraph();
+
+      size_t end_idx = idx + 1;
+      for (; end_idx < line.size() && isalpha(line[end_idx]); end_idx++)
+        ;
+
+      tag = line.substr(idx, end_idx - idx);
+
+      if (end_idx < line.size() && line[end_idx] == ' ') end_idx++;
+      // skip empty line
+      if (end_idx < line.size()) {
+        paragraph.push_back(line.substr(end_idx));
+      }
+    } else {
+      // gather paragraph lines with leading spaces trimmed
+      paragraph.push_back(line.substr(idx));
+    }
+  }
+
+  end_paragraph();
+
+  return tags;
+}
+
+}  // namespace
+
+Comment::Comment(const std::string& body) : body(body) {
+  if (StartsWith(body, kLineCommentBegin)) {
+    type = Type::LINE;
+  } else if (StartsWith(body, kBlockCommentBegin) && EndsWith(body, kBlockCommentEnd)) {
+    type = Type::BLOCK;
+  } else {
+    AIDL_FATAL(AIDL_LOCATION_HERE) << "invalid comments body:" << body;
+  }
+}
+
+// Returns the immediate block comment from the list of comments.
+// Only the last/block comment can have the tag.
+//
+//   /* @hide */
+//   int x;
+//
+// But tags in line or distant comments don't count. In the following,
+// the variable 'x' is not hidden.
+//
+//    // @hide
+//    int x;
+//
+//    /* @hide */
+//    /* this is the immemediate comment to 'x' */
+//    int x;
+//
+static std::optional<Comment> GetValidComment(const Comments& comments) {
+  if (!comments.empty() && comments.back().type == Comment::Type::BLOCK) {
+    return comments.back();
+  }
+  return std::nullopt;
+}
+
+// Sees if comments have the @hide tag.
+// Example: /** @hide */
+bool HasHideInComments(const Comments& comments) {
+  const auto valid_comment = GetValidComment(comments);
+  return valid_comment && std::regex_search(valid_comment->body, kTagHideRegex);
+}
+
+// Finds the @deprecated tag in comments and returns it with optional note which
+// follows the tag.
+// Example: /** @deprecated reason */
+std::optional<Deprecated> FindDeprecated(const Comments& comments) {
+  if (const auto valid_comment = GetValidComment(comments); valid_comment) {
+    for (const auto& [name, description] : BlockTags(comments.back())) {
+      // take the first @deprecated
+      if (kTagDeprecated == name) {
+        return Deprecated{description};
+      }
+    }
+  }
+  return std::nullopt;
+}
+
+// Formats comments for the Java backend.
+// The last/block comment is transformed into javadoc(/** */)
+// and others are used as they are.
+std::string FormatCommentsForJava(const Comments& comments) {
+  std::stringstream out;
+  for (auto it = begin(comments); it != end(comments); it++) {
+    const bool last = next(it) == end(comments);
+    // We only re-format the last/block comment which is not already a doc-style comment.
+    if (last && it->type == Comment::Type::BLOCK && !StartsWith(it->body, kDocCommentBegin)) {
+      out << kDocCommentBegin << ConsumePrefix(it->body, kBlockCommentBegin);
+    } else {
+      out << it->body;
+    }
+  }
+  return out.str();
+}
+
+}  // namespace aidl
+}  // namespace android
\ No newline at end of file
diff --git a/comments.h b/comments.h
new file mode 100644
index 0000000..8bf7b30
--- /dev/null
+++ b/comments.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <iostream>
+#include <optional>
+#include <string>
+#include <vector>
+
+namespace android {
+namespace aidl {
+
+// Represents a single comment
+struct Comment {
+  enum class Type { LINE, BLOCK };
+  Type type;
+  std::string body;
+
+  Comment(const std::string& body);
+
+  // for GTest assertions
+  friend inline bool operator==(const Comment& lhs, const Comment& rhs) {
+    return lhs.body == rhs.body;
+  }
+  friend std::ostream& operator<<(std::ostream& out, const Comment& c) { return out << c.body; }
+};
+
+using Comments = std::vector<Comment>;
+
+bool HasHideInComments(const Comments& comments);
+
+struct Deprecated {
+  std::string note;  // can be empty("")
+};
+
+std::optional<Deprecated> FindDeprecated(const Comments& comments);
+
+std::string FormatCommentsForJava(const Comments& comments);
+
+}  // namespace aidl
+}  // namespace android
\ No newline at end of file
diff --git a/diagnostics.cpp b/diagnostics.cpp
new file mode 100644
index 0000000..23ba0ae
--- /dev/null
+++ b/diagnostics.cpp
@@ -0,0 +1,270 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "diagnostics.h"
+
+#include <functional>
+#include <stack>
+#include <unordered_set>
+
+#include "aidl_language.h"
+#include "logging.h"
+
+using std::placeholders::_1;
+
+namespace android {
+namespace aidl {
+
+const std::map<std::string, DiagnosticOption> kAllDiagnostics = {
+#define DIAG(ENUM, NAME, ENABLED) {NAME, DiagnosticOption{DiagnosticID::ENUM, NAME, ENABLED}},
+#include "diagnostics.inc"
+#undef DIAG
+};
+
+static const std::map<DiagnosticID, std::string> kDiagnosticsNames = {
+#define DIAG(ENUM, NAME, ENABLED) {DiagnosticID::ENUM, NAME},
+#include "diagnostics.inc"
+#undef DIAG
+};
+
+void DiagnosticMapping::Severity(DiagnosticID id, DiagnosticSeverity severity) {
+  mapping_[id] = severity;
+}
+
+DiagnosticSeverity DiagnosticMapping::Severity(DiagnosticID id) const {
+  return mapping_.at(id);
+}
+
+std::string to_string(DiagnosticID id) {
+  return kDiagnosticsNames.at(id);
+}
+
+class DiagnosticsContext {
+ public:
+  DiagnosticsContext(DiagnosticMapping mapping) : mapping_({std::move(mapping)}) {}
+  AidlErrorLog Report(const AidlLocation& loc, DiagnosticID id,
+                      DiagnosticSeverity force_severity = DiagnosticSeverity::DISABLED) {
+    const std::string suffix = " [-W" + to_string(id) + "]";
+    auto severity = std::max(force_severity, mapping_.top().Severity(id));
+    switch (severity) {
+      case DiagnosticSeverity::DISABLED:
+        return AidlErrorLog(AidlErrorLog::NO_OP, loc);
+      case DiagnosticSeverity::WARNING:
+        return AidlErrorLog(AidlErrorLog::WARNING, loc, suffix);
+      case DiagnosticSeverity::ERROR:
+        error_count_++;
+        return AidlErrorLog(AidlErrorLog::ERROR, loc, suffix);
+    }
+  }
+  size_t ErrorCount() const { return error_count_; }
+  void Suppress(const AidlAnnotatable& a) {
+    const auto& warnings = a.SuppressWarnings();
+    DiagnosticMapping new_mapping = mapping_.top();
+    for (const auto& w : warnings) {
+      auto it = kAllDiagnostics.find(w);
+      if (it == kAllDiagnostics.end()) {
+        Report(a.GetLocation(), DiagnosticID::unknown_warning, DiagnosticSeverity::ERROR)
+            << "unknown warning: " << w;
+        continue;
+      }
+      new_mapping.Severity(it->second.id, DiagnosticSeverity::DISABLED);
+    }
+    mapping_.push(std::move(new_mapping));
+  }
+  void Restore(const AidlAnnotatable&) {
+    mapping_.pop();
+  }
+ private:
+  std::stack<DiagnosticMapping> mapping_;
+  size_t error_count_ = {};
+};
+
+class DiagnosticsVisitor : public AidlVisitor {
+ public:
+  DiagnosticsVisitor(DiagnosticsContext& diag) : diag(diag) {}
+  void Check(const AidlDocument& doc) {
+    DiagnosticsVisitor* visitor = this;
+    using Fun = std::function<void(const AidlAnnotatable&)>;
+    struct Hook : public AidlVisitor {
+      Fun fun;
+      Hook(Fun fun) : fun(fun) {}
+      void Visit(const AidlInterface& a) override { fun(a); }
+      void Visit(const AidlEnumDeclaration& a) override { fun(a); }
+      void Visit(const AidlStructuredParcelable& a) override { fun(a); }
+      void Visit(const AidlUnionDecl& a) override { fun(a); }
+      void Visit(const AidlParcelable& a) override { fun(a); }
+      void Visit(const AidlMethod& a) override { fun(a.GetType()); }
+    };
+    Hook suppress{std::bind(&DiagnosticsContext::Suppress, &diag, _1)};
+    Hook restore{std::bind(&DiagnosticsContext::Restore, &diag, _1)};
+    std::function<void(const AidlNode&)> top_down = [&top_down, &suppress, &restore,
+                                                     visitor](const AidlNode& a) {
+      a.DispatchVisit(suppress);
+      a.DispatchVisit(*visitor);
+      a.TraverseChildren(top_down);
+      a.DispatchVisit(restore);
+    };
+    top_down(doc);
+  }
+ protected:
+  DiagnosticsContext& diag;
+};
+
+struct DiagnoseInterfaceName : DiagnosticsVisitor {
+  DiagnoseInterfaceName(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlInterface& i) override {
+    if (auto name = i.GetName(); name.size() < 1 || name[0] != 'I') {
+      diag.Report(i.GetLocation(), DiagnosticID::interface_name)
+          << "Interface names should start with I.";
+    }
+  }
+};
+
+struct DiagnoseEnumZero : DiagnosticsVisitor {
+  DiagnoseEnumZero(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlEnumDeclaration& e) override {
+    AIDL_FATAL_IF(e.GetEnumerators().empty(), e)
+        << "The enum '" << e.GetName() << "' has no enumerators.";
+    const auto& first = e.GetEnumerators()[0];
+    if (auto first_value = first->ValueString(e.GetBackingType(), AidlConstantValueDecorator);
+        first_value != "0") {
+      diag.Report(first->GetLocation(), DiagnosticID::enum_zero)
+          << "The first enumerator '" << first->GetName() << "' should be 0, but it is "
+          << first_value << ".";
+    }
+  }
+};
+
+struct DiagnoseInoutParameter : DiagnosticsVisitor {
+  DiagnoseInoutParameter(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlArgument& a) override {
+    if (a.GetDirection() == AidlArgument::INOUT_DIR) {
+      diag.Report(a.GetLocation(), DiagnosticID::inout_parameter)
+          << a.GetName()
+          << " is 'inout'. Avoid inout parameters. This is somewhat confusing for clients "
+             "because although the parameters are 'in', they look out 'out' parameters.";
+    }
+  }
+};
+
+struct DiagnoseConstName : DiagnosticsVisitor {
+  DiagnoseConstName(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlEnumerator& e) override {
+    if (ToUpper(e.GetName()) != e.GetName()) {
+      diag.Report(e.GetLocation(), DiagnosticID::const_name)
+          << "Enum values should be named in upper cases: " << ToUpper(e.GetName());
+    }
+  }
+  void Visit(const AidlConstantDeclaration& c) override {
+    if (ToUpper(c.GetName()) != c.GetName()) {
+      diag.Report(c.GetLocation(), DiagnosticID::const_name)
+          << "Constants should be named in upper cases: " << ToUpper(c.GetName());
+    }
+  }
+  static std::string ToUpper(std::string name) {
+    for (auto& c : name) c = std::toupper(c);
+    return name;
+  }
+};
+
+struct DiagnoseExplicitDefault : DiagnosticsVisitor {
+  DiagnoseExplicitDefault(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlStructuredParcelable& p) override {
+    for (const auto& var : p.GetFields()) {
+      CheckExplicitDefault(*var);
+    }
+  }
+  void Visit(const AidlUnionDecl& u) override {
+    AIDL_FATAL_IF(u.GetFields().empty(), u) << "The union '" << u.GetName() << "' has no fields.";
+    const auto& first = u.GetFields()[0];
+    CheckExplicitDefault(*first);
+  }
+  void CheckExplicitDefault(const AidlVariableDeclaration& v) {
+    if (v.IsDefaultUserSpecified()) return;
+    if (v.GetType().IsNullable()) return;
+    if (v.GetType().IsArray()) {
+      diag.Report(v.GetLocation(), DiagnosticID::explicit_default)
+          << "The array field '" << v.GetName() << "' has no explicit value.";
+      return;
+    }
+    const auto type_name = v.GetType().GetName();
+    if (AidlTypenames::IsPrimitiveTypename(type_name) || type_name == "String" ||
+        type_name == "CharSequence") {
+      diag.Report(v.GetLocation(), DiagnosticID::explicit_default)
+          << "The primitive field '" << v.GetName() << "' has no explicit value.";
+      return;
+    }
+    const auto defined_type = v.GetType().GetDefinedType();
+    if (defined_type && defined_type->AsEnumDeclaration()) {
+      diag.Report(v.GetLocation(), DiagnosticID::enum_explicit_default)
+          << "The enum field '" << v.GetName() << "' has no explicit value.";
+      return;
+    }
+  }
+};
+
+struct DiagnoseMixedOneway : DiagnosticsVisitor {
+  DiagnoseMixedOneway(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlInterface& i) override {
+    const auto& methods = i.GetMethods();
+    if (std::adjacent_find(begin(methods), end(methods), [](const auto& a, const auto& b) {
+          return a->IsOneway() != b->IsOneway();
+        }) != end(methods)) {
+      diag.Report(i.GetLocation(), DiagnosticID::mixed_oneway)
+          << "The interface '" << i.GetName() << "' has both one-way and two-way methods.";
+    }
+  }
+};
+
+struct DiagnoseOutArray : DiagnosticsVisitor {
+  DiagnoseOutArray(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlMethod& m) override {
+    for (const auto& a : m.GetArguments()) {
+      if (a->GetType().IsArray() && a->IsOut()) {
+        diag.Report(m.GetLocation(), DiagnosticID::out_array)
+            << "The method '" << m.GetName() << "' an array output parameter '" << a->GetName()
+            << "'. Instead prefer APIs like '" << a->GetType().Signature() << " " << m.GetName()
+            << "(...).";
+      }
+    }
+  }
+};
+
+struct DiagnoseFileDescriptor : DiagnosticsVisitor {
+  DiagnoseFileDescriptor(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+  void Visit(const AidlTypeSpecifier& t) override {
+    if (t.GetName() == "FileDescriptor") {
+      diag.Report(t.GetLocation(), DiagnosticID::file_descriptor)
+          << "Please use ParcelFileDescriptor instead of FileDescriptor.";
+    }
+  }
+};
+
+bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping) {
+  DiagnosticsContext diag(mapping);
+
+  DiagnoseInterfaceName{diag}.Check(doc);
+  DiagnoseEnumZero{diag}.Check(doc);
+  DiagnoseInoutParameter{diag}.Check(doc);
+  DiagnoseConstName{diag}.Check(doc);
+  DiagnoseExplicitDefault{diag}.Check(doc);
+  DiagnoseMixedOneway{diag}.Check(doc);
+  DiagnoseOutArray{diag}.Check(doc);
+  DiagnoseFileDescriptor{diag}.Check(doc);
+
+  return diag.ErrorCount() == 0;
+}
+}  // namespace aidl
+}  // namespace android
diff --git a/diagnostics.h b/diagnostics.h
new file mode 100644
index 0000000..d9c40ea
--- /dev/null
+++ b/diagnostics.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <map>
+#include <stack>
+#include <string>
+#include <vector>
+
+#include <android-base/scopeguard.h>
+#include <android-base/strings.h>
+
+class AidlDocument;
+class AidlLocation;
+class AidlErrorLog;
+
+namespace android {
+namespace aidl {
+
+enum class DiagnosticSeverity {
+  DISABLED,
+  WARNING,
+  ERROR,
+};
+
+enum class DiagnosticID {
+#define DIAG(ENUM, NAME, ENABLED) ENUM,
+#include "diagnostics.inc"
+#undef DIAG
+};
+
+class DiagnosticMapping {
+ public:
+  DiagnosticSeverity Severity(DiagnosticID id) const;
+  void Severity(DiagnosticID id, DiagnosticSeverity severity);
+
+ private:
+  std::map<DiagnosticID, DiagnosticSeverity> mapping_;
+};
+
+struct DiagnosticOption {
+  DiagnosticID id;
+  const std::string name;
+  bool default_enabled;
+};
+
+extern const std::map<std::string, DiagnosticOption> kAllDiagnostics;
+
+// relying on Argument-dependent lookup
+std::string to_string(DiagnosticID id);
+
+bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping);
+
+}  // namespace aidl
+}  // namespace android
diff --git a/diagnostics.inc b/diagnostics.inc
new file mode 100644
index 0000000..fa2015d
--- /dev/null
+++ b/diagnostics.inc
@@ -0,0 +1,11 @@
+// DIAG(enum, name, enable-by-default)
+DIAG(const_name, "const-name", false)
+DIAG(enum_zero, "enum-zero", false)
+DIAG(explicit_default, "explicit-default", false)
+DIAG(enum_explicit_default, "enum-explicit-default", false)
+DIAG(file_descriptor, "file-descriptor", false)
+DIAG(inout_parameter, "inout-parameter", false)
+DIAG(interface_name, "interface-name", false)
+DIAG(mixed_oneway, "mixed-oneway", false)
+DIAG(out_array, "out-array", false)
+DIAG(unknown_warning, "unknown-warning", false)
diff --git a/diagnostics_unittest.cpp b/diagnostics_unittest.cpp
new file mode 100644
index 0000000..bf6b316
--- /dev/null
+++ b/diagnostics_unittest.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "diagnostics.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <string>
+#include <vector>
+
+#include "aidl.h"
+#include "parser.h"
+#include "tests/fake_io_delegate.h"
+
+using android::aidl::AidlError;
+using android::aidl::AidlTypenames;
+using android::aidl::DiagnosticID;
+using android::aidl::Options;
+using android::aidl::internals::load_and_validate_aidl;
+using android::aidl::test::FakeIoDelegate;
+using testing::internal::CaptureStderr;
+using testing::internal::GetCapturedStderr;
+
+struct DiagnosticsTest : testing::Test {
+  void ParseFiles(std::vector<std::pair<std::string, std::string>>&& files) {
+    ASSERT_TRUE(files.size() > 0);
+    const std::string main = files.begin()->first;
+    for (const auto& [file, contents] : files) {
+      io.SetFileContents(file, contents);
+    }
+    // emit diagnostics as warnings.
+    // "java" has no specific meaning here because we're testing CheckValid()
+    const Options options = Options::From("aidl -I . --lang java -o out -Weverything " + main);
+    CaptureStderr();
+    load_and_validate_aidl(main, options, io, &typenames, nullptr);
+    const std::string err = GetCapturedStderr();
+    if (expect_diagnostics.empty()) {
+      EXPECT_EQ("", err);
+    } else {
+      for (const auto id : expect_diagnostics) {
+        EXPECT_THAT(err, testing::HasSubstr("-W" + to_string(id)));
+      }
+    }
+  }
+
+  AidlTypenames typenames;
+  FakeIoDelegate io;
+  std::vector<DiagnosticID> expect_diagnostics;
+};
+
+TEST_F(DiagnosticsTest, const_name_ForEnumerator) {
+  expect_diagnostics = {DiagnosticID::const_name};
+  ParseFiles({{"Foo.aidl", "enum Foo { foo }"}});
+}
+
+TEST_F(DiagnosticsTest, const_name_ForConstants) {
+  expect_diagnostics = {DiagnosticID::const_name};
+  ParseFiles({{"IFoo.aidl", "interface IFoo { const int foo = 1; }"}});
+}
+
+TEST_F(DiagnosticsTest, interface_name) {
+  expect_diagnostics = {DiagnosticID::interface_name};
+  ParseFiles({{"Foo.aidl", "interface Foo { }"}});
+}
+
+TEST_F(DiagnosticsTest, enum_zero) {
+  expect_diagnostics = {DiagnosticID::enum_zero};
+  ParseFiles({{"Enum.aidl", "enum Enum { A = 1 }"}});
+}
+
+TEST_F(DiagnosticsTest, enum_zero_suppress_SuppressAtDeclLevel) {
+  expect_diagnostics = {};
+  ParseFiles({{"Enum.aidl", "@SuppressWarnings(value={\"enum-zero\"}) enum Enum { A = 1 }"}});
+}
+
+TEST_F(DiagnosticsTest, explicit_default) {
+  expect_diagnostics = {DiagnosticID::explicit_default};
+  ParseFiles({{"Foo.aidl", "parcelable Foo { int n; }"}});
+}
+
+TEST_F(DiagnosticsTest, enum_explicit_default) {
+  expect_diagnostics = {DiagnosticID::enum_explicit_default};
+  ParseFiles({{"Foo.aidl", "parcelable Foo { E e; }"}, {"E.aidl", "enum E { A }"}});
+}
+
+TEST_F(DiagnosticsTest, explicit_default_OkayForSomeTypesOrDefaultIsSet) {
+  expect_diagnostics = {};
+  ParseFiles({{"Foo.aidl",
+               "parcelable Foo { \n"
+               "  Bar bar;\n"
+               "  IBinder binder;\n"
+               "  @nullable String s;\n"
+               "  int[] numbers = {};\n"
+               "  List<String> stringList;\n"
+               "  IBaz baz;\n"
+               "}"},
+              {"Bar.aidl", "parcelable Bar { }"},
+              {"IBaz.aidl", "interface IBaz { }"}});
+}
+
+TEST_F(DiagnosticsTest, inout_parameter) {
+  expect_diagnostics = {DiagnosticID::inout_parameter};
+  ParseFiles({{"IFoo.aidl", "interface IFoo { void foo(inout Bar bar); }"},
+              {"Bar.aidl", "parcelable Bar {}"}});
+}
+
+TEST_F(DiagnosticsTest, inout_parameter_SuppressAtMethodLevel) {
+  expect_diagnostics = {};
+  ParseFiles({
+      {"IFoo.aidl",
+       "interface IFoo { @SuppressWarnings(value={\"inout-parameter\"}) void foo(inout Bar b); }"},
+      {"Bar.aidl", "parcelable Bar {}"},
+  });
+}
+
+TEST_F(DiagnosticsTest, inout_parameter_SuppressAtDeclLevel) {
+  expect_diagnostics = {};
+  ParseFiles({
+      {"IFoo.aidl",
+       "@SuppressWarnings(value={\"inout-parameter\"}) interface IFoo { void foo(inout Bar b); }"},
+      {"Bar.aidl", "parcelable Bar {}"},
+  });
+}
+
+TEST_F(DiagnosticsTest, UnknownWarning) {
+  expect_diagnostics = {DiagnosticID::unknown_warning};
+  ParseFiles({
+      {"IFoo.aidl", "@SuppressWarnings(value={\"blahblah\"}) interface IFoo { void foo(); }"},
+  });
+}
+
+TEST_F(DiagnosticsTest, CantSuppressUnknownWarning) {
+  expect_diagnostics = {DiagnosticID::unknown_warning};
+  ParseFiles({
+      {"IFoo.aidl",
+       "@SuppressWarnings(value={\"unknown-warning\"})\n"
+       "interface IFoo { @SuppressWarnings(value={\"blah-blah\"}) void foo(); }"},
+  });
+}
+
+TEST_F(DiagnosticsTest, DontMixOnewayWithTwowayMethods) {
+  expect_diagnostics = {DiagnosticID::mixed_oneway};
+  ParseFiles({
+      {"IFoo.aidl", "interface IFoo { void foo(); oneway void bar(); }"},
+  });
+}
+
+TEST_F(DiagnosticsTest, ArraysAsOutputParametersConsideredHarmful) {
+  expect_diagnostics = {DiagnosticID::out_array};
+  ParseFiles({
+      {"IFoo.aidl", "interface IFoo { void foo(out String[] ret); }"},
+  });
+}
+
+TEST_F(DiagnosticsTest, file_descriptor) {
+  expect_diagnostics = {DiagnosticID::file_descriptor};
+  ParseFiles({{"IFoo.aidl",
+               "interface IFoo { \n"
+               "  void foo(in FileDescriptor fd);\n"
+               "}"}});
+}
diff --git a/generate_cpp.cpp b/generate_cpp.cpp
index 5c26fe4..3e40a5c 100644
--- a/generate_cpp.cpp
+++ b/generate_cpp.cpp
@@ -24,6 +24,7 @@
 #include <set>
 #include <string>
 
+#include <android-base/format.h>
 #include <android-base/stringprintf.h>
 
 #include "aidl_language.h"
@@ -52,6 +53,7 @@
 const char kDataVarName[] = "_aidl_data";
 const char kErrorLabel[] = "_aidl_error";
 const char kImplVarName[] = "_aidl_impl";
+const char kParcelVarName[] = "_aidl_parcel";
 const char kReplyVarName[] = "_aidl_reply";
 const char kReturnVarName[] = "_aidl_return";
 const char kStatusVarName[] = "_aidl_status";
@@ -59,6 +61,7 @@
 const char kAndroidParcelLiteral[] = "::android::Parcel";
 const char kAndroidStatusLiteral[] = "::android::status_t";
 const char kAndroidStatusOk[] = "::android::OK";
+const char kAndroidStatusBadValue[] = "::android::BAD_VALUE";
 const char kBinderStatusLiteral[] = "::android::binder::Status";
 const char kIBinderHeader[] = "binder/IBinder.h";
 const char kIInterfaceHeader[] = "binder/IInterface.h";
@@ -165,9 +168,10 @@
     modifiers |= MethodDecl::IS_OVERRIDE;
   }
 
-  return unique_ptr<Declaration>{
-      new MethodDecl{kBinderStatusLiteral, method.GetName(),
-                     BuildArgList(typenames, method, true /* for method decl */), modifiers}};
+  const string attribute = GetDeprecatedAttribute(method);
+  return unique_ptr<Declaration>{new MethodDecl{
+      kBinderStatusLiteral, method.GetName(),
+      BuildArgList(typenames, method, true /* for method decl */), modifiers, attribute}};
 }
 
 unique_ptr<Declaration> BuildMetaMethodDecl(const AidlMethod& method, const AidlTypenames&,
@@ -236,6 +240,9 @@
 
   // Declare parcels to hold our query and the response.
   b->AddLiteral(StringPrintf("%s %s", kAndroidParcelLiteral, kDataVarName));
+  if (interface.IsSensitiveData()) {
+    b->AddLiteral(StringPrintf("%s.markSensitive()", kDataVarName));
+  }
   // Even if we're oneway, the transact method still takes a parcel.
   b->AddLiteral(StringPrintf("%s %s", kAndroidParcelLiteral, kReplyVarName));
 
@@ -290,14 +297,16 @@
   }
 
   // Invoke the transaction on the remote binder and confirm status.
-  string transaction_code = GetTransactionIdFor(method);
+  string transaction_code = GetTransactionIdFor(interface, method);
 
   vector<string> args = {transaction_code, kDataVarName,
                          StringPrintf("&%s", kReplyVarName)};
 
-  if (method.IsOneway()) {
-    args.push_back("::android::IBinder::FLAG_ONEWAY");
-  }
+  std::vector<std::string> flags;
+  if (method.IsOneway()) flags.push_back("::android::IBinder::FLAG_ONEWAY");
+  if (interface.IsSensitiveData()) flags.push_back("::android::IBinder::FLAG_CLEAR_BUF");
+
+  args.push_back(flags.empty() ? "0" : Join(flags, " | "));
 
   b->AddStatement(new Assignment(
       kAndroidStatusVarName,
@@ -408,7 +417,7 @@
          << "    ::android::Parcel data;\n"
          << "    ::android::Parcel reply;\n"
          << "    data.writeInterfaceToken(getInterfaceDescriptor());\n"
-         << "    ::android::status_t err = remote()->transact(" << GetTransactionIdFor(method)
+         << "    ::android::status_t err = remote()->transact(" << GetTransactionIdFor(interface, method)
          << ", data, &reply);\n"
          << "    if (err == ::android::OK) {\n"
          << "      ::android::binder::Status _aidl_status;\n"
@@ -432,7 +441,7 @@
          << "    ::android::Parcel data;\n"
          << "    ::android::Parcel reply;\n"
          << "    data.writeInterfaceToken(getInterfaceDescriptor());\n"
-         << "    ::android::status_t err = remote()->transact(" << GetTransactionIdFor(method)
+         << "    ::android::status_t err = remote()->transact(" << GetTransactionIdFor(interface, method)
          << ", data, &reply);\n"
          << "    if (err == ::android::OK) {\n"
          << "      ::android::binder::Status _aidl_status;\n"
@@ -455,31 +464,30 @@
                                        const AidlInterface& interface, const Options& options) {
   vector<string> include_list = {
       HeaderFile(interface, ClassNames::CLIENT, false),
+      HeaderFile(interface, ClassNames::SERVER, false), // for TRANSACTION_* consts
       kParcelHeader,
       kAndroidBaseMacrosHeader
   };
   if (options.GenLog()) {
     include_list.emplace_back("chrono");
     include_list.emplace_back("functional");
-    include_list.emplace_back("json/value.h");
   }
   vector<unique_ptr<Declaration>> file_decls;
 
   // The constructor just passes the IBinder instance up to the super
   // class.
   const string i_name = ClassName(interface, ClassNames::INTERFACE);
+  const string bp_name = ClassName(interface, ClassNames::CLIENT);
   file_decls.push_back(unique_ptr<Declaration>{new ConstructorImpl{
-      ClassName(interface, ClassNames::CLIENT),
-      ArgList{StringPrintf("const ::android::sp<::android::IBinder>& %s",
-                           kImplVarName)},
-      { "BpInterface<" + i_name + ">(" + kImplVarName + ")" }}});
+      bp_name,
+      ArgList{StringPrintf("const ::android::sp<::android::IBinder>& %s", kImplVarName)},
+      {"BpInterface<" + i_name + ">(" + kImplVarName + ")"}}});
 
   if (options.GenLog()) {
     string code;
-    ClassName(interface, ClassNames::CLIENT);
     CodeWriterPtr writer = CodeWriter::ForString(&code);
-    (*writer) << "std::function<void(const Json::Value&)> "
-              << ClassName(interface, ClassNames::CLIENT) << "::logFunc;\n";
+    (*writer) << "std::function<void(const " + bp_name + "::TransactionLog&)> " << bp_name
+              << "::logFunc;\n";
     writer->Close();
     file_decls.push_back(unique_ptr<Declaration>(new LiteralDecl(code)));
   }
@@ -502,6 +510,72 @@
 
 namespace {
 
+void BuildConstantDefinitions(const AidlDefinedType& type, const AidlTypenames& typenames,
+                              const std::vector<std::string>& type_params,
+                              const std::string& class_name,
+                              vector<unique_ptr<Declaration>>& decls) {
+  for (const auto& constant : type.GetConstantDeclarations()) {
+    const AidlConstantValue& value = constant->GetValue();
+    if (value.GetType() != AidlConstantValue::Type::STRING) continue;
+
+    std::string cppType = CppNameOf(constant->GetType(), typenames);
+    unique_ptr<MethodImpl> getter(
+        new MethodImpl("const " + cppType + "&", class_name, constant->GetName(), type_params, {}));
+    getter->GetStatementBlock()->AddLiteral(
+        StringPrintf("static const %s value(%s)", cppType.c_str(),
+                     constant->ValueString(ConstantValueDecorator).c_str()));
+    getter->GetStatementBlock()->AddLiteral("return value");
+    decls.push_back(std::move(getter));
+  }
+}
+
+void BuildConstantDeclarations(const AidlDefinedType& type, const AidlTypenames& typenames,
+                               unique_ptr<ClassDecl>& cls, set<string>& includes) {
+  std::vector<std::unique_ptr<Declaration>> string_constants;
+  unique_ptr<Enum> byte_constant_enum{new Enum{"", "int8_t", false}};
+  unique_ptr<Enum> int_constant_enum{new Enum{"", "int32_t", false}};
+  unique_ptr<Enum> long_constant_enum{new Enum{"", "int64_t", false}};
+  for (const auto& constant : type.GetConstantDeclarations()) {
+    const AidlTypeSpecifier& type = constant->GetType();
+    const AidlConstantValue& value = constant->GetValue();
+
+    const string attribute = GetDeprecatedAttribute(*constant);
+    if (type.Signature() == "String") {
+      std::string cppType = CppNameOf(constant->GetType(), typenames);
+      unique_ptr<Declaration> getter(new MethodDecl("const " + cppType + "&", constant->GetName(),
+                                                    {}, MethodDecl::IS_STATIC, attribute));
+      string_constants.push_back(std::move(getter));
+    } else if (type.Signature() == "byte") {
+      byte_constant_enum->AddValue(constant->GetName(),
+                                   constant->ValueString(ConstantValueDecorator), attribute);
+    } else if (type.Signature() == "int") {
+      int_constant_enum->AddValue(constant->GetName(),
+                                  constant->ValueString(ConstantValueDecorator), attribute);
+    } else if (type.Signature() == "long") {
+      long_constant_enum->AddValue(constant->GetName(),
+                                   constant->ValueString(ConstantValueDecorator), attribute);
+    } else {
+      AIDL_FATAL(value) << "Unrecognized constant type: " << type.Signature();
+    }
+  }
+  if (byte_constant_enum->HasValues()) {
+    cls->AddPublic(std::move(byte_constant_enum));
+  }
+  if (int_constant_enum->HasValues()) {
+    cls->AddPublic(std::move(int_constant_enum));
+  }
+  if (long_constant_enum->HasValues()) {
+    cls->AddPublic(std::move(long_constant_enum));
+  }
+  if (!string_constants.empty()) {
+    includes.insert(kString16Header);
+
+    for (auto& string_constant : string_constants) {
+      cls->AddPublic(std::move(string_constant));
+    }
+  }
+}
+
 bool HandleServerTransaction(const AidlTypenames& typenames, const AidlInterface& interface,
                              const AidlMethod& method, const Options& options, StatementBlock* b) {
   // Declare all the parameters now.  In the common case, we expect no errors
@@ -653,11 +727,9 @@
   if (options.GenLog()) {
     include_list.emplace_back("chrono");
     include_list.emplace_back("functional");
-    include_list.emplace_back("json/value.h");
   }
 
-  unique_ptr<ConstructorImpl> constructor{
-      new ConstructorImpl{ClassName(interface, ClassNames::SERVER), ArgList{}, {}}};
+  unique_ptr<ConstructorImpl> constructor{new ConstructorImpl{bn_name, ArgList{}, {}}};
 
   if (interface.IsVintfStability()) {
     constructor->GetStatementBlock()->AddLiteral("::android::internal::Stability::markVintf(this)");
@@ -687,7 +759,7 @@
 
   // The switch statement has a case statement for each transaction code.
   for (const auto& method : interface.GetMethods()) {
-    StatementBlock* b = s->AddCase(GetTransactionIdFor(*method));
+    StatementBlock* b = s->AddCase(GetTransactionIdFor(interface, *method));
     if (!b) { return nullptr; }
 
     bool success = false;
@@ -726,7 +798,19 @@
       StringPrintf("return %s", kAndroidStatusVarName));
   vector<unique_ptr<Declaration>> decls;
   decls.push_back(std::move(constructor));
+
+  bool deprecated = interface.IsDeprecated() ||
+                    std::any_of(interface.GetMethods().begin(), interface.GetMethods().end(),
+                                [](const auto& m) { return m->IsDeprecated(); });
+  if (deprecated) {
+    decls.emplace_back(
+        new LiteralDecl("#pragma clang diagnostic push\n"
+                        "#pragma clang diagnostic ignored \"-Wdeprecated\"\n"));
+  }
   decls.push_back(std::move(on_transact));
+  if (deprecated) {
+    decls.emplace_back(new LiteralDecl("#pragma clang diagnostic pop\n"));
+  }
 
   if (options.Version() > 0) {
     std::ostringstream code;
@@ -745,10 +829,9 @@
 
   if (options.GenLog()) {
     string code;
-    ClassName(interface, ClassNames::SERVER);
     CodeWriterPtr writer = CodeWriter::ForString(&code);
-    (*writer) << "std::function<void(const Json::Value&)> "
-              << ClassName(interface, ClassNames::SERVER) << "::logFunc;\n";
+    (*writer) << "std::function<void(const " + bn_name + "::TransactionLog&)> " << bn_name
+              << "::logFunc;\n";
     writer->Close();
     decls.push_back(unique_ptr<Declaration>(new LiteralDecl(code)));
   }
@@ -772,20 +855,8 @@
                                            '"' + interface.GetDescriptor() + '"'}}}};
   decls.push_back(std::move(meta_if));
 
-  for (const auto& constant : interface.GetConstantDeclarations()) {
-    const AidlConstantValue& value = constant->GetValue();
-    if (value.GetType() != AidlConstantValue::Type::STRING) continue;
-
-    std::string cppType = CppNameOf(constant->GetType(), typenames);
-    unique_ptr<MethodImpl> getter(new MethodImpl("const " + cppType + "&",
-                                                 ClassName(interface, ClassNames::INTERFACE),
-                                                 constant->GetName(), {}, {}));
-    getter->GetStatementBlock()->AddLiteral(
-        StringPrintf("static const %s value(%s)", cppType.c_str(),
-                     constant->ValueString(ConstantValueDecorator).c_str()));
-    getter->GetStatementBlock()->AddLiteral("return value");
-    decls.push_back(std::move(getter));
-  }
+  BuildConstantDefinitions(interface, typenames, {}, ClassName(interface, ClassNames::INTERFACE),
+                           decls);
 
   return unique_ptr<Document>{new CppSource{
       include_list,
@@ -812,6 +883,8 @@
       ConstructorDecl::IS_VIRTUAL | ConstructorDecl::IS_DEFAULT}};
 
   vector<unique_ptr<Declaration>> publics;
+  vector<unique_ptr<Declaration>> privates;
+
   publics.push_back(std::move(constructor));
   publics.push_back(std::move(destructor));
 
@@ -824,14 +897,13 @@
   }
 
   if (options.GenLog()) {
-    includes.emplace_back("chrono");      // for std::chrono::steady_clock
     includes.emplace_back("functional");  // for std::function
-    includes.emplace_back("json/value.h");
-    publics.emplace_back(
-        new LiteralDecl{"static std::function<void(const Json::Value&)> logFunc;\n"});
-  }
 
-  vector<unique_ptr<Declaration>> privates;
+    publics.emplace_back(new LiteralDecl{kTransactionLogStruct});
+    publics.emplace_back(
+        new LiteralDecl{"static std::function<void(const TransactionLog&)> logFunc;\n"});
+    privates.emplace_back(new LiteralDecl{kToStringHelper});
+  }
 
   if (options.Version() > 0) {
     privates.emplace_back(new LiteralDecl("int32_t cached_version_ = -1;\n"));
@@ -841,12 +913,14 @@
     privates.emplace_back(new LiteralDecl("std::mutex cached_hash_mutex_;\n"));
   }
 
+  const string attribute = GetDeprecatedAttribute(interface);
   unique_ptr<ClassDecl> bp_class{new ClassDecl{
       bp_name,
       "::android::BpInterface<" + i_name + ">",
       {},
       std::move(publics),
       std::move(privates),
+      attribute,
   }};
 
   return unique_ptr<Document>{
@@ -873,6 +947,15 @@
   vector<string> includes = {"binder/IInterface.h", HeaderFile(interface, ClassNames::RAW, false)};
 
   vector<unique_ptr<Declaration>> publics;
+  vector<unique_ptr<Declaration>> privates;
+
+  for (const auto& method : interface.GetMethods()) {
+    std::ostringstream code;
+    code << "static constexpr uint32_t TRANSACTION_" << method->GetName() << " = "
+         << "::android::IBinder::FIRST_CALL_TRANSACTION + " << method->GetId() << ";\n";
+    publics.push_back(std::make_unique<LiteralDecl>(code.str()));
+  }
+
   publics.push_back(std::move(constructor));
   publics.push_back(std::move(on_transact));
 
@@ -888,14 +971,22 @@
   }
 
   if (options.GenLog()) {
-    includes.emplace_back("chrono");      // for std::chrono::steady_clock
     includes.emplace_back("functional");  // for std::function
-    includes.emplace_back("json/value.h");
+
+    publics.emplace_back(new LiteralDecl{kTransactionLogStruct});
     publics.emplace_back(
-        new LiteralDecl{"static std::function<void(const Json::Value&)> logFunc;\n"});
+        new LiteralDecl{"static std::function<void(const TransactionLog&)> logFunc;\n"});
+    privates.emplace_back(new LiteralDecl{kToStringHelper});
   }
-  unique_ptr<ClassDecl> bn_class{
-      new ClassDecl{bn_name, "::android::BnInterface<" + i_name + ">", {}, std::move(publics), {}}};
+  const string attribute = GetDeprecatedAttribute(interface);
+  unique_ptr<ClassDecl> bn_class{new ClassDecl{
+      bn_name,
+      "::android::BnInterface<" + i_name + ">",
+      {},
+      std::move(publics),
+      std::move(privates),
+      attribute,
+  }};
 
   return unique_ptr<Document>{
       new CppHeader{includes, NestInNamespaces(std::move(bn_class), interface.GetSplitPackage())}};
@@ -914,7 +1005,8 @@
   }
 
   const string i_name = ClassName(interface, ClassNames::INTERFACE);
-  unique_ptr<ClassDecl> if_class{new ClassDecl{i_name, "::android::IInterface", {}}};
+  const string attribute = GetDeprecatedAttribute(interface);
+  unique_ptr<ClassDecl> if_class{new ClassDecl{i_name, "::android::IInterface", {}, attribute}};
   if_class->AddPublic(unique_ptr<Declaration>{new MacroDecl{
       "DECLARE_META_INTERFACE",
       ArgList{vector<string>{ClassName(interface, ClassNames::BASE)}}}});
@@ -932,43 +1024,7 @@
     if_class->AddPublic(unique_ptr<Declaration>(new LiteralDecl(code.str())));
   }
 
-  std::vector<std::unique_ptr<Declaration>> string_constants;
-  unique_ptr<Enum> int_constant_enum{new Enum{"", "int32_t", false}};
-  for (const auto& constant : interface.GetConstantDeclarations()) {
-    const AidlConstantValue& value = constant->GetValue();
-
-    switch (value.GetType()) {
-      case AidlConstantValue::Type::STRING: {
-        std::string cppType = CppNameOf(constant->GetType(), typenames);
-        unique_ptr<Declaration> getter(new MethodDecl("const " + cppType + "&", constant->GetName(),
-                                                      {}, MethodDecl::IS_STATIC));
-        string_constants.push_back(std::move(getter));
-        break;
-      }
-      case AidlConstantValue::Type::BOOLEAN:  // fall-through
-      case AidlConstantValue::Type::INT8:     // fall-through
-      case AidlConstantValue::Type::INT32:    // fall-through
-      // Type promotion may cause this. Value should be small enough to fit in int32.
-      case AidlConstantValue::Type::INT64: {
-        int_constant_enum->AddValue(constant->GetName(),
-                                    constant->ValueString(ConstantValueDecorator));
-        break;
-      }
-      default: {
-        AIDL_FATAL(value) << "Unrecognized constant type: " << static_cast<int>(value.GetType());
-      }
-    }
-  }
-  if (int_constant_enum->HasValues()) {
-    if_class->AddPublic(std::move(int_constant_enum));
-  }
-  if (!string_constants.empty()) {
-    includes.insert(kString16Header);
-
-    for (auto& string_constant : string_constants) {
-      if_class->AddPublic(std::move(string_constant));
-    }
-  }
+  BuildConstantDeclarations(interface, typenames, if_class, includes);
 
   if (options.GenTraces()) {
     includes.insert(kTraceHeader);
@@ -1002,7 +1058,9 @@
     if (method->IsUserDefined()) {
       std::ostringstream code;
       code << "::android::binder::Status " << method->GetName()
-           << BuildArgList(typenames, *method, true, true).ToString() << " override {\n"
+           << BuildArgList(typenames, *method, true, true).ToString() << " override";
+      GenerateDeprecated(code, *method);
+      code << " {\n"
            << "  return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);\n"
            << "}\n";
       method_decls.emplace_back(new LiteralDecl(code.str()));
@@ -1027,101 +1085,30 @@
   vector<unique_ptr<Declaration>> decls;
   decls.emplace_back(std::move(if_class));
   decls.emplace_back(new ClassDecl{
-      ClassName(interface, ClassNames::DEFAULT_IMPL), i_name, {}, std::move(method_decls), {}});
+      ClassName(interface, ClassNames::DEFAULT_IMPL),
+      i_name,
+      {},
+      std::move(method_decls),
+      {},
+      attribute,  // inherits the same attributes
+  });
 
   return unique_ptr<Document>{
       new CppHeader{vector<string>(includes.begin(), includes.end()),
                     NestInNamespaces(std::move(decls), interface.GetSplitPackage())}};
 }
 
-std::unique_ptr<Document> BuildParcelHeader(const AidlTypenames& typenames,
-                                            const AidlStructuredParcelable& parcel,
-                                            const Options&) {
-  const std::vector<std::string>& type_params =
-      parcel.IsGeneric() ? parcel.GetTypeParameters() : std::vector<std::string>();
-  unique_ptr<ClassDecl> parcel_class{
-      new ClassDecl{parcel.GetName(), "::android::Parcelable", type_params}};
-
-  set<string> includes = {kStatusHeader, kParcelHeader};
-  includes.insert("tuple");
-  for (const auto& variable : parcel.GetFields()) {
-    AddHeaders(variable->GetType(), typenames, &includes);
-  }
-
-  set<string> operators = {"<", ">", "==", ">=", "<=", "!="};
-  for (const auto& op : operators) {
-    std::ostringstream operator_code;
-    std::vector<std::string> variable_name;
-    std::vector<std::string> rhs_variable_name;
-    for (const auto& variable : parcel.GetFields()) {
-      variable_name.push_back(variable->GetName());
-      rhs_variable_name.push_back("rhs." + variable->GetName());
-    }
-
-    operator_code << "inline bool operator" << op << "([[maybe_unused]] const " << parcel.GetName()
-                  << "& rhs) const {\n"
-                  << "  return "
-                  << "std::tie(" << Join(variable_name, ", ") << ")" << op << "std::tie("
-                  << Join(rhs_variable_name, ", ") << ")"
-                  << ";\n"
-                  << "}\n";
-
-    parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(new LiteralDecl(operator_code.str())));
-  }
-  for (const auto& variable : parcel.GetFields()) {
-
-    std::ostringstream out;
-    std::string cppType = CppNameOf(variable->GetType(), typenames);
-    out << cppType.c_str() << " " << variable->GetName().c_str();
-    if (variable->GetDefaultValue()) {
-      out << " = " << cppType.c_str() << "(" << variable->ValueString(ConstantValueDecorator)
-          << ")";
-    } else if (variable->GetType().GetName() == "ParcelableHolder") {
-      if (parcel.IsVintfStability()) {
-        out << " { ::android::Parcelable::Stability::STABILITY_VINTF }";
-      } else {
-        out << " { ::android::Parcelable::Stability::STABILITY_LOCAL }";
-      }
-    }
-    out << ";\n";
-
-    parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(new LiteralDecl(out.str())));
-  }
-
-  if (parcel.IsVintfStability()) {
-    parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(
-        new LiteralDecl("::android::Parcelable::Stability getStability() const override { return "
-                        "::android::Parcelable::Stability::STABILITY_VINTF; }\n")));
-  }
-
-  unique_ptr<MethodDecl> read(new MethodDecl(kAndroidStatusLiteral, "readFromParcel",
-                                             ArgList("const ::android::Parcel* _aidl_parcel"),
-                                             MethodDecl::IS_OVERRIDE | MethodDecl::IS_FINAL));
-  parcel_class->AddPublic(std::move(read));
-  unique_ptr<MethodDecl> write(new MethodDecl(
-      kAndroidStatusLiteral, "writeToParcel", ArgList("::android::Parcel* _aidl_parcel"),
-      MethodDecl::IS_OVERRIDE | MethodDecl::IS_CONST | MethodDecl::IS_FINAL));
-  parcel_class->AddPublic(std::move(write));
-
-  parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(
-      new LiteralDecl(StringPrintf("static const std::string& getParcelableDescriptor() {\n"
-                                   "  static const std::string DESCIPTOR = \"%s\";\n"
-                                   "  return DESCIPTOR;\n"
-                                   "}\n",
-                                   parcel.GetCanonicalName().c_str()))));
-  return unique_ptr<Document>{
-      new CppHeader{vector<string>(includes.begin(), includes.end()),
-                    NestInNamespaces(std::move(parcel_class), parcel.GetSplitPackage())}};
+string GetInitializer(const AidlTypenames& typenames, const AidlVariableDeclaration& variable) {
+  string cppType = CppNameOf(variable.GetType(), typenames);
+  return cppType + "(" + variable.ValueString(ConstantValueDecorator) + ")";
 }
-std::unique_ptr<Document> BuildParcelSource(const AidlTypenames& typenames,
-                                            const AidlStructuredParcelable& parcel,
-                                            const Options&) {
-  const std::vector<std::string>& type_params =
-      parcel.IsGeneric() ? parcel.GetTypeParameters() : std::vector<std::string>();
-  unique_ptr<MethodImpl> read{new MethodImpl{kAndroidStatusLiteral, parcel.GetName(),
-                                             "readFromParcel", type_params,
-                                             ArgList("const ::android::Parcel* _aidl_parcel")}};
-  StatementBlock* read_block = read->GetStatementBlock();
+
+void AddTypeSpecificHeaders(const AidlStructuredParcelable&, std::set<std::string>& includes) {
+  includes.insert("tuple");  // std::tie in comparison operators
+}
+
+void BuildReadFromParcel(const AidlStructuredParcelable& parcel, const AidlTypenames& typenames,
+                         StatementBlock* read_block) {
   read_block->AddLiteral(
       StringPrintf("%s %s = %s", kAndroidStatusLiteral, kAndroidStatusVarName, kAndroidStatusOk));
 
@@ -1149,11 +1136,10 @@
         kAndroidStatusVarName));
   }
   read_block->AddLiteral(StringPrintf("return %s", kAndroidStatusVarName));
+}
 
-  unique_ptr<MethodImpl> write{
-      new MethodImpl{kAndroidStatusLiteral, parcel.GetName(), "writeToParcel", type_params,
-                     ArgList("::android::Parcel* _aidl_parcel"), true /*const*/}};
-  StatementBlock* write_block = write->GetStatementBlock();
+void BuildWriteToParcel(const AidlStructuredParcelable& parcel, const AidlTypenames& typenames,
+                        StatementBlock* write_block) {
   write_block->AddLiteral(
       StringPrintf("%s %s = %s", kAndroidStatusLiteral, kAndroidStatusVarName, kAndroidStatusOk));
 
@@ -1176,8 +1162,161 @@
       "_aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);\n"
       "_aidl_parcel->setDataPosition(_aidl_end_pos);");
   write_block->AddLiteral(StringPrintf("return %s", kAndroidStatusVarName));
+}
+
+ParcelWriterContext GetParcelWriterContext(const AidlTypenames& typenames) {
+  return ParcelWriterContext{
+      .status_type = kAndroidStatusLiteral,
+      .status_ok = kAndroidStatusOk,
+      .status_bad = kAndroidStatusBadValue,
+      .read_func =
+          [&](CodeWriter& out, const string& var, const AidlTypeSpecifier& type) {
+            out << fmt::format("{}->{}({})", kParcelVarName, ParcelReadMethodOf(type, typenames),
+                               ParcelReadCastOf(type, typenames, "&" + var));
+          },
+      .write_func =
+          [&](CodeWriter& out, const string& value, const AidlTypeSpecifier& type) {
+            out << fmt::format("{}->{}({})", kParcelVarName, ParcelWriteMethodOf(type, typenames),
+                               ParcelWriteCastOf(type, typenames, value));
+          },
+  };
+}
+
+void AddTypeSpecificHeaders(const AidlUnionDecl&, std::set<std::string>& includes) {
+  includes.insert(std::begin(UnionWriter::headers), std::end(UnionWriter::headers));
+}
+
+void BuildReadFromParcel(const AidlUnionDecl& decl, const AidlTypenames& typenames,
+                         StatementBlock* read_block) {
+  string body;
+  UnionWriter uw{decl, typenames, &CppNameOf, &ConstantValueDecorator};
+  uw.ReadFromParcel(*CodeWriter::ForString(&body), GetParcelWriterContext(typenames));
+  read_block->AddLiteral(body, /*add_semicolon=*/false);
+}
+
+void BuildWriteToParcel(const AidlUnionDecl& decl, const AidlTypenames& typenames,
+                        StatementBlock* write_block) {
+  string body;
+  UnionWriter uw{decl, typenames, &CppNameOf, &ConstantValueDecorator};
+  uw.WriteToParcel(*CodeWriter::ForString(&body), GetParcelWriterContext(typenames));
+  write_block->AddLiteral(body, /*add_semicolon=*/false);
+}
+
+void BuildParcelFields(ClassDecl& clazz, const AidlStructuredParcelable& decl,
+                       const AidlTypenames& typenames) {
+  for (const auto& variable : decl.GetFields()) {
+    std::ostringstream out;
+    std::string cppType = CppNameOf(variable->GetType(), typenames);
+    out << cppType;
+    GenerateDeprecated(out, *variable);
+    out << " " << variable->GetName().c_str();
+    if (variable->GetDefaultValue()) {
+      out << " = " << GetInitializer(typenames, *variable);
+    } else if (variable->GetType().GetName() == "ParcelableHolder") {
+      if (decl.IsVintfStability()) {
+        out << " { ::android::Parcelable::Stability::STABILITY_VINTF }";
+      } else {
+        out << " { ::android::Parcelable::Stability::STABILITY_LOCAL }";
+      }
+    }
+    out << ";\n";
+
+    clazz.AddPublic(std::unique_ptr<LiteralDecl>(new LiteralDecl(out.str())));
+  }
+}
+
+void BuildParcelFields(ClassDecl& clazz, const AidlUnionDecl& decl,
+                       const AidlTypenames& typenames) {
+  UnionWriter uw{decl, typenames, &CppNameOf, &ConstantValueDecorator};
+  string public_fields;
+  string private_fields;
+  uw.PublicFields(*CodeWriter::ForString(&public_fields));
+  uw.PrivateFields(*CodeWriter::ForString(&private_fields));
+  clazz.AddPublic(std::make_unique<LiteralDecl>(public_fields));
+  clazz.AddPrivate(std::make_unique<LiteralDecl>(private_fields));
+}
+
+template <typename ParcelableType>
+std::unique_ptr<Document> BuildParcelHeader(const AidlTypenames& typenames,
+                                            const ParcelableType& parcel, const Options&) {
+  const std::vector<std::string>& type_params =
+      parcel.IsGeneric() ? parcel.GetTypeParameters() : std::vector<std::string>();
+  const std::string attribute = GetDeprecatedAttribute(parcel);
+  unique_ptr<ClassDecl> parcel_class{
+      new ClassDecl{parcel.GetName(), "::android::Parcelable", type_params, attribute}};
+
+  set<string> includes = {kStatusHeader, kParcelHeader, kString16Header};
+  AddTypeSpecificHeaders(parcel, includes);
+
+  for (const auto& variable : parcel.GetFields()) {
+    AddHeaders(variable->GetType(), typenames, &includes);
+  }
+
+  string operator_code;
+  GenerateParcelableComparisonOperators(*CodeWriter::ForString(&operator_code), parcel);
+  parcel_class->AddPublic(std::make_unique<LiteralDecl>(operator_code));
+
+  BuildParcelFields(*parcel_class, parcel, typenames);
+  BuildConstantDeclarations(parcel, typenames, parcel_class, includes);
+
+  if (parcel.IsVintfStability()) {
+    parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(
+        new LiteralDecl("::android::Parcelable::Stability getStability() const override { return "
+                        "::android::Parcelable::Stability::STABILITY_VINTF; }\n")));
+  }
+
+  unique_ptr<MethodDecl> read(new MethodDecl(kAndroidStatusLiteral, "readFromParcel",
+                                             ArgList("const ::android::Parcel* _aidl_parcel"),
+                                             MethodDecl::IS_OVERRIDE | MethodDecl::IS_FINAL));
+  parcel_class->AddPublic(std::move(read));
+  unique_ptr<MethodDecl> write(new MethodDecl(
+      kAndroidStatusLiteral, "writeToParcel", ArgList("::android::Parcel* _aidl_parcel"),
+      MethodDecl::IS_OVERRIDE | MethodDecl::IS_CONST | MethodDecl::IS_FINAL));
+  parcel_class->AddPublic(std::move(write));
+
+  parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(
+      new LiteralDecl(StringPrintf("static const ::android::String16& getParcelableDescriptor() {\n"
+                                   "  static const ::android::StaticString16 DESCIPTOR (u\"%s\");\n"
+                                   "  return DESCIPTOR;\n"
+                                   "}\n",
+                                   parcel.GetCanonicalName().c_str()))));
+
+  // toString() method
+  includes.insert("codecvt");  // std::codecvt_utf8_utf16
+  includes.insert("locale");   // std::wstrinig_convert
+  includes.insert("sstream");  // std::ostringstream
+  string to_string;
+  GenerateToString(*CodeWriter::ForString(&to_string), parcel);
+  parcel_class->AddPublic(std::make_unique<LiteralDecl>(to_string));
+
+  auto decls = NestInNamespaces(std::move(parcel_class), parcel.GetSplitPackage());
+  // TODO(b/31559095) bionic on host should define this
+  if (parcel.AsUnionDeclaration()) {
+    decls.insert(decls.begin(),
+                 std::make_unique<LiteralDecl>(
+                     "#ifndef __BIONIC__\n#define __assert2(a,b,c,d) ((void)0)\n#endif\n\n"));
+  }
+  return unique_ptr<Document>{
+      new CppHeader{vector<string>(includes.begin(), includes.end()), std::move(decls)}};
+}
+
+template <typename T>
+std::unique_ptr<Document> BuildParcelSource(const AidlTypenames& typenames, const T& parcel,
+                                            const Options&) {
+  const std::vector<std::string>& type_params =
+      parcel.IsGeneric() ? parcel.GetTypeParameters() : std::vector<std::string>();
+  auto read =
+      std::make_unique<MethodImpl>(kAndroidStatusLiteral, parcel.GetName(), "readFromParcel",
+                                   type_params, ArgList("const ::android::Parcel* _aidl_parcel"));
+  BuildReadFromParcel(parcel, typenames, read->GetStatementBlock());
+
+  auto write = std::make_unique<MethodImpl>(
+      kAndroidStatusLiteral, parcel.GetName(), "writeToParcel", type_params,
+      ArgList("::android::Parcel* _aidl_parcel"), true /*const*/);
+  BuildWriteToParcel(parcel, typenames, write->GetStatementBlock());
 
   vector<unique_ptr<Declaration>> file_decls;
+  BuildConstantDefinitions(parcel, typenames, type_params, parcel.GetName(), file_decls);
   file_decls.push_back(std::move(read));
   file_decls.push_back(std::move(write));
 
@@ -1192,7 +1331,10 @@
 std::string GenerateEnumToString(const AidlTypenames& typenames,
                                  const AidlEnumDeclaration& enum_decl) {
   std::ostringstream code;
-  code << "static inline std::string toString(" << enum_decl.GetName() << " val) {\n";
+  const std::string signature =
+      "static inline std::string toString(" + enum_decl.GetName() + " val)";
+  GenerateDeprecated(code, enum_decl);
+  code << signature << " {\n";
   code << "  switch(val) {\n";
   std::set<std::string> unique_cases;
   for (const auto& enumerator : enum_decl.GetEnumerators()) {
@@ -1217,8 +1359,9 @@
 
 std::unique_ptr<Document> BuildEnumHeader(const AidlTypenames& typenames,
                                           const AidlEnumDeclaration& enum_decl) {
-  std::unique_ptr<Enum> generated_enum{
-      new Enum{enum_decl.GetName(), CppNameOf(enum_decl.GetBackingType(), typenames), true}};
+  const std::string attribute = GetDeprecatedAttribute(enum_decl);
+  std::unique_ptr<Enum> generated_enum{new Enum{
+      enum_decl.GetName(), CppNameOf(enum_decl.GetBackingType(), typenames), true, attribute}};
   for (const auto& enumerator : enum_decl.GetEnumerators()) {
     generated_enum->AddValue(
         enumerator->GetName(),
@@ -1314,9 +1457,10 @@
   return success;
 }
 
-bool GenerateCppParcel(const string& output_file, const Options& options,
-                       const AidlTypenames& typenames, const AidlStructuredParcelable& parcelable,
-                       const IoDelegate& io_delegate) {
+template <typename ParcelableType>
+bool GenerateCppParcelable(const std::string& output_file, const Options& options,
+                           const AidlTypenames& typenames, const ParcelableType& parcelable,
+                           const IoDelegate& io_delegate) {
   auto header = BuildParcelHeader(typenames, parcelable, options);
   auto source = BuildParcelSource(typenames, parcelable, options);
 
@@ -1413,9 +1557,16 @@
                  const AidlDefinedType& defined_type, const IoDelegate& io_delegate) {
   const AidlStructuredParcelable* parcelable = defined_type.AsStructuredParcelable();
   if (parcelable != nullptr) {
-    return GenerateCppParcel(output_file, options, typenames, *parcelable, io_delegate);
+    return GenerateCppParcelable(output_file, options, typenames, *parcelable, io_delegate);
   }
 
+  // should come before AsParcelable() because union is a parcelable
+  const AidlUnionDecl* union_decl = defined_type.AsUnionDeclaration();
+  if (union_decl != nullptr) {
+    return GenerateCppParcelable(output_file, options, typenames, *union_decl, io_delegate);
+  }
+
+  // unstructured parcelable
   const AidlParcelable* parcelable_decl = defined_type.AsParcelable();
   if (parcelable_decl != nullptr) {
     return GenerateCppParcelDeclaration(output_file, options, *parcelable_decl, io_delegate);
diff --git a/generate_cpp.h b/generate_cpp.h
index 3fd7caf..3b7d2b9 100644
--- a/generate_cpp.h
+++ b/generate_cpp.h
@@ -51,14 +51,6 @@
 std::unique_ptr<Document> BuildInterfaceHeader(const AidlTypenames& typenames,
                                                const AidlInterface& parsed_doc,
                                                const Options& options);
-
-std::unique_ptr<Document> BuildParcelHeader(const AidlTypenames& typenames,
-                                            const AidlStructuredParcelable& parsed_doc,
-                                            const Options& options);
-std::unique_ptr<Document> BuildParcelSource(const AidlTypenames& typenames,
-                                            const AidlStructuredParcelable& parsed_doc,
-                                            const Options& options);
-
 std::unique_ptr<Document> BuildEnumHeader(const AidlTypenames& typenames,
                                           const AidlEnumDeclaration& parsed_doc);
 }
diff --git a/generate_cpp_unittest.cpp b/generate_cpp_unittest.cpp
index d1ad504..8a1b23f 100644
--- a/generate_cpp_unittest.cpp
+++ b/generate_cpp_unittest.cpp
@@ -87,6 +87,7 @@
 
 const char kExpectedComplexTypeClientSourceOutput[] =
     R"(#include <android/os/BpComplexTypeInterface.h>
+#include <android/os/BnComplexTypeInterface.h>
 #include <binder/Parcel.h>
 #include <android-base/macros.h>
 
@@ -119,7 +120,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Send, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return);
   }
@@ -163,7 +164,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Piff, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->Piff(times);
   }
@@ -188,7 +189,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesABinder, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return);
   }
@@ -220,7 +221,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_NullableBinder, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return);
   }
@@ -256,7 +257,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_StringListMethod, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return);
   }
@@ -296,7 +297,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_BinderListMethod, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return);
   }
@@ -336,7 +337,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _aidl_return);
   }
@@ -372,7 +373,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return);
   }
@@ -402,6 +403,7 @@
 
 const char kExpectedComplexTypeClientWithTraceSourceOutput[] =
     R"(#include <android/os/BpComplexTypeInterface.h>
+#include <android/os/BnComplexTypeInterface.h>
 #include <binder/Parcel.h>
 #include <android-base/macros.h>
 
@@ -435,7 +437,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Send, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return);
   }
@@ -480,7 +482,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Piff, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->Piff(times);
   }
@@ -506,7 +508,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesABinder, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return);
   }
@@ -539,7 +541,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_NullableBinder, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return);
   }
@@ -576,7 +578,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_StringListMethod, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return);
   }
@@ -617,7 +619,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_BinderListMethod, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return);
   }
@@ -658,7 +660,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _aidl_return);
   }
@@ -695,7 +697,7 @@
   if (((_aidl_ret_status) != (::android::OK))) {
     goto _aidl_error;
   }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */, _aidl_data, &_aidl_reply);
+  _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray, _aidl_data, &_aidl_reply, 0);
   if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
      return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return);
   }
@@ -735,6 +737,14 @@
 
 class BnComplexTypeInterface : public ::android::BnInterface<IComplexTypeInterface> {
 public:
+  static constexpr uint32_t TRANSACTION_Send = ::android::IBinder::FIRST_CALL_TRANSACTION + 0;
+  static constexpr uint32_t TRANSACTION_Piff = ::android::IBinder::FIRST_CALL_TRANSACTION + 1;
+  static constexpr uint32_t TRANSACTION_TakesABinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 2;
+  static constexpr uint32_t TRANSACTION_NullableBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 3;
+  static constexpr uint32_t TRANSACTION_StringListMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 4;
+  static constexpr uint32_t TRANSACTION_BinderListMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 5;
+  static constexpr uint32_t TRANSACTION_TakesAFileDescriptor = ::android::IBinder::FIRST_CALL_TRANSACTION + 6;
+  static constexpr uint32_t TRANSACTION_TakesAFileDescriptorArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 7;
   explicit BnComplexTypeInterface();
   ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
 };  // class BnComplexTypeInterface
@@ -761,7 +771,7 @@
 ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
   ::android::status_t _aidl_ret_status = ::android::OK;
   switch (_aidl_code) {
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */:
+  case BnComplexTypeInterface::TRANSACTION_Send:
   {
     ::std::optional<::std::vector<int32_t>> in_goes_in;
     ::std::vector<double> in_goes_in_and_out;
@@ -805,7 +815,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */:
+  case BnComplexTypeInterface::TRANSACTION_Piff:
   {
     int32_t in_times;
     if (!(_aidl_data.checkInterface(this))) {
@@ -819,7 +829,7 @@
     ::android::binder::Status _aidl_status(Piff(in_times));
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */:
+  case BnComplexTypeInterface::TRANSACTION_TakesABinder:
   {
     ::android::sp<::foo::IFooType> in_f;
     ::android::sp<::foo::IFooType> _aidl_return;
@@ -845,7 +855,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */:
+  case BnComplexTypeInterface::TRANSACTION_NullableBinder:
   {
     ::android::sp<::foo::IFooType> _aidl_return;
     if (!(_aidl_data.checkInterface(this))) {
@@ -866,7 +876,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */:
+  case BnComplexTypeInterface::TRANSACTION_StringListMethod:
   {
     ::std::vector<::android::String16> in_input;
     ::std::vector<::android::String16> out_output;
@@ -897,7 +907,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */:
+  case BnComplexTypeInterface::TRANSACTION_BinderListMethod:
   {
     ::std::vector<::android::sp<::android::IBinder>> in_input;
     ::std::vector<::android::sp<::android::IBinder>> out_output;
@@ -928,7 +938,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */:
+  case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor:
   {
     ::android::base::unique_fd in_f;
     ::android::base::unique_fd _aidl_return;
@@ -954,7 +964,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */:
+  case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray:
   {
     ::std::vector<::android::base::unique_fd> in_f;
     ::std::vector<::android::base::unique_fd> _aidl_return;
@@ -1014,7 +1024,7 @@
 ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
   ::android::status_t _aidl_ret_status = ::android::OK;
   switch (_aidl_code) {
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Send */:
+  case BnComplexTypeInterface::TRANSACTION_Send:
   {
     ::std::optional<::std::vector<int32_t>> in_goes_in;
     ::std::vector<double> in_goes_in_and_out;
@@ -1059,7 +1069,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */:
+  case BnComplexTypeInterface::TRANSACTION_Piff:
   {
     int32_t in_times;
     if (!(_aidl_data.checkInterface(this))) {
@@ -1074,7 +1084,7 @@
     ::android::binder::Status _aidl_status(Piff(in_times));
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */:
+  case BnComplexTypeInterface::TRANSACTION_TakesABinder:
   {
     ::android::sp<::foo::IFooType> in_f;
     ::android::sp<::foo::IFooType> _aidl_return;
@@ -1101,7 +1111,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */:
+  case BnComplexTypeInterface::TRANSACTION_NullableBinder:
   {
     ::android::sp<::foo::IFooType> _aidl_return;
     if (!(_aidl_data.checkInterface(this))) {
@@ -1123,7 +1133,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */:
+  case BnComplexTypeInterface::TRANSACTION_StringListMethod:
   {
     ::std::vector<::android::String16> in_input;
     ::std::vector<::android::String16> out_output;
@@ -1155,7 +1165,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */:
+  case BnComplexTypeInterface::TRANSACTION_BinderListMethod:
   {
     ::std::vector<::android::sp<::android::IBinder>> in_input;
     ::std::vector<::android::sp<::android::IBinder>> out_output;
@@ -1187,7 +1197,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */:
+  case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor:
   {
     ::android::base::unique_fd in_f;
     ::android::base::unique_fd _aidl_return;
@@ -1214,7 +1224,7 @@
     }
   }
   break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */:
+  case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray:
   {
     ::std::vector<::android::base::unique_fd> in_f;
     ::std::vector<::android::base::unique_fd> _aidl_return;
diff --git a/generate_java.cpp b/generate_java.cpp
index 5b998df..17756c9 100644
--- a/generate_java.cpp
+++ b/generate_java.cpp
@@ -23,31 +23,288 @@
 #include <algorithm>
 #include <map>
 #include <memory>
+#include <optional>
 #include <sstream>
 
+#include <android-base/format.h>
 #include <android-base/stringprintf.h>
 
 #include "aidl_to_java.h"
 #include "code_writer.h"
 #include "logging.h"
 
-using std::unique_ptr;
-using ::android::aidl::java::Variable;
+using ::android::base::EndsWith;
+using ::android::base::Join;
+using ::android::base::StartsWith;
 using std::string;
+using std::unique_ptr;
+using std::vector;
 
 namespace {
-inline string get_setter_name(const AidlNode& context, const string& variablename) {
-  AIDL_FATAL_IF(variablename.size() <= 0, context) << "A field name cannot be empty.";
-  std::ostringstream out;
-  out << "set" << static_cast<char>(toupper(variablename[0])) << variablename.substr(1);
-  return out.str();
+using android::aidl::java::CodeGeneratorContext;
+using android::aidl::java::ConstantValueDecorator;
+
+inline string getter_name(const AidlVariableDeclaration& variable) {
+  return "get" + variable.GetCapitalizedName();
 }
+inline string setter_name(const AidlVariableDeclaration& variable) {
+  return "set" + variable.GetCapitalizedName();
+}
+
+// clang-format off
+const map<string, string> contents_describers {
+  {"FileDescriptor", R"(if (_v instanceof java.io.FileDescriptor) {
+  return android.os.Parcelable.CONTENTS_FILE_DESCRIPTOR;
+})"},
+  {"Parcelable", R"(if (_v instanceof android.os.Parcelable) {
+  return ((android.os.Parcelable) _v).describeContents();
+})"},
+  {"Map", R"(if (_v instanceof java.util.Map) {
+  return describeContents(((java.util.Map) _v).values());
+})"},
+  {"List", R"(if (_v instanceof java.util.Collection) {
+  int _mask = 0;
+  for (Object o : (java.util.Collection) _v) {
+    _mask |= describeContents(o);
+  }
+  return _mask;
+})"},
+  {"Array", R"(Class<?> _clazz = _v.getClass();
+if (_clazz.isArray() && _clazz.getComponentType() == Object.class) {
+  int _mask = 0;
+  for (Object o : (Object[]) _v) {
+    _mask |= describeContents(o);
+  }
+  return _mask;
+})"},
+};
+// clang-format on
+
+void GenerateDescribeContentsHelper(CodeWriter& out, const set<string>& describers) {
+  out << "private int describeContents(Object _v) {\n";
+  out.Indent();
+  out << "if (_v == null) return 0;\n";
+  for (const auto& d : describers) {
+    out << contents_describers.at(d) << "\n";
+  }
+  out << "return 0;\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+// Some types contribute to Parcelable.describeContents().
+// e.g. FileDescriptor, Parcelables, List<Parcelables> ...
+bool CanDescribeContents(const AidlTypeSpecifier& type, const AidlTypenames& types,
+                         set<string>* describers) {
+  if (type.IsArray()) {
+    if (CanDescribeContents(type.ArrayBase(), types, describers)) {
+      describers->insert("Array");
+      return true;
+    }
+    return false;
+  }
+
+  if (type.GetName() == "List") {
+    if (CanDescribeContents(*type.GetTypeParameters()[0], types, describers)) {
+      describers->insert("List");
+      return true;
+    }
+    return false;
+  }
+
+  if (type.GetName() == "Map") {
+    if (CanDescribeContents(*type.GetTypeParameters()[1], types, describers)) {
+      describers->insert("Map");  // Map describer uses List describer
+      describers->insert("List");
+      return true;
+    }
+    return false;
+  }
+
+  if (type.GetName() == "FileDescriptor") {
+    describers->insert("FileDescriptor");
+    return true;
+  }
+
+  if (type.GetName() == "ParcelFileDescriptor" || type.GetName() == "ParcelableHolder" ||
+      types.GetParcelable(type) != nullptr) {
+    describers->insert("Parcelable");
+    return true;
+  }
+
+  return false;
+}
+void GenerateParcelableDescribeContents(CodeWriter& out, const AidlStructuredParcelable& decl,
+                                        const AidlTypenames& types) {
+  set<string> describers;
+
+  out << "@Override\n";
+  out << "public int describeContents() {\n";
+  out.Indent();
+  out << "int _mask = 0;\n";
+  for (const auto& f : decl.GetFields()) {
+    if (CanDescribeContents(f->GetType(), types, &describers)) {
+      out << "_mask |= describeContents(" << f->GetName() << ");\n";
+    }
+  }
+  out << "return _mask;\n";
+  out.Dedent();
+  out << "}\n";
+  if (!describers.empty()) {
+    GenerateDescribeContentsHelper(out, describers);
+  }
+}
+
+void GenerateParcelableDescribeContents(CodeWriter& out, const AidlUnionDecl& decl,
+                                        const AidlTypenames& types) {
+  set<string> describers;
+
+  out << "@Override\n";
+  out << "public int describeContents() {\n";
+  out.Indent();
+  out << "int _mask = 0;\n";
+  out << "switch (getTag()) {\n";
+  for (const auto& f : decl.GetFields()) {
+    if (CanDescribeContents(f->GetType(), types, &describers)) {
+      out << "case " << f->GetName() << ":\n";
+      out.Indent();
+      out << "_mask |= describeContents(" << getter_name(*f) << "());\n";
+      out << "break;\n";
+      out.Dedent();
+    }
+  }
+  out << "}\n";
+  out << "return _mask;\n";
+  out.Dedent();
+  out << "}\n";
+  if (!describers.empty()) {
+    GenerateDescribeContentsHelper(out, describers);
+  }
+}
+
+void GenerateToString(CodeWriter& out, const AidlStructuredParcelable& parcel,
+                      const AidlTypenames& typenames) {
+  out << "@Override\n";
+  out << "public String toString() {\n";
+  out.Indent();
+  out << "java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(";
+  out << "\", \", \"{\", \"}\");\n";
+  for (const auto& field : parcel.GetFields()) {
+    CodeGeneratorContext ctx{
+        .writer = out,
+        .typenames = typenames,
+        .type = field->GetType(),
+        .var = field->GetName(),
+    };
+    out << "_aidl_sj.add(\"" << field->GetName() << ": \" + (";
+    ToStringFor(ctx);
+    out << "));\n";
+  }
+  out << "return \"" << parcel.GetCanonicalName() << "\" + _aidl_sj.toString()  ;\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+void GenerateToString(CodeWriter& out, const AidlUnionDecl& parcel,
+                      const AidlTypenames& typenames) {
+  out << "@Override\n";
+  out << "public String toString() {\n";
+  out.Indent();
+  out << "switch (_tag) {\n";
+  for (const auto& field : parcel.GetFields()) {
+    CodeGeneratorContext ctx{
+        .writer = out,
+        .typenames = typenames,
+        .type = field->GetType(),
+        .var = getter_name(*field) + "()",
+    };
+    out << "case " << field->GetName() << ": return \"" << parcel.GetCanonicalName() << "."
+        << field->GetName() << "(\" + (";
+    ToStringFor(ctx);
+    out << ") + \")\";\n";
+  }
+  out << "}\n";
+  out << "throw new IllegalStateException(\"unknown field: \" + _tag);\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+void GenerateEqualsAndHashCode(CodeWriter& out, const AidlStructuredParcelable& parcel,
+                      const AidlTypenames&) {
+  out << "@Override\n";
+  out << "public boolean equals(Object other) {\n";
+  out.Indent();
+  out << "if (this == other) return true;\n";
+  out << "if (other == null) return false;\n";
+  out << "if (!(other instanceof " << parcel.GetName() << ")) return false;\n";
+  out << parcel.GetName() << " that = (" << parcel.GetName() << ")other;\n";
+  for (const auto& field : parcel.GetFields()) {
+    out << "if (!java.util.Objects.deepEquals(" << field->GetName() << ", that." << field->GetName()
+        << ")) return false;\n";
+  }
+  out << "return true;\n";
+  out.Dedent();
+  out << "}\n";
+  out << "\n";
+  out << "@Override\n";
+  out << "public int hashCode() {\n";
+  out.Indent();
+  out << "return java.util.Arrays.deepHashCode(java.util.Arrays.asList(";
+  std::vector<std::string> names;
+  for (const auto& field : parcel.GetFields()) {
+    names.push_back(field->GetName());
+  }
+  out << android::base::Join(names, ", ") << ").toArray());\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+void GenerateEqualsAndHashCode(CodeWriter& out, const AidlUnionDecl& decl,
+                                 const AidlTypenames&) {
+  out << "@Override\n";
+  out << "public boolean equals(Object other) {\n";
+  out.Indent();
+  out << "if (this == other) return true;\n";
+  out << "if (other == null) return false;\n";
+  out << "if (!(other instanceof " << decl.GetName() << ")) return false;\n";
+  out << decl.GetName() << " that = (" << decl.GetName() << ")other;\n";
+  out << "if (_tag != that._tag) return false;\n";
+  out << "if (!java.util.Objects.deepEquals(_value, that._value)) return false;\n";
+  out << "return true;\n";
+  out.Dedent();
+  out << "}\n";
+  out << "\n";
+  out << "@Override\n";
+  out << "public int hashCode() {\n";
+  out.Indent();
+  out << "return java.util.Arrays.deepHashCode(java.util.Arrays.asList(_tag, _value).toArray());\n";
+  out.Dedent();
+  out << "}\n";
+  out << "\n";
+}
+
 }  // namespace
 
 namespace android {
 namespace aidl {
 namespace java {
 
+std::string GenerateComments(const AidlCommentable& node) {
+  std::string comments = FormatCommentsForJava(node.GetComments());
+  if (!comments.empty() && comments.back() != '\n') {
+    comments += '\n';
+  }
+  return comments;
+}
+
+std::string GenerateAnnotations(const AidlNode& node) {
+  std::string result;
+  for (const auto& a : JavaAnnotationsFor(node)) {
+    result += a + "\n";
+  }
+  return result;
+}
+
 bool generate_java_interface(const string& filename, const AidlInterface* iface,
                              const AidlTypenames& typenames, const IoDelegate& io_delegate,
                              const Options& options) {
@@ -83,6 +340,14 @@
   return true;
 }
 
+bool generate_java_union_declaration(const std::string& filename, const AidlUnionDecl* decl,
+                                     const AidlTypenames& typenames,
+                                     const IoDelegate& io_delegate) {
+  CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
+  generate_union(*code_writer, decl, typenames);
+  return true;
+}
+
 bool generate_java(const std::string& filename, const AidlDefinedType* defined_type,
                    const AidlTypenames& typenames, const IoDelegate& io_delegate,
                    const Options& options) {
@@ -100,6 +365,10 @@
     return generate_java_interface(filename, interface, typenames, io_delegate, options);
   }
 
+  if (const AidlUnionDecl* union_decl = defined_type->AsUnionDeclaration(); union_decl != nullptr) {
+    return generate_java_union_declaration(filename, union_decl, typenames, io_delegate);
+  }
+
   AIDL_FATAL(defined_type) << "Unrecognized type sent for Java generation.";
   return false;
 }
@@ -107,12 +376,12 @@
 std::unique_ptr<android::aidl::java::Class> generate_parcel_class(
     const AidlStructuredParcelable* parcel, const AidlTypenames& typenames) {
   auto parcel_class = std::make_unique<Class>();
-  parcel_class->comment = parcel->GetComments();
+  parcel_class->comment = GenerateComments(*parcel);
   parcel_class->modifiers = PUBLIC;
   parcel_class->what = Class::CLASS;
   parcel_class->type = parcel->GetCanonicalName();
   parcel_class->interfaces.push_back("android.os.Parcelable");
-  parcel_class->annotations = generate_java_annotations(*parcel);
+  parcel_class->annotations = JavaAnnotationsFor(*parcel);
 
   if (parcel->IsGeneric()) {
     parcel_class->type += "<" + base::Join(parcel->GetTypeParameters(), ",") + ">";
@@ -120,10 +389,8 @@
 
   for (const auto& variable : parcel->GetFields()) {
     std::ostringstream out;
-    out << variable->GetType().GetComments() << "\n";
-    for (const auto& a : generate_java_annotations(variable->GetType())) {
-      out << a << "\n";
-    }
+    out << GenerateComments(*variable);
+    out << GenerateAnnotations(*variable);
     out << "public ";
 
     if (variable->GetType().GetName() == "ParcelableHolder" || parcel->IsJavaOnlyImmutable()) {
@@ -162,7 +429,7 @@
         out << " = " << variable->ValueString(ConstantValueDecorator);
       }
       out << ";\n";
-      out << "public Builder " << get_setter_name(*variable, variable->GetName()) << "("
+      out << "public Builder " << setter_name(*variable) << "("
           << JavaSignatureOf(variable->GetType(), typenames) << " " << variable->GetName()
           << ") {\n"
           << "  "
@@ -338,8 +605,7 @@
     }
     CreateFromParcelFor(context);
     if (parcel->IsJavaOnlyImmutable()) {
-      context.writer.Write("%s.%s(%s);\n", builder_variable.c_str(),
-                           get_setter_name(*field, field->GetName()).c_str(),
+      context.writer.Write("%s.%s(%s);\n", builder_variable.c_str(), setter_name(*field).c_str(),
                            field_variable_name.c_str());
     }
     writer->Close();
@@ -364,39 +630,26 @@
 
   parcel_class->elements.push_back(read_or_create_method);
 
-  if (parcel->IsJavaDebug()) {
-    out.str("");
-    out << "@Override\n";
-    out << "public String toString() {\n";
-    out << "  java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(";
-    out << "\", \", \"{\", \"}\");\n";
-    for (const auto& field : parcel->GetFields()) {
-      std::string code;
-      CodeWriterPtr writer = CodeWriter::ForString(&code);
-      CodeGeneratorContext context{
-          .writer = *(writer.get()),
-          .typenames = typenames,
-          .type = field->GetType(),
-          .parcel = parcel_variable->name,
-          .var = field->GetName(),
-          .is_classloader_created = &is_classloader_created,
-      };
-      ToStringFor(context);
-      writer->Close();
-      out << "  _aidl_sj.add(\"" << field->GetName() << ": \" + (" << code << "));\n";
-    }
-    out << "  return \"" << parcel->GetCanonicalName() << "\" + _aidl_sj.toString()  ;\n";
-    out << "}\n";
-    parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(out.str()));
+  string constants;
+  generate_constant_declarations(*CodeWriter::ForString(&constants), *parcel);
+  parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(constants));
+
+  if (parcel->JavaDerive("toString")) {
+    string to_string;
+    GenerateToString(*CodeWriter::ForString(&to_string), *parcel, typenames);
+    parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(to_string));
   }
 
-  auto describe_contents_method = std::make_shared<Method>();
-  describe_contents_method->modifiers = PUBLIC | OVERRIDE;
-  describe_contents_method->returnType = "int";
-  describe_contents_method->name = "describeContents";
-  describe_contents_method->statements = std::make_shared<StatementBlock>();
-  describe_contents_method->statements->Add(std::make_shared<LiteralStatement>("return 0;\n"));
-  parcel_class->elements.push_back(describe_contents_method);
+  if (parcel->JavaDerive("equals")) {
+    string to_string;
+    GenerateEqualsAndHashCode(*CodeWriter::ForString(&to_string), *parcel, typenames);
+    parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(to_string));
+  }
+
+  string describe_contents;
+  GenerateParcelableDescribeContents(*CodeWriter::ForString(&describe_contents), *parcel,
+                                     typenames);
+  parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(describe_contents));
 
   return parcel_class;
 }
@@ -409,14 +662,13 @@
       " */\n");
 
   code_writer->Write("package %s;\n", enum_decl->GetPackage().c_str());
-  code_writer->Write("%s\n", enum_decl->GetComments().c_str());
-  for (const std::string& annotation : generate_java_annotations(*enum_decl)) {
-    code_writer->Write("%s", annotation.c_str());
-  }
+  (*code_writer) << GenerateComments(*enum_decl);
+  (*code_writer) << GenerateAnnotations(*enum_decl);
   code_writer->Write("public @interface %s {\n", enum_decl->GetName().c_str());
   code_writer->Indent();
   for (const auto& enumerator : enum_decl->GetEnumerators()) {
-    code_writer->Write("%s", enumerator->GetComments().c_str());
+    (*code_writer) << GenerateComments(*enumerator);
+    (*code_writer) << GenerateAnnotations(*enumerator);
     code_writer->Write(
         "public static final %s %s = %s;\n",
         JavaSignatureOf(enum_decl->GetBackingType(), typenames).c_str(),
@@ -427,6 +679,262 @@
   code_writer->Write("}\n");
 }
 
+void generate_union(CodeWriter& out, const AidlUnionDecl* decl, const AidlTypenames& typenames) {
+  const string tag_type = "int";
+  const AidlTypeSpecifier tag_type_specifier(AIDL_LOCATION_HERE, tag_type, false /* isArray */,
+                                             nullptr /* type_params */, Comments{});
+  const string clazz = decl->GetName();
+
+  out << "/*\n";
+  out << " * This file is auto-generated.  DO NOT MODIFY.\n";
+  out << " */\n";
+
+  out << "package " + decl->GetPackage() + ";\n";
+  out << "\n";
+  out << GenerateComments(*decl);
+  out << GenerateAnnotations(*decl);
+
+  out << "public final class " + clazz + " implements android.os.Parcelable {\n";
+  out.Indent();
+
+  size_t tag_index = 0;
+  out << "// tags for union fields\n";
+  for (const auto& variable : decl->GetFields()) {
+    auto signature = variable->Signature() + ";";
+    out << "public final static " + tag_type + " " + variable->GetName() + " = " +
+               std::to_string(tag_index++) + ";  // " + signature + "\n";
+  }
+  out << "\n";
+
+  const auto final_opt = decl->IsJavaOnlyImmutable() ? "final " : "";
+  out << "private " << final_opt << tag_type + " _tag;\n";
+  out << "private " << final_opt << "Object _value;\n";
+  out << "\n";
+
+  AIDL_FATAL_IF(decl->GetFields().empty(), *decl) << "Union '" << clazz << "' is empty.";
+  const auto& first_field = decl->GetFields()[0];
+  const auto& first_type = JavaSignatureOf(first_field->GetType(), typenames);
+  const auto& first_value = first_field->ValueString(ConstantValueDecorator);
+
+  // default ctor() inits with first member's default value
+  out << "public " + clazz + "() {\n";
+  out.Indent();
+  out << first_type + " _value = " << (first_value.empty() ? "null" : first_value) << ";\n";
+  out << "this._tag = " << first_field->GetName() << ";\n";
+  out << "this._value = _value;\n";
+  out.Dedent();
+  out << "}\n\n";
+
+  if (!decl->IsJavaOnlyImmutable()) {
+    // private ctor(Parcel)
+    out << "private " + clazz + "(android.os.Parcel _aidl_parcel) {\n";
+    out << "  readFromParcel(_aidl_parcel);\n";
+    out << "}\n\n";
+  }
+
+  // private ctor(tag, value)
+  out << "private " + clazz + "(" + tag_type + " _tag, Object _value) {\n";
+  out.Indent();
+  out << "this._tag = _tag;\n";
+  out << "this._value = _value;\n";
+  out.Dedent();
+  out << "}\n\n";
+
+  // getTag()
+  out << "public " + tag_type + " " + "getTag() {\n";
+  out.Indent();
+  out << "return _tag;\n";
+  out.Dedent();
+  out << "}\n\n";
+
+  // value ctor, getter, setter(for mutable) for each field
+  for (const auto& variable : decl->GetFields()) {
+    out << "// " + variable->Signature() + ";\n\n";
+
+    auto var_name = variable->GetName();
+    auto var_type = JavaSignatureOf(variable->GetType(), typenames);
+
+    // value ctor
+    out << GenerateComments(*variable);
+    out << GenerateAnnotations(*variable);
+    out << "public static " + clazz + " " + var_name + "(" + var_type + " _value) {\n";
+    out.Indent();
+    out << "return new " + clazz + "(" + var_name + ", _value);\n";
+    out.Dedent();
+    out << "}\n\n";
+
+    // getter
+    if (variable->GetType().IsGeneric()) {
+      out << "@SuppressWarnings(\"unchecked\")\n";
+    }
+    out << "public " + var_type + " " + getter_name(*variable) + "() {\n";
+    out.Indent();
+    out << "_assertTag(" + var_name + ");\n";
+    out << "return (" + var_type + ") _value;\n";
+    out.Dedent();
+    out << "}\n\n";
+
+    // setter
+    if (!decl->IsJavaOnlyImmutable()) {
+      out << "public void " + setter_name(*variable) + "(" + var_type + " _value) {\n";
+      out.Indent();
+      out << "_set(" + var_name + ", _value);\n";
+      out.Dedent();
+      out << "}\n\n";
+    }
+  }
+
+  if (decl->IsVintfStability()) {
+    out << "@Override\n";
+    out << "public final int getStability() {\n";
+    out << "  return android.os.Parcelable.PARCELABLE_STABILITY_VINTF;\n";
+    out << "}\n\n";
+  }
+
+  out << "public static final android.os.Parcelable.Creator<" << clazz << "> CREATOR = "
+      << "new android.os.Parcelable.Creator<" << clazz << ">() {\n";
+  out << "  @Override\n";
+  out << "  public " << clazz << " createFromParcel(android.os.Parcel _aidl_source) {\n";
+  if (decl->IsJavaOnlyImmutable()) {
+    out << "    return internalCreateFromParcel(_aidl_source);\n";
+  } else {
+    out << "    return new " + clazz + "(_aidl_source);\n";
+  }
+  out << "  }\n";
+  out << "  @Override\n";
+  out << "  public " << clazz << "[] newArray(int _aidl_size) {\n";
+  out << "    return new " << clazz << "[_aidl_size];\n";
+  out << "  }\n";
+  out << "};\n\n";
+
+  auto write_to_parcel = [&](const AidlTypeSpecifier& type, std::string name, std::string parcel) {
+    string code;
+    CodeWriterPtr writer = CodeWriter::ForString(&code);
+    CodeGeneratorContext context{
+        .writer = *(writer.get()),
+        .typenames = typenames,
+        .type = type,
+        .parcel = parcel,
+        .var = name,
+        .is_return_value = false,
+    };
+    WriteToParcelFor(context);
+    writer->Close();
+    return code;
+  };
+
+  out << "@Override\n";
+  out << "public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) {\n";
+  out.Indent();
+  out << write_to_parcel(tag_type_specifier, "_tag", "_aidl_parcel");
+  out << "switch (_tag) {\n";
+  for (const auto& variable : decl->GetFields()) {
+    out << "case " + variable->GetName() + ":\n";
+    out.Indent();
+    out << write_to_parcel(variable->GetType(), getter_name(*variable) + "()", "_aidl_parcel");
+    out << "break;\n";
+    out.Dedent();
+  }
+  out << "}\n";
+  out.Dedent();
+  out << "}\n\n";
+
+  // keep this across different fields in order to create the classloader
+  // at most once.
+  bool is_classloader_created = false;
+  auto read_from_parcel = [&](const AidlTypeSpecifier& type, std::string name, std::string parcel) {
+    string code;
+    CodeWriterPtr writer = CodeWriter::ForString(&code);
+    CodeGeneratorContext context{
+        .writer = *(writer.get()),
+        .typenames = typenames,
+        .type = type,
+        .parcel = parcel,
+        .var = name,
+        .is_classloader_created = &is_classloader_created,
+    };
+    CreateFromParcelFor(context);
+    writer->Close();
+    return code;
+  };
+
+  if (decl->IsJavaOnlyImmutable()) {
+    // When it's immutable we don't need readFromParcel, but we can use it from createFromParcel
+    out << "private static " + clazz +
+               " internalCreateFromParcel(android.os.Parcel _aidl_parcel) {\n";
+  } else {
+    // Not override, but as a user-defined parcelable, this method should be public
+    out << "public void readFromParcel(android.os.Parcel _aidl_parcel) {\n";
+  }
+  out.Indent();
+  out << tag_type + " _aidl_tag;\n";
+  out << read_from_parcel(tag_type_specifier, "_aidl_tag", "_aidl_parcel");
+  out << "switch (_aidl_tag) {\n";
+  for (const auto& variable : decl->GetFields()) {
+    auto var_name = variable->GetName();
+    auto var_type = JavaSignatureOf(variable->GetType(), typenames);
+    out << "case " + var_name + ": {\n";
+    out.Indent();
+    out << var_type + " _aidl_value;\n";
+    out << read_from_parcel(variable->GetType(), "_aidl_value", "_aidl_parcel");
+    if (decl->IsJavaOnlyImmutable()) {
+      out << "return new " << clazz << "(_aidl_tag, _aidl_value); }\n";
+    } else {
+      out << "_set(_aidl_tag, _aidl_value);\n";
+      out << "return; }\n";
+    }
+    out.Dedent();
+  }
+  out << "}\n";
+  out << "throw new IllegalArgumentException(\"union: unknown tag: \" + _aidl_tag);\n";
+  out.Dedent();
+  out << "}\n\n";
+
+  generate_constant_declarations(out, *decl);
+
+  GenerateParcelableDescribeContents(out, *decl, typenames);
+  out << "\n";
+  if (decl->JavaDerive("toString")) {
+    GenerateToString(out, *decl, typenames);
+  }
+
+  if (decl->JavaDerive("equals")) {
+    GenerateEqualsAndHashCode(out, *decl, typenames);
+  }
+
+  // helper: _assertTag
+  out << "private void _assertTag(" + tag_type + " tag) {\n";
+  out << "  if (getTag() != tag) {\n";
+  out << "    throw new IllegalStateException(\"bad access: \" + _tagString(tag) + \", \" + "
+         "_tagString(getTag()) + \" is available.\");\n";
+  out << "  }\n";
+  out << "}\n\n";
+
+  // helper: _tagString
+  out << "private String _tagString(" + tag_type + " _tag) {\n";
+  out << "  switch (_tag) {\n";
+  for (const auto& variable : decl->GetFields()) {
+    auto var_name = variable->GetName();
+    out << "  case " + var_name + ": return \"" + var_name + "\";\n";
+  }
+  out << "  }\n";
+  out << "  throw new IllegalStateException(\"unknown field: \" + _tag);\n";
+  out << "}\n";
+
+  if (!decl->IsJavaOnlyImmutable()) {
+    out << "\n";
+    out << "private void _set(int _tag, Object _value) {\n";
+    out.Indent();
+    out << "this._tag = _tag;\n";
+    out << "this._value = _value;\n";
+    out.Dedent();
+    out << "}\n";
+  }
+
+  out.Dedent();
+  out << "}\n";
+}
+
 std::string dump_location(const AidlNode& method) {
   return method.PrintLocation();
 }
@@ -440,7 +948,7 @@
     parameters_decl.push_back(param_name + " = " + param_value);
   }
   parameters_decl.push_back("overrideSourcePosition=\"" + dump_location(a) + "\"");
-  return "(" + base::Join(parameters_decl, ", ") + ")";
+  return "(" + Join(parameters_decl, ", ") + ")";
 }
 
 std::vector<std::string> generate_java_annotations(const AidlAnnotatable& a) {
@@ -455,28 +963,50 @@
                         generate_java_unsupportedappusage_parameters(*unsupported_app_usage));
   }
 
-  auto strip_double_quote = [](const AidlTypeSpecifier& type, const std::string& raw_value) -> std::string {
-    if (!android::base::StartsWith(raw_value, "\"") ||
-        !android::base::EndsWith(raw_value, "\"")) {
-      AIDL_FATAL(type) << "Java passthrough annotation " << raw_value << " is not properly quoted";
-      return "";
-    }
-    return raw_value.substr(1, raw_value.size() - 2);
-  };
-
-  const AidlAnnotation* java_passthrough = a.JavaPassthrough();
-  if (java_passthrough != nullptr) {
-    for (const auto& name_and_param : java_passthrough->AnnotationParams(strip_double_quote)) {
-      if (name_and_param.first == "annotation") {
-        result.emplace_back(name_and_param.second);
-        break;
-      }
+  for (const auto& annotation : a.GetAnnotations()) {
+    if (annotation.GetType() == AidlAnnotation::Type::JAVA_PASSTHROUGH) {
+      result.emplace_back(annotation.ParamValue<std::string>("annotation").value());
     }
   }
 
   return result;
 }
 
+struct JavaAnnotationsVisitor : AidlVisitor {
+  JavaAnnotationsVisitor(std::vector<std::string>& result) : result(result) {}
+  void Visit(const AidlTypeSpecifier& t) override { result = generate_java_annotations(t); }
+  void Visit(const AidlInterface& t) override { ForDefinedType(t); }
+  void Visit(const AidlParcelable& t) override { ForDefinedType(t); }
+  void Visit(const AidlStructuredParcelable& t) override { ForDefinedType(t); }
+  void Visit(const AidlUnionDecl& t) override { ForDefinedType(t); }
+  void Visit(const AidlEnumDeclaration& t) override { ForDefinedType(t); }
+  void Visit(const AidlMethod& m) override { ForMember(m); }
+  void Visit(const AidlConstantDeclaration& c) override { ForMember(c); }
+  void Visit(const AidlVariableDeclaration& v) override { ForMember(v); }
+  std::vector<std::string>& result;
+
+  void ForDefinedType(const AidlDefinedType& t) {
+    result = generate_java_annotations(t);
+    if (t.IsDeprecated()) {
+      result.push_back("@Deprecated");
+    }
+  }
+  template <typename Member>
+  void ForMember(const Member& t) {
+    result = generate_java_annotations(t.GetType());
+    if (t.IsDeprecated()) {
+      result.push_back("@Deprecated");
+    }
+  }
+};
+
+std::vector<std::string> JavaAnnotationsFor(const AidlNode& a) {
+  std::vector<std::string> result;
+  JavaAnnotationsVisitor visitor{result};
+  a.DispatchVisit(visitor);
+  return result;
+}
+
 }  // namespace java
 }  // namespace aidl
 }  // namespace android
diff --git a/generate_java.h b/generate_java.h
index d2c8a6d..b3cfd6f 100644
--- a/generate_java.h
+++ b/generate_java.h
@@ -40,7 +40,15 @@
 void generate_enum(const CodeWriterPtr& code_writer, const AidlEnumDeclaration* enum_decl,
                    const AidlTypenames& typenames);
 
-std::vector<std::string> generate_java_annotations(const AidlAnnotatable& a);
+void generate_union(CodeWriter& out, const AidlUnionDecl* decl, const AidlTypenames& typenames);
+
+void generate_constant_declarations(CodeWriter& out, const AidlDefinedType& type);
+
+std::string GenerateComments(const AidlCommentable& node);
+
+std::string GenerateAnnotations(const AidlNode& node);
+
+std::vector<std::string> JavaAnnotationsFor(const AidlNode& a);
 
 }  // namespace java
 }  // namespace aidl
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index 551e866..fa1c14a 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -16,6 +16,7 @@
 
 #include "aidl.h"
 #include "aidl_to_java.h"
+#include "ast_java.h"
 #include "generate_java.h"
 #include "logging.h"
 #include "options.h"
@@ -80,7 +81,8 @@
   std::shared_ptr<Variable> transact_data;
   std::shared_ptr<Variable> transact_reply;
   std::shared_ptr<Variable> transact_flags;
-  std::shared_ptr<SwitchStatement> transact_switch;
+  std::shared_ptr<SwitchStatement> transact_switch_meta;
+  std::shared_ptr<SwitchStatement> transact_switch_user;
   std::shared_ptr<StatementBlock> transact_statements;
   std::shared_ptr<SwitchStatement> code_to_method_name_switch;
 
@@ -193,7 +195,8 @@
   transact_statements = onTransact->statements;
   onTransact->exceptions.push_back("android.os.RemoteException");
   this->elements.push_back(onTransact);
-  this->transact_switch = std::make_shared<SwitchStatement>(this->transact_code);
+  this->transact_switch_meta = std::make_shared<SwitchStatement>(this->transact_code);
+  this->transact_switch_user = std::make_shared<SwitchStatement>(this->transact_code);
 }
 
 void StubClass::finish() {
@@ -204,9 +207,11 @@
       std::vector<std::shared_ptr<Expression>>{this->transact_code, this->transact_data,
                                                this->transact_reply, this->transact_flags});
   default_case->statements->Add(std::make_shared<ReturnStatement>(superCall));
-  transact_switch->cases.push_back(default_case);
+  transact_switch_user->cases.push_back(default_case);
 
-  transact_statements->Add(this->transact_switch);
+  // Meta transactions are looked up prior to user-defined transactions.
+  transact_statements->Add(this->transact_switch_meta);
+  transact_statements->Add(this->transact_switch_user);
 
   // getTransactionName
   if (options_.GenTransactionNames()) {
@@ -385,30 +390,28 @@
   addTo->Add(std::make_shared<LiteralStatement>(code));
 }
 
-static void generate_int_constant(Class* interface, const std::string& name,
-                                  const std::string& value) {
-  auto code = StringPrintf("public static final int %s = %s;\n", name.c_str(), value.c_str());
-  interface->elements.push_back(std::make_shared<LiteralClassElement>(code));
-}
-
-static void generate_string_constant(Class* interface, const std::string& name,
-                                     const std::string& value) {
-  auto code = StringPrintf("public static final String %s = %s;\n", name.c_str(), value.c_str());
-  interface->elements.push_back(std::make_shared<LiteralClassElement>(code));
+void generate_constant_declarations(CodeWriter& out, const AidlDefinedType& type) {
+  for (const auto& constant : type.GetConstantDeclarations()) {
+    const AidlTypeSpecifier& type = constant->GetType();
+    out << GenerateComments(*constant);
+    out << GenerateAnnotations(*constant);
+    out << "public static final " << type.Signature() << " " << constant->GetName() << " = "
+        << constant->ValueString(ConstantValueDecorator) << ";\n";
+  }
 }
 
 static std::shared_ptr<Method> generate_interface_method(const AidlMethod& method,
                                                          const AidlTypenames& typenames) {
   auto decl = std::make_shared<Method>();
-  decl->comment = method.GetComments();
+  decl->comment = GenerateComments(method);
   decl->modifiers = PUBLIC;
   decl->returnType = JavaSignatureOf(method.GetType(), typenames);
   decl->name = method.GetName();
-  decl->annotations = generate_java_annotations(method.GetType());
+  decl->annotations = JavaAnnotationsFor(method);
 
   for (const std::unique_ptr<AidlArgument>& arg : method.GetArguments()) {
     auto var = std::make_shared<Variable>(JavaSignatureOf(arg->GetType(), typenames), arg->GetName());
-    var->annotations = generate_java_annotations(arg->GetType());
+    var->annotations = JavaAnnotationsFor(arg->GetType());
     decl->parameters.push_back(var);
   }
 
@@ -536,7 +539,7 @@
   generate_stub_code(iface, method, oneway, stubClass->transact_data, stubClass->transact_reply,
                      typenames, c->statements, stubClass, options);
 
-  stubClass->transact_switch->cases.push_back(c);
+  stubClass->transact_switch_user->cases.push_back(c);
 }
 
 static void generate_stub_case_outline(const AidlInterface& iface, const AidlMethod& method,
@@ -572,7 +575,7 @@
                                          stubClass->transact_data, stubClass->transact_reply});
     c->statements->Add(std::make_shared<ReturnStatement>(helper_call));
 
-    stubClass->transact_switch->cases.push_back(c);
+    stubClass->transact_switch_user->cases.push_back(c);
   }
 }
 
@@ -581,7 +584,7 @@
     bool oneway, std::shared_ptr<ProxyClass> proxyClass, const AidlTypenames& typenames,
     const Options& options) {
   auto proxy = std::make_shared<Method>();
-  proxy->comment = method.GetComments();
+  proxy->comment = GenerateComments(method);
   proxy->modifiers = PUBLIC | OVERRIDE;
   proxy->returnType = JavaSignatureOf(method.GetType(), typenames);
   proxy->name = method.GetName();
@@ -596,6 +599,11 @@
   auto _data = std::make_shared<Variable>("android.os.Parcel", "_data");
   proxy->statements->Add(std::make_shared<VariableDeclaration>(
       _data, std::make_shared<MethodCall>("android.os.Parcel", "obtain")));
+
+  if (iface.IsSensitiveData()) {
+    proxy->statements->Add(std::make_shared<LiteralStatement>("_data.markSensitive();"));
+  }
+
   std::shared_ptr<Variable> _reply = nullptr;
   if (!oneway) {
     _reply = std::make_shared<Variable>("android.os.Parcel", "_reply");
@@ -652,13 +660,17 @@
     }
   }
 
+  std::vector<std::string> flags;
+  if (oneway) flags.push_back("android.os.IBinder.FLAG_ONEWAY");
+  if (iface.IsSensitiveData()) flags.push_back("android.os.IBinder.FLAG_CLEAR_BUF");
+
   // the transact call
   auto call = std::make_shared<MethodCall>(
       proxyClass->mRemote, "transact",
       std::vector<std::shared_ptr<Expression>>{
           std::make_shared<LiteralExpression>("Stub." + transactCodeName), _data,
           _reply ? _reply : NULL_VALUE,
-          std::make_shared<LiteralExpression>(oneway ? "android.os.IBinder.FLAG_ONEWAY" : "0")});
+          std::make_shared<LiteralExpression>(flags.empty() ? "0" : Join(flags, " | "))});
   auto _status = std::make_shared<Variable>("boolean", "_status");
   tryStatement->statements->Add(std::make_shared<VariableDeclaration>(_status, call));
 
@@ -821,7 +833,7 @@
            << "reply.writeInt(" << kGetInterfaceVersion << "());\n"
            << "return true;\n";
       c->statements->Add(std::make_shared<LiteralStatement>(code.str()));
-      stubClass->transact_switch->cases.push_back(c);
+      stubClass->transact_switch_meta->cases.push_back(c);
     }
     if (method.GetName() == kGetInterfaceHash && !options.Hash().empty()) {
       auto c = std::make_shared<Case>(transactCodeName);
@@ -831,7 +843,7 @@
            << "reply.writeString(" << kGetInterfaceHash << "());\n"
            << "return true;\n";
       c->statements->Add(std::make_shared<LiteralStatement>(code.str()));
-      stubClass->transact_switch->cases.push_back(c);
+      stubClass->transact_switch_meta->cases.push_back(c);
     }
   }
 
@@ -915,7 +927,7 @@
       stub->transact_reply, "writeString",
       std::vector<std::shared_ptr<Expression>>{stub->get_transact_descriptor(nullptr)}));
   c->statements->Add(std::make_shared<ReturnStatement>(TRUE_VALUE));
-  stub->transact_switch->cases.push_back(c);
+  stub->transact_switch_meta->cases.push_back(c);
 
   // and the proxy-side method returning the descriptor directly
   auto getDesc = std::make_shared<Method>();
@@ -972,7 +984,7 @@
     stub->all_method_count = iface->GetMethods().size();
     std::vector<const AidlMethod*> methods;
     methods.reserve(iface->GetMethods().size());
-    for (const std::unique_ptr<AidlMethod>& ptr : iface->GetMethods()) {
+    for (const auto& ptr : iface->GetMethods()) {
       methods.push_back(ptr.get());
     }
 
@@ -991,7 +1003,7 @@
 static shared_ptr<ClassElement> generate_default_impl_method(const AidlMethod& method,
                                                              const AidlTypenames& typenames) {
   auto default_method = std::make_shared<Method>();
-  default_method->comment = method.GetComments();
+  default_method->comment = GenerateComments(method);
   default_method->modifiers = PUBLIC | OVERRIDE;
   default_method->returnType = JavaSignatureOf(method.GetType(), typenames);
   default_method->name = method.GetName();
@@ -1022,7 +1034,7 @@
 
   for (const auto& m : iface.GetMethods()) {
     if (m->IsUserDefined()) {
-      default_class->elements.emplace_back(generate_default_impl_method(*m.get(), typenames));
+      default_class->elements.emplace_back(generate_default_impl_method(*m, typenames));
     } else {
       // These are called only when the remote side does not implement these
       // methods, which is normally impossible, because these methods are
@@ -1063,12 +1075,12 @@
                                                        const Options& options) {
   // the interface class
   auto interface = std::make_unique<Class>();
-  interface->comment = iface->GetComments();
+  interface->comment = GenerateComments(*iface);
   interface->modifiers = PUBLIC;
   interface->what = Class::INTERFACE;
   interface->type = iface->GetCanonicalName();
   interface->interfaces.push_back("android.os.IInterface");
-  interface->annotations = generate_java_annotations(*iface);
+  interface->annotations = JavaAnnotationsFor(*iface);
 
   if (options.Version()) {
     std::ostringstream code;
@@ -1108,37 +1120,9 @@
   generate_interface_descriptors(options, iface, interface.get(), stub, proxy);
 
   // all the declared constants of the interface
-  for (const auto& constant : iface->GetConstantDeclarations()) {
-    const AidlConstantValue& value = constant->GetValue();
-    auto comment = constant->GetType().GetComments();
-    if (comment.length() != 0) {
-      auto code = StringPrintf("%s\n", comment.c_str());
-      interface->elements.push_back(std::make_shared<LiteralClassElement>(code));
-    }
-    for (const std::string& annotation : generate_java_annotations(constant->GetType())) {
-      auto code = StringPrintf("%s\n", annotation.c_str());
-      interface->elements.push_back(std::make_shared<LiteralClassElement>(code));
-    }
-    switch (value.GetType()) {
-      case AidlConstantValue::Type::STRING: {
-        generate_string_constant(interface.get(), constant->GetName(),
-                                 constant->ValueString(ConstantValueDecorator));
-        break;
-      }
-      case AidlConstantValue::Type::BOOLEAN:  // fall-through
-      case AidlConstantValue::Type::INT8:     // fall-through
-      case AidlConstantValue::Type::INT32:    // fall-through
-      // Type promotion may cause this. Value should be small enough to fit in int32.
-      case AidlConstantValue::Type::INT64: {
-        generate_int_constant(interface.get(), constant->GetName(),
-                              constant->ValueString(ConstantValueDecorator));
-        break;
-      }
-      default: {
-        AIDL_FATAL(value) << "Unrecognized constant type: " << static_cast<int>(value.GetType());
-      }
-    }
-  }
+  string constants;
+  generate_constant_declarations(*CodeWriter::ForString(&constants), *iface);
+  interface->elements.push_back(std::make_shared<LiteralClassElement>(constants));
 
   // all the declared methods of the interface
 
diff --git a/generate_ndk.cpp b/generate_ndk.cpp
index e511680..4f93b29 100644
--- a/generate_ndk.cpp
+++ b/generate_ndk.cpp
@@ -37,6 +37,17 @@
 static constexpr const char* kCachedHashMutex = "_aidl_cached_hash_mutex";
 
 using namespace internals;
+namespace internals {
+void GenerateParcelHeader(CodeWriter& out, const AidlTypenames& types,
+                          const AidlStructuredParcelable& defined_type, const Options& options);
+void GenerateParcelSource(CodeWriter& out, const AidlTypenames& types,
+                          const AidlStructuredParcelable& defined_type, const Options& options);
+void GenerateParcelHeader(CodeWriter& out, const AidlTypenames& types,
+                          const AidlUnionDecl& defined_type, const Options& options);
+void GenerateParcelSource(CodeWriter& out, const AidlTypenames& types,
+                          const AidlUnionDecl& defined_type, const Options& options);
+}  // namespace internals
+
 using cpp::ClassNames;
 
 void GenerateNdkInterface(const string& output_file, const Options& options,
@@ -64,8 +75,9 @@
   AIDL_FATAL_IF(!source_writer->Close(), output_file);
 }
 
+template <typename ParcelableType>
 void GenerateNdkParcel(const string& output_file, const Options& options,
-                       const AidlTypenames& types, const AidlStructuredParcelable& defined_type,
+                       const AidlTypenames& types, const ParcelableType& defined_type,
                        const IoDelegate& io_delegate) {
   const string header_path =
       options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::RAW);
@@ -133,7 +145,13 @@
                  const AidlDefinedType& defined_type, const IoDelegate& io_delegate) {
   if (const AidlStructuredParcelable* parcelable = defined_type.AsStructuredParcelable();
       parcelable != nullptr) {
-    GenerateNdkParcel(output_file, options, types, *parcelable, io_delegate);
+    GenerateNdkParcel<AidlStructuredParcelable>(output_file, options, types, *parcelable,
+                                                io_delegate);
+    return;
+  }
+
+  if (const AidlUnionDecl* union_decl = defined_type.AsUnionDeclaration(); union_decl != nullptr) {
+    GenerateNdkParcel<AidlUnionDecl>(output_file, options, types, *union_decl, io_delegate);
     return;
   }
 
@@ -188,6 +206,11 @@
   out << "#include <android/binder_stability.h>\n";
   out << "#endif  // BINDER_STABILITY_SUPPORT\n";
 
+  if (defined_type.IsSensitiveData()) {
+    out << "#include <android/binder_parcel_platform.h>\n";
+    out << "#include <android/binder_ibinder_platform.h>\n";
+  }
+
   auto headerFilePath = [&types](const AidlTypeSpecifier& typespec) -> std::string {
     const AidlDefinedType* type = types.TryGetDefinedType(typespec.GetName());
     if (type == nullptr) {
@@ -199,6 +222,8 @@
       return NdkHeaderFile(*type, ClassNames::RAW, false /*use_os_sep*/);
     } else if (type->AsStructuredParcelable() != nullptr) {
       return NdkHeaderFile(*type, ClassNames::RAW, false /*use_os_sep*/);
+    } else if (type->AsUnionDeclaration() != nullptr) {
+      return NdkHeaderFile(*type, ClassNames::RAW, false /*use_os_sep*/);
     } else if (type->AsParcelable() != nullptr) {
       return type->AsParcelable()->GetCppHeader();
     } else if (type->AsEnumDeclaration() != nullptr) {
@@ -211,38 +236,51 @@
 
   std::set<std::string> includes;
 
+  // visit a type and collect all reference types' headers
+  std::function<void(const AidlTypeSpecifier& type)> visit = [&](const AidlTypeSpecifier& type) {
+    includes.insert(headerFilePath(type));
+    if (type.IsGeneric()) {
+      for (const auto& param : type.GetTypeParameters()) {
+        visit(*param);
+      }
+    }
+  };
+
   const AidlInterface* interface = defined_type.AsInterface();
   if (interface != nullptr) {
     for (const auto& method : interface->GetMethods()) {
-      includes.insert(headerFilePath(method->GetType()));
+      visit(method->GetType());
       for (const auto& argument : method->GetArguments()) {
-        includes.insert(headerFilePath(argument->GetType()));
-        // Check the method arguments for generic type arguments
-        if (argument->GetType().IsGeneric()) {
-          for (const auto& type_argument : argument->GetType().GetTypeParameters()) {
-            includes.insert(headerFilePath(*type_argument));
-          }
-        }
+        visit(argument->GetType());
       }
     }
   }
 
-  const AidlStructuredParcelable* parcelable = defined_type.AsStructuredParcelable();
-  if (parcelable != nullptr) {
-    for (const auto& field : parcelable->GetFields()) {
-      includes.insert(headerFilePath(field->GetType()));
+  auto visit_parcelable = [&](const auto& parcelable) {
+    for (const auto& field : parcelable.GetFields()) {
+      visit(field->GetType());
       // Check the fields for generic type arguments
       if (field->GetType().IsGeneric()) {
         for (const auto& type_argument : field->GetType().GetTypeParameters()) {
-          includes.insert(headerFilePath(*type_argument));
+          visit(*type_argument);
         }
       }
     }
+  };
+
+  const AidlStructuredParcelable* parcelable = defined_type.AsStructuredParcelable();
+  if (parcelable != nullptr) {
+    visit_parcelable(*parcelable);
+  }
+
+  const AidlUnionDecl* union_decl = defined_type.AsUnionDeclaration();
+  if (union_decl != nullptr) {
+    visit_parcelable(*union_decl);
   }
 
   const AidlEnumDeclaration* enum_decl = defined_type.AsEnumDeclaration();
   if (enum_decl != nullptr) {
-    includes.insert(headerFilePath(enum_decl->GetBackingType()));
+    visit(enum_decl->GetBackingType());
   }
 
   for (const auto& path : includes) {
@@ -269,57 +307,36 @@
   });
 }
 
-static void GenerateConstantDeclarations(CodeWriter& out, const AidlInterface& interface) {
-  for (const auto& constant : interface.GetConstantDeclarations()) {
-    const AidlConstantValue& value = constant->GetValue();
-    AIDL_FATAL_IF(value.GetType() == AidlConstantValue::Type::UNARY ||
-                      value.GetType() == AidlConstantValue::Type::BINARY,
-                  value);
-    if (value.GetType() == AidlConstantValue::Type::STRING) {
-      out << "static const char* " << constant->GetName() << ";\n";
-    }
-  }
-  out << "\n";
+template <typename TypeWithConstants>
+static void GenerateConstantDeclarations(CodeWriter& out, const AidlTypenames& types,
+                                         const TypeWithConstants& type) {
+  for (const auto& constant : type.GetConstantDeclarations()) {
+    const AidlTypeSpecifier& type = constant->GetType();
 
-  bool hasIntegralConstant = false;
-  for (const auto& constant : interface.GetConstantDeclarations()) {
-    const AidlConstantValue& value = constant->GetValue();
-    AIDL_FATAL_IF(value.GetType() == AidlConstantValue::Type::UNARY ||
-                      value.GetType() == AidlConstantValue::Type::BINARY,
-                  value);
-    if (value.GetType() == AidlConstantValue::Type::BOOLEAN ||
-        value.GetType() == AidlConstantValue::Type::INT8 ||
-        value.GetType() == AidlConstantValue::Type::INT32) {
-      hasIntegralConstant = true;
-      break;
+    if (type.Signature() == "String") {
+      out << "static const char*";
+      cpp::GenerateDeprecated(out, *constant);
+      out << " " << constant->GetName() << ";\n";
+    } else {
+      out << "enum : " << NdkNameOf(types, type, StorageMode::STACK) << " { ";
+      out << constant->GetName();
+      cpp::GenerateDeprecated(out, *constant);
+      out << " = " << constant->ValueString(ConstantValueDecorator) << " };\n";
     }
   }
-
-  if (hasIntegralConstant) {
-    out << "enum : int32_t {\n";
-    out.Indent();
-    for (const auto& constant : interface.GetConstantDeclarations()) {
-      const AidlConstantValue& value = constant->GetValue();
-      if (value.GetType() == AidlConstantValue::Type::BOOLEAN ||
-          value.GetType() == AidlConstantValue::Type::INT8 ||
-          value.GetType() == AidlConstantValue::Type::INT32) {
-        out << constant->GetName() << " = " << constant->ValueString(ConstantValueDecorator)
-            << ",\n";
-      }
-    }
-    out.Dedent();
-    out << "};\n";
-  }
 }
-static void GenerateConstantDefinitions(CodeWriter& out, const AidlInterface& interface) {
-  const std::string clazz = ClassName(interface, ClassNames::INTERFACE);
 
+template <typename TypeWithConstants>
+static void GenerateConstantDefinitions(CodeWriter& out, const TypeWithConstants& interface,
+                                        const std::string& clazz,
+                                        const std::string& tmpl_decl = "") {
   for (const auto& constant : interface.GetConstantDeclarations()) {
     const AidlConstantValue& value = constant->GetValue();
     AIDL_FATAL_IF(value.GetType() == AidlConstantValue::Type::UNARY ||
                       value.GetType() == AidlConstantValue::Type::BINARY,
                   value);
     if (value.GetType() == AidlConstantValue::Type::STRING) {
+      out << tmpl_decl;
       out << "const char* " << clazz << "::" << constant->GetName() << " = "
           << constant->ValueString(ConstantValueDecorator) << ";\n";
     }
@@ -332,6 +349,9 @@
   out << "\n";
 
   EnterNdkNamespace(out, defined_type);
+  if (options.GenLog()) {
+    out << cpp::kToStringHelper;
+  }
   GenerateClassSource(out, types, defined_type, options);
   GenerateClientSource(out, types, defined_type, options);
   GenerateServerSource(out, types, defined_type, options);
@@ -381,12 +401,15 @@
                                     false /* isServer */, true /* isNdk */);
   }
   if (options.GenTraces()) {
-    out << "ScopedTrace _aidl_trace(\"AIDL::" << Options::LanguageToString(options.TargetLanguage())
+    out << "ScopedTrace _aidl_trace(\"AIDL::" << to_string(options.TargetLanguage())
         << "::" << ClassName(defined_type, ClassNames::INTERFACE) << "::" << method.GetName()
         << "::client\");\n";
   }
 
   out << "_aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());\n";
+  if (defined_type.IsSensitiveData()) {
+    out << "AParcel_markSensitive(_aidl_in.get());\n";
+  }
   StatusCheckGoto(out);
 
   for (const auto& arg : method.GetArguments()) {
@@ -401,6 +424,7 @@
     } else if (arg->IsOut() && arg->GetType().IsArray()) {
       out << "_aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *" << var_name
           << ");\n";
+      StatusCheckGoto(out);
     }
   }
   out << "_aidl_ret_status = AIBinder_transact(\n";
@@ -409,7 +433,12 @@
   out << MethodId(method) << ",\n";
   out << "_aidl_in.getR(),\n";
   out << "_aidl_out.getR(),\n";
-  out << (method.IsOneway() ? "FLAG_ONEWAY" : "0") << "\n";
+
+  std::vector<std::string> flags;
+  if (method.IsOneway()) flags.push_back("FLAG_ONEWAY");
+  if (defined_type.IsSensitiveData()) flags.push_back("FLAG_CLEAR_BUF");
+  out << (flags.empty() ? "0" : base::Join(flags, " | ")) << "\n";
+
   out << "#ifdef BINDER_STABILITY_SUPPORT\n";
   out << "| FLAG_PRIVATE_LOCAL\n";
   out << "#endif  // BINDER_STABILITY_SUPPORT\n";
@@ -483,7 +512,7 @@
   }
   out << "\n";
   if (options.GenTraces()) {
-    out << "ScopedTrace _aidl_trace(\"AIDL::" << Options::LanguageToString(options.TargetLanguage())
+    out << "ScopedTrace _aidl_trace(\"AIDL::" << to_string(options.TargetLanguage())
         << "::" << ClassName(defined_type, ClassNames::INTERFACE) << "::" << method.GetName()
         << "::server\");\n";
   }
@@ -498,6 +527,7 @@
       StatusCheckBreak(out);
     } else if (arg->IsOut() && arg->GetType().IsArray()) {
       out << "_aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &" << var_name << ");\n";
+      StatusCheckBreak(out);
     }
   }
   if (options.GenLog()) {
@@ -548,7 +578,7 @@
     out << "class ScopedTrace {\n";
     out.Indent();
     out << "public:\n"
-        << "inline ScopedTrace(const char* name) {\n"
+        << "inline explicit ScopedTrace(const char* name) {\n"
         << "ATrace_beginSection(name);\n"
         << "}\n"
         << "inline ~ScopedTrace() {\n"
@@ -557,6 +587,13 @@
     out.Dedent();
     out << "};\n";
   }
+  bool deprecated = defined_type.IsDeprecated() ||
+                    std::any_of(defined_type.GetMethods().begin(), defined_type.GetMethods().end(),
+                                [](const auto& m) { return m->IsDeprecated(); });
+  if (deprecated) {
+    out << "#pragma clang diagnostic push\n";
+    out << "#pragma clang diagnostic ignored \"-Wdeprecated\"\n";
+  }
   out << "static binder_status_t "
       << "_aidl_onTransact"
       << "(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, "
@@ -587,7 +624,11 @@
 
   out << "static AIBinder_Class* " << kClazz << " = ::ndk::ICInterface::defineClass(" << clazz
       << "::" << kDescriptor << ", _aidl_onTransact);\n\n";
+  if (deprecated) {
+    out << "#pragma clang diagnostic pop\n";
+  }
 }
+
 void GenerateClientSource(CodeWriter& out, const AidlTypenames& types,
                           const AidlInterface& defined_type, const Options& options) {
   const std::string clazz = ClassName(defined_type, ClassNames::CLIENT);
@@ -595,7 +636,7 @@
   out << clazz << "::" << clazz << "(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}\n";
   out << clazz << "::~" << clazz << "() {}\n";
   if (options.GenLog()) {
-    out << "std::function<void(const Json::Value&)> " << clazz << "::logFunc;\n";
+    out << "std::function<void(const " + clazz + "::TransactionLog&)> " << clazz << "::logFunc;\n";
   }
   out << "\n";
   for (const auto& method : defined_type.GetMethods()) {
@@ -611,7 +652,7 @@
   out << clazz << "::" << clazz << "() {}\n";
   out << clazz << "::~" << clazz << "() {}\n";
   if (options.GenLog()) {
-    out << "std::function<void(const Json::Value&)> " << clazz << "::logFunc;\n";
+    out << "std::function<void(const " + clazz + "::TransactionLog&)> " << clazz << "::logFunc;\n";
   }
   out << "::ndk::SpAIBinder " << clazz << "::createBinder() {\n";
   out.Indent();
@@ -663,7 +704,7 @@
   out << clazz << "::" << clazz << "() {}\n";
   out << clazz << "::~" << clazz << "() {}\n";
   out << "\n";
-  GenerateConstantDefinitions(out, defined_type);
+  GenerateConstantDefinitions(out, defined_type, clazz);
   out << "\n";
 
   out << "std::shared_ptr<" << clazz << "> " << clazz
@@ -701,7 +742,7 @@
   out << "}\n";
 
   // defintion for static member setDefaultImpl
-  out << "bool " << clazz << "::setDefaultImpl(std::shared_ptr<" << clazz << "> impl) {\n";
+  out << "bool " << clazz << "::setDefaultImpl(const std::shared_ptr<" << clazz << ">& impl) {\n";
   out.Indent();
   out << "// Only one user of this interface can use this function\n";
   out << "// at a time. This is a heuristic to detect if two different\n";
@@ -784,7 +825,6 @@
   out << "\n";
   out << "#include <android/binder_ibinder.h>\n";
   if (options.GenLog()) {
-    out << "#include <json/value.h>\n";
     out << "#include <functional>\n";
     out << "#include <chrono>\n";
     out << "#include <sstream>\n";
@@ -794,15 +834,19 @@
   }
   out << "\n";
   EnterNdkNamespace(out, defined_type);
-  out << "class " << clazz << " : public ::ndk::BpCInterface<"
+  out << "class";
+  cpp::GenerateDeprecated(out, defined_type);
+  out << " " << clazz << " : public ::ndk::BpCInterface<"
       << ClassName(defined_type, ClassNames::INTERFACE) << "> {\n";
   out << "public:\n";
   out.Indent();
-  out << clazz << "(const ::ndk::SpAIBinder& binder);\n";
+  out << "explicit " << clazz << "(const ::ndk::SpAIBinder& binder);\n";
   out << "virtual ~" << clazz << "();\n";
   out << "\n";
   for (const auto& method : defined_type.GetMethods()) {
-    out << NdkMethodDecl(types, *method) << " override;\n";
+    out << NdkMethodDecl(types, *method) << " override";
+    cpp::GenerateDeprecated(out, *method);
+    out << ";\n";
   }
 
   if (options.Version() > 0) {
@@ -814,7 +858,8 @@
     out << "std::mutex " << kCachedHashMutex << ";\n";
   }
   if (options.GenLog()) {
-    out << "static std::function<void(const Json::Value&)> logFunc;\n";
+    out << cpp::kTransactionLogStruct;
+    out << "static std::function<void(const TransactionLog&)> logFunc;\n";
   }
   out.Dedent();
   out << "};\n";
@@ -832,7 +877,9 @@
   out << "#include <android/binder_ibinder.h>\n";
   out << "\n";
   EnterNdkNamespace(out, defined_type);
-  out << "class " << clazz << " : public ::ndk::BnCInterface<" << iface << "> {\n";
+  out << "class";
+  cpp::GenerateDeprecated(out, defined_type);
+  out << " " << clazz << " : public ::ndk::BnCInterface<" << iface << "> {\n";
   out << "public:\n";
   out.Indent();
   out << clazz << "();\n";
@@ -852,7 +899,8 @@
     }
   }
   if (options.GenLog()) {
-    out << "static std::function<void(const Json::Value&)> logFunc;\n";
+    out << cpp::kTransactionLogStruct;
+    out << "static std::function<void(const TransactionLog&)> logFunc;\n";
   }
   out.Dedent();
   out << "protected:\n";
@@ -872,7 +920,6 @@
   out << "#pragma once\n\n";
   out << "#include <android/binder_interface_utils.h>\n";
   if (options.GenLog()) {
-    out << "#include <json/value.h>\n";
     out << "#include <functional>\n";
     out << "#include <chrono>\n";
     out << "#include <sstream>\n";
@@ -883,14 +930,16 @@
   out << "\n";
 
   EnterNdkNamespace(out, defined_type);
-  out << "class " << clazz << " : public ::ndk::ICInterface {\n";
+  out << "class";
+  cpp::GenerateDeprecated(out, defined_type);
+  out << " " << clazz << " : public ::ndk::ICInterface {\n";
   out << "public:\n";
   out.Indent();
   out << "static const char* " << kDescriptor << ";\n";
   out << clazz << "();\n";
   out << "virtual ~" << clazz << "();\n";
   out << "\n";
-  GenerateConstantDeclarations(out, defined_type);
+  GenerateConstantDeclarations(out, types, defined_type);
   if (options.Version() > 0) {
     out << "static const int32_t " << kVersion << " = " << std::to_string(options.Version())
         << ";\n";
@@ -898,6 +947,13 @@
   if (!options.Hash().empty()) {
     out << "static inline const std::string " << kHash << " = \"" << options.Hash() << "\";\n";
   }
+  for (const auto& method : defined_type.GetMethods()) {
+    if (!method->IsUserDefined()) {
+      continue;
+    }
+    out << "static constexpr uint32_t TRANSACTION_" << method->GetName() << " = "
+        << "FIRST_CALL_TRANSACTION + " << std::to_string(method->GetId()) << ";\n";
+  }
   out << "\n";
   out << "static std::shared_ptr<" << clazz << "> fromBinder(const ::ndk::SpAIBinder& binder);\n";
   out << "static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<" << clazz
@@ -906,12 +962,14 @@
   out << "static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<" << clazz
       << ">* instance);";
   out << "\n";
-  out << "static bool setDefaultImpl(std::shared_ptr<" << clazz << "> impl);";
+  out << "static bool setDefaultImpl(const std::shared_ptr<" << clazz << ">& impl);";
   out << "\n";
   out << "static const std::shared_ptr<" << clazz << ">& getDefaultImpl();";
   out << "\n";
   for (const auto& method : defined_type.GetMethods()) {
-    out << "virtual " << NdkMethodDecl(types, *method) << " = 0;\n";
+    out << "virtual " << NdkMethodDecl(types, *method);
+    cpp::GenerateDeprecated(out, *method);
+    out << " = 0;\n";
   }
   out.Dedent();
   out << "private:\n";
@@ -921,13 +979,16 @@
   out << "};\n";
 
   const std::string defaultClazz = clazz + "Default";
-
-  out << "class " << defaultClazz << " : public " << clazz << " {\n";
+  out << "class";
+  cpp::GenerateDeprecated(out, defined_type);
+  out << " " << defaultClazz << " : public " << clazz << " {\n";
   out << "public:\n";
   out.Indent();
   for (const auto& method : defined_type.GetMethods()) {
     if (method->IsUserDefined()) {
-      out << NdkMethodDecl(types, *method) << " override;\n";
+      out << NdkMethodDecl(types, *method) << " override";
+      cpp::GenerateDeprecated(out, *method);
+      out << ";\n";
     } else if (method->GetName() == kGetInterfaceVersion && options.Version() > 0) {
       out << NdkMethodDecl(types, *method) << " override;\n";
     } else if (method->GetName() == kGetInterfaceHash && !options.Hash().empty()) {
@@ -949,13 +1010,19 @@
   out << "#pragma once\n";
   out << "#include <android/binder_interface_utils.h>\n";
   out << "#include <android/binder_parcelable_utils.h>\n";
-  out << "\n";
+
+  // used by toString()
+  out << "#include <codecvt>\n";
+  out << "#include <locale>\n";
+  out << "#include <sstream>\n";
 
   GenerateHeaderIncludes(out, types, defined_type);
 
   EnterNdkNamespace(out, defined_type);
   out << cpp::TemplateDecl(defined_type);
-  out << "class " << clazz << " {\n";
+  out << "class";
+  cpp::GenerateDeprecated(out, defined_type);
+  out << " " << clazz << " {\n";
   out << "public:\n";
   out.Indent();
   if (defined_type.IsFixedSize()) {
@@ -966,7 +1033,13 @@
   out << "static const char* descriptor;\n";
   out << "\n";
   for (const auto& variable : defined_type.GetFields()) {
-    out << NdkNameOf(types, variable->GetType(), StorageMode::STACK) << " " << variable->GetName();
+    out << NdkNameOf(types, variable->GetType(), StorageMode::STACK);
+    cpp::GenerateDeprecated(out, *variable);
+    out << " " << variable->GetName();
+    if (variable->GetType().GetName() == "ParcelableHolder") {
+      out << "{::ndk::" << (defined_type.IsVintfStability() ? "STABILITY_VINTF" : "STABILITY_LOCAL")
+          << "}";
+    }
     if (defined_type.IsFixedSize()) {
       int alignment = NdkAlignmentOf(types, variable->GetType());
       if (alignment > 0) {
@@ -981,9 +1054,16 @@
   out << "\n";
   out << "binder_status_t readFromParcel(const AParcel* parcel);\n";
   out << "binder_status_t writeToParcel(AParcel* parcel) const;\n";
+  out << "\n";
+
+  cpp::GenerateParcelableComparisonOperators(out, defined_type);
 
   out << "static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::"
       << (defined_type.IsVintfStability() ? "STABILITY_VINTF" : "STABILITY_LOCAL") << ";\n";
+
+  GenerateConstantDeclarations(out, types, defined_type);
+  cpp::GenerateToString(out, defined_type);
+
   out.Dedent();
   out << "};\n";
   LeaveNdkNamespace(out, defined_type);
@@ -1011,6 +1091,8 @@
       << defined_type.GetCanonicalName() << "\";\n";
   out << "\n";
 
+  GenerateConstantDefinitions(out, defined_type, clazz, cpp::TemplateDecl(defined_type));
+
   out << cpp::TemplateDecl(defined_type);
   out << "binder_status_t " << clazz << "::readFromParcel(const AParcel* parcel) {\n";
   out.Indent();
@@ -1063,10 +1145,143 @@
   LeaveNdkNamespace(out, defined_type);
 }
 
+void GenerateParcelHeader(CodeWriter& out, const AidlTypenames& types,
+                          const AidlUnionDecl& defined_type, const Options& /*options*/) {
+  const std::string clazz = ClassName(defined_type, ClassNames::RAW);
+  cpp::UnionWriter uw{defined_type, types,
+                      [&](const AidlTypeSpecifier& type, const AidlTypenames& types) {
+                        return NdkNameOf(types, type, StorageMode::STACK);
+                      },
+                      &ConstantValueDecorator};
+
+  out << "#pragma once\n";
+  out << "#include <android/binder_interface_utils.h>\n";
+  out << "#include <android/binder_parcelable_utils.h>\n";
+
+  // used by toString()
+  out << "#include <codecvt>\n";
+  out << "#include <locale>\n";
+  out << "#include <sstream>\n";
+
+  out << "\n";
+
+  for (const auto& header : cpp::UnionWriter::headers) {
+    out << "#include <" << header << ">\n";
+  }
+  GenerateHeaderIncludes(out, types, defined_type);
+
+  // TODO(b/31559095) bionic on host should define this
+  out << "\n";
+  out << "#ifndef __BIONIC__\n";
+  out << "#define __assert2(a,b,c,d) ((void)0)\n";
+  out << "#endif\n";
+  out << "\n";
+
+  EnterNdkNamespace(out, defined_type);
+  out << cpp::TemplateDecl(defined_type);
+  out << "class";
+  cpp::GenerateDeprecated(out, defined_type);
+  out << " " << clazz << " {\n";
+  out << "public:\n";
+  out.Indent();
+  if (defined_type.IsFixedSize()) {
+    out << "typedef std::true_type fixed_size;\n";
+  } else {
+    out << "typedef std::false_type fixed_size;\n";
+  }
+  out << "static const char* descriptor;\n";
+  out << "\n";
+  uw.PublicFields(out);
+
+  out << "binder_status_t readFromParcel(const AParcel* _parcel);\n";
+  out << "binder_status_t writeToParcel(AParcel* _parcel) const;\n";
+  out << "\n";
+
+  cpp::GenerateParcelableComparisonOperators(out, defined_type);
+
+  out << "static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::"
+      << (defined_type.IsVintfStability() ? "STABILITY_VINTF" : "STABILITY_LOCAL") << ";\n";
+  GenerateConstantDeclarations(out, types, defined_type);
+  cpp::GenerateToString(out, defined_type);
+  out.Dedent();
+  out << "private:\n";
+  out.Indent();
+  uw.PrivateFields(out);
+  out.Dedent();
+  out << "};\n";
+  LeaveNdkNamespace(out, defined_type);
+}
+void GenerateParcelSource(CodeWriter& out, const AidlTypenames& types,
+                          const AidlUnionDecl& defined_type, const Options& /*options*/) {
+  std::string clazz = ClassName(defined_type, ClassNames::RAW);
+  if (defined_type.IsGeneric()) {
+    std::vector<std::string> template_params;
+    for (const auto& parameter : defined_type.GetTypeParameters()) {
+      template_params.push_back(parameter);
+    }
+    clazz += base::StringPrintf("<%s>", base::Join(template_params, ", ").c_str());
+  }
+
+  cpp::UnionWriter uw{defined_type, types,
+                      [&](const AidlTypeSpecifier& type, const AidlTypenames& types) {
+                        return NdkNameOf(types, type, StorageMode::STACK);
+                      },
+                      &ConstantValueDecorator};
+  cpp::ParcelWriterContext ctx{
+      .status_type = "binder_status_t",
+      .status_ok = "STATUS_OK",
+      .status_bad = "STATUS_BAD_VALUE",
+      .read_func =
+          [&](CodeWriter& out, const std::string& var, const AidlTypeSpecifier& type) {
+            ReadFromParcelFor({out, types, type, "_parcel", "&" + var});
+          },
+      .write_func =
+          [&](CodeWriter& out, const std::string& value, const AidlTypeSpecifier& type) {
+            WriteToParcelFor({out, types, type, "_parcel", value});
+          },
+  };
+
+  out << "#include \"" << NdkHeaderFile(defined_type, ClassNames::RAW, false /*use_os_sep*/)
+      << "\"\n";
+  out << "\n";
+  GenerateSourceIncludes(out, types, defined_type);
+  out << "\n";
+  EnterNdkNamespace(out, defined_type);
+  out << cpp::TemplateDecl(defined_type);
+  out << "const char* " << clazz << "::" << kDescriptor << " = \""
+      << defined_type.GetCanonicalName() << "\";\n";
+  out << "\n";
+
+  GenerateConstantDefinitions(out, defined_type, clazz, cpp::TemplateDecl(defined_type));
+
+  out << cpp::TemplateDecl(defined_type);
+  out << "binder_status_t " << clazz << "::readFromParcel(const AParcel* _parcel) {\n";
+  out.Indent();
+  uw.ReadFromParcel(out, ctx);
+  out.Dedent();
+  out << "}\n";
+
+  out << cpp::TemplateDecl(defined_type);
+  out << "binder_status_t " << clazz << "::writeToParcel(AParcel* _parcel) const {\n";
+  out.Indent();
+  uw.WriteToParcel(out, ctx);
+  out.Dedent();
+  out << "}\n";
+  out << "\n";
+  LeaveNdkNamespace(out, defined_type);
+}
+
 std::string GenerateEnumToString(const AidlTypenames& typenames,
                                  const AidlEnumDeclaration& enum_decl) {
   std::ostringstream code;
-  code << "static inline std::string toString(" << enum_decl.GetName() << " val) {\n";
+  const std::string signature =
+      "static inline std::string toString(" + enum_decl.GetName() + " val)";
+  if (enum_decl.IsDeprecated()) {
+    code << signature;
+    cpp::GenerateDeprecated(code, enum_decl);
+    code << ";\n";
+  }
+  code << signature << " {\n";
   code << "  switch(val) {\n";
   std::set<std::string> unique_cases;
   for (const auto& enumerator : enum_decl.GetEnumerators()) {
@@ -1100,7 +1315,9 @@
   out << "#include <android/binder_enums.h>\n";
 
   EnterNdkNamespace(out, enum_decl);
-  out << "enum class " << enum_decl.GetName() << " : "
+  out << "enum class";
+  cpp::GenerateDeprecated(out, enum_decl);
+  out << " " << enum_decl.GetName() << " : "
       << NdkNameOf(types, enum_decl.GetBackingType(), StorageMode::STACK) << " {\n";
   out.Indent();
   for (const auto& enumerator : enum_decl.GetEnumerators()) {
diff --git a/generate_ndk.h b/generate_ndk.h
index 94a7669..6b893a3 100644
--- a/generate_ndk.h
+++ b/generate_ndk.h
@@ -47,11 +47,6 @@
 void GenerateInterfaceHeader(CodeWriter& out, const AidlTypenames& types,
                              const AidlInterface& defined_type, const Options& options);
 
-void GenerateParcelHeader(CodeWriter& out, const AidlTypenames& types,
-                          const AidlStructuredParcelable& defined_type, const Options& options);
-void GenerateParcelSource(CodeWriter& out, const AidlTypenames& types,
-                          const AidlStructuredParcelable& defined_type, const Options& options);
-
 void GenerateEnumHeader(CodeWriter& out, const AidlTypenames& types,
                         const AidlEnumDeclaration& enum_decl, const Options& options);
 
diff --git a/generate_rust.cpp b/generate_rust.cpp
index 912e817..372d30f 100644
--- a/generate_rust.cpp
+++ b/generate_rust.cpp
@@ -16,19 +16,20 @@
 
 #include "generate_rust.h"
 
+#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include <map>
 #include <memory>
 #include <sstream>
 
-#include <android-base/stringprintf.h>
-#include <android-base/strings.h>
-
 #include "aidl_to_cpp_common.h"
 #include "aidl_to_rust.h"
 #include "code_writer.h"
+#include "comments.h"
 #include "logging.h"
 
 using android::base::Join;
@@ -75,8 +76,9 @@
   return "fn " + method.GetName() + "(" + parameters + ") -> " + return_type;
 }
 
-void GenerateClientMethod(CodeWriter& out, const AidlMethod& method, const AidlTypenames& typenames,
-                          const Options& options, const std::string& trait_name) {
+void GenerateClientMethod(CodeWriter& out, const AidlInterface& iface, const AidlMethod& method,
+                          const AidlTypenames& typenames, const Options& options,
+                          const std::string& trait_name) {
   // Generate the method
   out << BuildMethod(method, typenames) << " {\n";
   out.Indent();
@@ -100,11 +102,19 @@
   }
 
   // Call transact()
-  auto transact_flags = method.IsOneway() ? "binder::SpIBinder::FLAG_ONEWAY" : "0";
+  vector<string> flags;
+  if (method.IsOneway()) flags.push_back("binder::SpIBinder::FLAG_ONEWAY");
+  if (iface.IsSensitiveData()) flags.push_back("binder::SpIBinder::FLAG_CLEAR_BUF");
+
+  string transact_flags = flags.empty() ? "0" : Join(flags, " | ");
   out << "let _aidl_reply = self.binder.transact("
       << "transactions::" << method.GetName() << ", " << transact_flags << ", |_aidl_data| {\n";
   out.Indent();
 
+  if (iface.IsSensitiveData()) {
+    out << "_aidl_data.mark_sensitive();\n";
+  }
+
   // Arguments
   for (const std::unique_ptr<AidlArgument>& arg : method.GetArguments()) {
     auto arg_name = kArgumentPrefix + arg->GetName();
@@ -133,19 +143,22 @@
   out << "});\n";
 
   // Check for UNKNOWN_TRANSACTION and call the default impl
-  string default_args;
-  for (const std::unique_ptr<AidlArgument>& arg : method.GetArguments()) {
-    if (!default_args.empty()) {
-      default_args += ", ";
+  if (method.IsUserDefined()) {
+    string default_args;
+    for (const std::unique_ptr<AidlArgument>& arg : method.GetArguments()) {
+      if (!default_args.empty()) {
+        default_args += ", ";
+      }
+      default_args += kArgumentPrefix;
+      default_args += arg->GetName();
     }
-    default_args += kArgumentPrefix;
-    default_args += arg->GetName();
+    out << "if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {\n";
+    out << "  if let Some(_aidl_default_impl) = <Self as " << trait_name
+        << ">::getDefaultImpl() {\n";
+    out << "    return _aidl_default_impl." << method.GetName() << "(" << default_args << ");\n";
+    out << "  }\n";
+    out << "}\n";
   }
-  out << "if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {\n";
-  out << "  if let Some(_aidl_default_impl) = <Self as " << trait_name << ">::getDefaultImpl() {\n";
-  out << "    return _aidl_default_impl." << method.GetName() << "(" << default_args << ");\n";
-  out << "  }\n";
-  out << "}\n";
 
   // Return all other errors
   out << "let _aidl_reply = _aidl_reply?;\n";
@@ -301,6 +314,39 @@
   out << "}\n";
 }
 
+void GenerateDeprecated(CodeWriter& out, const AidlCommentable& type) {
+  if (auto deprecated = FindDeprecated(type.GetComments()); deprecated.has_value()) {
+    if (deprecated->note.empty()) {
+      out << "#[deprecated]\n";
+    } else {
+      out << "#[deprecated = " << QuotedEscape(deprecated->note) << "]\n";
+    }
+  }
+}
+
+template <typename TypeWithConstants>
+void GenerateConstantDeclarations(CodeWriter& out, const TypeWithConstants& type,
+                                  const AidlTypenames& typenames) {
+  for (const auto& constant : type.GetConstantDeclarations()) {
+    const AidlTypeSpecifier& type = constant->GetType();
+    const AidlConstantValue& value = constant->GetValue();
+
+    string const_type;
+    if (type.Signature() == "String") {
+      const_type = "&str";
+    } else if (type.Signature() == "byte" || type.Signature() == "int" ||
+               type.Signature() == "long") {
+      const_type = RustNameOf(type, typenames, StorageMode::VALUE);
+    } else {
+      AIDL_FATAL(value) << "Unrecognized constant type: " << type.Signature();
+    }
+
+    GenerateDeprecated(out, *constant);
+    out << "pub const " << constant->GetName() << ": " << const_type << " = "
+        << constant->ValueString(ConstantValueDecoratorRef) << ";\n";
+  }
+}
+
 bool GenerateRustInterface(const string& filename, const AidlInterface* iface,
                            const AidlTypenames& typenames, const IoDelegate& io_delegate,
                            const Options& options) {
@@ -341,6 +387,7 @@
   code_writer->Dedent();
   *code_writer << "}\n";
 
+  GenerateDeprecated(*code_writer, *iface);
   *code_writer << "pub trait " << trait_name << ": binder::Interface + Send {\n";
   code_writer->Indent();
   *code_writer << "fn get_descriptor() -> &'static str where Self: Sized { \""
@@ -348,39 +395,55 @@
 
   for (const auto& method : iface->GetMethods()) {
     // Generate the method
-    *code_writer << BuildMethod(*method, typenames) << " {\n";
-    code_writer->Indent();
+    GenerateDeprecated(*code_writer, *method);
     if (method->IsUserDefined()) {
-      // Return Err(UNKNOWN_TRANSACTION) by default
-      *code_writer << "Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())\n";
+      *code_writer << BuildMethod(*method, typenames) << ";\n";
     } else {
       // Generate default implementations for meta methods
-      // FIXME: is this fine, or do we want to leave the defaults out
-      // and force users to implement them manually (or with a helper macro we
-      // provide) on the server side?
+      *code_writer << BuildMethod(*method, typenames) << " {\n";
+      code_writer->Indent();
       if (method->GetName() == kGetInterfaceVersion && options.Version() > 0) {
         *code_writer << "Ok(VERSION)\n";
       } else if (method->GetName() == kGetInterfaceHash && !options.Hash().empty()) {
         *code_writer << "Ok(HASH.into())\n";
       }
+      code_writer->Dedent();
+      *code_writer << "}\n";
     }
-    code_writer->Dedent();
-    *code_writer << "}\n";
   }
 
   // Emit the default implementation code inside the trait
-  auto default_name = ClassName(*iface, cpp::ClassNames::DEFAULT_IMPL);
+  auto default_trait_name = ClassName(*iface, cpp::ClassNames::DEFAULT_IMPL);
+  auto default_ref_name = default_trait_name + "Ref";
   *code_writer << "fn getDefaultImpl()"
-               << " -> " << default_name << " where Self: Sized {\n";
+               << " -> " << default_ref_name << " where Self: Sized {\n";
   *code_writer << "  DEFAULT_IMPL.lock().unwrap().clone()\n";
   *code_writer << "}\n";
-  *code_writer << "fn setDefaultImpl(d: " << default_name << ")"
-               << " -> " << default_name << " where Self: Sized {\n";
+  *code_writer << "fn setDefaultImpl(d: " << default_ref_name << ")"
+               << " -> " << default_ref_name << " where Self: Sized {\n";
   *code_writer << "  std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)\n";
   *code_writer << "}\n";
   code_writer->Dedent();
   *code_writer << "}\n";
 
+  // Emit the default trait
+  *code_writer << "pub trait " << default_trait_name << ": Send + Sync {\n";
+  code_writer->Indent();
+  for (const auto& method : iface->GetMethods()) {
+    if (!method->IsUserDefined()) {
+      continue;
+    }
+
+    // Generate the default method
+    *code_writer << BuildMethod(*method, typenames) << " {\n";
+    code_writer->Indent();
+    *code_writer << "Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())\n";
+    code_writer->Dedent();
+    *code_writer << "}\n";
+  }
+  code_writer->Dedent();
+  *code_writer << "}\n";
+
   // Generate the transaction code constants
   // The constants get their own sub-module to avoid conflicts
   *code_writer << "pub mod transactions {\n";
@@ -398,38 +461,16 @@
   *code_writer << "}\n";
 
   // Emit the default implementation code outside the trait
-  *code_writer << "pub type " << default_name << " = Option<std::sync::Arc<dyn " << trait_name
-               << " + Sync>>;\n";
+  *code_writer << "pub type " << default_ref_name << " = Option<std::sync::Arc<dyn "
+               << default_trait_name << ">>;\n";
   *code_writer << "use lazy_static::lazy_static;\n";
   *code_writer << "lazy_static! {\n";
-  *code_writer << "  static ref DEFAULT_IMPL: std::sync::Mutex<" << default_name
+  *code_writer << "  static ref DEFAULT_IMPL: std::sync::Mutex<" << default_ref_name
                << "> = std::sync::Mutex::new(None);\n";
   *code_writer << "}\n";
 
   // Emit the interface constants
-  for (const auto& constant : iface->GetConstantDeclarations()) {
-    const AidlConstantValue& value = constant->GetValue();
-    string const_type;
-    switch (value.GetType()) {
-      case AidlConstantValue::Type::STRING: {
-        const_type = "&str";
-        break;
-      }
-      case AidlConstantValue::Type::BOOLEAN:  // fall-through
-      case AidlConstantValue::Type::INT8:     // fall-through
-      case AidlConstantValue::Type::INT32:    // fall-through
-      // Type promotion may cause this. Value should be small enough to fit in int32.
-      case AidlConstantValue::Type::INT64: {
-        const_type = "i32";
-        break;
-      }
-      default: {
-        AIDL_FATAL(value) << "Unrecognized constant type: " << static_cast<int>(value.GetType());
-      }
-    }
-    *code_writer << "pub const " << constant->GetName() << ": " << const_type << " = "
-                 << constant->ValueString(ConstantValueDecoratorRef) << ";\n";
-  }
+  GenerateConstantDeclarations(*code_writer, *iface, typenames);
 
   GenerateMangledAlias(*code_writer, iface);
 
@@ -448,7 +489,7 @@
   *code_writer << "impl " << trait_name << " for " << client_name << " {\n";
   code_writer->Indent();
   for (const auto& method : iface->GetMethods()) {
-    GenerateClientMethod(*code_writer, *method, typenames, options, trait_name);
+    GenerateClientMethod(*code_writer, *iface, *method, typenames, options, trait_name);
   }
   code_writer->Dedent();
   *code_writer << "}\n";
@@ -459,6 +500,20 @@
   return true;
 }
 
+void GenerateParcelBody(CodeWriter& out, const AidlStructuredParcelable* parcel,
+                        const AidlTypenames& typenames) {
+  GenerateDeprecated(out, *parcel);
+  out << "pub struct " << parcel->GetName() << " {\n";
+  out.Indent();
+  for (const auto& variable : parcel->GetFields()) {
+    GenerateDeprecated(out, *variable);
+    auto field_type = RustNameOf(variable->GetType(), typenames, StorageMode::PARCELABLE_FIELD);
+    out << "pub " << variable->GetName() << ": " << field_type << ",\n";
+  }
+  out.Dedent();
+  out << "}\n";
+}
+
 void GenerateParcelDefault(CodeWriter& out, const AidlStructuredParcelable* parcel) {
   out << "impl Default for " << parcel->GetName() << " {\n";
   out.Indent();
@@ -481,7 +536,142 @@
   out << "}\n";
 }
 
-void GenerateParcelSerialize(CodeWriter& out, const AidlStructuredParcelable* parcel,
+void GenerateParcelSerializeBody(CodeWriter& out, const AidlStructuredParcelable* parcel,
+                                 const AidlTypenames& typenames) {
+  out << "parcel.sized_write(|subparcel| {\n";
+  out.Indent();
+  for (const auto& variable : parcel->GetFields()) {
+    if (!TypeHasDefault(variable->GetType(), typenames)) {
+      out << "let __field_ref = this." << variable->GetName()
+          << ".as_ref().ok_or(binder::StatusCode::UNEXPECTED_NULL)?;\n";
+      out << "subparcel.write(__field_ref)?;\n";
+    } else {
+      out << "subparcel.write(&this." << variable->GetName() << ")?;\n";
+    }
+  }
+  out << "Ok(())\n";
+  out.Dedent();
+  out << "})\n";
+}
+
+void GenerateParcelDeserializeBody(CodeWriter& out, const AidlStructuredParcelable* parcel,
+                                   const AidlTypenames& typenames) {
+  out << "let start_pos = parcel.get_data_position();\n";
+  out << "let parcelable_size: i32 = parcel.read()?;\n";
+  out << "if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }\n";
+
+  // Pre-emit the common field epilogue code, shared between all fields:
+  ostringstream epilogue;
+  epilogue << "if (parcel.get_data_position() - start_pos) == parcelable_size {\n";
+  // We assume the lhs can never be > parcelable_size, because then the read
+  // immediately preceding this check would have returned NOT_ENOUGH_DATA
+  epilogue << "  return Ok(Some(result));\n";
+  epilogue << "}\n";
+  string epilogue_str = epilogue.str();
+
+  out << "let mut result = Self::default();\n";
+  for (const auto& variable : parcel->GetFields()) {
+    if (!TypeHasDefault(variable->GetType(), typenames)) {
+      out << "result." << variable->GetName() << " = Some(parcel.read()?);\n";
+    } else {
+      out << "result." << variable->GetName() << " = parcel.read()?;\n";
+    }
+    out << epilogue_str;
+  }
+
+  out << "Ok(Some(result))\n";
+}
+
+void GenerateParcelBody(CodeWriter& out, const AidlUnionDecl* parcel,
+                        const AidlTypenames& typenames) {
+  GenerateDeprecated(out, *parcel);
+  out << "pub enum " << parcel->GetName() << " {\n";
+  out.Indent();
+  for (const auto& variable : parcel->GetFields()) {
+    GenerateDeprecated(out, *variable);
+    auto field_type = RustNameOf(variable->GetType(), typenames, StorageMode::PARCELABLE_FIELD);
+    out << variable->GetCapitalizedName() << "(" << field_type << "),\n";
+  }
+  out.Dedent();
+  out << "}\n";
+}
+
+void GenerateParcelDefault(CodeWriter& out, const AidlUnionDecl* parcel) {
+  out << "impl Default for " << parcel->GetName() << " {\n";
+  out.Indent();
+  out << "fn default() -> Self {\n";
+  out.Indent();
+
+  AIDL_FATAL_IF(parcel->GetFields().empty(), *parcel)
+      << "Union '" << parcel->GetName() << "' is empty.";
+  const auto& first_field = parcel->GetFields()[0];
+  const auto& first_value = first_field->ValueString(ConstantValueDecorator);
+
+  out << "Self::";
+  if (first_field->GetDefaultValue()) {
+    out << first_field->GetCapitalizedName() << "(" << first_value << ")\n";
+  } else {
+    out << first_field->GetCapitalizedName() << "(Default::default())\n";
+  }
+
+  out.Dedent();
+  out << "}\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+void GenerateParcelSerializeBody(CodeWriter& out, const AidlUnionDecl* parcel,
+                                 const AidlTypenames& typenames) {
+  out << "match this {\n";
+  out.Indent();
+  int tag = 0;
+  for (const auto& variable : parcel->GetFields()) {
+    out << "Self::" << variable->GetCapitalizedName() << "(v) => {\n";
+    out.Indent();
+    out << "parcel.write(&" << std::to_string(tag++) << "i32)?;\n";
+    if (!TypeHasDefault(variable->GetType(), typenames)) {
+      out << "let __field_ref = v.as_ref().ok_or(binder::StatusCode::UNEXPECTED_NULL)?;\n";
+      out << "parcel.write(__field_ref)\n";
+    } else {
+      out << "parcel.write(v)\n";
+    }
+    out.Dedent();
+    out << "}\n";
+  }
+  out.Dedent();
+  out << "}\n";
+}
+
+void GenerateParcelDeserializeBody(CodeWriter& out, const AidlUnionDecl* parcel,
+                                   const AidlTypenames& typenames) {
+  out << "let tag: i32 = parcel.read()?;\n";
+  out << "match tag {\n";
+  out.Indent();
+  int tag = 0;
+  for (const auto& variable : parcel->GetFields()) {
+    auto field_type = RustNameOf(variable->GetType(), typenames, StorageMode::PARCELABLE_FIELD);
+
+    out << std::to_string(tag++) << " => {\n";
+    out.Indent();
+    out << "let value: " << field_type << " = ";
+    if (!TypeHasDefault(variable->GetType(), typenames)) {
+      out << "Some(parcel.read()?);\n";
+    } else {
+      out << "parcel.read()?;\n";
+    }
+    out << "Ok(Some(Self::" << variable->GetCapitalizedName() << "(value)))\n";
+    out.Dedent();
+    out << "}\n";
+  }
+  out << "_ => {\n";
+  out << "  Err(binder::StatusCode::BAD_VALUE)\n";
+  out << "}\n";
+  out.Dedent();
+  out << "}\n";
+}
+
+template <typename ParcelableType>
+void GenerateParcelSerialize(CodeWriter& out, const ParcelableType* parcel,
                              const AidlTypenames& typenames) {
   out << "impl binder::parcel::Serialize for " << parcel->GetName() << " {\n";
   out << "  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {\n";
@@ -502,27 +692,17 @@
   out << "} else {\n";
   out << "  return parcel.write(&0i32);\n";
   out << "};\n";
-  out << "parcel.sized_write(|subparcel| {\n";
-  out.Indent();
-  for (const auto& variable : parcel->GetFields()) {
-    if (!TypeHasDefault(variable->GetType(), typenames)) {
-      out << "let __field_ref = this." << variable->GetName()
-          << ".as_ref().ok_or(binder::StatusCode::UNEXPECTED_NULL)?;\n";
-      out << "subparcel.write(__field_ref)?;\n";
-    } else {
-      out << "subparcel.write(&this." << variable->GetName() << ")?;\n";
-    }
-  }
-  out << "Ok(())\n";
-  out.Dedent();
-  out << "})\n";
+
+  GenerateParcelSerializeBody(out, parcel, typenames);
+
   out.Dedent();
   out << "}\n";
   out.Dedent();
   out << "}\n";
 }
 
-void GenerateParcelDeserialize(CodeWriter& out, const AidlStructuredParcelable* parcel,
+template <typename ParcelableType>
+void GenerateParcelDeserialize(CodeWriter& out, const ParcelableType* parcel,
                                const AidlTypenames& typenames) {
   out << "impl binder::parcel::Deserialize for " << parcel->GetName() << " {\n";
   out << "  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {\n";
@@ -535,39 +715,23 @@
   out << "impl binder::parcel::DeserializeArray for " << parcel->GetName() << " {}\n";
 
   out << "impl binder::parcel::DeserializeOption for " << parcel->GetName() << " {\n";
-  out << "  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> "
+  out.Indent();
+  out << "fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> "
          "{\n";
-  out << "    let status: i32 = parcel.read()?;\n";
-  out << "    if status == 0 { return Ok(None); }\n";
-  out << "    let start_pos = parcel.get_data_position();\n";
-  out << "    let parcelable_size: i32 = parcel.read()?;\n";
-  out << "    if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }\n";
+  out.Indent();
+  out << "let status: i32 = parcel.read()?;\n";
+  out << "if status == 0 { return Ok(None); }\n";
 
-  // Pre-emit the common field epilogue code, shared between all fields:
-  ostringstream epilogue;
-  epilogue << "    if (parcel.get_data_position() - start_pos) == parcelable_size {\n";
-  // We assume the lhs can never be > parcelable_size, because then the read
-  // immediately preceding this check would have returned NOT_ENOUGH_DATA
-  epilogue << "      return Ok(Some(result));\n";
-  epilogue << "    }\n";
-  string epilogue_str = epilogue.str();
+  GenerateParcelDeserializeBody(out, parcel, typenames);
 
-  out << "    let mut result = Self::default();\n";
-  for (const auto& variable : parcel->GetFields()) {
-    if (!TypeHasDefault(variable->GetType(), typenames)) {
-      out << "    result." << variable->GetName() << " = Some(parcel.read()?);\n";
-    } else {
-      out << "    result." << variable->GetName() << " = parcel.read()?;\n";
-    }
-    out << epilogue_str;
-  }
-
-  out << "    Ok(Some(result))\n";
-  out << "  }\n";
+  out.Dedent();
+  out << "}\n";
+  out.Dedent();
   out << "}\n";
 }
 
-bool GenerateRustParcel(const string& filename, const AidlStructuredParcelable* parcel,
+template <typename ParcelableType>
+bool GenerateRustParcel(const string& filename, const ParcelableType* parcel,
                         const AidlTypenames& typenames, const IoDelegate& io_delegate) {
   CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
 
@@ -585,20 +749,12 @@
   }
 
   *code_writer << "#[derive(" << Join(derives, ", ") << ")]\n";
-  *code_writer << "pub struct " << parcel->GetName() << " {\n";
-  code_writer->Indent();
-  for (const auto& variable : parcel->GetFields()) {
-    auto field_type = RustNameOf(variable->GetType(), typenames, StorageMode::PARCELABLE_FIELD);
-    *code_writer << "pub " << variable->GetName() << ": " << field_type << ", \n";
-  }
-  code_writer->Dedent();
-  *code_writer << "}\n";
-
+  GenerateParcelBody(*code_writer, parcel, typenames);
+  GenerateConstantDeclarations(*code_writer, *parcel, typenames);
   GenerateMangledAlias(*code_writer, parcel);
   GenerateParcelDefault(*code_writer, parcel);
   GenerateParcelSerialize(*code_writer, parcel, typenames);
   GenerateParcelDeserialize(*code_writer, parcel, typenames);
-
   return true;
 }
 
@@ -609,6 +765,7 @@
   const auto& aidl_backing_type = enum_decl->GetBackingType();
   auto backing_type = RustNameOf(aidl_backing_type, typenames, StorageMode::VALUE);
 
+  // TODO(b/177860423) support "deprecated" for enum types
   *code_writer << "#![allow(non_upper_case_globals)]\n";
   *code_writer << "use binder::declare_binder_enum;\n";
   *code_writer << "declare_binder_enum! { " << enum_decl->GetName() << " : " << backing_type
@@ -634,6 +791,10 @@
     return GenerateRustParcel(filename, parcelable, typenames, io_delegate);
   }
 
+  if (const AidlUnionDecl* parcelable = defined_type->AsUnionDeclaration(); parcelable != nullptr) {
+    return GenerateRustParcel(filename, parcelable, typenames, io_delegate);
+  }
+
   if (const AidlEnumDeclaration* enum_decl = defined_type->AsEnumDeclaration();
       enum_decl != nullptr) {
     return GenerateRustEnumDeclaration(filename, enum_decl, typenames, io_delegate);
diff --git a/import_resolver.cpp b/import_resolver.cpp
index edde65b..1bf2794 100644
--- a/import_resolver.cpp
+++ b/import_resolver.cpp
@@ -79,8 +79,7 @@
   } else if (num_found == 1) {
     return found_paths.front();
   } else {
-    AIDL_ERROR(input_file_name_) << "Duplicate files found for " << canonical_name
-                                 << " from:" << std::endl
+    AIDL_ERROR(input_file_name_) << "Duplicate files found for " << canonical_name << " from:\n"
                                  << android::base::Join(found_paths, "\n");
     return "";
   }
diff --git a/io_delegate_unittest.cpp b/io_delegate_unittest.cpp
index 39982bc..d952b83 100644
--- a/io_delegate_unittest.cpp
+++ b/io_delegate_unittest.cpp
@@ -14,21 +14,27 @@
  * limitations under the License.
  */
 
+#include "io_delegate.h"
+
 #include <string>
 
 #include <gtest/gtest.h>
 
-#include "io_delegate.h"
-
 using std::string;
+using testing::internal::CaptureStderr;
+using testing::internal::GetCapturedStderr;
 
 namespace android {
 namespace aidl {
 
 TEST(IoDelegateTest, CannotGetAbsolutePathFromEmptyString) {
+  string expected_error =
+      "ERROR: : Giving up on finding an absolute path to represent the empty string.\n";
+  CaptureStderr();
   string absolute_path;
   EXPECT_FALSE(IoDelegate::GetAbsolutePath("", &absolute_path));
   EXPECT_TRUE(absolute_path.empty());
+  EXPECT_EQ(expected_error, GetCapturedStderr());
 }
 
 TEST(IoDelegateTest, CurrentlyInfersLinuxAbsolutePath) {
diff --git a/location.cpp b/location.cpp
new file mode 100644
index 0000000..4b8a278
--- /dev/null
+++ b/location.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "location.h"
+
+AidlLocation::AidlLocation(const std::string& file, Point begin, Point end, Source source)
+    : file_(file), begin_(begin), end_(end), source_(source) {}
+
+std::ostream& operator<<(std::ostream& os, const AidlLocation& l) {
+  os << l.file_;
+  if (l.LocationKnown()) {
+    os << ":" << l.begin_.line << "." << l.begin_.column << "-";
+    if (l.begin_.line != l.end_.line) {
+      os << l.end_.line << ".";
+    }
+    os << l.end_.column;
+  }
+  return os;
+}
diff --git a/location.h b/location.h
new file mode 100644
index 0000000..9ccad24
--- /dev/null
+++ b/location.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <iostream>
+#include <string>
+
+class AidlLocation {
+ public:
+  struct Point {
+    int line;
+    int column;
+  };
+
+  enum class Source {
+    // From internal aidl source code
+    INTERNAL = 0,
+    // From a parsed file
+    EXTERNAL = 1
+  };
+
+  AidlLocation(const std::string& file, Point begin, Point end, Source source);
+  AidlLocation(const std::string& file, Source source)
+      : AidlLocation(file, {0, 0}, {0, 0}, source) {}
+
+  bool IsInternal() const { return source_ == Source::INTERNAL; }
+
+  // The first line of a file is line 1.
+  bool LocationKnown() const { return begin_.line != 0; }
+
+  std::string GetFile() const { return file_; }
+
+  friend std::ostream& operator<<(std::ostream& os, const AidlLocation& l);
+  friend class AidlNode;
+
+ private:
+  // INTENTIONALLY HIDDEN: only operator<< should access details here.
+  // Otherwise, locations should only ever be copied around to construct new
+  // objects.
+  const std::string file_;
+  Point begin_;
+  Point end_;
+  Source source_;
+};
+
+#define AIDL_LOCATION_HERE \
+  (AidlLocation{__FILE__, {__LINE__, 0}, {__LINE__, 0}, AidlLocation::Source::INTERNAL})
+
+std::ostream& operator<<(std::ostream& os, const AidlLocation& l);
\ No newline at end of file
diff --git a/logging.cpp b/logging.cpp
index 09bb2f7..3c75565 100644
--- a/logging.cpp
+++ b/logging.cpp
@@ -16,4 +16,33 @@
 
 #include "logging.h"
 
+#include "aidl_language.h"
+
 bool AidlErrorLog::sHadError = false;
+
+AidlErrorLog::AidlErrorLog(Severity severity, const AidlLocation& location,
+                           const std::string& suffix /* = "" */)
+    : os_(&std::cerr), severity_(severity), location_(location), suffix_(suffix) {
+  sHadError |= severity_ >= ERROR;
+  if (severity_ != NO_OP) {
+    (*os_) << (severity_ == WARNING ? "WARNING: " : "ERROR: ");
+    (*os_) << location << ": ";
+  }
+}
+
+AidlErrorLog::AidlErrorLog(Severity severity, const AidlNode& node)
+    : AidlErrorLog(severity, node.location_) {}
+
+AidlErrorLog::AidlErrorLog(Severity severity, const std::string& filename)
+    : AidlErrorLog(severity, AidlLocation(filename, AidlLocation::Source::EXTERNAL)) {}
+
+AidlErrorLog::~AidlErrorLog() {
+  if (severity_ == NO_OP) return;
+  (*os_) << suffix_ << std::endl;
+  if (severity_ == FATAL) abort();
+  if (location_.IsInternal()) {
+    (*os_) << "Logging an internal location should not happen. Offending location: " << location_
+           << std::endl;
+    abort();
+  }
+}
diff --git a/logging.h b/logging.h
index f6d6da1..e540105 100644
--- a/logging.h
+++ b/logging.h
@@ -16,51 +16,51 @@
 
 #pragma once
 
-#include "aidl_language.h"
-
 #include <iostream>
+#include <string>
+
+#include "location.h"
+
+class AidlNode;
 
 // Generic point for printing any error in the AIDL compiler.
 class AidlErrorLog {
  public:
-  AidlErrorLog(bool fatal, const AidlLocation& location)
-      : os_(std::cerr), fatal_(fatal), location_(location) {
-    sHadError = true;
+  enum Severity { NO_OP, WARNING, ERROR, FATAL };
 
-    os_ << "ERROR: ";
-    os_ << location << ": ";
-  }
-  AidlErrorLog(bool fatal, const std::string& filename)
-      : AidlErrorLog(fatal, AidlLocation(filename, AidlLocation::Source::EXTERNAL)) {}
-  AidlErrorLog(bool fatal, const AidlNode& node) : AidlErrorLog(fatal, node.location_) {}
-  AidlErrorLog(bool fatal, const AidlNode* node) : AidlErrorLog(fatal, *node) {}
+  AidlErrorLog(Severity severity, const AidlLocation& location, const std::string& suffix = "");
+  AidlErrorLog(Severity severity, const std::string& filename);
+  AidlErrorLog(Severity severity, const AidlNode& node);
+  AidlErrorLog(Severity severity, const AidlNode* node) : AidlErrorLog(severity, *node) {}
 
   template <typename T>
-  AidlErrorLog(bool fatal, const std::unique_ptr<T>& node) : AidlErrorLog(fatal, *node) {}
-  ~AidlErrorLog() {
-    os_ << std::endl;
-    if (fatal_) abort();
-    if (location_.IsInternal()) {
-      os_ << "Logging an internal location should not happen. Offending location: " << location_
-          << std::endl;
-      abort();
-    }
-  }
+  AidlErrorLog(Severity severity, const std::unique_ptr<T>& node) : AidlErrorLog(severity, *node) {}
+  ~AidlErrorLog();
 
-  // AidlErrorLog is a single use object. No need to copy or move
+  // AidlErrorLog is a single use object. No need to copy
   AidlErrorLog(const AidlErrorLog&) = delete;
-  AidlErrorLog(AidlErrorLog&&) = delete;
   AidlErrorLog& operator=(const AidlErrorLog&) = delete;
-  AidlErrorLog& operator=(AidlErrorLog&&) = delete;
 
-  std::ostream& os_;
+  // btw, making it movable so that functions can return it.
+  AidlErrorLog(AidlErrorLog&&) = default;
+  AidlErrorLog& operator=(AidlErrorLog&&) = default;
+
+  template <typename T>
+  AidlErrorLog& operator<<(T&& arg) {
+    if (severity_ != NO_OP) {
+      (*os_) << std::forward<T>(arg);
+    }
+    return *this;
+  }
 
   static void clearError() { sHadError = false; }
   static bool hadError() { return sHadError; }
 
  private:
-  bool fatal_;
+  std::ostream* os_;
+  Severity severity_;
   const AidlLocation location_;
+  const std::string suffix_;
   static bool sHadError;
 };
 
@@ -72,8 +72,8 @@
   __attribute__((noreturn)) ~AidlAbortOnDestruction() { abort(); }
 };
 
-#define AIDL_ERROR(CONTEXT) ::AidlErrorLog(false /*fatal*/, (CONTEXT)).os_
+#define AIDL_ERROR(CONTEXT) ::AidlErrorLog(AidlErrorLog::ERROR, (CONTEXT))
 #define AIDL_FATAL(CONTEXT) \
-  (::AidlAbortOnDestruction(), ::AidlErrorLog(true /*fatal*/, (CONTEXT)).os_)
+  (::AidlAbortOnDestruction(), ::AidlErrorLog(AidlErrorLog::FATAL, (CONTEXT)))
 #define AIDL_FATAL_IF(CONDITION, CONTEXT) \
   if (CONDITION) AIDL_FATAL(CONTEXT) << "Bad internal state: " << #CONDITION << ": "
diff --git a/metadata/Android.bp b/metadata/Android.bp
index e82da91..3b76f07 100644
--- a/metadata/Android.bp
+++ b/metadata/Android.bp
@@ -10,6 +10,7 @@
 
 cc_library_headers {
     name: "libaidlmetadata_headers",
+    product_available: true,
     recovery_available: true,
     host_supported: true,
     export_include_dirs: ["include"],
@@ -44,5 +45,8 @@
         "libgmock",
     ],
     srcs: ["test.cpp"],
+    test_options: {
+        unit_test: true,
+    },
     test_suites: ["general-tests"],
 }
diff --git a/options.cpp b/options.cpp
index 1018146..97eb6b0 100644
--- a/options.cpp
+++ b/options.cpp
@@ -55,9 +55,9 @@
        << myname_ << " --dumpapi --out=DIR INPUT..." << endl
        << "   Dump API signature of AIDL file(s) to DIR." << endl
        << endl
-       << myname_ << " --checkapi OLD_DIR NEW_DIR" << endl
-       << "   Checkes whether API dump NEW_DIR is backwards compatible extension " << endl
-       << "   of the API dump OLD_DIR." << endl
+       << myname_ << " --checkapi[={compatible|equal}] OLD_DIR NEW_DIR" << endl
+       << "   Check whether NEW_DIR API dump is {compatible|equal} extension " << endl
+       << "   of the API dump OLD_DIR. Default: compatible" << endl
 #endif
        << endl;
 
@@ -124,9 +124,19 @@
        << "  --log" << endl
        << "          Information about the transaction, e.g., method name, argument" << endl
        << "          values, execution time, etc., is provided via callback." << endl
-       << "  --parcelable-to-string" << endl
-       << "          Generates an implementation of toString() for Java parcelables," << endl
-       << "          and ostream& operator << for C++ parcelables." << endl
+       << "  -Werror" << endl
+       << "          Turn warnings into errors." << endl
+       << "  -Wno-error=<warning>" << endl
+       << "          Turn the specified warning into a warning even if -Werror is specified."
+       << endl
+       << "  -W<warning>" << endl
+       << "          Enable the specified warning." << endl
+       << "  -Wno-<warning>" << endl
+       << "          Disable the specified warning." << endl
+       << "  -w" << endl
+       << "          Disable all diagnostics. -w wins -Weverything" << endl
+       << "  -Weverything" << endl
+       << "          Enable all diagnostics." << endl
        << "  --help" << endl
        << "          Show this help." << endl
        << endl
@@ -145,7 +155,7 @@
   return sstr.str();
 }
 
-const string Options::LanguageToString(Language language) {
+string to_string(Options::Language language) {
   switch (language) {
     case Options::Language::CPP:
       return "cpp";
@@ -191,8 +201,12 @@
   return Options(argc, argv, lang);
 }
 
-Options::Options(int argc, const char* const argv[], Options::Language default_lang)
-    : myname_(argv[0]), language_(default_lang) {
+Options::Options(int argc, const char* const raw_argv[], Options::Language default_lang)
+    : myname_(raw_argv[0]), language_(default_lang) {
+  std::vector<const char*> argv = warning_options_.Parse(argc, raw_argv, error_message_);
+  if (!Ok()) return;
+  argc = argv.size();
+
   bool lang_option_found = false;
   optind = 0;
   while (true) {
@@ -201,7 +215,7 @@
         {"preprocess", no_argument, 0, 's'},
 #ifndef _WIN32
         {"dumpapi", no_argument, 0, 'u'},
-        {"checkapi", no_argument, 0, 'A'},
+        {"checkapi", optional_argument, 0, 'A'},
 #endif
         {"apimapping", required_argument, 0, 'i'},
         {"include", required_argument, 0, 'I'},
@@ -217,12 +231,11 @@
         {"transaction_names", no_argument, 0, 'c'},
         {"version", required_argument, 0, 'v'},
         {"log", no_argument, 0, 'L'},
-        {"parcelable-to-string", no_argument, 0, 'P'},
         {"hash", required_argument, 0, 'H'},
         {"help", no_argument, 0, 'e'},
         {0, 0, 0, 0},
     };
-    const int c = getopt_long(argc, const_cast<char* const*>(argv),
+    const int c = getopt_long(argc, const_cast<char* const*>(argv.data()),
                               "I:m:p:d:o:h:abtv:", long_options, nullptr);
     if (c == -1) {
       // no more options
@@ -272,6 +285,16 @@
           task_ = Options::Task::CHECK_API;
           // to ensure that all parcelables in the api dumpes are structured
           structured_ = true;
+          if (optarg) {
+            if (strcmp(optarg, "compatible") == 0)
+              check_api_level_ = CheckApiLevel::COMPATIBLE;
+            else if (strcmp(optarg, "equal") == 0)
+              check_api_level_ = CheckApiLevel::EQUAL;
+            else {
+              error_message_ << "Unsupported --checkapi level: '" << optarg << "'" << endl;
+              return;
+            }
+          }
         }
         break;
 #endif
@@ -353,9 +376,6 @@
         output_file_ = Trim(optarg);
         task_ = Task::DUMP_MAPPINGS;
         break;
-      case 'P':
-        gen_parcelable_to_string_ = true;
-        break;
       default:
         std::cerr << GetUsage();
         exit(1);
@@ -377,7 +397,7 @@
         // when output is omitted and -o option isn't set, the output is by
         // default set to the input file path with .aidl is replaced to .java.
         // If -o option is set, the output path is calculated by
-        // generate_outputFileName which returns "<output_dir>/<package/name>/
+        // GetOutputFilePath which returns "<output_dir>/<package/name>/
         // <typename>.java"
         output_file_ = input_files_.front();
         if (android::base::EndsWith(output_file_, ".aidl")) {
@@ -502,7 +522,7 @@
   }
   if (task_ == Options::Task::DUMP_API) {
     if (output_dir_.empty()) {
-      error_message_ << "--dump_api requires output directory. Use --out." << endl;
+      error_message_ << "--dumpapi requires output directory. Use --out." << endl;
       return;
     }
   }
@@ -512,5 +532,62 @@
                 output_header_dir_);
 }
 
+std::vector<const char*> WarningOptions::Parse(int argc, const char* const raw_argv[],
+                                               ErrorMessage& error_message) {
+  std::vector<const char*> remains;
+  for (int i = 0; i < argc; i++) {
+    auto arg = raw_argv[i];
+    if (strcmp(arg, "-Weverything") == 0) {
+      enable_all_ = true;
+    } else if (strcmp(arg, "-Werror") == 0) {
+      as_errors_ = true;
+    } else if (strcmp(arg, "-w") == 0) {
+      disable_all_ = true;
+    } else if (base::StartsWith(arg, "-Wno-error=")) {
+      no_errors_.insert(arg + strlen("-Wno-error="));
+    } else if (base::StartsWith(arg, "-Wno-")) {
+      disabled_.insert(arg + strlen("-Wno-"));
+    } else if (base::StartsWith(arg, "-W")) {
+      enabled_.insert(arg + strlen("-W"));
+    } else {
+      remains.push_back(arg);
+    }
+  }
+
+  for (const auto& names : {no_errors_, disabled_, enabled_}) {
+    for (const auto& name : names) {
+      if (kAllDiagnostics.count(name) == 0) {
+        error_message << "unknown warning: " << name << "\n";
+        return {};
+      }
+    }
+  }
+
+  return remains;
+}
+
+DiagnosticMapping WarningOptions::GetDiagnosticMapping() const {
+  DiagnosticMapping mapping;
+  for (const auto& [_, d] : kAllDiagnostics) {
+    bool enabled = d.default_enabled;
+    if (enable_all_ || enabled_.find(d.name) != enabled_.end()) {
+      enabled = true;
+    }
+    if (disable_all_ || disabled_.find(d.name) != disabled_.end()) {
+      enabled = false;
+    }
+
+    DiagnosticSeverity severity = DiagnosticSeverity::DISABLED;
+    if (enabled) {
+      severity = DiagnosticSeverity::WARNING;
+      if (as_errors_ && no_errors_.find(d.name) == no_errors_.end()) {
+        severity = DiagnosticSeverity::ERROR;
+      }
+    }
+    mapping.Severity(d.id, severity);
+  }
+  return mapping;
+}
+
 }  // namespace aidl
 }  // namespace android
diff --git a/options.h b/options.h
index 1ca76bd..418208a 100644
--- a/options.h
+++ b/options.h
@@ -16,10 +16,11 @@
 #pragma once
 
 #include <set>
-#include <sstream>
 #include <string>
 #include <vector>
 
+#include "diagnostics.h"
+
 namespace android {
 namespace aidl {
 
@@ -57,12 +58,29 @@
   }
 };
 
+// Handles warning-related options (e.g. -W, -w, ...)
+class WarningOptions {
+ public:
+  std::vector<const char*> Parse(int argc, const char* const argv[], ErrorMessage& error_message);
+  DiagnosticMapping GetDiagnosticMapping() const;
+
+ private:
+  bool as_errors_ = false;           // -Werror
+  bool enable_all_ = false;          // -Weverything
+  bool disable_all_ = false;         // -w
+  std::set<std::string> enabled_;    // -Wfoo
+  std::set<std::string> disabled_;   // -Wno-foo
+  std::set<std::string> no_errors_;  // -Wno-error=foo
+};
+
 class Options final {
  public:
   enum class Language { UNSPECIFIED, JAVA, CPP, NDK, RUST };
 
   enum class Task { UNSPECIFIED, COMPILE, PREPROCESS, DUMP_API, CHECK_API, DUMP_MAPPINGS };
 
+  enum class CheckApiLevel { COMPATIBLE, EQUAL };
+
   enum class Stability { UNSPECIFIED, VINTF };
   bool StabilityFromString(const std::string& stability, Stability* out_stability);
 
@@ -84,6 +102,8 @@
 
   Task GetTask() const { return task_; }
 
+  CheckApiLevel GetCheckApiLevel() const { return check_api_level_; }
+
   const set<string>& ImportDirs() const { return import_dirs_; }
 
   const set<string>& ImportFiles() const { return import_files_; }
@@ -125,8 +145,6 @@
 
   bool GenLog() const { return gen_log_; }
 
-  bool GenParcelableToString() const { return gen_parcelable_to_string_; }
-
   bool Ok() const { return error_message_.stream_.str().empty(); }
 
   string GetErrorMessage() const { return error_message_.stream_.str(); }
@@ -135,7 +153,7 @@
 
   bool GenApiMapping() const { return task_ == Task::DUMP_MAPPINGS; }
 
-  static const string LanguageToString(Language language);
+  DiagnosticMapping GetDiagnosticMapping() const { return warning_options_.GetDiagnosticMapping(); }
 
   // The following are for testability, but cannot be influenced on the command line.
   // Threshold of interface methods to enable outlining of onTransact cases.
@@ -149,6 +167,7 @@
   const string myname_;
   Language language_ = Language::UNSPECIFIED;
   Task task_ = Task::COMPILE;
+  CheckApiLevel check_api_level_ = CheckApiLevel::COMPATIBLE;
   set<string> import_dirs_;
   set<string> import_files_;
   vector<string> preprocessed_files_;
@@ -167,9 +186,11 @@
   int version_ = 0;
   string hash_ = "";
   bool gen_log_ = false;
-  bool gen_parcelable_to_string_ = false;
   ErrorMessage error_message_;
+  WarningOptions warning_options_;
 };
 
+std::string to_string(Options::Language language);
+
 }  // namespace aidl
 }  // namespace android
diff --git a/options_unittest.cpp b/options_unittest.cpp
index b51335b..9f07400 100644
--- a/options_unittest.cpp
+++ b/options_unittest.cpp
@@ -21,13 +21,20 @@
 #include <string>
 #include <vector>
 
+#include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
+#include "diagnostics.h"
+
+using android::aidl::DiagnosticID;
+using android::aidl::DiagnosticSeverity;
 using std::cerr;
 using std::endl;
 using std::string;
 using std::unique_ptr;
 using std::vector;
+using testing::internal::CaptureStderr;
+using testing::internal::GetCapturedStderr;
 
 namespace android {
 namespace aidl {
@@ -135,23 +142,6 @@
   EXPECT_EQ(string{kCompileCommandJavaOutput}, options->OutputFile());
   EXPECT_EQ(false, options->AutoDepFile());
   EXPECT_EQ(false, options->DependencyFileNinja());
-  EXPECT_EQ(false, options->GenParcelableToString());
-
-  const char* argv[] = {
-      "aidl",  "-b", kCompileCommandIncludePath, kCompileCommandInput, "--parcelable-to-string",
-      nullptr,
-  };
-  options = GetOptions(argv);
-  EXPECT_EQ(Options::Task::COMPILE, options->GetTask());
-  EXPECT_EQ(Options::Language::JAVA, options->TargetLanguage());
-  EXPECT_EQ(true, options->FailOnParcelable());
-  EXPECT_EQ(1u, options->ImportDirs().size());
-  EXPECT_EQ(0u, options->PreprocessedFiles().size());
-  EXPECT_EQ(string{kCompileCommandInput}, options->InputFiles().front());
-  EXPECT_EQ(string{kCompileCommandJavaOutput}, options->OutputFile());
-  EXPECT_EQ(false, options->AutoDepFile());
-  EXPECT_EQ(false, options->DependencyFileNinja());
-  EXPECT_EQ(true, options->GenParcelableToString());
 }
 
 TEST(OptionsTests, ParsesCompileJavaNinja) {
@@ -176,27 +166,6 @@
   EXPECT_EQ(kCompileCommandInput, options->InputFiles().front());
   EXPECT_EQ(kCompileCommandHeaderDir, options->OutputHeaderDir());
   EXPECT_EQ(kCompileCommandCppOutput, options->OutputFile());
-  EXPECT_EQ(false, options->GenParcelableToString());
-
-  const char* argv[] = {
-      "aidl-cpp",
-      kCompileCommandIncludePath,
-      kCompileDepFile,
-      kCompileCommandInput,
-      kCompileCommandHeaderDir,
-      kCompileCommandCppOutput,
-      "--parcelable-to-string",
-      nullptr,
-  };
-  options = GetOptions(argv, Options::Language::CPP);
-  ASSERT_EQ(1u, options->ImportDirs().size());
-  EXPECT_EQ(string{kCompileCommandIncludePath}.substr(2), *options->ImportDirs().begin());
-  EXPECT_EQ(string{kCompileDepFile}.substr(2), options->DependencyFile());
-  EXPECT_EQ(false, options->DependencyFileNinja());
-  EXPECT_EQ(kCompileCommandInput, options->InputFiles().front());
-  EXPECT_EQ(kCompileCommandHeaderDir, options->OutputHeaderDir());
-  EXPECT_EQ(kCompileCommandCppOutput, options->OutputFile());
-  EXPECT_EQ(true, options->GenParcelableToString());
 }
 
 TEST(OptionsTests, ParsesCompileCppNinja) {
@@ -254,11 +223,12 @@
   EXPECT_EQ(string{"src_out/"}, options->OutputDir());
   EXPECT_EQ(false, options->AutoDepFile());
   EXPECT_EQ(false, options->DependencyFileNinja());
-  EXPECT_EQ(false, options->GenParcelableToString());
 }
 
-TEST(OptionsTests, ParsesCompileJavaInvalid) {
+TEST(OptionsTests, ParsesCompileJavaInvalid_OutRequired) {
   // -o option is required
+  string expected_error = "Output directory is not set. Set with --out.";
+  CaptureStderr();
   const char* arg_with_no_out_dir[] = {
       "aidl",
       "--lang=java",
@@ -269,7 +239,12 @@
       nullptr,
   };
   EXPECT_EQ(false, GetOptions(arg_with_no_out_dir)->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
+}
 
+TEST(OptionsTests, ParsesCompileJavaInvalid_RejectHeaderOut) {
+  string expected_error = "Header output directory is set, which does not make sense for Java.";
+  CaptureStderr();
   // -h options is not for Java
   const char* arg_with_header_dir[] = {
       "aidl",          "--lang=java",           kCompileCommandIncludePath, "-o src_out",
@@ -277,6 +252,7 @@
       nullptr,
   };
   EXPECT_EQ(false, GetOptions(arg_with_header_dir)->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
 }
 
 TEST(OptionsTests, ParsesCompileCppMultiInput) {
@@ -307,8 +283,10 @@
   EXPECT_EQ(string{"src_out/"}, options->OutputDir());
 }
 
-TEST(OptionsTests, ParsesCompileCppInvalid) {
+TEST(OptionsTests, ParsesCompileCppInvalid_OutRequired) {
   // -o option is required
+  string expected_error = "Output directory is not set. Set with --out.";
+  CaptureStderr();
   const char* arg_with_no_out_dir[] = {
       "aidl",
       "--lang=cpp",
@@ -319,8 +297,13 @@
       nullptr,
   };
   EXPECT_EQ(false, GetOptions(arg_with_no_out_dir)->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
+}
 
+TEST(OptionsTests, ParsesCompileCppInvalid_HeaderOutRequired) {
   // -h options is required as well
+  string expected_error = "Header output directory is not set. Set with --header_out";
+  CaptureStderr();
   const char* arg_with_no_header_dir[] = {
       "aidl",
       "--lang=cpp",
@@ -332,10 +315,13 @@
       nullptr,
   };
   EXPECT_EQ(false, GetOptions(arg_with_no_header_dir)->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
 }
 
-TEST(OptionsTests, ParsesCompileRustInvalid) {
+TEST(OptionsTests, ParsesCompileRustInvalid_OutRequired) {
   // -o option is required
+  string expected_error = "Output directory is not set. Set with --out";
+  CaptureStderr();
   const char* arg_with_no_out_dir[] = {
       "aidl",
       "--lang=rust",
@@ -346,7 +332,12 @@
       nullptr,
   };
   EXPECT_EQ(false, GetOptions(arg_with_no_out_dir)->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
+}
 
+TEST(OptionsTests, ParsesCompileRustInvalid_RejectHeaderOut) {
+  string expected_error = "Header output directory is set, which does not make sense for Rust.";
+  CaptureStderr();
   // -h options is not for Rust
   const char* arg_with_header_dir[] = {
       "aidl",          "--lang=rust",           kCompileCommandIncludePath, "-o src_out",
@@ -354,6 +345,104 @@
       nullptr,
   };
   EXPECT_EQ(false, GetOptions(arg_with_header_dir)->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
+}
+
+TEST(OptionsTests, ParsesWarningEnableAll) {
+  const char* args[] = {
+      "aidl", "--lang=java", "-Weverything", "--out=out", "input.aidl", nullptr,
+  };
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  auto mapping = options->GetDiagnosticMapping();
+  EXPECT_EQ(DiagnosticSeverity::WARNING, mapping.Severity(DiagnosticID::interface_name));
+}
+
+TEST(OptionsTests, ParsesWarningEnableSpecificWarning) {
+  const char* args[] = {
+      "aidl", "--lang=java", "-Winterface-name", "--out=out", "input.aidl", nullptr,
+  };
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  auto mapping = options->GetDiagnosticMapping();
+  EXPECT_EQ(DiagnosticSeverity::WARNING, mapping.Severity(DiagnosticID::interface_name));
+}
+
+TEST(OptionsTests, ParsesWarningDisableSpecificWarning) {
+  const char* args[] = {
+      "aidl",      "--lang=java", "-Weverything", "-Wno-interface-name",
+      "--out=out", "input.aidl",  nullptr,
+  };
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  auto mapping = options->GetDiagnosticMapping();
+  EXPECT_EQ(DiagnosticSeverity::DISABLED, mapping.Severity(DiagnosticID::interface_name));
+}
+
+TEST(OptionsTests, ParsesWarningAsErrors) {
+  const char* args[] = {
+      "aidl", "--lang=java", "-Werror", "-Weverything", "--out=out", "input.aidl", nullptr,
+  };
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  auto mapping = options->GetDiagnosticMapping();
+  EXPECT_EQ(DiagnosticSeverity::ERROR, mapping.Severity(DiagnosticID::interface_name));
+}
+
+TEST(OptionsTests, RejectsUnknownWarning) {
+  const char* args[] = {
+      "aidl", "--lang=java", "-Wfoobar", "--out=out", "input.aidl", nullptr,
+  };
+  CaptureStderr();
+  auto options = GetOptions(args);
+  EXPECT_FALSE(options->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr("unknown warning: foobar"));
+}
+
+TEST(OptionsTests, CheckApi) {
+  const char* args[] = {
+      "aidl", "--checkapi", "old", "new", nullptr,
+  };
+  CaptureStderr();
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  EXPECT_EQ("", GetCapturedStderr());
+  EXPECT_EQ(Options::Task::CHECK_API, options->GetTask());
+  EXPECT_EQ(Options::CheckApiLevel::COMPATIBLE, options->GetCheckApiLevel());
+}
+
+TEST(OptionsTests, CheckApiWithCompatible) {
+  const char* args[] = {
+      "aidl", "--checkapi=compatible", "old", "new", nullptr,
+  };
+  CaptureStderr();
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  EXPECT_EQ("", GetCapturedStderr());
+  EXPECT_EQ(Options::Task::CHECK_API, options->GetTask());
+  EXPECT_EQ(Options::CheckApiLevel::COMPATIBLE, options->GetCheckApiLevel());
+}
+
+TEST(OptionsTests, CheckApiWithEqual) {
+  const char* args[] = {
+      "aidl", "--checkapi=equal", "old", "new", nullptr,
+  };
+  CaptureStderr();
+  auto options = GetOptions(args);
+  EXPECT_TRUE(options->Ok());
+  EXPECT_EQ("", GetCapturedStderr());
+  EXPECT_EQ(Options::Task::CHECK_API, options->GetTask());
+  EXPECT_EQ(Options::CheckApiLevel::EQUAL, options->GetCheckApiLevel());
+}
+
+TEST(OptionsTests, CheckApiWithUnknown) {
+  const char* args[] = {
+      "aidl", "--checkapi=unknown", "old", "new", nullptr,
+  };
+  CaptureStderr();
+  auto options = GetOptions(args);
+  EXPECT_FALSE(options->Ok());
+  EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr("Unsupported --checkapi level: 'unknown'"));
 }
 
 }  // namespace aidl
diff --git a/parser.cpp b/parser.cpp
index f2b9c55..721979f 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -48,15 +48,107 @@
   return parser;
 }
 
-bool Parser::Resolve() {
+void Parser::SetTypeParameters(AidlTypeSpecifier* type,
+                               std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args) {
+  if (type->IsArray()) {
+    AIDL_ERROR(type) << "Must specify type parameters (<>) before array ([]).";
+    AddError();
+  }
+  if (!type->SetTypeParameters(type_args)) {
+    AIDL_ERROR(type) << "Can only specify one set of type parameters.";
+    AddError();
+    delete type_args;
+  }
+}
+
+class ConstantReferenceResolver : public AidlVisitor {
+ public:
+  ConstantReferenceResolver(const AidlDefinedType* scope, const AidlTypenames& typenames,
+                            TypeResolver& resolver, bool* success)
+      : scope_(scope), typenames_(typenames), resolver_(resolver), success_(success) {}
+  void Visit(const AidlConstantReference& v) override {
+    if (IsCircularReference(&v)) {
+      *success_ = false;
+      return;
+    }
+
+    if (v.GetRefType() && !v.GetRefType()->IsResolved()) {
+      if (!resolver_(typenames_.GetDocumentFor(scope_), v.GetRefType().get())) {
+        AIDL_ERROR(v.GetRefType()) << "Unknown type '" << v.GetRefType()->GetName() << "'";
+        *success_ = false;
+        return;
+      }
+    }
+    const AidlConstantValue* resolved = v.Resolve(scope_);
+    if (!resolved) {
+      AIDL_ERROR(v) << "Unknown reference '" << v.Literal() << "'";
+      *success_ = false;
+      return;
+    }
+
+    // resolve recursive references
+    Push(&v);
+    VisitTopDown(*this, *resolved);
+    Pop();
+  }
+
+ private:
+  struct StackElem {
+    const AidlDefinedType* scope;
+    const AidlConstantReference* ref;
+  };
+
+  void Push(const AidlConstantReference* ref) {
+    stack_.push_back({scope_, ref});
+    if (ref->GetRefType()) {
+      scope_ = ref->GetRefType()->GetDefinedType();
+    }
+  }
+
+  void Pop() {
+    scope_ = stack_.back().scope;
+    stack_.pop_back();
+  }
+
+  bool IsCircularReference(const AidlConstantReference* ref) {
+    auto it = std::find_if(stack_.begin(), stack_.end(),
+                           [&](const auto& elem) { return elem.ref == ref; });
+    if (it == stack_.end()) {
+      return false;
+    }
+    std::vector<std::string> path;
+    while (it != stack_.end()) {
+      path.push_back(it->ref->Literal());
+      ++it;
+    }
+    path.push_back(ref->Literal());
+    AIDL_ERROR(ref) << "Found a circular reference: " << android::base::Join(path, " -> ");
+    return true;
+  }
+
+  const AidlDefinedType* scope_;
+  const AidlTypenames& typenames_;
+  TypeResolver& resolver_;
+  bool* success_;
+  std::vector<StackElem> stack_ = {};
+};
+
+bool Parser::Resolve(TypeResolver& type_resolver) {
   bool success = true;
   for (AidlTypeSpecifier* typespec : unresolved_typespecs_) {
-    if (!typespec->Resolve(typenames_)) {
+    if (!type_resolver(document_, typespec)) {
       AIDL_ERROR(typespec) << "Failed to resolve '" << typespec->GetUnresolvedName() << "'";
       success = false;
       // don't stop to show more errors if any
     }
   }
+
+  // resolve "field references" as well.
+  for (const auto& type : document_->DefinedTypes()) {
+    ConstantReferenceResolver ref_resolver{type.get(), typenames_, type_resolver, &success};
+    VisitTopDown(ref_resolver, *type);
+  }
+
   return success;
 }
 
diff --git a/parser.h b/parser.h
index 0d39342..e2dea08 100644
--- a/parser.h
+++ b/parser.h
@@ -18,6 +18,7 @@
 
 #include "aidl_language.h"
 #include "aidl_typenames.h"
+#include "comments.h"
 #include "io_delegate.h"
 #include "logging.h"
 #include "options.h"
@@ -31,8 +32,8 @@
 
 class AidlToken {
  public:
-  AidlToken(const std::string& text, const std::string& comments)
-      : text_(text), comments_(comments) {}
+  AidlToken(const std::string& text, android::aidl::Comments comments)
+      : text_(text), comments_(std::move(comments)) {}
   ~AidlToken() = default;
 
   AidlToken(const AidlToken&) = delete;
@@ -41,13 +42,20 @@
   AidlToken& operator=(AidlToken&&) = delete;
 
   const std::string& GetText() const { return text_; }
-  const std::string& GetComments() const { return comments_; }
+  const android::aidl::Comments& GetComments() const { return comments_; }
+
+  template <typename T>
+  void Append(T&& text) {
+    text_ += std::forward<T>(text);
+  }
 
  private:
   std::string text_;
-  std::string comments_;
+  android::aidl::Comments comments_;
 };
 
+using TypeResolver = std::function<bool(const AidlDocument*, AidlTypeSpecifier*)>;
+
 class Parser {
  public:
   // non-copyable, non-assignable
@@ -67,6 +75,15 @@
   const std::string& FileName() const { return filename_; }
   void* Scanner() const { return scanner_; }
 
+  // This restricts the grammar to something more reasonable. One alternative
+  // would be to support multiple sets of type specifiers in our AST, but then a
+  // lot of later code would have to deal with this more complicated type. So,
+  // in order to keep the AST simpler, restricting the grammar here.
+  //
+  // Takes ownership of type_args, modifies type.
+  void SetTypeParameters(AidlTypeSpecifier* type,
+                         std::vector<std::unique_ptr<AidlTypeSpecifier>>* type_args);
+
   void SetPackage(const std::string& package) { package_ = package; }
   const std::string& Package() const { return package_; }
 
@@ -76,7 +93,7 @@
 
   const vector<AidlTypeSpecifier*>& GetUnresolvedTypespecs() const { return unresolved_typespecs_; }
 
-  bool Resolve();
+  bool Resolve(TypeResolver& type_resolver);
   void SetDocument(std::unique_ptr<AidlDocument>&& document) {
     // The parsed document is owned by typenames_. This parser object only has
     // a reference to it.
diff --git a/run_integration_tests.sh b/run_integration_tests.sh
index 618a86e..f1896a1 100755
--- a/run_integration_tests.sh
+++ b/run_integration_tests.sh
@@ -28,6 +28,6 @@
 adb wait-for-device
 adb sync data
 adb install -r \
-    ${ANDROID_PRODUCT_OUT}/testcases/aidl_test_services/x86/aidl_test_services.apk
+    ${ANDROID_PRODUCT_OUT}/testcases/aidl_test_java/x86/aidl_test_java.apk
 
 ${ANDROID_BUILD_TOP}/system/tools/aidl/tests/aidl_integration_test.py
diff --git a/tests/aidl_integration_test.py b/tests/aidl_integration_test.py
index a6b53d7..97eb9f0 100755
--- a/tests/aidl_integration_test.py
+++ b/tests/aidl_integration_test.py
@@ -8,11 +8,14 @@
 BITNESS_32 = ("", "32")
 BITNESS_64 = ("64", "64")
 
+APP_PROCESS_FOR_PRETTY_BITNESS = 'app_process%s'
 NATIVE_TEST_CLIENT_FOR_BITNESS = ' /data/nativetest%s/aidl_test_client/aidl_test_client%s'
 NATIVE_TEST_SERVICE_FOR_BITNESS = ' /data/nativetest%s/aidl_test_service/aidl_test_service%s'
+RUST_TEST_CLIENT_FOR_BITNESS = ' /data/nativetest%s/aidl_test_rust_client/aidl_test_rust_client%s'
+RUST_TEST_SERVICE_FOR_BITNESS = ' /data/nativetest%s/aidl_test_rust_service/aidl_test_rust_service%s'
 
-# From tools/base/ddmlib/src/main/java/com/android/ddmlib/testrunner/InstrumentationResultParser.java
-INSTRUMENTATION_FAILURES_PATTERN = r'There (was|were) \d+ failure'
+# From AidlTestsJava.java
+INSTRUMENTATION_SUCCESS_PATTERN = r'TEST SUCCESS\n$'
 
 class TestFail(Exception):
     """Raised on test failures."""
@@ -117,25 +120,46 @@
             raise TestFail(result.stdout)
 
 class JavaClient:
-    def __init__(self, host, native_bitness):
-        self.name = "java_client"
+    def __init__(self, host, bitness):
+        self.name = "java_client_%s" % pretty_bitness(bitness)
         self.host = host
-        self.native_bitness = native_bitness
+        self.bitness = bitness
     def cleanup(self):
-        host.run('setenforce 1')
-        self.host.run('killall android.aidl.tests', ignore_status=True)
+        self.host.run('killall app_process', ignore_status=True)
     def run(self):
-        host.run('setenforce 0') # Java app needs selinux off
-        result = self.host.run('am instrument -w --no-hidden-api-checks '
-                               'android.aidl.tests/'
-                               'androidx.test.runner.AndroidJUnitRunner')
+        result = self.host.run('CLASSPATH=/data/framework/aidl_test_java.jar '
+                               + APP_PROCESS_FOR_PRETTY_BITNESS % pretty_bitness(self.bitness) +
+                               ' /data/framework android.aidl.tests.AidlJavaTests')
         print(result.printable_string())
-        if re.search(INSTRUMENTATION_FAILURES_PATTERN, result.stdout) is not None:
+        if re.search(INSTRUMENTATION_SUCCESS_PATTERN, result.stdout) is None:
             raise TestFail(result.stdout)
 
 def getprop(host, prop):
     return host.run('getprop "%s"' % prop).stdout.strip()
 
+class RustClient:
+    def __init__(self, host, bitness):
+        self.name = "%s_bit_rust_client" % pretty_bitness(bitness)
+        self.host = host
+        self.binary = RUST_TEST_CLIENT_FOR_BITNESS % bitness
+    def cleanup(self):
+        self.host.run('killall %s' % self.binary, ignore_status=True)
+    def run(self):
+        result = self.host.run(self.binary, ignore_status=True)
+        print(result.printable_string())
+        if result.exit_status:
+            raise TestFail(result.stdout)
+
+class RustServer:
+    def __init__(self, host, bitness):
+        self.name = "%s_bit_rust_server" % pretty_bitness(bitness)
+        self.host = host
+        self.binary = RUST_TEST_SERVICE_FOR_BITNESS % bitness
+    def cleanup(self):
+        self.host.run('killall %s' % self.binary, ignore_status=True)
+    def run(self):
+        return self.host.run(self.binary, background=True)
+
 def supported_bitnesses(host):
     bitnesses = []
     if getprop(host, "ro.product.cpu.abilist32") != "":
@@ -174,9 +198,14 @@
         clients += [NativeClient(host, bitness)]
         servers += [NativeServer(host, bitness)]
 
-    # Java only supports one bitness, but needs to run a native binary
-    # to process its results
-    clients += [JavaClient(host, bitnesses[-1])]
+
+    for bitness in bitnesses:
+        clients += [JavaClient(host, bitness)]
+        # TODO(b/169704480): Java server
+
+    for bitness in bitnesses:
+        clients += [RustClient(host, bitness)]
+        servers += [RustServer(host, bitness)]
 
     for client in clients:
         for server in servers:
diff --git a/tests/aidl_integration_test.xml b/tests/aidl_integration_test.xml
index 0224310..d66c02c 100644
--- a/tests/aidl_integration_test.xml
+++ b/tests/aidl_integration_test.xml
@@ -29,13 +29,15 @@
       <option name="push" value="aidl_test_service32->/data/nativetest/aidl_test_service/aidl_test_service32" />
       <option name="push" value="aidl_test_service64->/data/nativetest64/aidl_test_service/aidl_test_service64" />
 
-      <option name="cleanup" value="true" />
-    </target_preparer>
+      <option name="push" value="aidl_test_rust_client32->/data/nativetest/aidl_test_rust_client/aidl_test_rust_client32" />
+      <option name="push" value="aidl_test_rust_client64->/data/nativetest64/aidl_test_rust_client/aidl_test_rust_client64" />
 
-    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
-        <option name="force-install-mode" value="FULL"/>
-        <option name="cleanup-apks" value="true" />
-        <option name="test-file-name" value="aidl_test_services.apk" />
+      <option name="push" value="aidl_test_rust_service32->/data/nativetest/aidl_test_rust_service/aidl_test_rust_service32" />
+      <option name="push" value="aidl_test_rust_service64->/data/nativetest64/aidl_test_rust_service/aidl_test_rust_service64" />
+
+      <option name="push" value="aidl_test_java.jar->/data/framework/aidl_test_java.jar" />
+
+      <option name="cleanup" value="true" />
     </target_preparer>
 
     <test class="com.android.tradefed.testtype.python.PythonBinaryHostTest" >
diff --git a/tests/aidl_parser_fuzzer.dict b/tests/aidl_parser_fuzzer.dict
index 3db1ef4..055f4f7 100644
--- a/tests/aidl_parser_fuzzer.dict
+++ b/tests/aidl_parser_fuzzer.dict
@@ -12,6 +12,7 @@
 " interface "
 " oneway "
 " enum "
+" union "
 
 # types
 " void "
@@ -24,25 +25,40 @@
 " double "
 " String "
 " List "
+" List< "
 " Map "
+" Map< "
 " IBinder "
 " FileDescriptor "
 " CharSequence "
 " ParcelFileDescriptor "
 " java.util.List "
+" java.util.List< "
 " java.util.Map "
+" java.util.Map< "
 " android.os.ParcelFileDescriptor "
 " ParcelableHolder "
+" > "
 
 # annotations
 " @nullable "
 " @utf8InCpp "
 " @VintfStability "
+" @SensitiveData "
 " @UnsupportedAppUsage "
 " @SystemApi "
+" @JavaPassthrough "
 " @JavaOnlyStableParcelable "
+" @Hide "
 " @Backing "
+" @FixedSize "
+" @Descriptor "
+" @JavaDervie "
 " @RustDerive "
+
+# annotation arguments
+" value "
+" toString "
 " expectedSignature "
 " implicitMember "
 " maxTargetSdk "
diff --git a/tests/aidl_test_client.h b/tests/aidl_test_client.h
index b0d1411..96e93b0 100644
--- a/tests/aidl_test_client.h
+++ b/tests/aidl_test_client.h
@@ -16,12 +16,14 @@
 
 #pragma once
 
+#include <android/aidl/tests/ICppJavaTests.h>
 #include <android/aidl/tests/ITestService.h>
 #include <binder/IServiceManager.h>
 #include <gtest/gtest.h>
 #include <utils/String16.h>
 
 using android::sp;
+using android::aidl::tests::ICppJavaTests;
 using android::aidl::tests::ITestService;
 
 class AidlTest : public testing::Test {
@@ -33,7 +35,13 @@
 
     ASSERT_EQ(OK, getService(ITestService::descriptor, &service));
     ASSERT_NE(nullptr, service);
+
+    sp<android::IBinder> ibinder;
+    auto status = service->GetCppJavaTests(&ibinder);
+    ASSERT_TRUE(status.isOk());
+    cpp_java_tests = android::interface_cast<ICppJavaTests>(ibinder);
   }
 
   sp<ITestService> service;
+  sp<ICppJavaTests> cpp_java_tests;
 };
diff --git a/tests/aidl_test_client_file_descriptors.cpp b/tests/aidl_test_client_file_descriptors.cpp
index d143905..2d0f7e6 100644
--- a/tests/aidl_test_client_file_descriptors.cpp
+++ b/tests/aidl_test_client_file_descriptors.cpp
@@ -63,12 +63,14 @@
 };
 
 TEST_F(FdTest, fileDescriptor) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   unique_fd read_fd;
   unique_fd write_fd;
   DoPipe(&read_fd, &write_fd);
 
   unique_fd return_fd;
-  auto status = service->RepeatFileDescriptor(std::move(write_fd), &return_fd);
+  auto status = cpp_java_tests->RepeatFileDescriptor(std::move(write_fd), &return_fd);
   ASSERT_TRUE(status.isOk());
 
   /* A note on some of the spookier stuff going on here: IIUC writes to pipes
@@ -80,13 +82,15 @@
 }
 
 TEST_F(FdTest, fileDescriptorArray) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   std::vector<unique_fd> array;
   array.resize(2);
   DoPipe(&array[0], &array[1]);
 
   std::vector<unique_fd> repeated;
   std::vector<unique_fd> reversed;
-  auto status = service->ReverseFileDescriptorArray(array, &repeated, &reversed);
+  auto status = cpp_java_tests->ReverseFileDescriptorArray(array, &repeated, &reversed);
   ASSERT_TRUE(status.isOk());
 
   WriteStringToFd("First", array[1]);
diff --git a/tests/aidl_test_client_loggable_interface.cpp b/tests/aidl_test_client_loggable_interface.cpp
new file mode 100644
index 0000000..6a6146f
--- /dev/null
+++ b/tests/aidl_test_client_loggable_interface.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android/aidl/loggable/ILoggableInterface.h>
+
+#include "aidl_test_client.h"
+
+#include <android/aidl/loggable/BpLoggableInterface.h>
+#include <android/aidl/tests/BackendType.h>
+#include <binder/IServiceManager.h>
+#include <binder/ParcelFileDescriptor.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <utils/String16.h>
+
+using android::IBinder;
+using android::sp;
+using android::String16;
+using android::aidl::loggable::BpLoggableInterface;
+using android::aidl::loggable::Data;
+using android::aidl::loggable::Enum;
+using android::aidl::loggable::ILoggableInterface;
+using android::aidl::loggable::Union;
+using android::aidl::tests::BackendType;
+using android::os::ParcelFileDescriptor;
+using std::optional;
+using std::pair;
+using std::string;
+using std::vector;
+using testing::Eq;
+
+TEST_F(AidlTest, LoggableInterface) {
+  BackendType backendType;
+  auto status = service->getBackendType(&backendType);
+  EXPECT_TRUE(status.isOk());
+  if (backendType != BackendType::CPP) GTEST_SKIP();
+
+  sp<ILoggableInterface> loggable;
+  EXPECT_EQ(android::OK, android::getService(ILoggableInterface::descriptor, &loggable));
+  ASSERT_NE(nullptr, loggable);
+
+  BpLoggableInterface::TransactionLog log;
+  BpLoggableInterface::logFunc = [&](const BpLoggableInterface::TransactionLog& tx) { log = tx; };
+
+  bool boolValue = true;
+  vector<bool> boolArray{false, true};
+  int8_t byteValue = 41;
+  vector<uint8_t> byteArray{42, 43};
+  char16_t charValue = 'x';
+  vector<char16_t> charArray{'a', 'b', 'c'};
+  int32_t intValue{44};
+  vector<int32_t> intArray{45, 46};
+  int64_t longValue = 47;
+  vector<int64_t> longArray{48, 49};
+  float floatValue{50};
+  vector<float> floatArray{51, 52};
+  double doubleValue{52};
+  vector<double> doubleArray{53, 54};
+  String16 stringValue("def");
+  vector<String16> stringArray{String16("ghi"), String16("jkl")};
+  vector<String16> listValue{String16("mno")};
+  Data dataValue;
+  dataValue.num = 42;
+  dataValue.str = "abc";
+  dataValue.nestedUnion = "def";
+  dataValue.nestedEnum = Enum::FOO;
+  sp<IBinder> binderValue;
+  optional<ParcelFileDescriptor> pfdValue;
+  vector<ParcelFileDescriptor> pfdArray;
+  vector<String16> _aidl_return;
+
+  status = loggable->LogThis(boolValue, &boolArray, byteValue, &byteArray, charValue, &charArray,
+                             intValue, &intArray, longValue, &longArray, floatValue, &floatArray,
+                             doubleValue, &doubleArray, stringValue, &stringArray, &listValue,
+                             dataValue, binderValue, &pfdValue, &pfdArray, &_aidl_return);
+  EXPECT_TRUE(status.isOk());
+  EXPECT_EQ(vector<String16>{String16("loggable")}, _aidl_return);
+
+  // check the captured log
+  EXPECT_EQ("[loggable]", log.result);
+  EXPECT_EQ("android.aidl.loggable.ILoggableInterface", log.interface_name);
+  EXPECT_EQ("LogThis", log.method_name);
+  EXPECT_EQ(0, log.exception_code);
+  EXPECT_EQ("", log.exception_message);
+  EXPECT_EQ(0, log.transaction_error);
+  EXPECT_EQ(0, log.service_specific_error_code);
+  EXPECT_THAT(
+      log.input_args,
+      Eq(vector<pair<string, string>>{
+          {"boolValue", "true"},
+          {"boolArray", "[false, true]"},
+          {"byteValue", "41"},
+          {"byteArray", "[42, 43]"},
+          {"charValue", "x"},
+          {"charArray", "[a, b, c]"},
+          {"intValue", "44"},
+          {"intArray", "[45, 46]"},
+          {"longValue", "47"},
+          {"longArray", "[48, 49]"},
+          {"floatValue", "50.000000"},
+          {"floatArray", "[51.000000, 52.000000]"},
+          {"doubleValue", "52.000000"},
+          {"doubleArray", "[53.000000, 54.000000]"},
+          {"stringValue", "def"},
+          {"stringArray", "[ghi, jkl]"},
+          {"listValue", "[mno]"},
+          {"dataValue", "Data{num: 42, str: abc, nestedUnion: Union{str: def}, nestedEnum: FOO}"},
+          {"binderValue", ""},
+          {"pfdValue", ""},
+          {"pfdArray", ""},
+      }));
+  EXPECT_THAT(log.output_args,
+              Eq(vector<pair<string, string>>{{"boolArray", "[false, true]"},
+                                              {"byteArray", "[42, 43]"},
+                                              {"charArray", "[a, b, c]"},
+                                              {"intArray", "[45, 46]"},
+                                              {"longArray", "[48, 49]"},
+                                              {"floatArray", "[51.000000, 52.000000]"},
+                                              {"doubleArray", "[53.000000, 54.000000]"},
+                                              {"stringArray", "[ghi, jkl]"},
+                                              {"listValue", "[mno]"},
+                                              {"pfdValue", ""},
+                                              {"pfdArray", ""}}));
+}
diff --git a/tests/aidl_test_client_nullables.cpp b/tests/aidl_test_client_nullables.cpp
index 905e247..8a6b4d3 100644
--- a/tests/aidl_test_client_nullables.cpp
+++ b/tests/aidl_test_client_nullables.cpp
@@ -36,6 +36,7 @@
 using android::aidl::tests::ITestService;
 using android::aidl::tests::LongEnum;
 using android::aidl::tests::SimpleParcelable;
+using android::aidl::tests::StructuredParcelable;
 
 using testing::Eq;
 using testing::Ne;
@@ -93,8 +94,19 @@
 }
 
 TEST_F(RepeatNullableTest, parcelable) {
-  DoTest(&ITestService::RepeatNullableParcelable,
-         std::make_optional<SimpleParcelable>("Booya", 42));
+  auto input = std::make_optional<StructuredParcelable>();
+  input->f = 42;
+
+  std::optional<StructuredParcelable> output;
+  auto status = service->RepeatNullableParcelable(input, &output);
+  ASSERT_TRUE(status.isOk());
+  ASSERT_TRUE(output.has_value());
+  ASSERT_THAT(*output, Eq(*input));
+
+  input.reset();
+  status = service->RepeatNullableParcelable(input, &output);
+  ASSERT_TRUE(status.isOk());
+  ASSERT_FALSE(output.has_value());
 }
 
 TEST_F(AidlTest, nullBinder) {
@@ -103,8 +115,10 @@
 }
 
 TEST_F(AidlTest, binderListWithNull) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   std::vector<sp<IBinder>> input{new BBinder(), nullptr};
-  auto status = service->TakesAnIBinderList(input);
+  auto status = cpp_java_tests->TakesAnIBinderList(input);
   ASSERT_THAT(status.exceptionCode(), Eq(android::binder::Status::EX_NULL_POINTER));
 }
 
@@ -115,8 +129,10 @@
 }
 
 TEST_F(AidlTest, binderListWithoutNull) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   std::vector<sp<IBinder>> input{new BBinder(), new BBinder()};
-  auto status = service->TakesAnIBinderList(input);
+  auto status = cpp_java_tests->TakesAnIBinderList(input);
   ASSERT_TRUE(status.isOk());
 }
 
@@ -126,8 +142,10 @@
 }
 
 TEST_F(AidlTest, binderListWithNullToAnnotatedMethod) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   std::vector<sp<IBinder>> input{new BBinder(), nullptr};
-  auto status = service->TakesANullableIBinderList(input);
+  auto status = cpp_java_tests->TakesANullableIBinderList(input);
   ASSERT_TRUE(status.isOk());
 }
 
@@ -138,8 +156,10 @@
 }
 
 TEST_F(AidlTest, binderListWithoutNullToAnnotatedMethod) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   std::vector<sp<IBinder>> input{new BBinder(), new BBinder()};
-  auto status = service->TakesANullableIBinderList(input);
+  auto status = cpp_java_tests->TakesANullableIBinderList(input);
   ASSERT_TRUE(status.isOk());
 }
 
diff --git a/tests/aidl_test_client_parcelables.cpp b/tests/aidl_test_client_parcelables.cpp
index aa56676..eb77ccc 100644
--- a/tests/aidl_test_client_parcelables.cpp
+++ b/tests/aidl_test_client_parcelables.cpp
@@ -14,11 +14,14 @@
  * limitations under the License.
  */
 
+#include <android/aidl/tests/ParcelableForToString.h>
 #include <android/aidl/tests/extension/MyExt.h>
 #include <android/aidl/tests/extension/MyExt2.h>
 #include <android/aidl/tests/extension/MyExtLike.h>
+#include <android/aidl/tests/unions/EnumUnion.h>
 #include "aidl_test_client.h"
 
+#include <string>
 #include <vector>
 
 using android::IInterface;
@@ -29,42 +32,53 @@
 using android::aidl::tests::INamedCallback;
 using android::aidl::tests::IntEnum;
 using android::aidl::tests::ITestService;
+using android::aidl::tests::OtherParcelableForToString;
+using android::aidl::tests::ParcelableForToString;
 using android::aidl::tests::SimpleParcelable;
 using android::aidl::tests::StructuredParcelable;
+using android::aidl::tests::Union;
 using android::aidl::tests::extension::ExtendableParcelable;
 using android::aidl::tests::extension::MyExt;
 using android::aidl::tests::extension::MyExt2;
 using android::aidl::tests::extension::MyExtLike;
+using android::aidl::tests::unions::EnumUnion;
 using android::binder::Status;
 using android::os::PersistableBundle;
+using std::string;
 using std::vector;
 
 TEST_F(AidlTest, RepeatSimpleParcelable) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   SimpleParcelable input("Booya", 42);
   SimpleParcelable out_param, returned;
-  Status status = service->RepeatSimpleParcelable(input, &out_param, &returned);
+  Status status = cpp_java_tests->RepeatSimpleParcelable(input, &out_param, &returned);
   ASSERT_TRUE(status.isOk()) << status.toString8();
   EXPECT_EQ(input, out_param);
   EXPECT_EQ(input, returned);
 }
 
 TEST_F(AidlTest, RepeatGenericStructureParcelable) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum> input, out_param, returned;
   input.a = 41;
   input.b = 42;
-  Status status = service->RepeatGenericParcelable(input, &out_param, &returned);
+  Status status = cpp_java_tests->RepeatGenericParcelable(input, &out_param, &returned);
   ASSERT_TRUE(status.isOk()) << status.toString8();
   EXPECT_EQ(input, out_param);
   EXPECT_EQ(input, returned);
 }
 
 TEST_F(AidlTest, ReverseSimpleParcelable) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   const vector<SimpleParcelable> original{SimpleParcelable("first", 0),
                                           SimpleParcelable("second", 1),
                                           SimpleParcelable("third", 2)};
   vector<SimpleParcelable> repeated;
   vector<SimpleParcelable> reversed;
-  Status status = service->ReverseSimpleParcelables(original, &repeated, &reversed);
+  Status status = cpp_java_tests->ReverseSimpleParcelables(original, &repeated, &reversed);
   ASSERT_TRUE(status.isOk()) << status.toString8();
 
   EXPECT_EQ(repeated, original);
@@ -73,13 +87,17 @@
 }
 
 TEST_F(AidlTest, ConfirmPersistableBundles) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   PersistableBundle empty_bundle, returned;
-  Status status = service->RepeatPersistableBundle(empty_bundle, &returned);
+  Status status = cpp_java_tests->RepeatPersistableBundle(empty_bundle, &returned);
   ASSERT_TRUE(status.isOk()) << status.toString8();
   EXPECT_EQ(empty_bundle, returned);
 }
 
 TEST_F(AidlTest, ConfirmPersistableBundlesNonEmpty) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   PersistableBundle non_empty_bundle, returned;
   non_empty_bundle.putBoolean(String16("test_bool"), false);
   non_empty_bundle.putInt(String16("test_int"), 33);
@@ -99,12 +117,14 @@
   non_empty_bundle.putPersistableBundle(String16("test_persistable_bundle"),
                                         nested_bundle);
 
-  Status status = service->RepeatPersistableBundle(non_empty_bundle, &returned);
+  Status status = cpp_java_tests->RepeatPersistableBundle(non_empty_bundle, &returned);
   ASSERT_TRUE(status.isOk()) << status.toString8();
   EXPECT_EQ(non_empty_bundle, returned);
 }
 
 TEST_F(AidlTest, ReversePersistableBundles) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
   PersistableBundle first;
   PersistableBundle second;
   PersistableBundle third;
@@ -115,7 +135,7 @@
 
   vector<PersistableBundle> repeated;
   vector<PersistableBundle> reversed;
-  Status status = service->ReversePersistableBundles(original, &repeated, &reversed);
+  Status status = cpp_java_tests->ReversePersistableBundles(original, &repeated, &reversed);
   ASSERT_TRUE(status.isOk()) << status.toString8();
 
   EXPECT_EQ(repeated, original);
@@ -124,6 +144,65 @@
   EXPECT_EQ(reversed, original);
 }
 
+TEST_F(AidlTest, ReverseUnion) {
+  if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
+
+  Union original = Union::make<Union::ns>({1, 2, 3});
+  Union repeated, reversed;
+  Status status = cpp_java_tests->ReverseUnion(original, &repeated, &reversed);
+  ASSERT_TRUE(status.isOk()) << status.toString8();
+
+  EXPECT_EQ(repeated, original);
+
+  std::reverse(reversed.get<Union::ns>().begin(), reversed.get<Union::ns>().end());
+  EXPECT_EQ(reversed, original);
+}
+
+TEST_F(AidlTest, UnionUsage) {
+  // default ctor inits with first member's default value
+  EXPECT_EQ(Union::make<Union::ns>(), Union());
+
+  // make<tag>(...) to create a value for a tag.
+  Union one_two_three = Union::make<Union::ns>({1, 2, 3});
+
+  // getTag() queries the tag of the content
+  EXPECT_EQ(Union::ns, one_two_three.getTag());
+
+  // Ctor(...) works if a target tag has a unique type among fields.
+  EXPECT_EQ(one_two_three, Union(std::vector{1, 2, 3}));
+  EXPECT_EQ(one_two_three, std::vector<int>({1, 2, 3}));
+
+  // Use std::in_place_index<tag> to avoid "move"
+  // Note that make<tag>(...) involves "move" of the content value
+  EXPECT_EQ(Union::make<Union::ns>(3, 0), Union(std::in_place_index<Union::ns>, 3, 0));
+
+  Union one_two = one_two_three;
+  // get<tag> can be used to modify the content
+  one_two.get<Union::ns>().pop_back();
+  EXPECT_EQ(one_two, std::vector<int>({1, 2}));
+  // get<tag> can be lvalue
+  one_two.get<Union::ns>() = std::vector<int>{1, 2};
+  EXPECT_EQ(one_two, std::vector<int>({1, 2}));
+
+  // abort with a bad access
+  EXPECT_DEATH(one_two.get<Union::n>(), "bad access");
+
+  // set<tag>(...) overwrites the content with a new tag
+  one_two_three.set<Union::s>("123");
+  EXPECT_EQ(one_two_three, std::string("123"));
+
+  // Or, you can simply assign a new value.
+  // note that this works only if the target type is unique
+  one_two_three = std::vector<std::string>{"1", "2", "3"};
+  EXPECT_EQ(Union::ss, one_two_three.getTag());
+}
+
+TEST_F(AidlTest, UnionDefaultConstructorInitializeWithFirstMember) {
+  EXPECT_EQ(Union::make<Union::ns>(), Union());  // int[] ns
+  EXPECT_EQ(EnumUnion::make<EnumUnion::intEnum>(IntEnum::FOO),
+            EnumUnion());  // IntEnum intEnum = IntEnum.FOO
+}
+
 TEST_F(AidlTest, StructuredParcelableEquality) {
   // TODO: break up equality tests, these are hard to read, because you need to
   // keep the state of the parcelables in mind
@@ -194,6 +273,8 @@
   EXPECT_EQ(parcelable.arrayDefaultsTo123[2], 3);
   EXPECT_TRUE(parcelable.arrayDefaultsToEmpty.empty());
 
+  EXPECT_EQ(parcelable.defaultWithFoo, IntEnum::FOO);
+
   service->FillOutStructuredParcelable(&parcelable);
 
   ASSERT_EQ(parcelable.shouldContainThreeFs.size(), 3u);
@@ -231,6 +312,12 @@
 
   EXPECT_EQ(parcelable.addString1, "hello world!");
   EXPECT_EQ(parcelable.addString2, "The quick brown fox jumps over the lazy dog.");
+
+  EXPECT_EQ(StructuredParcelable::BIT0 | StructuredParcelable::BIT2,
+            parcelable.shouldSetBit0AndBit2);
+
+  EXPECT_EQ(parcelable.u->get<Union::ns>(), vector<int32_t>({1, 2, 3}));
+  EXPECT_EQ(parcelable.shouldBeConstS1->get<Union::s>(), Union::S1());
 }
 
 TEST_F(AidlTest, EmptyParcelableHolder) {
@@ -239,18 +326,60 @@
   {
     ExtendableParcelable ep;
     ep.writeToParcel(&parcel);
-    auto emptyExt = ep.ext.getParcelable<MyExt>();
+    std::shared_ptr<MyExt> emptyExt;
+    ep.ext.getParcelable(&emptyExt);
     EXPECT_FALSE(emptyExt);
   }
   {
     parcel.setDataPosition(0);
     ExtendableParcelable ep;
     ep.readFromParcel(&parcel);
-    auto emptyExt = ep.ext.getParcelable<MyExt>();
+    std::shared_ptr<MyExt> emptyExt;
+    ep.ext.getParcelable(&emptyExt);
     EXPECT_FALSE(emptyExt);
   }
 }
 
+TEST_F(AidlTest, ParcelableHolderEqualityOperator) {
+  auto ph1 = android::os::ParcelableHolder(android::Parcelable::Stability::STABILITY_LOCAL);
+  auto ph2 = android::os::ParcelableHolder(android::Parcelable::Stability::STABILITY_LOCAL);
+  auto ph3 = android::os::ParcelableHolder(android::Parcelable::Stability::STABILITY_LOCAL);
+  auto ptr1 = std::make_shared<MyExt>();
+  auto ptr2 = std::make_shared<MyExt>();
+  ptr1->a = 1;
+  ptr1->b = "a";
+  ptr2->a = 1;
+  ptr2->b = "a";
+
+  ph1.setParcelable(ptr1);
+  ph2.setParcelable(ptr1);
+  ph3.setParcelable(ptr2);
+
+  // ParcelableHolder always uses its address as a comparison criterion.
+  EXPECT_TRUE(ph1 != ph2);
+  EXPECT_TRUE(ph2 != ph3);
+  EXPECT_TRUE(ph1 == ph1);
+  EXPECT_TRUE(ph2 == ph2);
+  EXPECT_TRUE(ph3 == ph3);
+
+  android::Parcel parcel;
+  ph1.writeToParcel(&parcel);
+  ph2.writeToParcel(&parcel);
+  ph3.writeToParcel(&parcel);
+  parcel.setDataPosition(0);
+
+  ph1.readFromParcel(&parcel);
+  ph2.readFromParcel(&parcel);
+  ph3.readFromParcel(&parcel);
+
+  // ParcelableHolder always uses its address as a comparison criterion.
+  EXPECT_TRUE(ph1 != ph2);
+  EXPECT_TRUE(ph2 != ph3);
+  EXPECT_TRUE(ph1 == ph1);
+  EXPECT_TRUE(ph2 == ph2);
+  EXPECT_TRUE(ph3 == ph3);
+}
+
 TEST_F(AidlTest, NativeExtednableParcelable) {
   using namespace android::aidl::tests::extension;
   MyExt ext;
@@ -269,15 +398,18 @@
     ep.b = "a";
     ep.c = 42L;
 
-    EXPECT_TRUE(ep.ext.setParcelable(ext));
-    EXPECT_TRUE(ep.ext2.setParcelable(ext2));
+    EXPECT_TRUE(ep.ext.setParcelable(ext) == android::OK);
+    EXPECT_TRUE(ep.ext2.setParcelable(ext2) == android::OK);
 
-    auto extLike = ep.ext.getParcelable<MyExtLike>();
+    std::shared_ptr<MyExtLike> extLike;
+    ep.ext.getParcelable(&extLike);
     EXPECT_FALSE(extLike) << "The extension type must be MyExt, so it has to fail even though "
                              "MyExtLike has the same structure as MyExt.";
 
-    auto actualExt = ep.ext.getParcelable<MyExt>();
-    auto actualExt2 = ep.ext2.getParcelable<MyExt2>();
+    std::shared_ptr<MyExt> actualExt;
+    ep.ext.getParcelable(&actualExt);
+    std::shared_ptr<MyExt2> actualExt2;
+    ep.ext2.getParcelable(&actualExt2);
 
     EXPECT_TRUE(actualExt);
     EXPECT_TRUE(actualExt2);
@@ -293,14 +425,18 @@
     ExtendableParcelable ep;
     ep.readFromParcel(&parcel);
 
-    auto extLike = ep.ext.getParcelable<MyExtLike>();
+    std::shared_ptr<MyExtLike> extLike;
+    ep.ext.getParcelable(&extLike);
     EXPECT_FALSE(extLike) << "The extension type must be MyExt, so it has to fail even though "
                              "MyExtLike has the same structure as MyExt.";
 
-    auto actualExt = ep.ext.getParcelable<MyExt>();
-    auto actualExt2 = ep.ext2.getParcelable<MyExt2>();
+    std::shared_ptr<MyExt> actualExt;
+    ep.ext.getParcelable(&actualExt);
+    std::shared_ptr<MyExt2> actualExt2;
+    ep.ext2.getParcelable(&actualExt2);
 
-    auto emptyExt = ep.ext2.getParcelable<MyExt>();
+    std::shared_ptr<MyExt> emptyExt;
+    ep.ext2.getParcelable(&emptyExt);
     EXPECT_FALSE(emptyExt);
 
     EXPECT_TRUE(actualExt);
@@ -310,3 +446,66 @@
     EXPECT_EQ(ext2, *actualExt2);
   }
 }
+
+TEST_F(AidlTest, ParcelableToString) {
+  ParcelableForToString p;
+  p.intValue = 10;
+  p.intArray = {20, 30};
+  p.longValue = 100L;
+  p.longArray = {200L, 300L};
+  p.doubleValue = 3.14;
+  p.doubleArray = {1.1, 1.2};
+  p.floatValue = 3.14f;
+  p.floatArray = {1.1f, 1.2f};
+  p.byteValue = 3;
+  p.byteArray = {5, 6};
+  p.booleanValue = true;
+  p.booleanArray = {true, false};
+  p.stringValue = String16("this is a string");
+  p.stringArray = {String16("hello"), String16("world")};
+  p.stringList = {String16("alice"), String16("bob")};
+  OtherParcelableForToString op;
+  op.field = String16("other");
+  p.parcelableValue = op;
+  p.parcelableArray = {op, op};
+  p.enumValue = IntEnum::FOO;
+  p.enumArray = {IntEnum::FOO, IntEnum::BAR};
+  // p.nullArray = null;
+  // p.nullList = null;
+  GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum> gen;
+  gen.a = 1;
+  gen.b = 2;
+  p.parcelableGeneric = gen;
+  p.unionValue = Union(std::vector<std::string>{"union", "value"});
+
+  const string expected =
+      "ParcelableForToString{"
+      "intValue: 10, "
+      "intArray: [20, 30], "
+      "longValue: 100, "
+      "longArray: [200, 300], "
+      "doubleValue: 3.140000, "
+      "doubleArray: [1.100000, 1.200000], "
+      "floatValue: 3.140000, "
+      "floatArray: [1.100000, 1.200000], "
+      "byteValue: 3, "
+      "byteArray: [5, 6], "
+      "booleanValue: true, "
+      "booleanArray: [true, false], "
+      "stringValue: this is a string, "
+      "stringArray: [hello, world], "
+      "stringList: [alice, bob], "
+      "parcelableValue: OtherParcelableForToString{field: other}, "
+      "parcelableArray: ["
+      "OtherParcelableForToString{field: other}, "
+      "OtherParcelableForToString{field: other}], "
+      "enumValue: FOO, "
+      "enumArray: [FOO, BAR], "
+      "nullArray: [], "
+      "nullList: [], "
+      "parcelableGeneric: GenericStructuredParcelable{a: 1, b: 2}, "
+      "unionValue: Union{ss: [union, value]}"
+      "}";
+
+  EXPECT_EQ(expected, p.toString());
+}
diff --git a/tests/aidl_test_client_primitives.cpp b/tests/aidl_test_client_primitives.cpp
index 481cc81..9c2a00b 100644
--- a/tests/aidl_test_client_primitives.cpp
+++ b/tests/aidl_test_client_primitives.cpp
@@ -94,6 +94,13 @@
   DoTest(&ITestService::RepeatDouble, double{1.0 / 3.0});
 }
 
+TEST_F(AidlPrimitiveTest, byteConstants) {
+  constexpr int8_t consts[] = {ITestService::BYTE_TEST_CONSTANT};
+  for (auto sent : consts) {
+    DoTest(&ITestService::RepeatByte, sent);
+  }
+}
+
 TEST_F(AidlPrimitiveTest, intConstants) {
   constexpr int32_t consts[] = {
       ITestService::TEST_CONSTANT,   ITestService::TEST_CONSTANT2,  ITestService::TEST_CONSTANT3,
@@ -105,6 +112,13 @@
   }
 }
 
+TEST_F(AidlPrimitiveTest, longConstants) {
+  constexpr int64_t consts[] = {ITestService::LONG_TEST_CONSTANT};
+  for (auto sent : consts) {
+    DoTest(&ITestService::RepeatLong, sent);
+  }
+}
+
 TEST_F(AidlPrimitiveTest, strings) {
   std::vector<String16> strings = {
       String16("Deliver us from evil."), String16(), String16("\0\0", 2),
@@ -182,27 +196,29 @@
     input.push_back(INamedCallback::asBinder(got));
   }
 
-  std::vector<sp<IBinder>> output;
-  std::vector<sp<IBinder>> reversed;
-  auto status = service->ReverseNamedCallbackList(input, &output, &reversed);
-  ASSERT_TRUE(status.isOk());
-  ASSERT_THAT(output.size(), Eq(3u));
-  ASSERT_THAT(reversed.size(), Eq(3u));
-
-  for (int i = 0; i < 3; i++) {
-    String16 ret;
-    sp<INamedCallback> named_callback = android::interface_cast<INamedCallback>(output[i]);
-    auto status = named_callback->GetName(&ret);
+  if (cpp_java_tests) {
+    std::vector<sp<IBinder>> output;
+    std::vector<sp<IBinder>> reversed;
+    auto status = cpp_java_tests->ReverseNamedCallbackList(input, &output, &reversed);
     ASSERT_TRUE(status.isOk());
-    ASSERT_THAT(ret, Eq(names[i]));
-  }
+    ASSERT_THAT(output.size(), Eq(3u));
+    ASSERT_THAT(reversed.size(), Eq(3u));
 
-  for (int i = 0; i < 3; i++) {
-    String16 ret;
-    sp<INamedCallback> named_callback = android::interface_cast<INamedCallback>(reversed[i]);
-    auto status = named_callback->GetName(&ret);
-    ASSERT_TRUE(status.isOk());
-    ASSERT_THAT(ret, Eq(names[2 - i]));
+    for (int i = 0; i < 3; i++) {
+      String16 ret;
+      sp<INamedCallback> named_callback = android::interface_cast<INamedCallback>(output[i]);
+      auto status = named_callback->GetName(&ret);
+      ASSERT_TRUE(status.isOk());
+      ASSERT_THAT(ret, Eq(names[i]));
+    }
+
+    for (int i = 0; i < 3; i++) {
+      String16 ret;
+      sp<INamedCallback> named_callback = android::interface_cast<INamedCallback>(reversed[i]);
+      auto status = named_callback->GetName(&ret);
+      ASSERT_TRUE(status.isOk());
+      ASSERT_THAT(ret, Eq(names[2 - i]));
+    }
   }
 }
 
diff --git a/tests/aidl_test_client_service_exceptions.cpp b/tests/aidl_test_client_service_exceptions.cpp
index 50e5f9c..e9eb049 100644
--- a/tests/aidl_test_client_service_exceptions.cpp
+++ b/tests/aidl_test_client_service_exceptions.cpp
@@ -17,9 +17,15 @@
 #include "aidl_test_client.h"
 #include "gmock/gmock.h"
 
-using testing::Eq;
+TEST_F(AidlTest, onewayNoError) {
+  // oneway servers try to return an error
+  auto status = service->TestOneway();
+  EXPECT_TRUE(status.isOk()) << status;
+}
 
 TEST_F(AidlTest, serviceSpecificException) {
+  using testing::Eq;
+
   for (int32_t i = -1; i < 2; ++i) {
     auto status = service->ThrowServiceException(i);
     ASSERT_THAT(status.exceptionCode(), Eq(android::binder::Status::EX_SERVICE_SPECIFIC));
diff --git a/tests/aidl_test_client_versioned_interface.cpp b/tests/aidl_test_client_versioned_interface.cpp
index 3f26c32..53c0ac9 100644
--- a/tests/aidl_test_client_versioned_interface.cpp
+++ b/tests/aidl_test_client_versioned_interface.cpp
@@ -22,6 +22,7 @@
 using android::OK;
 using android::sp;
 using android::String16;
+using android::aidl::versioned::tests::BazUnion;
 using android::aidl::versioned::tests::IFooInterface;
 
 class VersionedInterfaceTest : public testing::Test {
@@ -39,5 +40,20 @@
 }
 
 TEST_F(VersionedInterfaceTest, getInterfaceHash) {
-  EXPECT_EQ("fcd4f9c806cbc8af3694d569fd1de1ecc8cf7d22", service->getInterfaceHash());
+  EXPECT_EQ("796b4ab269d476662bed4ab57092ed000e48d5d7", service->getInterfaceHash());
+}
+
+TEST_F(VersionedInterfaceTest, noProblemWhenPassingAUnionWithOldField) {
+  std::string result;
+  auto status = service->acceptUnionAndReturnString(BazUnion::make<BazUnion::intNum>(42), &result);
+  EXPECT_TRUE(status.isOk());
+  EXPECT_EQ("42", result);
+}
+
+TEST_F(VersionedInterfaceTest, errorWhenPassingAUnionWithNewField) {
+  std::string result;
+  auto status =
+      service->acceptUnionAndReturnString(BazUnion::make<BazUnion::longNum>(42L), &result);
+  EXPECT_FALSE(status.isOk());
+  EXPECT_EQ(::android::BAD_VALUE, status.transactionError());
 }
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index c6c5608..e008237 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -34,6 +34,7 @@
 #include <utils/String8.h>
 #include <utils/StrongPointer.h>
 
+#include "android/aidl/tests/BackendType.h"
 #include "android/aidl/tests/BnTestService.h"
 #include "android/aidl/tests/ITestService.h"
 
@@ -46,9 +47,16 @@
 #include "android/aidl/tests/BnNewName.h"
 #include "android/aidl/tests/BnOldName.h"
 
+#include "android/aidl/tests/BnCppJavaTests.h"
+#include "android/aidl/tests/ICppJavaTests.h"
+
+#include "android/aidl/tests/Union.h"
 #include "android/aidl/tests/extension/MyExt.h"
 #include "android/aidl/tests/extension/MyExt2.h"
 
+#include "android/aidl/loggable/BnLoggableInterface.h"
+#include "android/aidl/loggable/Data.h"
+
 // Used implicitly.
 #undef LOG_TAG
 #define LOG_TAG "aidl_native_service"
@@ -74,6 +82,8 @@
 using android::binder::Status;
 
 // Generated code:
+using android::aidl::tests::BackendType;
+using android::aidl::tests::BnCppJavaTests;
 using android::aidl::tests::BnNamedCallback;
 using android::aidl::tests::BnNewName;
 using android::aidl::tests::BnOldName;
@@ -81,6 +91,7 @@
 using android::aidl::tests::ByteEnum;
 using android::aidl::tests::ConstantExpressionEnum;
 using android::aidl::tests::GenericStructuredParcelable;
+using android::aidl::tests::ICppJavaTests;
 using android::aidl::tests::INamedCallback;
 using android::aidl::tests::INewName;
 using android::aidl::tests::IntEnum;
@@ -88,6 +99,7 @@
 using android::aidl::tests::LongEnum;
 using android::aidl::tests::SimpleParcelable;
 using android::aidl::tests::StructuredParcelable;
+using android::aidl::tests::Union;
 using android::os::ParcelFileDescriptor;
 using android::os::PersistableBundle;
 
@@ -145,6 +157,131 @@
   }
 };
 
+template <typename T>
+Status ReverseArray(const vector<T>& input, vector<T>* repeated, vector<T>* _aidl_return) {
+  ALOGI("Reversing array of length %zu", input.size());
+  *repeated = input;
+  *_aidl_return = input;
+  std::reverse(_aidl_return->begin(), _aidl_return->end());
+  return Status::ok();
+}
+
+template <typename T>
+Status RepeatNullable(const optional<T>& input, optional<T>* _aidl_return) {
+  ALOGI("Repeating nullable value");
+  *_aidl_return = input;
+  return Status::ok();
+}
+
+class CppJavaTests : public BnCppJavaTests {
+ public:
+  CppJavaTests() = default;
+  ~CppJavaTests() = default;
+
+  Status RepeatSimpleParcelable(const SimpleParcelable& input, SimpleParcelable* repeat,
+                                SimpleParcelable* _aidl_return) override {
+    ALOGI("Repeated a SimpleParcelable %s", input.toString().c_str());
+    *repeat = input;
+    *_aidl_return = input;
+    return Status::ok();
+  }
+
+  Status RepeatGenericParcelable(
+      const GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>& input,
+      GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>* repeat,
+      GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>* _aidl_return) {
+    ALOGI("Repeating Generic Parcelable");
+    *repeat = input;
+    *_aidl_return = input;
+    return Status::ok();
+  }
+
+  Status RepeatPersistableBundle(const PersistableBundle& input,
+                                 PersistableBundle* _aidl_return) override {
+    ALOGI("Repeated a PersistableBundle");
+    *_aidl_return = input;
+    return Status::ok();
+  }
+
+  Status ReverseSimpleParcelables(const vector<SimpleParcelable>& input,
+                                  vector<SimpleParcelable>* repeated,
+                                  vector<SimpleParcelable>* _aidl_return) override {
+    return ReverseArray(input, repeated, _aidl_return);
+  }
+  Status ReversePersistableBundles(const vector<PersistableBundle>& input,
+                                   vector<PersistableBundle>* repeated,
+                                   vector<PersistableBundle>* _aidl_return) override {
+    return ReverseArray(input, repeated, _aidl_return);
+  }
+  Status ReverseUnion(const Union& input, Union* repeated, Union* _aidl_return) override {
+    ALOGI("Repeated a Union");
+    *repeated = input;
+    *_aidl_return = input;
+    auto reverse = [](auto& reversible) {
+      std::reverse(std::begin(reversible), std::end(reversible));
+    };
+    switch (input.getTag()) {
+      case Union::ns:  // int[]
+        reverse(_aidl_return->get<Union::ns>());
+        break;
+      case Union::s:  // String
+        reverse(_aidl_return->get<Union::s>());
+        break;
+      case Union::ss:  // List<String>
+        reverse(_aidl_return->get<Union::ss>());
+        break;
+      default:
+        break;
+    }
+    return Status::ok();
+  }
+  Status ReverseNamedCallbackList(const vector<sp<IBinder>>& input, vector<sp<IBinder>>* repeated,
+                                  vector<sp<IBinder>>* _aidl_return) override {
+    return ReverseArray(input, repeated, _aidl_return);
+  }
+
+  Status RepeatFileDescriptor(unique_fd read, unique_fd* _aidl_return) override {
+    ALOGE("Repeating file descriptor");
+    *_aidl_return = unique_fd(dup(read.get()));
+    return Status::ok();
+  }
+
+  Status ReverseFileDescriptorArray(const vector<unique_fd>& input, vector<unique_fd>* repeated,
+                                    vector<unique_fd>* _aidl_return) override {
+    ALOGI("Reversing descriptor array of length %zu", input.size());
+    for (const auto& item : input) {
+      repeated->push_back(unique_fd(dup(item.get())));
+      _aidl_return->push_back(unique_fd(dup(item.get())));
+    }
+    std::reverse(_aidl_return->begin(), _aidl_return->end());
+    return Status::ok();
+  }
+
+  Status TakesAnIBinderList(const vector<sp<IBinder>>& input) override {
+    (void)input;
+    return Status::ok();
+  }
+  Status TakesANullableIBinderList(const optional<vector<sp<IBinder>>>& input) {
+    (void)input;
+    return Status::ok();
+  }
+
+  ::android::binder::Status RepeatExtendableParcelable(
+      const ::android::aidl::tests::extension::ExtendableParcelable& ep,
+      ::android::aidl::tests::extension::ExtendableParcelable* ep2) {
+    ep2->a = ep.a * 2;
+    ep2->b = ep.b + "BAR";
+    std::shared_ptr<android::aidl::tests::extension::MyExt> myExt;
+    ep.ext.getParcelable(&myExt);
+    ::android::aidl::tests::extension::MyExt retMyExt;
+    retMyExt.a = myExt->a * 2;
+    retMyExt.b = myExt->b + "BAR";
+    ep2->ext.setParcelable(retMyExt);
+
+    return Status::ok();
+  }
+};
+
 class NativeService : public BnTestService {
  public:
   NativeService() {}
@@ -162,6 +299,8 @@
     ALOGI("Repeating token %s", token_str.str().c_str());
   }
 
+  Status TestOneway() override { return Status::fromStatusT(android::UNKNOWN_ERROR); }
+
   Status RepeatBoolean(bool token, bool* _aidl_return) override {
     LogRepeatedToken(token ? 1 : 0);
     *_aidl_return = token;
@@ -218,39 +357,6 @@
     return Status::ok();
   }
 
-  Status RepeatSimpleParcelable(const SimpleParcelable& input,
-                                SimpleParcelable* repeat,
-                                SimpleParcelable* _aidl_return) override {
-    ALOGI("Repeated a SimpleParcelable %s", input.toString().c_str());
-    *repeat = input;
-    *_aidl_return = input;
-    return Status::ok();
-  }
-
-  Status RepeatPersistableBundle(const PersistableBundle& input,
-                                 PersistableBundle* _aidl_return) override {
-    ALOGI("Repeated a PersistableBundle");
-    *_aidl_return = input;
-    return Status::ok();
-  }
-
-  template <typename T>
-  Status ReverseArray(const vector<T>& input, vector<T>* repeated,
-                      vector<T>* _aidl_return) {
-    ALOGI("Reversing array of length %zu", input.size());
-    *repeated = input;
-    *_aidl_return = input;
-    std::reverse(_aidl_return->begin(), _aidl_return->end());
-    return Status::ok();
-  }
-
-  template <typename T>
-  Status RepeatNullable(const optional<T>& input, optional<T>* _aidl_return) {
-    ALOGI("Repeating nullable value");
-    *_aidl_return = input;
-    return Status::ok();
-  }
-
   Status ReverseBoolean(const vector<bool>& input,
                         vector<bool>* repeated,
                         vector<bool>* _aidl_return) override {
@@ -303,18 +409,6 @@
                          vector<LongEnum>* _aidl_return) override {
     return ReverseArray(input, repeated, _aidl_return);
   }
-  Status ReverseSimpleParcelables(
-      const vector<SimpleParcelable>& input,
-      vector<SimpleParcelable>* repeated,
-      vector<SimpleParcelable>* _aidl_return) override {
-    return ReverseArray(input, repeated, _aidl_return);
-  }
-  Status ReversePersistableBundles(
-      const vector<PersistableBundle>& input,
-      vector<PersistableBundle>* repeated,
-      vector<PersistableBundle>* _aidl_return) override {
-    return ReverseArray(input, repeated, _aidl_return);
-  }
 
   Status GetOtherTestService(const String16& name,
                              sp<INamedCallback>* returned_service) override {
@@ -345,31 +439,6 @@
     return ReverseArray(input, repeated, _aidl_return);
   }
 
-  Status ReverseNamedCallbackList(const vector<sp<IBinder>>& input,
-                                  vector<sp<IBinder>>* repeated,
-                                  vector<sp<IBinder>>* _aidl_return) override {
-    return ReverseArray(input, repeated, _aidl_return);
-  }
-
-  Status RepeatFileDescriptor(unique_fd read,
-                              unique_fd* _aidl_return) override {
-    ALOGE("Repeating file descriptor");
-    *_aidl_return = unique_fd(dup(read.get()));
-    return Status::ok();
-  }
-
-  Status ReverseFileDescriptorArray(const vector<unique_fd>& input,
-                                    vector<unique_fd>* repeated,
-                                    vector<unique_fd>* _aidl_return) override {
-    ALOGI("Reversing descriptor array of length %zu", input.size());
-    for (const auto& item : input) {
-      repeated->push_back(unique_fd(dup(item.get())));
-      _aidl_return->push_back(unique_fd(dup(item.get())));
-    }
-    std::reverse(_aidl_return->begin(), _aidl_return->end());
-    return Status::ok();
-  }
-
   Status RepeatParcelFileDescriptor(const ParcelFileDescriptor& read,
                                     ParcelFileDescriptor* _aidl_return) override {
     ALOGE("Repeating parcel file descriptor");
@@ -425,37 +494,19 @@
     return RepeatNullable(input, _aidl_return);
   }
 
-  Status RepeatNullableParcelable(const optional<SimpleParcelable>& input,
-                                  optional<SimpleParcelable>* _aidl_return) {
+  Status RepeatNullableParcelable(const optional<StructuredParcelable>& input,
+                                  optional<StructuredParcelable>* _aidl_return) {
     return RepeatNullable(input, _aidl_return);
   }
 
-  Status RepeatGenericParcelable(
-      const GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>& input,
-      GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>* repeat,
-      GenericStructuredParcelable<int32_t, StructuredParcelable, IntEnum>* _aidl_return) {
-    ALOGI("Repeating Generic Parcelable");
-    *repeat = input;
-    *_aidl_return = input;
-    return Status::ok();
-  }
-
   Status TakesAnIBinder(const sp<IBinder>& input) override {
     (void)input;
     return Status::ok();
   }
-  Status TakesAnIBinderList(const vector<sp<IBinder>>& input) override {
-    (void)input;
-    return Status::ok();
-  }
   Status TakesANullableIBinder(const sp<IBinder>& input) {
     (void)input;
     return Status::ok();
   }
-  Status TakesANullableIBinderList(const optional<vector<sp<IBinder>>>& input) {
-    (void)input;
-    return Status::ok();
-  }
 
   Status RepeatUtf8CppString(const string& token,
                              string* _aidl_return) override {
@@ -529,20 +580,10 @@
     parcelable->const_exprs_9 = ConstantExpressionEnum::hexInt32_3;
     parcelable->const_exprs_10 = ConstantExpressionEnum::hexInt64_1;
 
-    return Status::ok();
-  }
+    parcelable->shouldSetBit0AndBit2 = StructuredParcelable::BIT0 | StructuredParcelable::BIT2;
 
-  ::android::binder::Status RepeatExtendableParcelable(
-      const ::android::aidl::tests::extension::ExtendableParcelable& ep,
-      ::android::aidl::tests::extension::ExtendableParcelable* ep2) {
-    ep2->a = ep.a * 2;
-    ep2->b = ep.b + "BAR";
-    auto myExt = ep.ext.getParcelable<android::aidl::tests::extension::MyExt>();
-    ::android::aidl::tests::extension::MyExt retMyExt;
-    retMyExt.a = myExt->a * 2;
-    retMyExt.b = myExt->b + "BAR";
-    ep2->ext.setParcelable(retMyExt);
-
+    parcelable->u = Union::make<Union::ns>({1, 2, 3});
+    parcelable->shouldBeConstS1 = Union::S1();
     return Status::ok();
   }
 
@@ -560,6 +601,16 @@
     return Status::ok();
   }
 
+  Status GetCppJavaTests(sp<IBinder>* ret) {
+    *ret = new CppJavaTests;
+    return Status::ok();
+  }
+
+  Status getBackendType(BackendType* _aidl_return) override {
+    *_aidl_return = BackendType::CPP;
+    return Status::ok();
+  }
+
   android::status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply,
                                uint32_t flags) override {
     if (code == ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* UnimplementedMethod */) {
@@ -579,7 +630,33 @@
   VersionedService() {}
   virtual ~VersionedService() = default;
 
-  Status foo() override { return Status::ok(); }
+  Status originalApi() override { return Status::ok(); }
+  Status acceptUnionAndReturnString(const ::android::aidl::versioned::tests::BazUnion& u,
+                                    std::string* _aidl_return) override {
+    switch (u.getTag()) {
+      case ::android::aidl::versioned::tests::BazUnion::intNum:
+        *_aidl_return =
+            std::to_string(u.get<::android::aidl::versioned::tests::BazUnion::intNum>());
+        break;
+    }
+    return Status::ok();
+  }
+};
+
+class LoggableInterfaceService : public android::aidl::loggable::BnLoggableInterface {
+ public:
+  LoggableInterfaceService() {}
+  virtual ~LoggableInterfaceService() = default;
+
+  virtual Status LogThis(bool, vector<bool>*, int8_t, vector<uint8_t>*, char16_t, vector<char16_t>*,
+                         int32_t, vector<int32_t>*, int64_t, vector<int64_t>*, float,
+                         vector<float>*, double, vector<double>*, const String16&,
+                         vector<String16>*, vector<String16>*, const android::aidl::loggable::Data&,
+                         const sp<IBinder>&, optional<ParcelFileDescriptor>*,
+                         vector<ParcelFileDescriptor>*, vector<String16>* _aidl_return) override {
+    *_aidl_return = vector<String16>{String16("loggable")};
+    return Status::ok();
+  }
 };
 
 int Run() {
@@ -614,6 +691,15 @@
     return -1;
   }
 
+  android::sp<LoggableInterfaceService> loggableInterfaceService = new LoggableInterfaceService;
+  status = defaultServiceManager()->addService(loggableInterfaceService->getInterfaceDescriptor(),
+                                               loggableInterfaceService);
+  if (status != OK) {
+    ALOGE("Failed to add service %s",
+          String8(loggableInterfaceService->getInterfaceDescriptor()).c_str());
+    return -1;
+  }
+
   ALOGI("Entering loop");
   while (true) {
     const int result = looper->pollAll(-1 /* timeoutMillis */);
diff --git a/tests/android/aidl/loggable/Data.aidl b/tests/android/aidl/loggable/Data.aidl
new file mode 100644
index 0000000..cd7f4ae
--- /dev/null
+++ b/tests/android/aidl/loggable/Data.aidl
@@ -0,0 +1,11 @@
+package android.aidl.loggable;
+
+import android.aidl.loggable.Enum;
+import android.aidl.loggable.Union;
+
+parcelable Data {
+    int num;
+    @utf8InCpp String str;
+    Union nestedUnion;
+    Enum nestedEnum;
+}
\ No newline at end of file
diff --git a/tests/android/aidl/loggable/Enum.aidl b/tests/android/aidl/loggable/Enum.aidl
new file mode 100644
index 0000000..bb6a180
--- /dev/null
+++ b/tests/android/aidl/loggable/Enum.aidl
@@ -0,0 +1,3 @@
+package android.aidl.loggable;
+
+enum Enum { FOO = 42 }
\ No newline at end of file
diff --git a/tests/android/aidl/loggable/ILoggableInterface.aidl b/tests/android/aidl/loggable/ILoggableInterface.aidl
index 0b62df3..a19efc1 100644
--- a/tests/android/aidl/loggable/ILoggableInterface.aidl
+++ b/tests/android/aidl/loggable/ILoggableInterface.aidl
@@ -1,4 +1,5 @@
 package android.aidl.loggable;
+import  android.aidl.loggable.Data;
 
 interface ILoggableInterface {
     String[] LogThis(boolean boolValue, inout boolean[] boolArray,
@@ -10,6 +11,7 @@
                    double doubleValue, inout double[] doubleArray,
                    String stringValue, inout String[] stringArray,
                    inout List<String> listValue,
-                   IBinder binderValue,
-                   inout ParcelFileDescriptor pfdValue, inout ParcelFileDescriptor[] pfdArray);
+                   in Data dataValue,
+                   @nullable IBinder binderValue,
+                   inout @nullable ParcelFileDescriptor pfdValue, inout ParcelFileDescriptor[] pfdArray);
 }
diff --git a/tests/android/aidl/loggable/Union.aidl b/tests/android/aidl/loggable/Union.aidl
new file mode 100644
index 0000000..4e116ae
--- /dev/null
+++ b/tests/android/aidl/loggable/Union.aidl
@@ -0,0 +1,6 @@
+package android.aidl.loggable;
+
+union Union {
+    int num = 43;
+    @utf8InCpp String str;
+}
\ No newline at end of file
diff --git a/tests/android/aidl/tests/BackendType.aidl b/tests/android/aidl/tests/BackendType.aidl
new file mode 100644
index 0000000..a17c942
--- /dev/null
+++ b/tests/android/aidl/tests/BackendType.aidl
@@ -0,0 +1,8 @@
+package android.aidl.tests;
+
+enum BackendType {
+    CPP,
+    JAVA,
+    NDK,
+    RUST,
+}
\ No newline at end of file
diff --git a/tests/android/aidl/tests/GenericStructuredParcelable.aidl b/tests/android/aidl/tests/GenericStructuredParcelable.aidl
index 6e71be5..af93692 100644
--- a/tests/android/aidl/tests/GenericStructuredParcelable.aidl
+++ b/tests/android/aidl/tests/GenericStructuredParcelable.aidl
@@ -16,7 +16,7 @@
 
 package android.aidl.tests;
 
-@JavaDebug
+@JavaDerive(toString=true)
 parcelable GenericStructuredParcelable<T, U, B> {
   int a;
   int b;
diff --git a/tests/android/aidl/tests/ICppJavaTests.aidl b/tests/android/aidl/tests/ICppJavaTests.aidl
new file mode 100644
index 0000000..dcd7607
--- /dev/null
+++ b/tests/android/aidl/tests/ICppJavaTests.aidl
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aidl.tests;
+
+import android.aidl.tests.GenericStructuredParcelable;
+import android.aidl.tests.IntEnum;
+import android.aidl.tests.SimpleParcelable;
+import android.aidl.tests.StructuredParcelable;
+import android.aidl.tests.Union;
+import android.aidl.tests.extension.ExtendableParcelable;
+import android.os.PersistableBundle;
+
+// Tests that are only supported by the C++/Java backends, not NDK/Rust
+interface ICppJavaTests {
+  SimpleParcelable RepeatSimpleParcelable(in SimpleParcelable input,
+                                          out SimpleParcelable repeat);
+  GenericStructuredParcelable<int, StructuredParcelable, IntEnum> RepeatGenericParcelable(in GenericStructuredParcelable<int, StructuredParcelable, IntEnum> input, out GenericStructuredParcelable<int, StructuredParcelable, IntEnum> repeat);
+  PersistableBundle RepeatPersistableBundle(in PersistableBundle input);
+
+  SimpleParcelable[]  ReverseSimpleParcelables(in SimpleParcelable[] input,
+                                               out SimpleParcelable[] repeated);
+  PersistableBundle[] ReversePersistableBundles(
+      in PersistableBundle[] input, out PersistableBundle[] repeated);
+  Union ReverseUnion(in Union input, out Union repeated);
+  // Test that List<T> types work correctly.
+  List<IBinder> ReverseNamedCallbackList(in List<IBinder> input,
+                                         out List<IBinder> repeated);
+
+  FileDescriptor RepeatFileDescriptor(in FileDescriptor read);
+  FileDescriptor[] ReverseFileDescriptorArray(in FileDescriptor[] input,
+                                              out FileDescriptor[] repeated);
+
+  void TakesAnIBinderList(in List<IBinder> input);
+  void TakesANullableIBinderList(in @nullable List<IBinder> input);
+
+  void RepeatExtendableParcelable(in ExtendableParcelable ep, out ExtendableParcelable ep2);
+}
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index df061a0..5e9acb3 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -16,18 +16,16 @@
 
 package android.aidl.tests;
 
+import android.aidl.tests.BackendType;
 import android.aidl.tests.ByteEnum;
 import android.aidl.tests.INamedCallback;
-import android.aidl.tests.GenericStructuredParcelable;
 import android.aidl.tests.IntEnum;
 import android.aidl.tests.LongEnum;
-import android.aidl.tests.SimpleParcelable;
 import android.aidl.tests.StructuredParcelable;
 import android.aidl.tests.IOldName;
 import android.aidl.tests.INewName;
-import android.aidl.tests.extension.ExtendableParcelable;
-import android.os.PersistableBundle;
 
+@SensitiveData
 interface ITestService {
   // Test that constants are accessible
   const int TEST_CONSTANT = 42;
@@ -43,6 +41,9 @@
   const int TEST_CONSTANT11 = 0xFA;
   const int TEST_CONSTANT12 = 0xffffffff;
 
+  const byte BYTE_TEST_CONSTANT = 17;
+  const long LONG_TEST_CONSTANT = 1L << 40;
+
   const String STRING_TEST_CONSTANT = "foo";
   const String STRING_TEST_CONSTANT2 = "bar";
 
@@ -61,6 +62,8 @@
   // methods to be added and removed.
   int UnimplementedMethod(int arg);
 
+  oneway void TestOneway();
+
   // Test that primitives work as parameters and return types.
   boolean RepeatBoolean(boolean token);
   byte RepeatByte(byte token);
@@ -74,11 +77,6 @@
   IntEnum RepeatIntEnum(IntEnum token);
   LongEnum RepeatLongEnum(LongEnum token);
 
-  SimpleParcelable RepeatSimpleParcelable(in SimpleParcelable input,
-                                          out SimpleParcelable repeat);
-  GenericStructuredParcelable<int, StructuredParcelable, IntEnum> RepeatGenericParcelable(in GenericStructuredParcelable<int, StructuredParcelable, IntEnum> input, out GenericStructuredParcelable<int, StructuredParcelable, IntEnum> repeat);
-  PersistableBundle RepeatPersistableBundle(in PersistableBundle input);
-
   // Test that arrays work as parameters and return types.
   boolean[]   ReverseBoolean  (in boolean[]   input, out boolean[]   repeated);
   byte[]      ReverseByte     (in byte[]      input, out byte[]      repeated);
@@ -92,11 +90,6 @@
   IntEnum[]   ReverseIntEnum  (in IntEnum[]   input, out IntEnum[]   repeated);
   LongEnum[]  ReverseLongEnum (in LongEnum[]  input, out LongEnum[]  repeated);
 
-  SimpleParcelable[]  ReverseSimpleParcelables(in SimpleParcelable[] input,
-                                               out SimpleParcelable[] repeated);
-  PersistableBundle[] ReversePersistableBundles(
-      in PersistableBundle[] input, out PersistableBundle[] repeated);
-
   // Test that clients can send and receive Binders.
   INamedCallback GetOtherTestService(String name);
   boolean VerifyName(INamedCallback service, String name);
@@ -104,12 +97,6 @@
   // Test that List<T> types work correctly.
   List<String> ReverseStringList(in List<String> input,
                                  out List<String> repeated);
-  List<IBinder> ReverseNamedCallbackList(in List<IBinder> input,
-                                         out List<IBinder> repeated);
-
-  FileDescriptor RepeatFileDescriptor(in FileDescriptor read);
-  FileDescriptor[] ReverseFileDescriptorArray(in FileDescriptor[] input,
-                                              out FileDescriptor[] repeated);
 
   ParcelFileDescriptor RepeatParcelFileDescriptor(in ParcelFileDescriptor read);
   ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(in ParcelFileDescriptor[] input,
@@ -125,12 +112,10 @@
   @nullable LongEnum[] RepeatNullableLongEnumArray(in @nullable LongEnum[] input);
   @nullable String RepeatNullableString(in @nullable String input);
   @nullable List<String> RepeatNullableStringList(in @nullable List<String> input);
-  @nullable SimpleParcelable RepeatNullableParcelable(in @nullable SimpleParcelable input);
+  @nullable StructuredParcelable RepeatNullableParcelable(in @nullable StructuredParcelable input);
 
   void TakesAnIBinder(in IBinder input);
-  void TakesAnIBinderList(in List<IBinder> input);
   void TakesANullableIBinder(in @nullable IBinder input);
-  void TakesANullableIBinderList(in @nullable List<IBinder> input);
 
   // Test utf8 decoding from utf16 wire format
   @utf8InCpp String RepeatUtf8CppString(@utf8InCpp String token);
@@ -154,8 +139,6 @@
   // inefficient to use an IPC to fill it out in practice.
   void FillOutStructuredParcelable(inout StructuredParcelable parcel);
 
-  void RepeatExtendableParcelable(in ExtendableParcelable ep, out ExtendableParcelable ep2);
-
   // All these constant expressions should be equal to 1
   const int A1 = (~(-1)) == 0;
   const int A2 = ~~(1 << 31) == (1 << 31);
@@ -217,4 +200,9 @@
 
   IOldName GetOldNameInterface();
   INewName GetNewNameInterface();
+
+  // Retrieve the ICppJavaTests if the server supports it
+  @nullable IBinder GetCppJavaTests();
+
+  BackendType getBackendType();
 }
diff --git a/tests/android/aidl/tests/OtherParcelableForToString.aidl b/tests/android/aidl/tests/OtherParcelableForToString.aidl
index 8bff893..f042ab5 100644
--- a/tests/android/aidl/tests/OtherParcelableForToString.aidl
+++ b/tests/android/aidl/tests/OtherParcelableForToString.aidl
@@ -16,7 +16,7 @@
 
 package android.aidl.tests;
 
-@JavaDebug
+@JavaDerive(toString=true)
 parcelable OtherParcelableForToString {
     String field;
 }
diff --git a/tests/android/aidl/tests/ParcelableForToString.aidl b/tests/android/aidl/tests/ParcelableForToString.aidl
index 3647a34..d1c2bd3 100644
--- a/tests/android/aidl/tests/ParcelableForToString.aidl
+++ b/tests/android/aidl/tests/ParcelableForToString.aidl
@@ -20,8 +20,9 @@
 import android.aidl.tests.StructuredParcelable;
 import android.aidl.tests.OtherParcelableForToString;
 import android.aidl.tests.IntEnum;
+import android.aidl.tests.Union;
 
-@JavaDebug
+@JavaDerive(toString=true)
 parcelable ParcelableForToString {
     int intValue;
     int[] intArray;
@@ -45,4 +46,5 @@
     String[] nullArray;
     List<String> nullList;
     GenericStructuredParcelable<int, StructuredParcelable, IntEnum> parcelableGeneric;
+    Union unionValue;
 }
diff --git a/tests/android/aidl/tests/StructuredParcelable.aidl b/tests/android/aidl/tests/StructuredParcelable.aidl
index c559aa1..2d4e367 100644
--- a/tests/android/aidl/tests/StructuredParcelable.aidl
+++ b/tests/android/aidl/tests/StructuredParcelable.aidl
@@ -20,8 +20,10 @@
 import android.aidl.tests.IntEnum;
 import android.aidl.tests.LongEnum;
 import android.aidl.tests.ConstantExpressionEnum;
+import android.aidl.tests.Union;
 
-@JavaDebug
+@JavaDerive(toString=true, equals=true)
+@RustDerive(Clone=true, PartialEq=true)
 parcelable StructuredParcelable {
     int[] shouldContainThreeFs;
     int f;
@@ -129,7 +131,7 @@
       (~42 & (1 << 3 | 16 >> 2) ^ 7) == 3,
       (2 + 3 - 4 * -7 / (10 % 3)) - 33 == 0,
       (2 + (-3&4 / 7)) == 2,
-      (((((1 + 0)))))
+      (((((1 + 0))))),
     };
 
     long[] int64_1 = {
@@ -162,5 +164,15 @@
     // String expressions
     @utf8InCpp String addString1 = "hello" + " world!";
     @utf8InCpp String addString2 = "The quick brown fox jumps " + "over the lazy dog.";
+
+    const int BIT0 = 0x1;
+    const int BIT1 = 0x1 << 1;
+    const int BIT2 = 0x1 << 2;
+    int shouldSetBit0AndBit2;
+
+    @nullable Union u;
+    @nullable Union shouldBeConstS1;
+
+    IntEnum defaultWithFoo = IntEnum.FOO;
 }
 
diff --git a/tests/android/aidl/tests/Union.aidl b/tests/android/aidl/tests/Union.aidl
new file mode 100644
index 0000000..d43131e
--- /dev/null
+++ b/tests/android/aidl/tests/Union.aidl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aidl.tests;
+import android.aidl.tests.ByteEnum;
+
+@JavaDerive(toString=true, equals=true)
+@RustDerive(Clone=true, PartialEq=true)
+union Union {
+    int[] ns = {};
+    int n;
+    int m;
+    @utf8InCpp String s;
+    @nullable IBinder ibinder;
+    @utf8InCpp List<String> ss;
+    ByteEnum be;
+
+    const @utf8InCpp String S1 = "a string constant in union";
+}
+
diff --git a/tests/java_app/src/android/aidl/tests/TestFailException.java b/tests/android/aidl/tests/UnionWithFd.aidl
similarity index 69%
rename from tests/java_app/src/android/aidl/tests/TestFailException.java
rename to tests/android/aidl/tests/UnionWithFd.aidl
index de000fa..5f59695 100644
--- a/tests/java_app/src/android/aidl/tests/TestFailException.java
+++ b/tests/android/aidl/tests/UnionWithFd.aidl
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2016, The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,9 +16,7 @@
 
 package android.aidl.tests;
 
-public class TestFailException extends Exception {
-    public TestFailException(String message) {
-        super(message);
-    }
+union UnionWithFd {
+    int num;
+    ParcelFileDescriptor pfd;
 }
-
diff --git a/tests/android/aidl/tests/immutable/Foo.aidl b/tests/android/aidl/tests/immutable/Foo.aidl
index c923d8a..4e5d28d 100644
--- a/tests/android/aidl/tests/immutable/Foo.aidl
+++ b/tests/android/aidl/tests/immutable/Foo.aidl
@@ -17,6 +17,7 @@
 package android.aidl.tests.immutable;
 
 import android.aidl.tests.immutable.Bar;
+import android.aidl.tests.immutable.Union;
 
 @JavaOnlyImmutable
 parcelable Foo {
@@ -25,4 +26,5 @@
     List<Bar> c;
     Map<String, Bar> d;
     Bar[] e;
+    Union u;
 }
\ No newline at end of file
diff --git a/tests/android/aidl/tests/immutable/Union.aidl b/tests/android/aidl/tests/immutable/Union.aidl
new file mode 100644
index 0000000..9c23567
--- /dev/null
+++ b/tests/android/aidl/tests/immutable/Union.aidl
@@ -0,0 +1,10 @@
+package android.aidl.tests.immutable;
+
+import android.aidl.tests.immutable.Bar;
+
+@JavaOnlyImmutable
+union Union {
+    int num;
+    String[] str;
+    Bar bar;
+}
\ No newline at end of file
diff --git a/tests/android/aidl/tests/unions/EnumUnion.aidl b/tests/android/aidl/tests/unions/EnumUnion.aidl
new file mode 100644
index 0000000..714e34f
--- /dev/null
+++ b/tests/android/aidl/tests/unions/EnumUnion.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aidl.tests.unions;
+import android.aidl.tests.IntEnum;
+import android.aidl.tests.LongEnum;
+
+@JavaDerive(toString=true, equals=true)
+@RustDerive(Clone=true, PartialEq=true)
+union EnumUnion {
+  IntEnum intEnum = IntEnum.FOO;
+  LongEnum longEnum;
+}
+
diff --git a/tests/corpus/const_overflow b/tests/corpus/const_overflow
new file mode 100644
index 0000000..065a432
--- /dev/null
+++ b/tests/corpus/const_overflow
@@ -0,0 +1 @@
+–enum o{p=- s,zp=- false ,s,U,U,s,s,sU,s,T,teS,s,U,U,byt,U,U,s,s,sU,s,U,teS,s,U,U,byt,s}
\ No newline at end of file
diff --git a/tests/corpus/enum_string b/tests/corpus/enum_string
new file mode 100644
index 0000000..645e109
--- /dev/null
+++ b/tests/corpus/enum_string
@@ -0,0 +1 @@
+ enum o{p="§"}
\ No newline at end of file
diff --git a/tests/corpus/shift_zero_left_32 b/tests/corpus/shift_zero_left_32
new file mode 100644
index 0000000..4bf12f7
--- /dev/null
+++ b/tests/corpus/shift_zero_left_32
@@ -0,0 +1 @@
+ enum o{p=0>>-32}
\ No newline at end of file
diff --git a/tests/end_to_end_tests.cpp b/tests/end_to_end_tests.cpp
deleted file mode 100644
index fd60c1d..0000000
--- a/tests/end_to_end_tests.cpp
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <android-base/logging.h>
-#include <gtest/gtest.h>
-
-#include "aidl.h"
-#include "options.h"
-#include "tests/fake_io_delegate.h"
-#include "tests/test_data.h"
-#include "tests/test_util.h"
-
-using android::aidl::test::CanonicalNameToPath;
-using android::aidl::test::FakeIoDelegate;
-using std::string;
-using std::unique_ptr;
-using std::vector;
-
-namespace android {
-namespace aidl {
-
-class EndToEndTest : public ::testing::Test {
- protected:
-  void SetUp() override {
-  }
-
-  void AddStubAidls(const char** parcelables, const char** interfaces,
-                    const char* cpp_header=nullptr) {
-    for ( ; *parcelables; ++parcelables) {
-      io_delegate_.AddStubParcelable(
-          *parcelables, (cpp_header) ? cpp_header : "");
-    }
-    for ( ; *interfaces; ++interfaces) {
-      io_delegate_.AddStubInterface(*interfaces);
-    }
-  }
-
-  void CheckFileContents(const string& rel_path,
-                         const string& expected_content) {
-    string actual_content;
-    ASSERT_TRUE(io_delegate_.GetWrittenContents(rel_path, &actual_content))
-        << "Expected aidl to write to " << rel_path << " but it did not.";
-
-    if (actual_content == expected_content) {
-      return;  // success!
-    }
-
-    test::PrintDiff(expected_content, actual_content);
-    FAIL() << "Actual contents of " << rel_path
-           << " did not match expected content";
-  }
-
-  FakeIoDelegate io_delegate_;
-};
-
-TEST_F(EndToEndTest, IExampleInterface) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    "-I .",
-    "-d an/arbitrary/path/to/dep.P",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinition);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable",
-                                     {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutput);
-  CheckFileContents(options.DependencyFile(), kExpectedJavaDepsOutput);
-}
-
-TEST_F(EndToEndTest, IExampleInterface_WithTrace) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    "-I .",
-    "-t", //trace
-    "-d an/arbitrary/path/to/dep.P",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinition);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable",
-                                     {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutputWithTrace);
-  CheckFileContents(options.DependencyFile(), kExpectedJavaDepsOutput);
-}
-
-TEST_F(EndToEndTest, IExampleInterface_WithTransactionNames) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    "-I .",
-    "--transaction_name", //trace
-    "-d an/arbitrary/path/to/dep.P",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinition);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable",
-                                     {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutputWithTransactionNames);
-  CheckFileContents(options.DependencyFile(), kExpectedJavaDepsOutput);
-}
-
-TEST_F(EndToEndTest, IExampleInterface_Outlining) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    "-I .",
-    "-d an/arbitrary/path/to/dep.P",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-  options.onTransact_outline_threshold_ = 4;
-  options.onTransact_non_outline_count_ = 3;
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinitionOutlining);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable",
-                                     {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutputOutlining);
-  CheckFileContents(options.DependencyFile(), kExpectedJavaDepsOutput);
-}
-
-TEST_F(EndToEndTest, IExampleInterface_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    "-I .",
-    "-d an/arbitrary/path/to/dep.P",
-    "--version=10",
-    "--hash=abcdefg",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-  options.onTransact_outline_threshold_ = 4;
-  options.onTransact_non_outline_count_ = 3;
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinitionOutlining);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable",
-                                     {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutputWithVersionAndHash);
-  CheckFileContents(options.DependencyFile(), kExpectedJavaDepsOutput);
-}
-
-TEST_F(EndToEndTest, IExampleInterfaceRust) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {"aidl",
-                         "--lang=rust",
-                         "-b",
-                         "-I .",
-                         "-d an/arbitrary/path/to/dep.P",
-                         "-o",
-                         kRustOutputDirectory,
-                         CanonicalNameToPath(kCanonicalName, ".aidl")};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinition);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable", {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kRustOutputPath, kExpectedRustOutput);
-  CheckFileContents(options.DependencyFile(), kExpectedRustDepsOutput);
-}
-
-TEST_F(EndToEndTest, IExampleInterfaceRust_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::example_interface;
-
-  vector<string> args = {"aidl",
-                         "--lang=rust",
-                         "-b",
-                         "-I .",
-                         "-d an/arbitrary/path/to/dep.P",
-                         "--version=10",
-                         "--hash=abcdefg",
-                         "-o",
-                         kRustOutputDirectory,
-                         CanonicalNameToPath(kCanonicalName, ".aidl")};
-  Options options = Options::From(args);
-  options.onTransact_outline_threshold_ = 4;
-  options.onTransact_non_outline_count_ = 3;
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(options.InputFiles().front(), kInterfaceDefinitionOutlining);
-  io_delegate_.AddCompoundParcelable("android.test.CompoundParcelable", {"Subclass1", "Subclass2"});
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kRustOutputPath, kExpectedRustOutputWithVersionAndHash);
-  CheckFileContents(options.DependencyFile(), kExpectedRustDepsOutput);
-}
-
-TEST_F(EndToEndTest, IPingResponderCpp) {
-  using namespace ::android::aidl::test_data::ping_responder;
-
-  vector<string> args = {
-    "aidl-cpp",
-    "-d deps.P",
-    "-I .",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kGenHeaderDir,
-    kCppOutputPath};
-  Options options = Options::From(args);
-
-  // Set up input paths.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-  AddStubAidls(kImportedParcelables, kImportedInterfaces, kCppParcelableHeader);
-
-  // Check that we parse and generate code correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kCppOutputPath, kExpectedCppOutput);
-  CheckFileContents(kGenInterfaceHeaderPath, kExpectedIHeaderOutput);
-  CheckFileContents(kGenClientHeaderPath, kExpectedBpHeaderOutput);
-  CheckFileContents(kGenServerHeaderPath, kExpectedBnHeaderOutput);
-  CheckFileContents(options.DependencyFile(), kExpectedCppDepsOutput);
-}
-
-TEST_F(EndToEndTest, IPingResponderCpp_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::ping_responder;
-
-  vector<string> args = {
-    "aidl-cpp",
-    "-d deps.P",
-    "-I .",
-    "--version=10",
-    "--hash=abcdefg",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kGenHeaderDir,
-    kCppOutputPath};
-  Options options = Options::From(args);
-
-  // Set up input paths.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-  AddStubAidls(kImportedParcelables, kImportedInterfaces, kCppParcelableHeader);
-
-  // Check that we parse and generate code correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kCppOutputPath, kExpectedCppOutputWithVersionAndHash);
-  CheckFileContents(kGenInterfaceHeaderPath, kExpectedIHeaderOutputWithVersionAndHash);
-  CheckFileContents(kGenClientHeaderPath, kExpectedBpHeaderOutputWithVersionAndHash);
-  CheckFileContents(kGenServerHeaderPath, kExpectedBnHeaderOutputWithVersionAndHash);
-  CheckFileContents(options.DependencyFile(), kExpectedCppDepsOutput);
-}
-
-TEST_F(EndToEndTest, IPingResponderRust) {
-  using namespace ::android::aidl::test_data::ping_responder;
-
-  vector<string> args = {"aidl",
-                         "--lang=rust",
-                         "-d deps.P",
-                         "-I .",
-                         "-o",
-                         kRustOutputDirectory,
-                         CanonicalNameToPath(kCanonicalName, ".aidl")};
-  Options options = Options::From(args);
-
-  // Set up input paths.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse and generate code correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kRustOutputPath, kExpectedRustOutput);
-  CheckFileContents(options.DependencyFile(), kExpectedRustDepsOutput);
-}
-
-TEST_F(EndToEndTest, IPingResponderRust_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::ping_responder;
-
-  vector<string> args = {
-      "aidl", "--lang=rust",        "-d deps.P",
-      "-I .", "--version=10",       "--hash=abcdefg",
-      "-o",   kRustOutputDirectory, CanonicalNameToPath(kCanonicalName, ".aidl")};
-  Options options = Options::From(args);
-
-  // Set up input paths.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-  AddStubAidls(kImportedParcelables, kImportedInterfaces);
-
-  // Check that we parse and generate code correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kRustOutputPath, kExpectedRustOutputWithVersionAndHash);
-  CheckFileContents(options.DependencyFile(), kExpectedRustDepsOutput);
-}
-
-TEST_F(EndToEndTest, StringConstantsInCpp) {
-  using namespace ::android::aidl::test_data::string_constants;
-
-  vector<string> args = {
-    "aidl-cpp",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kGenHeaderDir,
-    kCppOutputPath};
-  Options options = Options::From(args);
-
-  // Set up input paths.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-
-  // Check that we parse and generate code correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kCppOutputPath, kExpectedCppOutput);
-  CheckFileContents(kGenInterfaceHeaderPath, kExpectedIHeaderOutput);
-}
-
-TEST_F(EndToEndTest, StringConstantsInJava) {
-  using namespace ::android::aidl::test_data::string_constants;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutput);
-}
-
-TEST_F(EndToEndTest, StringConstantsInRust) {
-  using namespace ::android::aidl::test_data::string_constants;
-
-  vector<string> args = {
-      "aidl", "--lang=rust",        "-b",
-      "-o",   kRustOutputDirectory, CanonicalNameToPath(kCanonicalName, ".aidl")};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kRustOutputPath, kExpectedRustOutput);
-}
-
-TEST_F(EndToEndTest, StringConstantsInCpp_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::string_constants;
-
-  vector<string> args = {
-    "aidl-cpp",
-    "--version=10",
-    "--hash=abcdefg",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kGenHeaderDir,
-    kCppOutputPath};
-  Options options = Options::From(args);
-
-  // Set up input paths.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-
-  // Check that we parse and generate code correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kCppOutputPath, kExpectedCppOutputWithVersionAndHash);
-  CheckFileContents(kGenInterfaceHeaderPath, kExpectedIHeaderOutputWithVersionAndHash);
-}
-
-TEST_F(EndToEndTest, StringConstantsInJava_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::string_constants;
-
-  vector<string> args = {
-    "aidl",
-    "-b",
-    "--version=10",
-    "--hash=abcdefg",
-    CanonicalNameToPath(kCanonicalName, ".aidl"),
-    kJavaOutputPath};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kJavaOutputPath, kExpectedJavaOutputWithVersionAndHash);
-}
-
-TEST_F(EndToEndTest, StringConstantsInRust_WithVersionAndHash) {
-  using namespace ::android::aidl::test_data::string_constants;
-
-  vector<string> args = {"aidl",
-                         "--lang=rust",
-                         "-b",
-                         "--version=10",
-                         "--hash=abcdefg",
-                         "-o",
-                         kRustOutputDirectory,
-                         CanonicalNameToPath(kCanonicalName, ".aidl")};
-  Options options = Options::From(args);
-
-  // Load up our fake file system with data.
-  io_delegate_.SetFileContents(CanonicalNameToPath(kCanonicalName, ".aidl"), kInterfaceDefinition);
-
-  // Check that we parse correctly.
-  EXPECT_EQ(android::aidl::compile_aidl(options, io_delegate_), 0);
-  CheckFileContents(kRustOutputPath, kExpectedRustOutputWithVersionAndHash);
-}
-
-}  // namespace aidl
-}  // namespace android
diff --git a/tests/golden_output/.clang-format b/tests/golden_output/.clang-format
new file mode 100644
index 0000000..1b1c664
--- /dev/null
+++ b/tests/golden_output/.clang-format
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+DisableFormat: true
+SortIncludes: false
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp.d
new file mode 100644
index 0000000..776a1ea
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/BackendType.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp.d
new file mode 100644
index 0000000..6ed9138
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/ByteEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp.d
new file mode 100644
index 0000000..c8de960
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp
@@ -0,0 +1 @@
+
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp.d
new file mode 100644
index 0000000..37ac9e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp
new file mode 100644
index 0000000..00fe303
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp
@@ -0,0 +1,124 @@
+#include <android/aidl/tests/INamedCallback.h>
+#include <android/aidl/tests/BpNamedCallback.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(NamedCallback, "android.aidl.tests.INamedCallback")
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BpNamedCallback.h>
+#include <android/aidl/tests/BnNamedCallback.h>
+#include <binder/Parcel.h>
+#include <android-base/macros.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BpNamedCallback::BpNamedCallback(const ::android::sp<::android::IBinder>& _aidl_impl)
+    : BpInterface<INamedCallback>(_aidl_impl){
+}
+
+::android::binder::Status BpNamedCallback::GetName(::android::String16* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnNamedCallback::TRANSACTION_GetName, _aidl_data, &_aidl_reply, 0);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && INamedCallback::getDefaultImpl())) {
+     return INamedCallback::getDefaultImpl()->GetName(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BnNamedCallback.h>
+#include <binder/Parcel.h>
+#include <binder/Stability.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BnNamedCallback::BnNamedCallback()
+{
+  ::android::internal::Stability::markCompilationUnit(this);
+}
+
+::android::status_t BnNamedCallback::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  switch (_aidl_code) {
+  case BnNamedCallback::TRANSACTION_GetName:
+  {
+    ::android::String16 _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(GetName(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  default:
+  {
+    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
+  }
+  break;
+  }
+  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
+    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
+  }
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp.d
new file mode 100644
index 0000000..9a61844
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp
new file mode 100644
index 0000000..c66d7b0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp
@@ -0,0 +1,124 @@
+#include <android/aidl/tests/INewName.h>
+#include <android/aidl/tests/BpNewName.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(NewName, "android.aidl.tests.IOldName")
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BpNewName.h>
+#include <android/aidl/tests/BnNewName.h>
+#include <binder/Parcel.h>
+#include <android-base/macros.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BpNewName::BpNewName(const ::android::sp<::android::IBinder>& _aidl_impl)
+    : BpInterface<INewName>(_aidl_impl){
+}
+
+::android::binder::Status BpNewName::RealName(::android::String16* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnNewName::TRANSACTION_RealName, _aidl_data, &_aidl_reply, 0);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && INewName::getDefaultImpl())) {
+     return INewName::getDefaultImpl()->RealName(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BnNewName.h>
+#include <binder/Parcel.h>
+#include <binder/Stability.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BnNewName::BnNewName()
+{
+  ::android::internal::Stability::markCompilationUnit(this);
+}
+
+::android::status_t BnNewName::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  switch (_aidl_code) {
+  case BnNewName::TRANSACTION_RealName:
+  {
+    ::android::String16 _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(RealName(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  default:
+  {
+    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
+  }
+  break;
+  }
+  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
+    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
+  }
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp.d
new file mode 100644
index 0000000..b0f129f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp
new file mode 100644
index 0000000..7497f49
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp
@@ -0,0 +1,124 @@
+#include <android/aidl/tests/IOldName.h>
+#include <android/aidl/tests/BpOldName.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(OldName, "android.aidl.tests.IOldName")
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BpOldName.h>
+#include <android/aidl/tests/BnOldName.h>
+#include <binder/Parcel.h>
+#include <android-base/macros.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BpOldName::BpOldName(const ::android::sp<::android::IBinder>& _aidl_impl)
+    : BpInterface<IOldName>(_aidl_impl){
+}
+
+::android::binder::Status BpOldName::RealName(::android::String16* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnOldName::TRANSACTION_RealName, _aidl_data, &_aidl_reply, 0);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IOldName::getDefaultImpl())) {
+     return IOldName::getDefaultImpl()->RealName(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BnOldName.h>
+#include <binder/Parcel.h>
+#include <binder/Stability.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BnOldName::BnOldName()
+{
+  ::android::internal::Stability::markCompilationUnit(this);
+}
+
+::android::status_t BnOldName::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  switch (_aidl_code) {
+  case BnOldName::TRANSACTION_RealName:
+  {
+    ::android::String16 _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(RealName(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  default:
+  {
+    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
+  }
+  break;
+  }
+  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
+    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
+  }
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp.d
new file mode 100644
index 0000000..ed3c327
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
new file mode 100644
index 0000000..3918003
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
@@ -0,0 +1,3405 @@
+#include <android/aidl/tests/ITestService.h>
+#include <android/aidl/tests/BpTestService.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(TestService, "android.aidl.tests.ITestService")
+
+const ::android::String16& ITestService::STRING_TEST_CONSTANT() {
+  static const ::android::String16 value(::android::String16("foo"));
+  return value;
+}
+
+const ::android::String16& ITestService::STRING_TEST_CONSTANT2() {
+  static const ::android::String16 value(::android::String16("bar"));
+  return value;
+}
+
+const ::std::string& ITestService::STRING_TEST_CONSTANT_UTF8() {
+  static const ::std::string value("baz");
+  return value;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BpTestService.h>
+#include <android/aidl/tests/BnTestService.h>
+#include <binder/Parcel.h>
+#include <android-base/macros.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BpTestService::BpTestService(const ::android::sp<::android::IBinder>& _aidl_impl)
+    : BpInterface<ITestService>(_aidl_impl){
+}
+
+::android::binder::Status BpTestService::UnimplementedMethod(int32_t arg, int32_t* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32(arg);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_UnimplementedMethod, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->UnimplementedMethod(arg, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::TestOneway() {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_TestOneway, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY | ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->TestOneway();
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatBoolean(bool token, bool* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeBool(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatBoolean, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatBoolean(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readBool(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatByte(int8_t token, int8_t* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeByte(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatByte, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatByte(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readByte(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatChar(char16_t token, char16_t* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeChar(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatChar, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatChar(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readChar(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatInt(int32_t token, int32_t* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatInt, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatInt(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatLong(int64_t token, int64_t* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt64(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatLong, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatLong(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt64(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatFloat(float token, float* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeFloat(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatFloat, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatFloat(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readFloat(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatDouble(double token, double* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeDouble(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatDouble, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatDouble(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readDouble(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatString(const ::android::String16& token, ::android::String16* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatString(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatByteEnum(::android::aidl::tests::ByteEnum token, ::android::aidl::tests::ByteEnum* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeByte(static_cast<int8_t>(token));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatByteEnum, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatByteEnum(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readByte(reinterpret_cast<int8_t *>(_aidl_return));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatIntEnum(::android::aidl::tests::IntEnum token, ::android::aidl::tests::IntEnum* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32(static_cast<int32_t>(token));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatIntEnum, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatIntEnum(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32(reinterpret_cast<int32_t *>(_aidl_return));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatLongEnum(::android::aidl::tests::LongEnum token, ::android::aidl::tests::LongEnum* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt64(static_cast<int64_t>(token));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatLongEnum, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatLongEnum(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt64(reinterpret_cast<int64_t *>(_aidl_return));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseBoolean(const ::std::vector<bool>& input, ::std::vector<bool>* repeated, ::std::vector<bool>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeBoolVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseBoolean, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseBoolean(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readBoolVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readBoolVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseByte(const ::std::vector<uint8_t>& input, ::std::vector<uint8_t>* repeated, ::std::vector<uint8_t>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeByteVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseByte, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseByte(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readByteVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readByteVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseChar(const ::std::vector<char16_t>& input, ::std::vector<char16_t>* repeated, ::std::vector<char16_t>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeCharVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseChar, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseChar(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readCharVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readCharVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseInt(const ::std::vector<int32_t>& input, ::std::vector<int32_t>* repeated, ::std::vector<int32_t>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseInt, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseInt(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseLong(const ::std::vector<int64_t>& input, ::std::vector<int64_t>* repeated, ::std::vector<int64_t>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt64Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseLong, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseLong(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt64Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readInt64Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseFloat(const ::std::vector<float>& input, ::std::vector<float>* repeated, ::std::vector<float>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeFloatVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseFloat, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseFloat(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readFloatVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readFloatVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseDouble(const ::std::vector<double>& input, ::std::vector<double>* repeated, ::std::vector<double>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeDoubleVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseDouble, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseDouble(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readDoubleVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readDoubleVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseString(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* repeated, ::std::vector<::android::String16>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseString(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseByteEnum(const ::std::vector<::android::aidl::tests::ByteEnum>& input, ::std::vector<::android::aidl::tests::ByteEnum>* repeated, ::std::vector<::android::aidl::tests::ByteEnum>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeEnumVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseByteEnum, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseByteEnum(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseIntEnum(const ::std::vector<::android::aidl::tests::IntEnum>& input, ::std::vector<::android::aidl::tests::IntEnum>* repeated, ::std::vector<::android::aidl::tests::IntEnum>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeEnumVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseIntEnum, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseIntEnum(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseLongEnum(const ::std::vector<::android::aidl::tests::LongEnum>& input, ::std::vector<::android::aidl::tests::LongEnum>* repeated, ::std::vector<::android::aidl::tests::LongEnum>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeEnumVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseLongEnum, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseLongEnum(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::GetOtherTestService(const ::android::String16& name, ::android::sp<::android::aidl::tests::INamedCallback>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16(name);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_GetOtherTestService, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->GetOtherTestService(name, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::VerifyName(const ::android::sp<::android::aidl::tests::INamedCallback>& service, const ::android::String16& name, bool* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeStrongBinder(::android::aidl::tests::INamedCallback::asBinder(service));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16(name);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_VerifyName, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->VerifyName(service, name, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readBool(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseStringList(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* repeated, ::std::vector<::android::String16>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseStringList, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseStringList(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatParcelFileDescriptor(const ::android::os::ParcelFileDescriptor& read, ::android::os::ParcelFileDescriptor* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeParcelable(read);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatParcelFileDescriptor, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatParcelFileDescriptor(read, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelable(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseParcelFileDescriptorArray(const ::std::vector<::android::os::ParcelFileDescriptor>& input, ::std::vector<::android::os::ParcelFileDescriptor>* repeated, ::std::vector<::android::os::ParcelFileDescriptor>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeParcelableVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseParcelFileDescriptorArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseParcelFileDescriptorArray(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelableVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelableVector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ThrowServiceException(int32_t code) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32(code);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ThrowServiceException, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ThrowServiceException(code);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableIntArray(const ::std::optional<::std::vector<int32_t>>& input, ::std::optional<::std::vector<int32_t>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableIntArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableIntArray(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableByteEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeEnumVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableByteEnumArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableByteEnumArray(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableIntEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeEnumVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableIntEnumArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableIntEnumArray(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableLongEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeEnumVector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableLongEnumArray, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableLongEnumArray(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableString(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableString(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableStringList(const ::std::optional<::std::vector<::std::optional<::android::String16>>>& input, ::std::optional<::std::vector<::std::optional<::android::String16>>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableStringList, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableStringList(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableParcelable(const ::std::optional<::android::aidl::tests::StructuredParcelable>& input, ::std::optional<::android::aidl::tests::StructuredParcelable>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeNullableParcelable(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableParcelable, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableParcelable(input, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelable(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::TakesAnIBinder(const ::android::sp<::android::IBinder>& input) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeStrongBinder(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_TakesAnIBinder, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->TakesAnIBinder(input);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::TakesANullableIBinder(const ::android::sp<::android::IBinder>& input) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeStrongBinder(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_TakesANullableIBinder, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->TakesANullableIBinder(input);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatUtf8CppString(const ::std::string& token, ::std::string* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatUtf8CppString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatUtf8CppString(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::RepeatNullableUtf8CppString(const ::std::optional<::std::string>& token, ::std::optional<::std::string>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(token);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_RepeatNullableUtf8CppString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->RepeatNullableUtf8CppString(token, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseUtf8CppString(const ::std::vector<::std::string>& input, ::std::vector<::std::string>* repeated, ::std::vector<::std::string>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeUtf8VectorAsUtf16Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseUtf8CppString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseUtf8CppString(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8VectorFromUtf16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8VectorFromUtf16Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseNullableUtf8CppString(const ::std::optional<::std::vector<::std::optional<::std::string>>>& input, ::std::optional<::std::vector<::std::optional<::std::string>>>* repeated, ::std::optional<::std::vector<::std::optional<::std::string>>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeUtf8VectorAsUtf16Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeVectorSize(*repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseNullableUtf8CppString, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseNullableUtf8CppString(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8VectorFromUtf16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8VectorFromUtf16Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::ReverseUtf8CppStringList(const ::std::optional<::std::vector<::std::optional<::std::string>>>& input, ::std::optional<::std::vector<::std::optional<::std::string>>>* repeated, ::std::optional<::std::vector<::std::optional<::std::string>>>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeUtf8VectorAsUtf16Vector(input);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_ReverseUtf8CppStringList, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->ReverseUtf8CppStringList(input, repeated, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8VectorFromUtf16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readUtf8VectorFromUtf16Vector(repeated);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::GetCallback(bool return_null, ::android::sp<::android::aidl::tests::INamedCallback>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeBool(return_null);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_GetCallback, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->GetCallback(return_null, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::FillOutStructuredParcelable(::android::aidl::tests::StructuredParcelable* parcel) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeParcelable(*parcel);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_FillOutStructuredParcelable, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->FillOutStructuredParcelable(parcel);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelable(parcel);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_GetOldNameInterface, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->GetOldNameInterface(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_GetNewNameInterface, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->GetNewNameInterface(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_GetCppJavaTests, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->GetCppJavaTests(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+::android::binder::Status BpTestService::getBackendType(::android::aidl::tests::BackendType* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  _aidl_data.markSensitive();
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_getBackendType, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+     return ITestService::getDefaultImpl()->getBackendType(_aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readByte(reinterpret_cast<int8_t *>(_aidl_return));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  return _aidl_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/BnTestService.h>
+#include <binder/Parcel.h>
+#include <binder/Stability.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BnTestService::BnTestService()
+{
+  ::android::internal::Stability::markCompilationUnit(this);
+}
+
+::android::status_t BnTestService::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  switch (_aidl_code) {
+  case BnTestService::TRANSACTION_UnimplementedMethod:
+  {
+    int32_t in_arg;
+    int32_t _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32(&in_arg);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(UnimplementedMethod(in_arg, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_TestOneway:
+  {
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(TestOneway());
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatBoolean:
+  {
+    bool in_token;
+    bool _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readBool(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatBoolean(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeBool(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatByte:
+  {
+    int8_t in_token;
+    int8_t _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readByte(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatByte(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeByte(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatChar:
+  {
+    char16_t in_token;
+    char16_t _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readChar(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatChar(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeChar(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatInt:
+  {
+    int32_t in_token;
+    int32_t _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatInt(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatLong:
+  {
+    int64_t in_token;
+    int64_t _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt64(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatLong(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt64(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatFloat:
+  {
+    float in_token;
+    float _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readFloat(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatFloat(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeFloat(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatDouble:
+  {
+    double in_token;
+    double _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readDouble(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatDouble(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeDouble(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatString:
+  {
+    ::android::String16 in_token;
+    ::android::String16 _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatString(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatByteEnum:
+  {
+    ::android::aidl::tests::ByteEnum in_token;
+    ::android::aidl::tests::ByteEnum _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readByte(reinterpret_cast<int8_t *>(&in_token));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatByteEnum(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeByte(static_cast<int8_t>(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatIntEnum:
+  {
+    ::android::aidl::tests::IntEnum in_token;
+    ::android::aidl::tests::IntEnum _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32(reinterpret_cast<int32_t *>(&in_token));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatIntEnum(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32(static_cast<int32_t>(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatLongEnum:
+  {
+    ::android::aidl::tests::LongEnum in_token;
+    ::android::aidl::tests::LongEnum _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt64(reinterpret_cast<int64_t *>(&in_token));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatLongEnum(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt64(static_cast<int64_t>(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseBoolean:
+  {
+    ::std::vector<bool> in_input;
+    ::std::vector<bool> out_repeated;
+    ::std::vector<bool> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readBoolVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseBoolean(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeBoolVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeBoolVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseByte:
+  {
+    ::std::vector<uint8_t> in_input;
+    ::std::vector<uint8_t> out_repeated;
+    ::std::vector<uint8_t> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readByteVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseByte(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeByteVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeByteVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseChar:
+  {
+    ::std::vector<char16_t> in_input;
+    ::std::vector<char16_t> out_repeated;
+    ::std::vector<char16_t> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readCharVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseChar(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeCharVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeCharVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseInt:
+  {
+    ::std::vector<int32_t> in_input;
+    ::std::vector<int32_t> out_repeated;
+    ::std::vector<int32_t> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseInt(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseLong:
+  {
+    ::std::vector<int64_t> in_input;
+    ::std::vector<int64_t> out_repeated;
+    ::std::vector<int64_t> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt64Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseLong(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt64Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt64Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseFloat:
+  {
+    ::std::vector<float> in_input;
+    ::std::vector<float> out_repeated;
+    ::std::vector<float> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readFloatVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseFloat(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeFloatVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeFloatVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseDouble:
+  {
+    ::std::vector<double> in_input;
+    ::std::vector<double> out_repeated;
+    ::std::vector<double> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readDoubleVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseDouble(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeDoubleVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeDoubleVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseString:
+  {
+    ::std::vector<::android::String16> in_input;
+    ::std::vector<::android::String16> out_repeated;
+    ::std::vector<::android::String16> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseString(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseByteEnum:
+  {
+    ::std::vector<::android::aidl::tests::ByteEnum> in_input;
+    ::std::vector<::android::aidl::tests::ByteEnum> out_repeated;
+    ::std::vector<::android::aidl::tests::ByteEnum> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readEnumVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseByteEnum(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseIntEnum:
+  {
+    ::std::vector<::android::aidl::tests::IntEnum> in_input;
+    ::std::vector<::android::aidl::tests::IntEnum> out_repeated;
+    ::std::vector<::android::aidl::tests::IntEnum> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readEnumVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseIntEnum(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseLongEnum:
+  {
+    ::std::vector<::android::aidl::tests::LongEnum> in_input;
+    ::std::vector<::android::aidl::tests::LongEnum> out_repeated;
+    ::std::vector<::android::aidl::tests::LongEnum> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readEnumVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseLongEnum(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_GetOtherTestService:
+  {
+    ::android::String16 in_name;
+    ::android::sp<::android::aidl::tests::INamedCallback> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16(&in_name);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(GetOtherTestService(in_name, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeStrongBinder(::android::aidl::tests::INamedCallback::asBinder(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_VerifyName:
+  {
+    ::android::sp<::android::aidl::tests::INamedCallback> in_service;
+    ::android::String16 in_name;
+    bool _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readStrongBinder(&in_service);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16(&in_name);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(VerifyName(in_service, in_name, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeBool(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseStringList:
+  {
+    ::std::vector<::android::String16> in_input;
+    ::std::vector<::android::String16> out_repeated;
+    ::std::vector<::android::String16> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseStringList(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatParcelFileDescriptor:
+  {
+    ::android::os::ParcelFileDescriptor in_read;
+    ::android::os::ParcelFileDescriptor _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelable(&in_read);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatParcelFileDescriptor(in_read, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeParcelable(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseParcelFileDescriptorArray:
+  {
+    ::std::vector<::android::os::ParcelFileDescriptor> in_input;
+    ::std::vector<::android::os::ParcelFileDescriptor> out_repeated;
+    ::std::vector<::android::os::ParcelFileDescriptor> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelableVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseParcelFileDescriptorArray(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeParcelableVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeParcelableVector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ThrowServiceException:
+  {
+    int32_t in_code;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32(&in_code);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ThrowServiceException(in_code));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableIntArray:
+  {
+    ::std::optional<::std::vector<int32_t>> in_input;
+    ::std::optional<::std::vector<int32_t>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableIntArray(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableByteEnumArray:
+  {
+    ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>> in_input;
+    ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readEnumVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableByteEnumArray(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableIntEnumArray:
+  {
+    ::std::optional<::std::vector<::android::aidl::tests::IntEnum>> in_input;
+    ::std::optional<::std::vector<::android::aidl::tests::IntEnum>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readEnumVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableIntEnumArray(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableLongEnumArray:
+  {
+    ::std::optional<::std::vector<::android::aidl::tests::LongEnum>> in_input;
+    ::std::optional<::std::vector<::android::aidl::tests::LongEnum>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readEnumVector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableLongEnumArray(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableString:
+  {
+    ::std::optional<::android::String16> in_input;
+    ::std::optional<::android::String16> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableString(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableStringList:
+  {
+    ::std::optional<::std::vector<::std::optional<::android::String16>>> in_input;
+    ::std::optional<::std::vector<::std::optional<::android::String16>>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableStringList(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableParcelable:
+  {
+    ::std::optional<::android::aidl::tests::StructuredParcelable> in_input;
+    ::std::optional<::android::aidl::tests::StructuredParcelable> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelable(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableParcelable(in_input, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeNullableParcelable(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_TakesAnIBinder:
+  {
+    ::android::sp<::android::IBinder> in_input;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readStrongBinder(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(TakesAnIBinder(in_input));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_TakesANullableIBinder:
+  {
+    ::android::sp<::android::IBinder> in_input;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readNullableStrongBinder(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(TakesANullableIBinder(in_input));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatUtf8CppString:
+  {
+    ::std::string in_token;
+    ::std::string _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatUtf8CppString(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_RepeatNullableUtf8CppString:
+  {
+    ::std::optional<::std::string> in_token;
+    ::std::optional<::std::string> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_token);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(RepeatNullableUtf8CppString(in_token, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseUtf8CppString:
+  {
+    ::std::vector<::std::string> in_input;
+    ::std::vector<::std::string> out_repeated;
+    ::std::vector<::std::string> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readUtf8VectorFromUtf16Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseUtf8CppString(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8VectorAsUtf16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8VectorAsUtf16Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseNullableUtf8CppString:
+  {
+    ::std::optional<::std::vector<::std::optional<::std::string>>> in_input;
+    ::std::optional<::std::vector<::std::optional<::std::string>>> out_repeated;
+    ::std::optional<::std::vector<::std::optional<::std::string>>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readUtf8VectorFromUtf16Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.resizeOutVector(&out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseNullableUtf8CppString(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8VectorAsUtf16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8VectorAsUtf16Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_ReverseUtf8CppStringList:
+  {
+    ::std::optional<::std::vector<::std::optional<::std::string>>> in_input;
+    ::std::optional<::std::vector<::std::optional<::std::string>>> out_repeated;
+    ::std::optional<::std::vector<::std::optional<::std::string>>> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readUtf8VectorFromUtf16Vector(&in_input);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(ReverseUtf8CppStringList(in_input, &out_repeated, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8VectorAsUtf16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeUtf8VectorAsUtf16Vector(out_repeated);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_GetCallback:
+  {
+    bool in_return_null;
+    ::android::sp<::android::aidl::tests::INamedCallback> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readBool(&in_return_null);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(GetCallback(in_return_null, &_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeStrongBinder(::android::aidl::tests::INamedCallback::asBinder(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_FillOutStructuredParcelable:
+  {
+    ::android::aidl::tests::StructuredParcelable in_parcel;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelable(&in_parcel);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    ::android::binder::Status _aidl_status(FillOutStructuredParcelable(&in_parcel));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeParcelable(in_parcel);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_GetOldNameInterface:
+  {
+    ::android::sp<::android::aidl::tests::IOldName> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(GetOldNameInterface(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeStrongBinder(::android::aidl::tests::IOldName::asBinder(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_GetNewNameInterface:
+  {
+    ::android::sp<::android::aidl::tests::INewName> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(GetNewNameInterface(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeStrongBinder(::android::aidl::tests::INewName::asBinder(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_GetCppJavaTests:
+  {
+    ::android::sp<::android::IBinder> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(GetCppJavaTests(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeStrongBinder(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  case BnTestService::TRANSACTION_getBackendType:
+  {
+    ::android::aidl::tests::BackendType _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::binder::Status _aidl_status(getBackendType(&_aidl_return));
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeByte(static_cast<int8_t>(_aidl_return));
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  default:
+  {
+    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
+  }
+  break;
+  }
+  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
+    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
+  }
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d
new file mode 100644
index 0000000..fef37e7
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d
@@ -0,0 +1,10 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ITestService.aidl \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp.d
new file mode 100644
index 0000000..5cb6ac6
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/IntEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp.d
new file mode 100644
index 0000000..881dfcf
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/LongEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp
new file mode 100644
index 0000000..f80a21d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp
@@ -0,0 +1,47 @@
+#include <android/aidl/tests/OtherParcelableForToString.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+::android::status_t OtherParcelableForToString::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  [[maybe_unused]] size_t _aidl_start_pos = _aidl_parcel->dataPosition();
+  int32_t _aidl_parcelable_raw_size = _aidl_parcel->readInt32();
+  if (_aidl_parcelable_raw_size < 0) return ::android::BAD_VALUE;
+  [[maybe_unused]] size_t _aidl_parcelable_size = static_cast<size_t>(_aidl_parcelable_raw_size);
+  if (_aidl_start_pos > SIZE_MAX - _aidl_parcelable_size) return ::android::BAD_VALUE;
+  ;
+  _aidl_ret_status = _aidl_parcel->readString16(&field);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  return _aidl_ret_status;
+}
+
+::android::status_t OtherParcelableForToString::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  auto _aidl_start_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->writeInt32(0);;
+  _aidl_ret_status = _aidl_parcel->writeString16(field);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  auto _aidl_end_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->setDataPosition(_aidl_start_pos);
+  _aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);
+  _aidl_parcel->setDataPosition(_aidl_end_pos);;
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp.d
new file mode 100644
index 0000000..3d6fc45
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/OtherParcelableForToString.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp
new file mode 100644
index 0000000..03c85a8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp
@@ -0,0 +1,311 @@
+#include <android/aidl/tests/ParcelableForToString.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+::android::status_t ParcelableForToString::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  [[maybe_unused]] size_t _aidl_start_pos = _aidl_parcel->dataPosition();
+  int32_t _aidl_parcelable_raw_size = _aidl_parcel->readInt32();
+  if (_aidl_parcelable_raw_size < 0) return ::android::BAD_VALUE;
+  [[maybe_unused]] size_t _aidl_parcelable_size = static_cast<size_t>(_aidl_parcelable_raw_size);
+  if (_aidl_start_pos > SIZE_MAX - _aidl_parcelable_size) return ::android::BAD_VALUE;
+  ;
+  _aidl_ret_status = _aidl_parcel->readInt32(&intValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32Vector(&intArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64(&longValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64Vector(&longArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readDouble(&doubleValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readDoubleVector(&doubleArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readFloat(&floatValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readFloatVector(&floatArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readByte(&byteValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readByteVector(&byteArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readBool(&booleanValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readBoolVector(&booleanArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16(&stringValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16Vector(&stringArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16Vector(&stringList);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelable(&parcelableValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelableVector(&parcelableArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&enumValue));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readEnumVector(&enumArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16Vector(&nullArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16Vector(&nullList);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelable(&parcelableGeneric);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelable(&unionValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  return _aidl_ret_status;
+}
+
+::android::status_t ParcelableForToString::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  auto _aidl_start_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->writeInt32(0);;
+  _aidl_ret_status = _aidl_parcel->writeInt32(intValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32Vector(intArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64(longValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64Vector(longArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeDouble(doubleValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeDoubleVector(doubleArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeFloat(floatValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeFloatVector(floatArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeByte(byteValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeByteVector(byteArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeBool(booleanValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeBoolVector(booleanArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16(stringValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16Vector(stringArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16Vector(stringList);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeParcelable(parcelableValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeParcelableVector(parcelableArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(enumValue));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeEnumVector(enumArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16Vector(nullArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16Vector(nullList);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeParcelable(parcelableGeneric);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeParcelable(unionValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  auto _aidl_end_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->setDataPosition(_aidl_start_pos);
+  _aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);
+  _aidl_parcel->setDataPosition(_aidl_end_pos);;
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp.d
new file mode 100644
index 0000000..be201f2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/ParcelableForToString.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp
new file mode 100644
index 0000000..f9a6cce
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp
@@ -0,0 +1,671 @@
+#include <android/aidl/tests/StructuredParcelable.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+::android::status_t StructuredParcelable::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  [[maybe_unused]] size_t _aidl_start_pos = _aidl_parcel->dataPosition();
+  int32_t _aidl_parcelable_raw_size = _aidl_parcel->readInt32();
+  if (_aidl_parcelable_raw_size < 0) return ::android::BAD_VALUE;
+  [[maybe_unused]] size_t _aidl_parcelable_size = static_cast<size_t>(_aidl_parcelable_raw_size);
+  if (_aidl_start_pos > SIZE_MAX - _aidl_parcelable_size) return ::android::BAD_VALUE;
+  ;
+  _aidl_ret_status = _aidl_parcel->readInt32Vector(&shouldContainThreeFs);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&f);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readUtf8FromUtf16(&shouldBeJerry);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readByte(reinterpret_cast<int8_t *>(&shouldBeByteBar));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&shouldBeIntBar));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64(reinterpret_cast<int64_t *>(&shouldBeLongBar));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readEnumVector(&shouldContainTwoByteFoos);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readEnumVector(&shouldContainTwoIntFoos);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readEnumVector(&shouldContainTwoLongFoos);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16(&stringDefaultsToFoo);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readByte(&byteDefaultsToFour);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&intDefaultsToFive);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64(&longDefaultsToNegativeSeven);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readBool(&booleanDefaultsToTrue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readChar(&charDefaultsToC);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readFloat(&floatDefaultsToPi);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readDouble(&doubleWithDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32Vector(&arrayDefaultsTo123);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32Vector(&arrayDefaultsToEmpty);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readBool(&boolDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readByte(&byteDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&intDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64(&longDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readFloat(&floatDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readDouble(&doubleDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readDouble(&checkDoubleFromFloat);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readString16Vector(&checkStringArray1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readUtf8VectorFromUtf16Vector(&checkStringArray2);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&int32_min);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&int32_max);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64(&int64_max);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&hexInt32_neg_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readNullableStrongBinder(&ibinder);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32Vector(&int32_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt64Vector(&int64_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&hexInt32_pos_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&hexInt64_pos_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_1));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_2));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_3));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_4));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_5));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_6));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_7));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_8));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_9));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&const_exprs_10));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readUtf8FromUtf16(&addString1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readUtf8FromUtf16(&addString2);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&shouldSetBit0AndBit2);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelable(&u);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelable(&shouldBeConstS1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&defaultWithFoo));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  return _aidl_ret_status;
+}
+
+::android::status_t StructuredParcelable::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  auto _aidl_start_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->writeInt32(0);;
+  _aidl_ret_status = _aidl_parcel->writeInt32Vector(shouldContainThreeFs);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(f);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeUtf8AsUtf16(shouldBeJerry);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeByte(static_cast<int8_t>(shouldBeByteBar));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(shouldBeIntBar));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64(static_cast<int64_t>(shouldBeLongBar));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeEnumVector(shouldContainTwoByteFoos);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeEnumVector(shouldContainTwoIntFoos);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeEnumVector(shouldContainTwoLongFoos);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16(stringDefaultsToFoo);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeByte(byteDefaultsToFour);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(intDefaultsToFive);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64(longDefaultsToNegativeSeven);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeBool(booleanDefaultsToTrue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeChar(charDefaultsToC);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeFloat(floatDefaultsToPi);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeDouble(doubleWithDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32Vector(arrayDefaultsTo123);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32Vector(arrayDefaultsToEmpty);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeBool(boolDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeByte(byteDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(intDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64(longDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeFloat(floatDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeDouble(doubleDefault);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeDouble(checkDoubleFromFloat);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeString16Vector(checkStringArray1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeUtf8VectorAsUtf16Vector(checkStringArray2);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(int32_min);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(int32_max);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64(int64_max);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(hexInt32_neg_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeStrongBinder(ibinder);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32Vector(int32_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt64Vector(int64_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(hexInt32_pos_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(hexInt64_pos_1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_1));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_2));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_3));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_4));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_5));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_6));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_7));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_8));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_9));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(const_exprs_10));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeUtf8AsUtf16(addString1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeUtf8AsUtf16(addString2);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(shouldSetBit0AndBit2);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeNullableParcelable(u);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeNullableParcelable(shouldBeConstS1);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(static_cast<int32_t>(defaultWithFoo));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  auto _aidl_end_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->setDataPosition(_aidl_start_pos);
+  _aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);
+  _aidl_parcel->setDataPosition(_aidl_end_pos);;
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp.d
new file mode 100644
index 0000000..912494d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/StructuredParcelable.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp
new file mode 100644
index 0000000..06a3f37
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp
@@ -0,0 +1,112 @@
+#include <android/aidl/tests/Union.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+const ::std::string& Union::S1() {
+  static const ::std::string value("a string constant in union");
+  return value;
+}
+
+::android::status_t Union::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_tag)) != ::android::OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case ns: {
+    ::std::vector<int32_t> _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt32Vector(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::std::vector<int32_t>>) {
+      set<ns>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<ns>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case n: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<n>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<n>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case m: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<m>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<m>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case s: {
+    ::std::string _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readUtf8FromUtf16(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::std::string>) {
+      set<s>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<s>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case ibinder: {
+    ::android::sp<::android::IBinder> _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readNullableStrongBinder(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::android::sp<::android::IBinder>>) {
+      set<ibinder>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<ibinder>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case ss: {
+    ::std::vector<::std::string> _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readUtf8VectorFromUtf16Vector(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::std::vector<::std::string>>) {
+      set<ss>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<ss>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case be: {
+    ::android::aidl::tests::ByteEnum _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readByte(reinterpret_cast<int8_t *>(&_aidl_value))) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::android::aidl::tests::ByteEnum>) {
+      set<be>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<be>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  }
+  return ::android::BAD_VALUE;
+}
+
+::android::status_t Union::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = _aidl_parcel->writeInt32(getTag());
+  if (_aidl_ret_status != ::android::OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case ns: return _aidl_parcel->writeInt32Vector(get<ns>());
+  case n: return _aidl_parcel->writeInt32(get<n>());
+  case m: return _aidl_parcel->writeInt32(get<m>());
+  case s: return _aidl_parcel->writeUtf8AsUtf16(get<s>());
+  case ibinder: return _aidl_parcel->writeStrongBinder(get<ibinder>());
+  case ss: return _aidl_parcel->writeUtf8VectorAsUtf16Vector(get<ss>());
+  case be: return _aidl_parcel->writeByte(static_cast<int8_t>(get<be>()));
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp.d
new file mode 100644
index 0000000..69ddafa
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/Union.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp
new file mode 100644
index 0000000..5fb2ddf
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp
@@ -0,0 +1,52 @@
+#include <android/aidl/tests/UnionWithFd.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+::android::status_t UnionWithFd::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_tag)) != ::android::OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case num: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<num>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<num>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case pfd: {
+    ::android::os::ParcelFileDescriptor _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readParcelable(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::android::os::ParcelFileDescriptor>) {
+      set<pfd>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<pfd>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  }
+  return ::android::BAD_VALUE;
+}
+
+::android::status_t UnionWithFd::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = _aidl_parcel->writeInt32(getTag());
+  if (_aidl_ret_status != ::android::OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case num: return _aidl_parcel->writeInt32(get<num>());
+  case pfd: return _aidl_parcel->writeParcelable(get<pfd>());
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp.d
new file mode 100644
index 0000000..0ac1ec4
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/UnionWithFd.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/UnionWithFd.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp
new file mode 100644
index 0000000..9c3493a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp
@@ -0,0 +1,56 @@
+#include <android/aidl/tests/unions/EnumUnion.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+namespace unions {
+
+::android::status_t EnumUnion::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_tag)) != ::android::OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case intEnum: {
+    ::android::aidl::tests::IntEnum _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt32(reinterpret_cast<int32_t *>(&_aidl_value))) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::android::aidl::tests::IntEnum>) {
+      set<intEnum>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<intEnum>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case longEnum: {
+    ::android::aidl::tests::LongEnum _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt64(reinterpret_cast<int64_t *>(&_aidl_value))) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::android::aidl::tests::LongEnum>) {
+      set<longEnum>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<longEnum>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  }
+  return ::android::BAD_VALUE;
+}
+
+::android::status_t EnumUnion::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = _aidl_parcel->writeInt32(getTag());
+  if (_aidl_ret_status != ::android::OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case intEnum: return _aidl_parcel->writeInt32(static_cast<int32_t>(get<intEnum>()));
+  case longEnum: return _aidl_parcel->writeInt64(static_cast<int64_t>(get<longEnum>()));
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace unions
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp.d
new file mode 100644
index 0000000..b8e1647
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/EnumUnion.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BackendType.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BackendType.h
new file mode 100644
index 0000000..79d27b8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BackendType.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <array>
+#include <binder/Enums.h>
+#include <cstdint>
+#include <string>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+enum class BackendType : int8_t {
+  CPP = 0,
+  JAVA = 1,
+  NDK = 2,
+  RUST = 3,
+};
+
+static inline std::string toString(BackendType val) {
+  switch(val) {
+  case BackendType::CPP:
+    return "CPP";
+  case BackendType::JAVA:
+    return "JAVA";
+  case BackendType::NDK:
+    return "NDK";
+  case BackendType::RUST:
+    return "RUST";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+namespace android {
+
+namespace internal {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<::android::aidl::tests::BackendType, 4> enum_values<::android::aidl::tests::BackendType> = {
+  ::android::aidl::tests::BackendType::CPP,
+  ::android::aidl::tests::BackendType::JAVA,
+  ::android::aidl::tests::BackendType::NDK,
+  ::android::aidl::tests::BackendType::RUST,
+};
+#pragma clang diagnostic pop
+
+}  // namespace internal
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnBackendType.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnBackendType.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnBackendType.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnByteEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnByteEnum.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnByteEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnConstantExpressionEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnConstantExpressionEnum.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnConstantExpressionEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnGenericStructuredParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnGenericStructuredParcelable.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnGenericStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnIntEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnIntEnum.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnIntEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnLongEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnLongEnum.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnLongEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnNamedCallback.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnNamedCallback.h
new file mode 100644
index 0000000..85c0443
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnNamedCallback.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/tests/INamedCallback.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BnNamedCallback : public ::android::BnInterface<INamedCallback> {
+public:
+  static constexpr uint32_t TRANSACTION_GetName = ::android::IBinder::FIRST_CALL_TRANSACTION + 0;
+  explicit BnNamedCallback();
+  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
+};  // class BnNamedCallback
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnNewName.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnNewName.h
new file mode 100644
index 0000000..fecf1a6
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnNewName.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/tests/INewName.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BnNewName : public ::android::BnInterface<INewName> {
+public:
+  static constexpr uint32_t TRANSACTION_RealName = ::android::IBinder::FIRST_CALL_TRANSACTION + 0;
+  explicit BnNewName();
+  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
+};  // class BnNewName
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnOldName.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnOldName.h
new file mode 100644
index 0000000..a0381ac
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnOldName.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/tests/IOldName.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BnOldName : public ::android::BnInterface<IOldName> {
+public:
+  static constexpr uint32_t TRANSACTION_RealName = ::android::IBinder::FIRST_CALL_TRANSACTION + 0;
+  explicit BnOldName();
+  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
+};  // class BnOldName
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnOtherParcelableForToString.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnOtherParcelableForToString.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnOtherParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnParcelableForToString.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnParcelableForToString.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnStructuredParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnStructuredParcelable.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
new file mode 100644
index 0000000..ca25ef3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
@@ -0,0 +1,72 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/tests/ITestService.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BnTestService : public ::android::BnInterface<ITestService> {
+public:
+  static constexpr uint32_t TRANSACTION_UnimplementedMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 0;
+  static constexpr uint32_t TRANSACTION_TestOneway = ::android::IBinder::FIRST_CALL_TRANSACTION + 1;
+  static constexpr uint32_t TRANSACTION_RepeatBoolean = ::android::IBinder::FIRST_CALL_TRANSACTION + 2;
+  static constexpr uint32_t TRANSACTION_RepeatByte = ::android::IBinder::FIRST_CALL_TRANSACTION + 3;
+  static constexpr uint32_t TRANSACTION_RepeatChar = ::android::IBinder::FIRST_CALL_TRANSACTION + 4;
+  static constexpr uint32_t TRANSACTION_RepeatInt = ::android::IBinder::FIRST_CALL_TRANSACTION + 5;
+  static constexpr uint32_t TRANSACTION_RepeatLong = ::android::IBinder::FIRST_CALL_TRANSACTION + 6;
+  static constexpr uint32_t TRANSACTION_RepeatFloat = ::android::IBinder::FIRST_CALL_TRANSACTION + 7;
+  static constexpr uint32_t TRANSACTION_RepeatDouble = ::android::IBinder::FIRST_CALL_TRANSACTION + 8;
+  static constexpr uint32_t TRANSACTION_RepeatString = ::android::IBinder::FIRST_CALL_TRANSACTION + 9;
+  static constexpr uint32_t TRANSACTION_RepeatByteEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 10;
+  static constexpr uint32_t TRANSACTION_RepeatIntEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 11;
+  static constexpr uint32_t TRANSACTION_RepeatLongEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 12;
+  static constexpr uint32_t TRANSACTION_ReverseBoolean = ::android::IBinder::FIRST_CALL_TRANSACTION + 13;
+  static constexpr uint32_t TRANSACTION_ReverseByte = ::android::IBinder::FIRST_CALL_TRANSACTION + 14;
+  static constexpr uint32_t TRANSACTION_ReverseChar = ::android::IBinder::FIRST_CALL_TRANSACTION + 15;
+  static constexpr uint32_t TRANSACTION_ReverseInt = ::android::IBinder::FIRST_CALL_TRANSACTION + 16;
+  static constexpr uint32_t TRANSACTION_ReverseLong = ::android::IBinder::FIRST_CALL_TRANSACTION + 17;
+  static constexpr uint32_t TRANSACTION_ReverseFloat = ::android::IBinder::FIRST_CALL_TRANSACTION + 18;
+  static constexpr uint32_t TRANSACTION_ReverseDouble = ::android::IBinder::FIRST_CALL_TRANSACTION + 19;
+  static constexpr uint32_t TRANSACTION_ReverseString = ::android::IBinder::FIRST_CALL_TRANSACTION + 20;
+  static constexpr uint32_t TRANSACTION_ReverseByteEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 21;
+  static constexpr uint32_t TRANSACTION_ReverseIntEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 22;
+  static constexpr uint32_t TRANSACTION_ReverseLongEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 23;
+  static constexpr uint32_t TRANSACTION_GetOtherTestService = ::android::IBinder::FIRST_CALL_TRANSACTION + 24;
+  static constexpr uint32_t TRANSACTION_VerifyName = ::android::IBinder::FIRST_CALL_TRANSACTION + 25;
+  static constexpr uint32_t TRANSACTION_ReverseStringList = ::android::IBinder::FIRST_CALL_TRANSACTION + 26;
+  static constexpr uint32_t TRANSACTION_RepeatParcelFileDescriptor = ::android::IBinder::FIRST_CALL_TRANSACTION + 27;
+  static constexpr uint32_t TRANSACTION_ReverseParcelFileDescriptorArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 28;
+  static constexpr uint32_t TRANSACTION_ThrowServiceException = ::android::IBinder::FIRST_CALL_TRANSACTION + 29;
+  static constexpr uint32_t TRANSACTION_RepeatNullableIntArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 30;
+  static constexpr uint32_t TRANSACTION_RepeatNullableByteEnumArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 31;
+  static constexpr uint32_t TRANSACTION_RepeatNullableIntEnumArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 32;
+  static constexpr uint32_t TRANSACTION_RepeatNullableLongEnumArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 33;
+  static constexpr uint32_t TRANSACTION_RepeatNullableString = ::android::IBinder::FIRST_CALL_TRANSACTION + 34;
+  static constexpr uint32_t TRANSACTION_RepeatNullableStringList = ::android::IBinder::FIRST_CALL_TRANSACTION + 35;
+  static constexpr uint32_t TRANSACTION_RepeatNullableParcelable = ::android::IBinder::FIRST_CALL_TRANSACTION + 36;
+  static constexpr uint32_t TRANSACTION_TakesAnIBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 37;
+  static constexpr uint32_t TRANSACTION_TakesANullableIBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 38;
+  static constexpr uint32_t TRANSACTION_RepeatUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 39;
+  static constexpr uint32_t TRANSACTION_RepeatNullableUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 40;
+  static constexpr uint32_t TRANSACTION_ReverseUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 41;
+  static constexpr uint32_t TRANSACTION_ReverseNullableUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 42;
+  static constexpr uint32_t TRANSACTION_ReverseUtf8CppStringList = ::android::IBinder::FIRST_CALL_TRANSACTION + 43;
+  static constexpr uint32_t TRANSACTION_GetCallback = ::android::IBinder::FIRST_CALL_TRANSACTION + 44;
+  static constexpr uint32_t TRANSACTION_FillOutStructuredParcelable = ::android::IBinder::FIRST_CALL_TRANSACTION + 45;
+  static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 46;
+  static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 47;
+  static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 48;
+  static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 49;
+  explicit BnTestService();
+  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
+};  // class BnTestService
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnUnion.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnUnionWithFd.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnUnionWithFd.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnUnionWithFd.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpBackendType.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpBackendType.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpBackendType.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpByteEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpByteEnum.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpByteEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpConstantExpressionEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpConstantExpressionEnum.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpConstantExpressionEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpGenericStructuredParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpGenericStructuredParcelable.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpGenericStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpIntEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpIntEnum.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpIntEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpLongEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpLongEnum.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpLongEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpNamedCallback.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpNamedCallback.h
new file mode 100644
index 0000000..4c3eb91
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpNamedCallback.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/tests/INamedCallback.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BpNamedCallback : public ::android::BpInterface<INamedCallback> {
+public:
+  explicit BpNamedCallback(const ::android::sp<::android::IBinder>& _aidl_impl);
+  virtual ~BpNamedCallback() = default;
+  ::android::binder::Status GetName(::android::String16* _aidl_return) override;
+};  // class BpNamedCallback
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpNewName.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpNewName.h
new file mode 100644
index 0000000..d9ba90e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpNewName.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/tests/INewName.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BpNewName : public ::android::BpInterface<INewName> {
+public:
+  explicit BpNewName(const ::android::sp<::android::IBinder>& _aidl_impl);
+  virtual ~BpNewName() = default;
+  ::android::binder::Status RealName(::android::String16* _aidl_return) override;
+};  // class BpNewName
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpOldName.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpOldName.h
new file mode 100644
index 0000000..a362664
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpOldName.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/tests/IOldName.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BpOldName : public ::android::BpInterface<IOldName> {
+public:
+  explicit BpOldName(const ::android::sp<::android::IBinder>& _aidl_impl);
+  virtual ~BpOldName() = default;
+  ::android::binder::Status RealName(::android::String16* _aidl_return) override;
+};  // class BpOldName
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpOtherParcelableForToString.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpOtherParcelableForToString.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpOtherParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpParcelableForToString.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpParcelableForToString.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpStructuredParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpStructuredParcelable.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
new file mode 100644
index 0000000..153119f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
@@ -0,0 +1,74 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/tests/ITestService.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class BpTestService : public ::android::BpInterface<ITestService> {
+public:
+  explicit BpTestService(const ::android::sp<::android::IBinder>& _aidl_impl);
+  virtual ~BpTestService() = default;
+  ::android::binder::Status UnimplementedMethod(int32_t arg, int32_t* _aidl_return) override;
+  ::android::binder::Status TestOneway() override;
+  ::android::binder::Status RepeatBoolean(bool token, bool* _aidl_return) override;
+  ::android::binder::Status RepeatByte(int8_t token, int8_t* _aidl_return) override;
+  ::android::binder::Status RepeatChar(char16_t token, char16_t* _aidl_return) override;
+  ::android::binder::Status RepeatInt(int32_t token, int32_t* _aidl_return) override;
+  ::android::binder::Status RepeatLong(int64_t token, int64_t* _aidl_return) override;
+  ::android::binder::Status RepeatFloat(float token, float* _aidl_return) override;
+  ::android::binder::Status RepeatDouble(double token, double* _aidl_return) override;
+  ::android::binder::Status RepeatString(const ::android::String16& token, ::android::String16* _aidl_return) override;
+  ::android::binder::Status RepeatByteEnum(::android::aidl::tests::ByteEnum token, ::android::aidl::tests::ByteEnum* _aidl_return) override;
+  ::android::binder::Status RepeatIntEnum(::android::aidl::tests::IntEnum token, ::android::aidl::tests::IntEnum* _aidl_return) override;
+  ::android::binder::Status RepeatLongEnum(::android::aidl::tests::LongEnum token, ::android::aidl::tests::LongEnum* _aidl_return) override;
+  ::android::binder::Status ReverseBoolean(const ::std::vector<bool>& input, ::std::vector<bool>* repeated, ::std::vector<bool>* _aidl_return) override;
+  ::android::binder::Status ReverseByte(const ::std::vector<uint8_t>& input, ::std::vector<uint8_t>* repeated, ::std::vector<uint8_t>* _aidl_return) override;
+  ::android::binder::Status ReverseChar(const ::std::vector<char16_t>& input, ::std::vector<char16_t>* repeated, ::std::vector<char16_t>* _aidl_return) override;
+  ::android::binder::Status ReverseInt(const ::std::vector<int32_t>& input, ::std::vector<int32_t>* repeated, ::std::vector<int32_t>* _aidl_return) override;
+  ::android::binder::Status ReverseLong(const ::std::vector<int64_t>& input, ::std::vector<int64_t>* repeated, ::std::vector<int64_t>* _aidl_return) override;
+  ::android::binder::Status ReverseFloat(const ::std::vector<float>& input, ::std::vector<float>* repeated, ::std::vector<float>* _aidl_return) override;
+  ::android::binder::Status ReverseDouble(const ::std::vector<double>& input, ::std::vector<double>* repeated, ::std::vector<double>* _aidl_return) override;
+  ::android::binder::Status ReverseString(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* repeated, ::std::vector<::android::String16>* _aidl_return) override;
+  ::android::binder::Status ReverseByteEnum(const ::std::vector<::android::aidl::tests::ByteEnum>& input, ::std::vector<::android::aidl::tests::ByteEnum>* repeated, ::std::vector<::android::aidl::tests::ByteEnum>* _aidl_return) override;
+  ::android::binder::Status ReverseIntEnum(const ::std::vector<::android::aidl::tests::IntEnum>& input, ::std::vector<::android::aidl::tests::IntEnum>* repeated, ::std::vector<::android::aidl::tests::IntEnum>* _aidl_return) override;
+  ::android::binder::Status ReverseLongEnum(const ::std::vector<::android::aidl::tests::LongEnum>& input, ::std::vector<::android::aidl::tests::LongEnum>* repeated, ::std::vector<::android::aidl::tests::LongEnum>* _aidl_return) override;
+  ::android::binder::Status GetOtherTestService(const ::android::String16& name, ::android::sp<::android::aidl::tests::INamedCallback>* _aidl_return) override;
+  ::android::binder::Status VerifyName(const ::android::sp<::android::aidl::tests::INamedCallback>& service, const ::android::String16& name, bool* _aidl_return) override;
+  ::android::binder::Status ReverseStringList(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* repeated, ::std::vector<::android::String16>* _aidl_return) override;
+  ::android::binder::Status RepeatParcelFileDescriptor(const ::android::os::ParcelFileDescriptor& read, ::android::os::ParcelFileDescriptor* _aidl_return) override;
+  ::android::binder::Status ReverseParcelFileDescriptorArray(const ::std::vector<::android::os::ParcelFileDescriptor>& input, ::std::vector<::android::os::ParcelFileDescriptor>* repeated, ::std::vector<::android::os::ParcelFileDescriptor>* _aidl_return) override;
+  ::android::binder::Status ThrowServiceException(int32_t code) override;
+  ::android::binder::Status RepeatNullableIntArray(const ::std::optional<::std::vector<int32_t>>& input, ::std::optional<::std::vector<int32_t>>* _aidl_return) override;
+  ::android::binder::Status RepeatNullableByteEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>* _aidl_return) override;
+  ::android::binder::Status RepeatNullableIntEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>* _aidl_return) override;
+  ::android::binder::Status RepeatNullableLongEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>* _aidl_return) override;
+  ::android::binder::Status RepeatNullableString(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) override;
+  ::android::binder::Status RepeatNullableStringList(const ::std::optional<::std::vector<::std::optional<::android::String16>>>& input, ::std::optional<::std::vector<::std::optional<::android::String16>>>* _aidl_return) override;
+  ::android::binder::Status RepeatNullableParcelable(const ::std::optional<::android::aidl::tests::StructuredParcelable>& input, ::std::optional<::android::aidl::tests::StructuredParcelable>* _aidl_return) override;
+  ::android::binder::Status TakesAnIBinder(const ::android::sp<::android::IBinder>& input) override;
+  ::android::binder::Status TakesANullableIBinder(const ::android::sp<::android::IBinder>& input) override;
+  ::android::binder::Status RepeatUtf8CppString(const ::std::string& token, ::std::string* _aidl_return) override;
+  ::android::binder::Status RepeatNullableUtf8CppString(const ::std::optional<::std::string>& token, ::std::optional<::std::string>* _aidl_return) override;
+  ::android::binder::Status ReverseUtf8CppString(const ::std::vector<::std::string>& input, ::std::vector<::std::string>* repeated, ::std::vector<::std::string>* _aidl_return) override;
+  ::android::binder::Status ReverseNullableUtf8CppString(const ::std::optional<::std::vector<::std::optional<::std::string>>>& input, ::std::optional<::std::vector<::std::optional<::std::string>>>* repeated, ::std::optional<::std::vector<::std::optional<::std::string>>>* _aidl_return) override;
+  ::android::binder::Status ReverseUtf8CppStringList(const ::std::optional<::std::vector<::std::optional<::std::string>>>& input, ::std::optional<::std::vector<::std::optional<::std::string>>>* repeated, ::std::optional<::std::vector<::std::optional<::std::string>>>* _aidl_return) override;
+  ::android::binder::Status GetCallback(bool return_null, ::android::sp<::android::aidl::tests::INamedCallback>* _aidl_return) override;
+  ::android::binder::Status FillOutStructuredParcelable(::android::aidl::tests::StructuredParcelable* parcel) override;
+  ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) override;
+  ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override;
+  ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override;
+  ::android::binder::Status getBackendType(::android::aidl::tests::BackendType* _aidl_return) override;
+};  // class BpTestService
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpUnion.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpUnionWithFd.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpUnionWithFd.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpUnionWithFd.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ByteEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ByteEnum.h
new file mode 100644
index 0000000..41e3957
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ByteEnum.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <array>
+#include <binder/Enums.h>
+#include <cstdint>
+#include <string>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+enum class ByteEnum : int8_t {
+  FOO = 1,
+  BAR = 2,
+  BAZ = 3,
+};
+
+static inline std::string toString(ByteEnum val) {
+  switch(val) {
+  case ByteEnum::FOO:
+    return "FOO";
+  case ByteEnum::BAR:
+    return "BAR";
+  case ByteEnum::BAZ:
+    return "BAZ";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+namespace android {
+
+namespace internal {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<::android::aidl::tests::ByteEnum, 3> enum_values<::android::aidl::tests::ByteEnum> = {
+  ::android::aidl::tests::ByteEnum::FOO,
+  ::android::aidl::tests::ByteEnum::BAR,
+  ::android::aidl::tests::ByteEnum::BAZ,
+};
+#pragma clang diagnostic pop
+
+}  // namespace internal
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ConstantExpressionEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ConstantExpressionEnum.h
new file mode 100644
index 0000000..af8f983
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ConstantExpressionEnum.h
@@ -0,0 +1,64 @@
+#pragma once
+
+#include <array>
+#include <binder/Enums.h>
+#include <cstdint>
+#include <string>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+enum class ConstantExpressionEnum : int32_t {
+  decInt32_1 = 1,
+  decInt32_2 = 1,
+  decInt64_1 = 1,
+  decInt64_2 = 1,
+  decInt64_3 = 1,
+  decInt64_4 = 1,
+  hexInt32_1 = 1,
+  hexInt32_2 = 1,
+  hexInt32_3 = 1,
+  hexInt64_1 = 1,
+};
+
+static inline std::string toString(ConstantExpressionEnum val) {
+  switch(val) {
+  case ConstantExpressionEnum::decInt32_1:
+    return "decInt32_1";
+  default:
+    return std::to_string(static_cast<int32_t>(val));
+  }
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+namespace android {
+
+namespace internal {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<::android::aidl::tests::ConstantExpressionEnum, 10> enum_values<::android::aidl::tests::ConstantExpressionEnum> = {
+  ::android::aidl::tests::ConstantExpressionEnum::decInt32_1,
+  ::android::aidl::tests::ConstantExpressionEnum::decInt32_2,
+  ::android::aidl::tests::ConstantExpressionEnum::decInt64_1,
+  ::android::aidl::tests::ConstantExpressionEnum::decInt64_2,
+  ::android::aidl::tests::ConstantExpressionEnum::decInt64_3,
+  ::android::aidl::tests::ConstantExpressionEnum::decInt64_4,
+  ::android::aidl::tests::ConstantExpressionEnum::hexInt32_1,
+  ::android::aidl::tests::ConstantExpressionEnum::hexInt32_2,
+  ::android::aidl::tests::ConstantExpressionEnum::hexInt32_3,
+  ::android::aidl::tests::ConstantExpressionEnum::hexInt64_1,
+};
+#pragma clang diagnostic pop
+
+}  // namespace internal
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/GenericStructuredParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/GenericStructuredParcelable.h
new file mode 100644
index 0000000..a0e5fcf
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/GenericStructuredParcelable.h
@@ -0,0 +1,132 @@
+#pragma once
+
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <sstream>
+#include <tuple>
+#include <utils/String16.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+template <typename T, typename U, typename B>
+class GenericStructuredParcelable : public ::android::Parcelable {
+public:
+  inline bool operator!=(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) != std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator<(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) < std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator<=(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) <= std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator==(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) == std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator>(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) > std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator>=(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) >= std::tie(rhs.a, rhs.b);
+  }
+
+  int32_t a = int32_t(0);
+  int32_t b = int32_t(0);
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.GenericStructuredParcelable");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "GenericStructuredParcelable{";
+    os << "a: " << std::to_string(a);
+    os << ", b: " << std::to_string(b);
+    os << "}";
+    return os.str();
+  }
+};  // class GenericStructuredParcelable
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/tests/GenericStructuredParcelable.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+template <typename T, typename U, typename B>
+::android::status_t GenericStructuredParcelable<T,U,B>::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  [[maybe_unused]] size_t _aidl_start_pos = _aidl_parcel->dataPosition();
+  int32_t _aidl_parcelable_raw_size = _aidl_parcel->readInt32();
+  if (_aidl_parcelable_raw_size < 0) return ::android::BAD_VALUE;
+  [[maybe_unused]] size_t _aidl_parcelable_size = static_cast<size_t>(_aidl_parcelable_raw_size);
+  if (_aidl_start_pos > SIZE_MAX - _aidl_parcelable_size) return ::android::BAD_VALUE;
+  ;
+  _aidl_ret_status = _aidl_parcel->readInt32(&a);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readInt32(&b);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  return _aidl_ret_status;
+}
+
+template <typename T, typename U, typename B>
+::android::status_t GenericStructuredParcelable<T,U,B>::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  auto _aidl_start_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->writeInt32(0);;
+  _aidl_ret_status = _aidl_parcel->writeInt32(a);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeInt32(b);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  auto _aidl_end_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->setDataPosition(_aidl_start_pos);
+  _aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);
+  _aidl_parcel->setDataPosition(_aidl_end_pos);;
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/INamedCallback.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/INamedCallback.h
new file mode 100644
index 0000000..910294c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/INamedCallback.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/Status.h>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class INamedCallback : public ::android::IInterface {
+public:
+  DECLARE_META_INTERFACE(NamedCallback)
+  virtual ::android::binder::Status GetName(::android::String16* _aidl_return) = 0;
+};  // class INamedCallback
+
+class INamedCallbackDefault : public INamedCallback {
+public:
+  ::android::IBinder* onAsBinder() override {
+    return nullptr;
+  }
+  ::android::binder::Status GetName(::android::String16*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+};  // class INamedCallbackDefault
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/INewName.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/INewName.h
new file mode 100644
index 0000000..a3d911c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/INewName.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/Status.h>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class INewName : public ::android::IInterface {
+public:
+  DECLARE_META_INTERFACE(NewName)
+  virtual ::android::binder::Status RealName(::android::String16* _aidl_return) = 0;
+};  // class INewName
+
+class INewNameDefault : public INewName {
+public:
+  ::android::IBinder* onAsBinder() override {
+    return nullptr;
+  }
+  ::android::binder::Status RealName(::android::String16*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+};  // class INewNameDefault
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IOldName.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IOldName.h
new file mode 100644
index 0000000..ab5530b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IOldName.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/Status.h>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class IOldName : public ::android::IInterface {
+public:
+  DECLARE_META_INTERFACE(OldName)
+  virtual ::android::binder::Status RealName(::android::String16* _aidl_return) = 0;
+};  // class IOldName
+
+class IOldNameDefault : public IOldName {
+public:
+  ::android::IBinder* onAsBinder() override {
+    return nullptr;
+  }
+  ::android::binder::Status RealName(::android::String16*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+};  // class IOldNameDefault
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
new file mode 100644
index 0000000..05efe5a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
@@ -0,0 +1,324 @@
+#pragma once
+
+#include <android/aidl/tests/BackendType.h>
+#include <android/aidl/tests/ByteEnum.h>
+#include <android/aidl/tests/INamedCallback.h>
+#include <android/aidl/tests/INewName.h>
+#include <android/aidl/tests/IOldName.h>
+#include <android/aidl/tests/IntEnum.h>
+#include <android/aidl/tests/LongEnum.h>
+#include <android/aidl/tests/StructuredParcelable.h>
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/ParcelFileDescriptor.h>
+#include <binder/Status.h>
+#include <cstdint>
+#include <optional>
+#include <string>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+#include <vector>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class ITestService : public ::android::IInterface {
+public:
+  DECLARE_META_INTERFACE(TestService)
+  enum  : int8_t {
+    BYTE_TEST_CONSTANT = 17,
+  };
+  enum  : int32_t {
+    TEST_CONSTANT = 42,
+    TEST_CONSTANT2 = -42,
+    TEST_CONSTANT3 = 42,
+    TEST_CONSTANT4 = 4,
+    TEST_CONSTANT5 = -4,
+    TEST_CONSTANT6 = 0,
+    TEST_CONSTANT7 = 0,
+    TEST_CONSTANT8 = 0,
+    TEST_CONSTANT9 = 86,
+    TEST_CONSTANT10 = 165,
+    TEST_CONSTANT11 = 250,
+    TEST_CONSTANT12 = -1,
+    A1 = 1,
+    A2 = 1,
+    A3 = 1,
+    A4 = 1,
+    A5 = 1,
+    A6 = 1,
+    A7 = 1,
+    A8 = 1,
+    A9 = 1,
+    A10 = 1,
+    A11 = 1,
+    A12 = 1,
+    A13 = 1,
+    A14 = 1,
+    A15 = 1,
+    A16 = 1,
+    A17 = 1,
+    A18 = 1,
+    A19 = 1,
+    A20 = 1,
+    A21 = 1,
+    A22 = 1,
+    A23 = 1,
+    A24 = 1,
+    A25 = 1,
+    A26 = 1,
+    A27 = 1,
+    A28 = 1,
+    A29 = 1,
+    A30 = 1,
+    A31 = 1,
+    A32 = 1,
+    A33 = 1,
+    A34 = 1,
+    A35 = 1,
+    A36 = 1,
+    A37 = 1,
+    A38 = 1,
+    A39 = 1,
+    A40 = 1,
+    A41 = 1,
+    A42 = 1,
+    A43 = 1,
+    A44 = 1,
+    A45 = 1,
+    A46 = 1,
+    A47 = 1,
+    A48 = 1,
+    A49 = 1,
+    A50 = 1,
+    A51 = 1,
+    A52 = 1,
+    A53 = 1,
+    A54 = 1,
+    A55 = 1,
+    A56 = 1,
+    A57 = 1,
+  };
+  enum  : int64_t {
+    LONG_TEST_CONSTANT = 1099511627776L,
+  };
+  static const ::android::String16& STRING_TEST_CONSTANT();
+  static const ::android::String16& STRING_TEST_CONSTANT2();
+  static const ::std::string& STRING_TEST_CONSTANT_UTF8();
+  virtual ::android::binder::Status UnimplementedMethod(int32_t arg, int32_t* _aidl_return) = 0;
+  virtual ::android::binder::Status TestOneway() = 0;
+  virtual ::android::binder::Status RepeatBoolean(bool token, bool* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatByte(int8_t token, int8_t* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatChar(char16_t token, char16_t* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatInt(int32_t token, int32_t* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatLong(int64_t token, int64_t* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatFloat(float token, float* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatDouble(double token, double* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatString(const ::android::String16& token, ::android::String16* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatByteEnum(::android::aidl::tests::ByteEnum token, ::android::aidl::tests::ByteEnum* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatIntEnum(::android::aidl::tests::IntEnum token, ::android::aidl::tests::IntEnum* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatLongEnum(::android::aidl::tests::LongEnum token, ::android::aidl::tests::LongEnum* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseBoolean(const ::std::vector<bool>& input, ::std::vector<bool>* repeated, ::std::vector<bool>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseByte(const ::std::vector<uint8_t>& input, ::std::vector<uint8_t>* repeated, ::std::vector<uint8_t>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseChar(const ::std::vector<char16_t>& input, ::std::vector<char16_t>* repeated, ::std::vector<char16_t>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseInt(const ::std::vector<int32_t>& input, ::std::vector<int32_t>* repeated, ::std::vector<int32_t>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseLong(const ::std::vector<int64_t>& input, ::std::vector<int64_t>* repeated, ::std::vector<int64_t>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseFloat(const ::std::vector<float>& input, ::std::vector<float>* repeated, ::std::vector<float>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseDouble(const ::std::vector<double>& input, ::std::vector<double>* repeated, ::std::vector<double>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseString(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* repeated, ::std::vector<::android::String16>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseByteEnum(const ::std::vector<::android::aidl::tests::ByteEnum>& input, ::std::vector<::android::aidl::tests::ByteEnum>* repeated, ::std::vector<::android::aidl::tests::ByteEnum>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseIntEnum(const ::std::vector<::android::aidl::tests::IntEnum>& input, ::std::vector<::android::aidl::tests::IntEnum>* repeated, ::std::vector<::android::aidl::tests::IntEnum>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseLongEnum(const ::std::vector<::android::aidl::tests::LongEnum>& input, ::std::vector<::android::aidl::tests::LongEnum>* repeated, ::std::vector<::android::aidl::tests::LongEnum>* _aidl_return) = 0;
+  virtual ::android::binder::Status GetOtherTestService(const ::android::String16& name, ::android::sp<::android::aidl::tests::INamedCallback>* _aidl_return) = 0;
+  virtual ::android::binder::Status VerifyName(const ::android::sp<::android::aidl::tests::INamedCallback>& service, const ::android::String16& name, bool* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseStringList(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* repeated, ::std::vector<::android::String16>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatParcelFileDescriptor(const ::android::os::ParcelFileDescriptor& read, ::android::os::ParcelFileDescriptor* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseParcelFileDescriptorArray(const ::std::vector<::android::os::ParcelFileDescriptor>& input, ::std::vector<::android::os::ParcelFileDescriptor>* repeated, ::std::vector<::android::os::ParcelFileDescriptor>* _aidl_return) = 0;
+  virtual ::android::binder::Status ThrowServiceException(int32_t code) = 0;
+  virtual ::android::binder::Status RepeatNullableIntArray(const ::std::optional<::std::vector<int32_t>>& input, ::std::optional<::std::vector<int32_t>>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableByteEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableIntEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableLongEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>& input, ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableString(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableStringList(const ::std::optional<::std::vector<::std::optional<::android::String16>>>& input, ::std::optional<::std::vector<::std::optional<::android::String16>>>* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableParcelable(const ::std::optional<::android::aidl::tests::StructuredParcelable>& input, ::std::optional<::android::aidl::tests::StructuredParcelable>* _aidl_return) = 0;
+  virtual ::android::binder::Status TakesAnIBinder(const ::android::sp<::android::IBinder>& input) = 0;
+  virtual ::android::binder::Status TakesANullableIBinder(const ::android::sp<::android::IBinder>& input) = 0;
+  virtual ::android::binder::Status RepeatUtf8CppString(const ::std::string& token, ::std::string* _aidl_return) = 0;
+  virtual ::android::binder::Status RepeatNullableUtf8CppString(const ::std::optional<::std::string>& token, ::std::optional<::std::string>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseUtf8CppString(const ::std::vector<::std::string>& input, ::std::vector<::std::string>* repeated, ::std::vector<::std::string>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseNullableUtf8CppString(const ::std::optional<::std::vector<::std::optional<::std::string>>>& input, ::std::optional<::std::vector<::std::optional<::std::string>>>* repeated, ::std::optional<::std::vector<::std::optional<::std::string>>>* _aidl_return) = 0;
+  virtual ::android::binder::Status ReverseUtf8CppStringList(const ::std::optional<::std::vector<::std::optional<::std::string>>>& input, ::std::optional<::std::vector<::std::optional<::std::string>>>* repeated, ::std::optional<::std::vector<::std::optional<::std::string>>>* _aidl_return) = 0;
+  virtual ::android::binder::Status GetCallback(bool return_null, ::android::sp<::android::aidl::tests::INamedCallback>* _aidl_return) = 0;
+  virtual ::android::binder::Status FillOutStructuredParcelable(::android::aidl::tests::StructuredParcelable* parcel) = 0;
+  virtual ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) = 0;
+  virtual ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) = 0;
+  virtual ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) = 0;
+  virtual ::android::binder::Status getBackendType(::android::aidl::tests::BackendType* _aidl_return) = 0;
+};  // class ITestService
+
+class ITestServiceDefault : public ITestService {
+public:
+  ::android::IBinder* onAsBinder() override {
+    return nullptr;
+  }
+  ::android::binder::Status UnimplementedMethod(int32_t, int32_t*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status TestOneway() override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatBoolean(bool, bool*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatByte(int8_t, int8_t*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatChar(char16_t, char16_t*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatInt(int32_t, int32_t*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatLong(int64_t, int64_t*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatFloat(float, float*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatDouble(double, double*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatString(const ::android::String16&, ::android::String16*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatByteEnum(::android::aidl::tests::ByteEnum, ::android::aidl::tests::ByteEnum*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatIntEnum(::android::aidl::tests::IntEnum, ::android::aidl::tests::IntEnum*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatLongEnum(::android::aidl::tests::LongEnum, ::android::aidl::tests::LongEnum*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseBoolean(const ::std::vector<bool>&, ::std::vector<bool>*, ::std::vector<bool>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseByte(const ::std::vector<uint8_t>&, ::std::vector<uint8_t>*, ::std::vector<uint8_t>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseChar(const ::std::vector<char16_t>&, ::std::vector<char16_t>*, ::std::vector<char16_t>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseInt(const ::std::vector<int32_t>&, ::std::vector<int32_t>*, ::std::vector<int32_t>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseLong(const ::std::vector<int64_t>&, ::std::vector<int64_t>*, ::std::vector<int64_t>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseFloat(const ::std::vector<float>&, ::std::vector<float>*, ::std::vector<float>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseDouble(const ::std::vector<double>&, ::std::vector<double>*, ::std::vector<double>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseString(const ::std::vector<::android::String16>&, ::std::vector<::android::String16>*, ::std::vector<::android::String16>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseByteEnum(const ::std::vector<::android::aidl::tests::ByteEnum>&, ::std::vector<::android::aidl::tests::ByteEnum>*, ::std::vector<::android::aidl::tests::ByteEnum>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseIntEnum(const ::std::vector<::android::aidl::tests::IntEnum>&, ::std::vector<::android::aidl::tests::IntEnum>*, ::std::vector<::android::aidl::tests::IntEnum>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseLongEnum(const ::std::vector<::android::aidl::tests::LongEnum>&, ::std::vector<::android::aidl::tests::LongEnum>*, ::std::vector<::android::aidl::tests::LongEnum>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status GetOtherTestService(const ::android::String16&, ::android::sp<::android::aidl::tests::INamedCallback>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status VerifyName(const ::android::sp<::android::aidl::tests::INamedCallback>&, const ::android::String16&, bool*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseStringList(const ::std::vector<::android::String16>&, ::std::vector<::android::String16>*, ::std::vector<::android::String16>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatParcelFileDescriptor(const ::android::os::ParcelFileDescriptor&, ::android::os::ParcelFileDescriptor*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseParcelFileDescriptorArray(const ::std::vector<::android::os::ParcelFileDescriptor>&, ::std::vector<::android::os::ParcelFileDescriptor>*, ::std::vector<::android::os::ParcelFileDescriptor>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ThrowServiceException(int32_t) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableIntArray(const ::std::optional<::std::vector<int32_t>>&, ::std::optional<::std::vector<int32_t>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableByteEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>&, ::std::optional<::std::vector<::android::aidl::tests::ByteEnum>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableIntEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>&, ::std::optional<::std::vector<::android::aidl::tests::IntEnum>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableLongEnumArray(const ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>&, ::std::optional<::std::vector<::android::aidl::tests::LongEnum>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableString(const ::std::optional<::android::String16>&, ::std::optional<::android::String16>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableStringList(const ::std::optional<::std::vector<::std::optional<::android::String16>>>&, ::std::optional<::std::vector<::std::optional<::android::String16>>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableParcelable(const ::std::optional<::android::aidl::tests::StructuredParcelable>&, ::std::optional<::android::aidl::tests::StructuredParcelable>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status TakesAnIBinder(const ::android::sp<::android::IBinder>&) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status TakesANullableIBinder(const ::android::sp<::android::IBinder>&) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatUtf8CppString(const ::std::string&, ::std::string*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status RepeatNullableUtf8CppString(const ::std::optional<::std::string>&, ::std::optional<::std::string>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseUtf8CppString(const ::std::vector<::std::string>&, ::std::vector<::std::string>*, ::std::vector<::std::string>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseNullableUtf8CppString(const ::std::optional<::std::vector<::std::optional<::std::string>>>&, ::std::optional<::std::vector<::std::optional<::std::string>>>*, ::std::optional<::std::vector<::std::optional<::std::string>>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status ReverseUtf8CppStringList(const ::std::optional<::std::vector<::std::optional<::std::string>>>&, ::std::optional<::std::vector<::std::optional<::std::string>>>*, ::std::optional<::std::vector<::std::optional<::std::string>>>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status GetCallback(bool, ::android::sp<::android::aidl::tests::INamedCallback>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status FillOutStructuredParcelable(::android::aidl::tests::StructuredParcelable*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+  ::android::binder::Status getBackendType(::android::aidl::tests::BackendType*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+};  // class ITestServiceDefault
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IntEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IntEnum.h
new file mode 100644
index 0000000..e8f9a19
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IntEnum.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <array>
+#include <binder/Enums.h>
+#include <cstdint>
+#include <string>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+enum class IntEnum : int32_t {
+  FOO = 1000,
+  BAR = 2000,
+  BAZ = 2001,
+};
+
+static inline std::string toString(IntEnum val) {
+  switch(val) {
+  case IntEnum::FOO:
+    return "FOO";
+  case IntEnum::BAR:
+    return "BAR";
+  case IntEnum::BAZ:
+    return "BAZ";
+  default:
+    return std::to_string(static_cast<int32_t>(val));
+  }
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+namespace android {
+
+namespace internal {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<::android::aidl::tests::IntEnum, 3> enum_values<::android::aidl::tests::IntEnum> = {
+  ::android::aidl::tests::IntEnum::FOO,
+  ::android::aidl::tests::IntEnum::BAR,
+  ::android::aidl::tests::IntEnum::BAZ,
+};
+#pragma clang diagnostic pop
+
+}  // namespace internal
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/LongEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/LongEnum.h
new file mode 100644
index 0000000..bd35399
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/LongEnum.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <array>
+#include <binder/Enums.h>
+#include <cstdint>
+#include <string>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+enum class LongEnum : int64_t {
+  FOO = 100000000000L,
+  BAR = 200000000000L,
+  BAZ = 200000000001L,
+};
+
+static inline std::string toString(LongEnum val) {
+  switch(val) {
+  case LongEnum::FOO:
+    return "FOO";
+  case LongEnum::BAR:
+    return "BAR";
+  case LongEnum::BAZ:
+    return "BAZ";
+  default:
+    return std::to_string(static_cast<int64_t>(val));
+  }
+}
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
+namespace android {
+
+namespace internal {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<::android::aidl::tests::LongEnum, 3> enum_values<::android::aidl::tests::LongEnum> = {
+  ::android::aidl::tests::LongEnum::FOO,
+  ::android::aidl::tests::LongEnum::BAR,
+  ::android::aidl::tests::LongEnum::BAZ,
+};
+#pragma clang diagnostic pop
+
+}  // namespace internal
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/OtherParcelableForToString.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/OtherParcelableForToString.h
new file mode 100644
index 0000000..e9a02ea
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/OtherParcelableForToString.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <tuple>
+#include <utils/String16.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class OtherParcelableForToString : public ::android::Parcelable {
+public:
+  inline bool operator!=(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) != std::tie(rhs.field);
+  }
+  inline bool operator<(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) < std::tie(rhs.field);
+  }
+  inline bool operator<=(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) <= std::tie(rhs.field);
+  }
+  inline bool operator==(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) == std::tie(rhs.field);
+  }
+  inline bool operator>(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) > std::tie(rhs.field);
+  }
+  inline bool operator>=(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) >= std::tie(rhs.field);
+  }
+
+  ::android::String16 field;
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.OtherParcelableForToString");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "OtherParcelableForToString{";
+    os << "field: " << (std::ostringstream() << field).str();
+    os << "}";
+    return os.str();
+  }
+};  // class OtherParcelableForToString
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ParcelableForToString.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ParcelableForToString.h
new file mode 100644
index 0000000..1a4080f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ParcelableForToString.h
@@ -0,0 +1,118 @@
+#pragma once
+
+#include <android/aidl/tests/GenericStructuredParcelable.h>
+#include <android/aidl/tests/IntEnum.h>
+#include <android/aidl/tests/OtherParcelableForToString.h>
+#include <android/aidl/tests/StructuredParcelable.h>
+#include <android/aidl/tests/Union.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <sstream>
+#include <tuple>
+#include <utils/String16.h>
+#include <vector>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class ParcelableForToString : public ::android::Parcelable {
+public:
+  inline bool operator!=(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) != std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator<(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) < std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator<=(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) <= std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator==(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) == std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator>(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) > std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator>=(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) >= std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+
+  int32_t intValue = int32_t(0);
+  ::std::vector<int32_t> intArray;
+  int64_t longValue = int64_t(0L);
+  ::std::vector<int64_t> longArray;
+  double doubleValue = double(0.000000);
+  ::std::vector<double> doubleArray;
+  float floatValue = float(0.000000f);
+  ::std::vector<float> floatArray;
+  int8_t byteValue = int8_t(0);
+  ::std::vector<uint8_t> byteArray;
+  bool booleanValue = bool(false);
+  ::std::vector<bool> booleanArray;
+  ::android::String16 stringValue;
+  ::std::vector<::android::String16> stringArray;
+  ::std::vector<::android::String16> stringList;
+  ::android::aidl::tests::OtherParcelableForToString parcelableValue;
+  ::std::vector<::android::aidl::tests::OtherParcelableForToString> parcelableArray;
+  ::android::aidl::tests::IntEnum enumValue;
+  ::std::vector<::android::aidl::tests::IntEnum> enumArray;
+  ::std::vector<::android::String16> nullArray;
+  ::std::vector<::android::String16> nullList;
+  ::android::aidl::tests::GenericStructuredParcelable<int32_t, ::android::aidl::tests::StructuredParcelable, ::android::aidl::tests::IntEnum> parcelableGeneric;
+  ::android::aidl::tests::Union unionValue;
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.ParcelableForToString");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "ParcelableForToString{";
+    os << "intValue: " << std::to_string(intValue);
+    os << ", intArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", longValue: " << std::to_string(longValue);
+    os << ", longArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", doubleValue: " << std::to_string(doubleValue);
+    os << ", doubleArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", floatValue: " << std::to_string(floatValue);
+    os << ", floatArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", byteValue: " << std::to_string(byteValue);
+    os << ", byteArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", booleanValue: " << (booleanValue?"true":"false");
+    os << ", booleanArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: booleanArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }();
+    os << ", stringValue: " << (std::ostringstream() << stringValue).str();
+    os << ", stringArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", stringList: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: stringList) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", parcelableValue: " << _call_toString(parcelableValue);
+    os << ", parcelableArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: parcelableArray) { (void)v; if (first) first = false; else o << ", "; o << _call_toString(v); }; o << "]"; return o.str(); }();
+    os << ", enumValue: " << android::aidl::tests::toString(enumValue);
+    os << ", enumArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: enumArray) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", nullArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: nullArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", nullList: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: nullList) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", parcelableGeneric: " << _call_toString(parcelableGeneric);
+    os << ", unionValue: " << _call_toString(unionValue);
+    os << "}";
+    return os.str();
+  }
+};  // class ParcelableForToString
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/StructuredParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/StructuredParcelable.h
new file mode 100644
index 0000000..b4e489f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/StructuredParcelable.h
@@ -0,0 +1,186 @@
+#pragma once
+
+#include <android/aidl/tests/ByteEnum.h>
+#include <android/aidl/tests/ConstantExpressionEnum.h>
+#include <android/aidl/tests/IntEnum.h>
+#include <android/aidl/tests/LongEnum.h>
+#include <android/aidl/tests/Union.h>
+#include <binder/IBinder.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <optional>
+#include <sstream>
+#include <string>
+#include <tuple>
+#include <utils/String16.h>
+#include <vector>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class StructuredParcelable : public ::android::Parcelable {
+public:
+  inline bool operator!=(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) != std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator<(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) < std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator<=(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) <= std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator==(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) == std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator>(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) > std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator>=(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) >= std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+
+  ::std::vector<int32_t> shouldContainThreeFs;
+  int32_t f = int32_t(0);
+  ::std::string shouldBeJerry;
+  ::android::aidl::tests::ByteEnum shouldBeByteBar;
+  ::android::aidl::tests::IntEnum shouldBeIntBar;
+  ::android::aidl::tests::LongEnum shouldBeLongBar;
+  ::std::vector<::android::aidl::tests::ByteEnum> shouldContainTwoByteFoos;
+  ::std::vector<::android::aidl::tests::IntEnum> shouldContainTwoIntFoos;
+  ::std::vector<::android::aidl::tests::LongEnum> shouldContainTwoLongFoos;
+  ::android::String16 stringDefaultsToFoo = ::android::String16(::android::String16("foo"));
+  int8_t byteDefaultsToFour = int8_t(4);
+  int32_t intDefaultsToFive = int32_t(5);
+  int64_t longDefaultsToNegativeSeven = int64_t(-7L);
+  bool booleanDefaultsToTrue = bool(true);
+  char16_t charDefaultsToC = char16_t('C');
+  float floatDefaultsToPi = float(3.140000f);
+  double doubleWithDefault = double(-314000000000000000.000000);
+  ::std::vector<int32_t> arrayDefaultsTo123 = ::std::vector<int32_t>({1, 2, 3});
+  ::std::vector<int32_t> arrayDefaultsToEmpty = ::std::vector<int32_t>({});
+  bool boolDefault = bool(false);
+  int8_t byteDefault = int8_t(0);
+  int32_t intDefault = int32_t(0);
+  int64_t longDefault = int64_t(0L);
+  float floatDefault = float(0.000000f);
+  double doubleDefault = double(0.000000);
+  double checkDoubleFromFloat = double(3.140000);
+  ::std::vector<::android::String16> checkStringArray1 = ::std::vector<::android::String16>({::android::String16("a"), ::android::String16("b")});
+  ::std::vector<::std::string> checkStringArray2 = ::std::vector<::std::string>({"a", "b"});
+  int32_t int32_min = int32_t(-2147483648);
+  int32_t int32_max = int32_t(2147483647);
+  int64_t int64_max = int64_t(9223372036854775807L);
+  int32_t hexInt32_neg_1 = int32_t(-1);
+  ::android::sp<::android::IBinder> ibinder;
+  ::std::vector<int32_t> int32_1 = ::std::vector<int32_t>({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1});
+  ::std::vector<int64_t> int64_1 = ::std::vector<int64_t>({1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L});
+  int32_t hexInt32_pos_1 = int32_t(1);
+  int32_t hexInt64_pos_1 = int32_t(1);
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_1;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_2;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_3;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_4;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_5;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_6;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_7;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_8;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_9;
+  ::android::aidl::tests::ConstantExpressionEnum const_exprs_10;
+  ::std::string addString1 = ::std::string("hello world!");
+  ::std::string addString2 = ::std::string("The quick brown fox jumps over the lazy dog.");
+  int32_t shouldSetBit0AndBit2 = int32_t(0);
+  ::std::optional<::android::aidl::tests::Union> u;
+  ::std::optional<::android::aidl::tests::Union> shouldBeConstS1;
+  ::android::aidl::tests::IntEnum defaultWithFoo = ::android::aidl::tests::IntEnum(::android::aidl::tests::IntEnum::FOO);
+  enum  : int32_t {
+    BIT0 = 1,
+    BIT1 = 2,
+    BIT2 = 4,
+  };
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.StructuredParcelable");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "StructuredParcelable{";
+    os << "shouldContainThreeFs: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainThreeFs) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", f: " << std::to_string(f);
+    os << ", shouldBeJerry: " << (std::ostringstream() << shouldBeJerry).str();
+    os << ", shouldBeByteBar: " << android::aidl::tests::toString(shouldBeByteBar);
+    os << ", shouldBeIntBar: " << android::aidl::tests::toString(shouldBeIntBar);
+    os << ", shouldBeLongBar: " << android::aidl::tests::toString(shouldBeLongBar);
+    os << ", shouldContainTwoByteFoos: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainTwoByteFoos) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", shouldContainTwoIntFoos: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainTwoIntFoos) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", shouldContainTwoLongFoos: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainTwoLongFoos) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", stringDefaultsToFoo: " << (std::ostringstream() << stringDefaultsToFoo).str();
+    os << ", byteDefaultsToFour: " << std::to_string(byteDefaultsToFour);
+    os << ", intDefaultsToFive: " << std::to_string(intDefaultsToFive);
+    os << ", longDefaultsToNegativeSeven: " << std::to_string(longDefaultsToNegativeSeven);
+    os << ", booleanDefaultsToTrue: " << (booleanDefaultsToTrue?"true":"false");
+    os << ", charDefaultsToC: " << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(charDefaultsToC);
+    os << ", floatDefaultsToPi: " << std::to_string(floatDefaultsToPi);
+    os << ", doubleWithDefault: " << std::to_string(doubleWithDefault);
+    os << ", arrayDefaultsTo123: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: arrayDefaultsTo123) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", arrayDefaultsToEmpty: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: arrayDefaultsToEmpty) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", boolDefault: " << (boolDefault?"true":"false");
+    os << ", byteDefault: " << std::to_string(byteDefault);
+    os << ", intDefault: " << std::to_string(intDefault);
+    os << ", longDefault: " << std::to_string(longDefault);
+    os << ", floatDefault: " << std::to_string(floatDefault);
+    os << ", doubleDefault: " << std::to_string(doubleDefault);
+    os << ", checkDoubleFromFloat: " << std::to_string(checkDoubleFromFloat);
+    os << ", checkStringArray1: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: checkStringArray1) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", checkStringArray2: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: checkStringArray2) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", int32_min: " << std::to_string(int32_min);
+    os << ", int32_max: " << std::to_string(int32_max);
+    os << ", int64_max: " << std::to_string(int64_max);
+    os << ", hexInt32_neg_1: " << std::to_string(hexInt32_neg_1);
+    os << ", ibinder: " << "";
+    os << ", int32_1: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: int32_1) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", int64_1: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: int64_1) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", hexInt32_pos_1: " << std::to_string(hexInt32_pos_1);
+    os << ", hexInt64_pos_1: " << std::to_string(hexInt64_pos_1);
+    os << ", const_exprs_1: " << android::aidl::tests::toString(const_exprs_1);
+    os << ", const_exprs_2: " << android::aidl::tests::toString(const_exprs_2);
+    os << ", const_exprs_3: " << android::aidl::tests::toString(const_exprs_3);
+    os << ", const_exprs_4: " << android::aidl::tests::toString(const_exprs_4);
+    os << ", const_exprs_5: " << android::aidl::tests::toString(const_exprs_5);
+    os << ", const_exprs_6: " << android::aidl::tests::toString(const_exprs_6);
+    os << ", const_exprs_7: " << android::aidl::tests::toString(const_exprs_7);
+    os << ", const_exprs_8: " << android::aidl::tests::toString(const_exprs_8);
+    os << ", const_exprs_9: " << android::aidl::tests::toString(const_exprs_9);
+    os << ", const_exprs_10: " << android::aidl::tests::toString(const_exprs_10);
+    os << ", addString1: " << (std::ostringstream() << addString1).str();
+    os << ", addString2: " << (std::ostringstream() << addString2).str();
+    os << ", shouldSetBit0AndBit2: " << std::to_string(shouldSetBit0AndBit2);
+    os << ", u: " << ((u) ? _call_toString(*u): "(null)");
+    os << ", shouldBeConstS1: " << ((shouldBeConstS1) ? _call_toString(*shouldBeConstS1): "(null)");
+    os << ", defaultWithFoo: " << android::aidl::tests::toString(defaultWithFoo);
+    os << "}";
+    return os.str();
+  }
+};  // class StructuredParcelable
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h
new file mode 100644
index 0000000..89e8b1b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h
@@ -0,0 +1,148 @@
+#pragma once
+
+#include <android/aidl/tests/ByteEnum.h>
+#include <binder/IBinder.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <sstream>
+#include <string>
+#include <type_traits>
+#include <utility>
+#include <utils/String16.h>
+#include <variant>
+#include <vector>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class Union : public ::android::Parcelable {
+public:
+  inline bool operator!=(const Union& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const Union& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const Union& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const Union& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const Union& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const Union& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  enum Tag : int32_t {
+    ns = 0,  // int[] ns;
+    n,  // int n;
+    m,  // int m;
+    s,  // String s;
+    ibinder,  // IBinder ibinder;
+    ss,  // List<String> ss;
+    be,  // android.aidl.tests.ByteEnum be;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
+
+  Union() : _value(std::in_place_index<ns>, ::std::vector<int32_t>({})) { }
+  Union(const Union&) = default;
+  Union(Union&&) = default;
+  Union& operator=(const Union&) = default;
+  Union& operator=(Union&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr Union(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit Union(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static Union make(_Tp&&... _args) {
+    return Union(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static Union make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return Union(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  static const ::std::string& S1();
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.Union");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Union{";
+    switch (getTag()) {
+    case ns: os << "ns: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: get<ns>()) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }(); break;
+    case n: os << "n: " << std::to_string(get<n>()); break;
+    case m: os << "m: " << std::to_string(get<m>()); break;
+    case s: os << "s: " << (std::ostringstream() << get<s>()).str(); break;
+    case ibinder: os << "ibinder: " << ""; break;
+    case ss: os << "ss: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: get<ss>()) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }(); break;
+    case be: os << "be: " << android::aidl::tests::toString(get<be>()); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<::std::vector<int32_t>, int32_t, int32_t, ::std::string, ::android::sp<::android::IBinder>, ::std::vector<::std::string>, ::android::aidl::tests::ByteEnum> _value;
+};  // class Union
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h
new file mode 100644
index 0000000..6730479
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h
@@ -0,0 +1,134 @@
+#pragma once
+
+#include <binder/Parcel.h>
+#include <binder/ParcelFileDescriptor.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <sstream>
+#include <type_traits>
+#include <utility>
+#include <utils/String16.h>
+#include <variant>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class UnionWithFd : public ::android::Parcelable {
+public:
+  inline bool operator!=(const UnionWithFd& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const UnionWithFd& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const UnionWithFd& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const UnionWithFd& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const UnionWithFd& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const UnionWithFd& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    pfd,  // ParcelFileDescriptor pfd;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>;
+
+  UnionWithFd() : _value(std::in_place_index<num>, int32_t(0)) { }
+  UnionWithFd(const UnionWithFd&) = default;
+  UnionWithFd(UnionWithFd&&) = default;
+  UnionWithFd& operator=(const UnionWithFd&) = default;
+  UnionWithFd& operator=(UnionWithFd&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr UnionWithFd(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit UnionWithFd(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static UnionWithFd make(_Tp&&... _args) {
+    return UnionWithFd(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static UnionWithFd make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return UnionWithFd(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.UnionWithFd");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "UnionWithFd{";
+    switch (getTag()) {
+    case num: os << "num: " << std::to_string(get<num>()); break;
+    case pfd: os << "pfd: " << ""; break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<int32_t, ::android::os::ParcelFileDescriptor> _value;
+};  // class UnionWithFd
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BnEnumUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BnEnumUnion.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BnEnumUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BpEnumUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BpEnumUnion.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BpEnumUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h
new file mode 100644
index 0000000..799cdbb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h
@@ -0,0 +1,138 @@
+#pragma once
+
+#include <android/aidl/tests/IntEnum.h>
+#include <android/aidl/tests/LongEnum.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <type_traits>
+#include <utility>
+#include <utils/String16.h>
+#include <variant>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+namespace unions {
+
+class EnumUnion : public ::android::Parcelable {
+public:
+  inline bool operator!=(const EnumUnion& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const EnumUnion& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const EnumUnion& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const EnumUnion& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const EnumUnion& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const EnumUnion& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  enum Tag : int32_t {
+    intEnum = 0,  // android.aidl.tests.IntEnum intEnum;
+    longEnum,  // android.aidl.tests.LongEnum longEnum;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>;
+
+  EnumUnion() : _value(std::in_place_index<intEnum>, ::android::aidl::tests::IntEnum(::android::aidl::tests::IntEnum::FOO)) { }
+  EnumUnion(const EnumUnion&) = default;
+  EnumUnion(EnumUnion&&) = default;
+  EnumUnion& operator=(const EnumUnion&) = default;
+  EnumUnion& operator=(EnumUnion&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr EnumUnion(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit EnumUnion(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static EnumUnion make(_Tp&&... _args) {
+    return EnumUnion(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static EnumUnion make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return EnumUnion(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.unions.EnumUnion");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "EnumUnion{";
+    switch (getTag()) {
+    case intEnum: os << "intEnum: " << android::aidl::tests::toString(get<intEnum>()); break;
+    case longEnum: os << "longEnum: " << android::aidl::tests::toString(get<longEnum>()); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<::android::aidl::tests::IntEnum, ::android::aidl::tests::LongEnum> _value;
+};  // class EnumUnion
+
+}  // namespace unions
+
+}  // namespace tests
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/timestamp b/tests/golden_output/aidl-test-interface-cpp-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/timestamp
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java
new file mode 100644
index 0000000..7dfe146
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java
@@ -0,0 +1,10 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public @interface BackendType {
+  public static final byte CPP = 0;
+  public static final byte JAVA = 1;
+  public static final byte NDK = 2;
+  public static final byte RUST = 3;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java.d
new file mode 100644
index 0000000..bd69a28
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/BackendType.java : \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java
new file mode 100644
index 0000000..0f5a3ea
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java
@@ -0,0 +1,13 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+/**
+ * Hello, world!
+ */
+public @interface ByteEnum {
+  // Comment about FOO.
+  public static final byte FOO = 1;
+  public static final byte BAR = 2;
+  public static final byte BAZ = 3;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java.d
new file mode 100644
index 0000000..cf9a22f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/ByteEnum.java : \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java
new file mode 100644
index 0000000..44c41ee
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java
@@ -0,0 +1,23 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public @interface ConstantExpressionEnum {
+  // Should be all true / ones.
+  // dec literals are either int or long
+  public static final int decInt32_1 = 1;
+  public static final int decInt32_2 = 1;
+  public static final int decInt64_1 = 1;
+  public static final int decInt64_2 = 1;
+  public static final int decInt64_3 = 1;
+  public static final int decInt64_4 = 1;
+  // hex literals could be int or long
+  // 0x7fffffff is int, hence can be negated
+  public static final int hexInt32_1 = 1;
+  // 0x80000000 is int32_t max + 1
+  public static final int hexInt32_2 = 1;
+  // 0xFFFFFFFF is int32_t, not long; if it were long then ~(long)0xFFFFFFFF != 0
+  public static final int hexInt32_3 = 1;
+  // 0x7FFFFFFFFFFFFFFF is long, hence can be negated
+  public static final int hexInt64_1 = 1;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java.d
new file mode 100644
index 0000000..deebbb2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/ConstantExpressionEnum.java : \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java
new file mode 100644
index 0000000..dbcd69d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java
@@ -0,0 +1,61 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public class GenericStructuredParcelable<T,U,B> implements android.os.Parcelable
+{
+  public int a = 0;
+  public int b = 0;
+  public static final android.os.Parcelable.Creator<GenericStructuredParcelable> CREATOR = new android.os.Parcelable.Creator<GenericStructuredParcelable>() {
+    @Override
+    public GenericStructuredParcelable createFromParcel(android.os.Parcel _aidl_source) {
+      GenericStructuredParcelable _aidl_out = new GenericStructuredParcelable();
+      _aidl_out.readFromParcel(_aidl_source);
+      return _aidl_out;
+    }
+    @Override
+    public GenericStructuredParcelable[] newArray(int _aidl_size) {
+      return new GenericStructuredParcelable[_aidl_size];
+    }
+  };
+  @Override public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.writeInt(0);
+    _aidl_parcel.writeInt(a);
+    _aidl_parcel.writeInt(b);
+    int _aidl_end_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.setDataPosition(_aidl_start_pos);
+    _aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
+    _aidl_parcel.setDataPosition(_aidl_end_pos);
+  }
+  public final void readFromParcel(android.os.Parcel _aidl_parcel)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    int _aidl_parcelable_size = _aidl_parcel.readInt();
+    try {
+      if (_aidl_parcelable_size < 0) return;
+      a = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      b = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+    } finally {
+      if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {
+        throw new android.os.BadParcelableException("Overflow in the size of parcelable");
+      }
+      _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    }
+  }
+  @Override
+  public String toString() {
+    java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(", ", "{", "}");
+    _aidl_sj.add("a: " + (a));
+    _aidl_sj.add("b: " + (b));
+    return "android.aidl.tests.GenericStructuredParcelable" + _aidl_sj.toString()  ;
+  }
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    return _mask;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java.d
new file mode 100644
index 0000000..a78038d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/GenericStructuredParcelable.java : \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
new file mode 100644
index 0000000..60ddc7a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java
@@ -0,0 +1,132 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public interface INamedCallback extends android.os.IInterface
+{
+  /** Default implementation for INamedCallback. */
+  public static class Default implements android.aidl.tests.INamedCallback
+  {
+    @Override public java.lang.String GetName() throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override
+    public android.os.IBinder asBinder() {
+      return null;
+    }
+  }
+  /** Local-side IPC implementation stub class. */
+  public static abstract class Stub extends android.os.Binder implements android.aidl.tests.INamedCallback
+  {
+    /** Construct the stub at attach it to the interface. */
+    public Stub()
+    {
+      this.attachInterface(this, DESCRIPTOR);
+    }
+    /**
+     * Cast an IBinder object into an android.aidl.tests.INamedCallback interface,
+     * generating a proxy if needed.
+     */
+    public static android.aidl.tests.INamedCallback asInterface(android.os.IBinder obj)
+    {
+      if ((obj==null)) {
+        return null;
+      }
+      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
+      if (((iin!=null)&&(iin instanceof android.aidl.tests.INamedCallback))) {
+        return ((android.aidl.tests.INamedCallback)iin);
+      }
+      return new android.aidl.tests.INamedCallback.Stub.Proxy(obj);
+    }
+    @Override public android.os.IBinder asBinder()
+    {
+      return this;
+    }
+    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
+    {
+      java.lang.String descriptor = DESCRIPTOR;
+      switch (code)
+      {
+        case INTERFACE_TRANSACTION:
+        {
+          reply.writeString(descriptor);
+          return true;
+        }
+      }
+      switch (code)
+      {
+        case TRANSACTION_GetName:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _result = this.GetName();
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        default:
+        {
+          return super.onTransact(code, data, reply, flags);
+        }
+      }
+    }
+    private static class Proxy implements android.aidl.tests.INamedCallback
+    {
+      private android.os.IBinder mRemote;
+      Proxy(android.os.IBinder remote)
+      {
+        mRemote = remote;
+      }
+      @Override public android.os.IBinder asBinder()
+      {
+        return mRemote;
+      }
+      public java.lang.String getInterfaceDescriptor()
+      {
+        return DESCRIPTOR;
+      }
+      @Override public java.lang.String GetName() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_GetName, _data, _reply, 0);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().GetName();
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      public static android.aidl.tests.INamedCallback sDefaultImpl;
+    }
+    static final int TRANSACTION_GetName = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+    public static boolean setDefaultImpl(android.aidl.tests.INamedCallback impl) {
+      // Only one user of this interface can use this function
+      // at a time. This is a heuristic to detect if two different
+      // users in the same process use this function.
+      if (Stub.Proxy.sDefaultImpl != null) {
+        throw new IllegalStateException("setDefaultImpl() called twice");
+      }
+      if (impl != null) {
+        Stub.Proxy.sDefaultImpl = impl;
+        return true;
+      }
+      return false;
+    }
+    public static android.aidl.tests.INamedCallback getDefaultImpl() {
+      return Stub.Proxy.sDefaultImpl;
+    }
+  }
+  public static final java.lang.String DESCRIPTOR = "android$aidl$tests$INamedCallback".replace('$', '.');
+  public java.lang.String GetName() throws android.os.RemoteException;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java.d
new file mode 100644
index 0000000..c262450
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/INamedCallback.java : \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
new file mode 100644
index 0000000..893e43f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java
@@ -0,0 +1,132 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public interface INewName extends android.os.IInterface
+{
+  /** Default implementation for INewName. */
+  public static class Default implements android.aidl.tests.INewName
+  {
+    @Override public java.lang.String RealName() throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override
+    public android.os.IBinder asBinder() {
+      return null;
+    }
+  }
+  /** Local-side IPC implementation stub class. */
+  public static abstract class Stub extends android.os.Binder implements android.aidl.tests.INewName
+  {
+    /** Construct the stub at attach it to the interface. */
+    public Stub()
+    {
+      this.attachInterface(this, DESCRIPTOR);
+    }
+    /**
+     * Cast an IBinder object into an android.aidl.tests.INewName interface,
+     * generating a proxy if needed.
+     */
+    public static android.aidl.tests.INewName asInterface(android.os.IBinder obj)
+    {
+      if ((obj==null)) {
+        return null;
+      }
+      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
+      if (((iin!=null)&&(iin instanceof android.aidl.tests.INewName))) {
+        return ((android.aidl.tests.INewName)iin);
+      }
+      return new android.aidl.tests.INewName.Stub.Proxy(obj);
+    }
+    @Override public android.os.IBinder asBinder()
+    {
+      return this;
+    }
+    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
+    {
+      java.lang.String descriptor = DESCRIPTOR;
+      switch (code)
+      {
+        case INTERFACE_TRANSACTION:
+        {
+          reply.writeString(descriptor);
+          return true;
+        }
+      }
+      switch (code)
+      {
+        case TRANSACTION_RealName:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _result = this.RealName();
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        default:
+        {
+          return super.onTransact(code, data, reply, flags);
+        }
+      }
+    }
+    private static class Proxy implements android.aidl.tests.INewName
+    {
+      private android.os.IBinder mRemote;
+      Proxy(android.os.IBinder remote)
+      {
+        mRemote = remote;
+      }
+      @Override public android.os.IBinder asBinder()
+      {
+        return mRemote;
+      }
+      public java.lang.String getInterfaceDescriptor()
+      {
+        return DESCRIPTOR;
+      }
+      @Override public java.lang.String RealName() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RealName, _data, _reply, 0);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RealName();
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      public static android.aidl.tests.INewName sDefaultImpl;
+    }
+    static final int TRANSACTION_RealName = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+    public static boolean setDefaultImpl(android.aidl.tests.INewName impl) {
+      // Only one user of this interface can use this function
+      // at a time. This is a heuristic to detect if two different
+      // users in the same process use this function.
+      if (Stub.Proxy.sDefaultImpl != null) {
+        throw new IllegalStateException("setDefaultImpl() called twice");
+      }
+      if (impl != null) {
+        Stub.Proxy.sDefaultImpl = impl;
+        return true;
+      }
+      return false;
+    }
+    public static android.aidl.tests.INewName getDefaultImpl() {
+      return Stub.Proxy.sDefaultImpl;
+    }
+  }
+  public static final java.lang.String DESCRIPTOR = "android$aidl$tests$IOldName".replace('$', '.');
+  public java.lang.String RealName() throws android.os.RemoteException;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java.d
new file mode 100644
index 0000000..431e219
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/INewName.java : \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
new file mode 100644
index 0000000..c52387c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java
@@ -0,0 +1,132 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public interface IOldName extends android.os.IInterface
+{
+  /** Default implementation for IOldName. */
+  public static class Default implements android.aidl.tests.IOldName
+  {
+    @Override public java.lang.String RealName() throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override
+    public android.os.IBinder asBinder() {
+      return null;
+    }
+  }
+  /** Local-side IPC implementation stub class. */
+  public static abstract class Stub extends android.os.Binder implements android.aidl.tests.IOldName
+  {
+    /** Construct the stub at attach it to the interface. */
+    public Stub()
+    {
+      this.attachInterface(this, DESCRIPTOR);
+    }
+    /**
+     * Cast an IBinder object into an android.aidl.tests.IOldName interface,
+     * generating a proxy if needed.
+     */
+    public static android.aidl.tests.IOldName asInterface(android.os.IBinder obj)
+    {
+      if ((obj==null)) {
+        return null;
+      }
+      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
+      if (((iin!=null)&&(iin instanceof android.aidl.tests.IOldName))) {
+        return ((android.aidl.tests.IOldName)iin);
+      }
+      return new android.aidl.tests.IOldName.Stub.Proxy(obj);
+    }
+    @Override public android.os.IBinder asBinder()
+    {
+      return this;
+    }
+    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
+    {
+      java.lang.String descriptor = DESCRIPTOR;
+      switch (code)
+      {
+        case INTERFACE_TRANSACTION:
+        {
+          reply.writeString(descriptor);
+          return true;
+        }
+      }
+      switch (code)
+      {
+        case TRANSACTION_RealName:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _result = this.RealName();
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        default:
+        {
+          return super.onTransact(code, data, reply, flags);
+        }
+      }
+    }
+    private static class Proxy implements android.aidl.tests.IOldName
+    {
+      private android.os.IBinder mRemote;
+      Proxy(android.os.IBinder remote)
+      {
+        mRemote = remote;
+      }
+      @Override public android.os.IBinder asBinder()
+      {
+        return mRemote;
+      }
+      public java.lang.String getInterfaceDescriptor()
+      {
+        return DESCRIPTOR;
+      }
+      @Override public java.lang.String RealName() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RealName, _data, _reply, 0);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RealName();
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      public static android.aidl.tests.IOldName sDefaultImpl;
+    }
+    static final int TRANSACTION_RealName = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+    public static boolean setDefaultImpl(android.aidl.tests.IOldName impl) {
+      // Only one user of this interface can use this function
+      // at a time. This is a heuristic to detect if two different
+      // users in the same process use this function.
+      if (Stub.Proxy.sDefaultImpl != null) {
+        throw new IllegalStateException("setDefaultImpl() called twice");
+      }
+      if (impl != null) {
+        Stub.Proxy.sDefaultImpl = impl;
+        return true;
+      }
+      return false;
+    }
+    public static android.aidl.tests.IOldName getDefaultImpl() {
+      return Stub.Proxy.sDefaultImpl;
+    }
+  }
+  public static final java.lang.String DESCRIPTOR = "android$aidl$tests$IOldName".replace('$', '.');
+  public java.lang.String RealName() throws android.os.RemoteException;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java.d
new file mode 100644
index 0000000..9bc46ea
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/IOldName.java : \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
new file mode 100644
index 0000000..ba14ba4
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -0,0 +1,2448 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public interface ITestService extends android.os.IInterface
+{
+  /** Default implementation for ITestService. */
+  public static class Default implements android.aidl.tests.ITestService
+  {
+    // This is to emulate a method that is added after the service is implemented.
+    // So the client cannot assume that a call to this method will be successful
+    // or not. However, inside the test environment, we can't build client and
+    // the server with different version of this AIDL file. So, we let the server
+    // actually implement this and intercept the dispatch to the method
+    // inside onTransact().
+    // WARNING: Must be first method.
+    // This requires hard coding the transaction number. As long as this method is
+    // the first in this interface, it can keep the
+    // "::android::IBinder::FIRST_CALL_TRANSACTION + 0" value and allow
+    // methods to be added and removed.
+    @Override public int UnimplementedMethod(int arg) throws android.os.RemoteException
+    {
+      return 0;
+    }
+    @Override public void TestOneway() throws android.os.RemoteException
+    {
+    }
+    // Test that primitives work as parameters and return types.
+    @Override public boolean RepeatBoolean(boolean token) throws android.os.RemoteException
+    {
+      return false;
+    }
+    @Override public byte RepeatByte(byte token) throws android.os.RemoteException
+    {
+      return 0;
+    }
+    @Override public char RepeatChar(char token) throws android.os.RemoteException
+    {
+      return '\u0000';
+    }
+    @Override public int RepeatInt(int token) throws android.os.RemoteException
+    {
+      return 0;
+    }
+    @Override public long RepeatLong(long token) throws android.os.RemoteException
+    {
+      return 0L;
+    }
+    @Override public float RepeatFloat(float token) throws android.os.RemoteException
+    {
+      return 0.0f;
+    }
+    @Override public double RepeatDouble(double token) throws android.os.RemoteException
+    {
+      return 0.0d;
+    }
+    @Override public java.lang.String RepeatString(java.lang.String token) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public byte RepeatByteEnum(byte token) throws android.os.RemoteException
+    {
+      return 0;
+    }
+    @Override public int RepeatIntEnum(int token) throws android.os.RemoteException
+    {
+      return 0;
+    }
+    @Override public long RepeatLongEnum(long token) throws android.os.RemoteException
+    {
+      return 0L;
+    }
+    // Test that arrays work as parameters and return types.
+    @Override public boolean[] ReverseBoolean(boolean[] input, boolean[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public byte[] ReverseByte(byte[] input, byte[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public char[] ReverseChar(char[] input, char[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public int[] ReverseInt(int[] input, int[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public long[] ReverseLong(long[] input, long[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public float[] ReverseFloat(float[] input, float[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public double[] ReverseDouble(double[] input, double[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.lang.String[] ReverseString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public byte[] ReverseByteEnum(byte[] input, byte[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public int[] ReverseIntEnum(int[] input, int[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public long[] ReverseLongEnum(long[] input, long[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    // Test that clients can send and receive Binders.
+    @Override public android.aidl.tests.INamedCallback GetOtherTestService(java.lang.String name) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public boolean VerifyName(android.aidl.tests.INamedCallback service, java.lang.String name) throws android.os.RemoteException
+    {
+      return false;
+    }
+    // Test that List<T> types work correctly.
+    @Override public java.util.List<java.lang.String> ReverseStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public android.os.ParcelFileDescriptor RepeatParcelFileDescriptor(android.os.ParcelFileDescriptor read) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public android.os.ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(android.os.ParcelFileDescriptor[] input, android.os.ParcelFileDescriptor[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    // Test that service specific exceptions work correctly.
+    @Override public void ThrowServiceException(int code) throws android.os.RemoteException
+    {
+    }
+    // Test nullability
+    @Override public int[] RepeatNullableIntArray(int[] input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public byte[] RepeatNullableByteEnumArray(byte[] input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public int[] RepeatNullableIntEnumArray(int[] input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public long[] RepeatNullableLongEnumArray(long[] input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.lang.String RepeatNullableString(java.lang.String input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.util.List<java.lang.String> RepeatNullableStringList(java.util.List<java.lang.String> input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public android.aidl.tests.StructuredParcelable RepeatNullableParcelable(android.aidl.tests.StructuredParcelable input) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public void TakesAnIBinder(android.os.IBinder input) throws android.os.RemoteException
+    {
+    }
+    @Override public void TakesANullableIBinder(android.os.IBinder input) throws android.os.RemoteException
+    {
+    }
+    // Test utf8 decoding from utf16 wire format
+    @Override public java.lang.String RepeatUtf8CppString(java.lang.String token) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.lang.String RepeatNullableUtf8CppString(java.lang.String token) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.lang.String[] ReverseUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.lang.String[] ReverseNullableUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public java.util.List<java.lang.String> ReverseUtf8CppStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public android.aidl.tests.INamedCallback GetCallback(boolean return_null) throws android.os.RemoteException
+    {
+      return null;
+    }
+    // Since this paracelable has clearly defined default values, it would be
+    // inefficient to use an IPC to fill it out in practice.
+    @Override public void FillOutStructuredParcelable(android.aidl.tests.StructuredParcelable parcel) throws android.os.RemoteException
+    {
+    }
+    @Override public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException
+    {
+      return null;
+    }
+    // Retrieve the ICppJavaTests if the server supports it
+    @Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override public byte getBackendType() throws android.os.RemoteException
+    {
+      return 0;
+    }
+    @Override
+    public android.os.IBinder asBinder() {
+      return null;
+    }
+  }
+  /** Local-side IPC implementation stub class. */
+  public static abstract class Stub extends android.os.Binder implements android.aidl.tests.ITestService
+  {
+    /** Construct the stub at attach it to the interface. */
+    public Stub()
+    {
+      this.attachInterface(this, DESCRIPTOR);
+    }
+    /**
+     * Cast an IBinder object into an android.aidl.tests.ITestService interface,
+     * generating a proxy if needed.
+     */
+    public static android.aidl.tests.ITestService asInterface(android.os.IBinder obj)
+    {
+      if ((obj==null)) {
+        return null;
+      }
+      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
+      if (((iin!=null)&&(iin instanceof android.aidl.tests.ITestService))) {
+        return ((android.aidl.tests.ITestService)iin);
+      }
+      return new android.aidl.tests.ITestService.Stub.Proxy(obj);
+    }
+    @Override public android.os.IBinder asBinder()
+    {
+      return this;
+    }
+    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
+    {
+      java.lang.String descriptor = DESCRIPTOR;
+      switch (code)
+      {
+        case INTERFACE_TRANSACTION:
+        {
+          reply.writeString(descriptor);
+          return true;
+        }
+      }
+      switch (code)
+      {
+        case TRANSACTION_UnimplementedMethod:
+        {
+          data.enforceInterface(descriptor);
+          int _arg0;
+          _arg0 = data.readInt();
+          int _result = this.UnimplementedMethod(_arg0);
+          reply.writeNoException();
+          reply.writeInt(_result);
+          return true;
+        }
+        case TRANSACTION_TestOneway:
+        {
+          data.enforceInterface(descriptor);
+          this.TestOneway();
+          return true;
+        }
+        case TRANSACTION_RepeatBoolean:
+        {
+          data.enforceInterface(descriptor);
+          boolean _arg0;
+          _arg0 = (0!=data.readInt());
+          boolean _result = this.RepeatBoolean(_arg0);
+          reply.writeNoException();
+          reply.writeInt(((_result)?(1):(0)));
+          return true;
+        }
+        case TRANSACTION_RepeatByte:
+        {
+          data.enforceInterface(descriptor);
+          byte _arg0;
+          _arg0 = data.readByte();
+          byte _result = this.RepeatByte(_arg0);
+          reply.writeNoException();
+          reply.writeByte(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatChar:
+        {
+          data.enforceInterface(descriptor);
+          char _arg0;
+          _arg0 = (char)data.readInt();
+          char _result = this.RepeatChar(_arg0);
+          reply.writeNoException();
+          reply.writeInt(((int)_result));
+          return true;
+        }
+        case TRANSACTION_RepeatInt:
+        {
+          data.enforceInterface(descriptor);
+          int _arg0;
+          _arg0 = data.readInt();
+          int _result = this.RepeatInt(_arg0);
+          reply.writeNoException();
+          reply.writeInt(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatLong:
+        {
+          data.enforceInterface(descriptor);
+          long _arg0;
+          _arg0 = data.readLong();
+          long _result = this.RepeatLong(_arg0);
+          reply.writeNoException();
+          reply.writeLong(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatFloat:
+        {
+          data.enforceInterface(descriptor);
+          float _arg0;
+          _arg0 = data.readFloat();
+          float _result = this.RepeatFloat(_arg0);
+          reply.writeNoException();
+          reply.writeFloat(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatDouble:
+        {
+          data.enforceInterface(descriptor);
+          double _arg0;
+          _arg0 = data.readDouble();
+          double _result = this.RepeatDouble(_arg0);
+          reply.writeNoException();
+          reply.writeDouble(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _arg0;
+          _arg0 = data.readString();
+          java.lang.String _result = this.RepeatString(_arg0);
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatByteEnum:
+        {
+          data.enforceInterface(descriptor);
+          byte _arg0;
+          _arg0 = data.readByte();
+          byte _result = this.RepeatByteEnum(_arg0);
+          reply.writeNoException();
+          reply.writeByte(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatIntEnum:
+        {
+          data.enforceInterface(descriptor);
+          int _arg0;
+          _arg0 = data.readInt();
+          int _result = this.RepeatIntEnum(_arg0);
+          reply.writeNoException();
+          reply.writeInt(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatLongEnum:
+        {
+          data.enforceInterface(descriptor);
+          long _arg0;
+          _arg0 = data.readLong();
+          long _result = this.RepeatLongEnum(_arg0);
+          reply.writeNoException();
+          reply.writeLong(_result);
+          return true;
+        }
+        case TRANSACTION_ReverseBoolean:
+        {
+          data.enforceInterface(descriptor);
+          boolean[] _arg0;
+          _arg0 = data.createBooleanArray();
+          boolean[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new boolean[_arg1_length];
+          }
+          boolean[] _result = this.ReverseBoolean(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeBooleanArray(_result);
+          reply.writeBooleanArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseByte:
+        {
+          data.enforceInterface(descriptor);
+          byte[] _arg0;
+          _arg0 = data.createByteArray();
+          byte[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new byte[_arg1_length];
+          }
+          byte[] _result = this.ReverseByte(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeByteArray(_result);
+          reply.writeByteArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseChar:
+        {
+          data.enforceInterface(descriptor);
+          char[] _arg0;
+          _arg0 = data.createCharArray();
+          char[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new char[_arg1_length];
+          }
+          char[] _result = this.ReverseChar(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeCharArray(_result);
+          reply.writeCharArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseInt:
+        {
+          data.enforceInterface(descriptor);
+          int[] _arg0;
+          _arg0 = data.createIntArray();
+          int[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new int[_arg1_length];
+          }
+          int[] _result = this.ReverseInt(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeIntArray(_result);
+          reply.writeIntArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseLong:
+        {
+          data.enforceInterface(descriptor);
+          long[] _arg0;
+          _arg0 = data.createLongArray();
+          long[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new long[_arg1_length];
+          }
+          long[] _result = this.ReverseLong(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeLongArray(_result);
+          reply.writeLongArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseFloat:
+        {
+          data.enforceInterface(descriptor);
+          float[] _arg0;
+          _arg0 = data.createFloatArray();
+          float[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new float[_arg1_length];
+          }
+          float[] _result = this.ReverseFloat(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeFloatArray(_result);
+          reply.writeFloatArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseDouble:
+        {
+          data.enforceInterface(descriptor);
+          double[] _arg0;
+          _arg0 = data.createDoubleArray();
+          double[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new double[_arg1_length];
+          }
+          double[] _result = this.ReverseDouble(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeDoubleArray(_result);
+          reply.writeDoubleArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String[] _arg0;
+          _arg0 = data.createStringArray();
+          java.lang.String[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new java.lang.String[_arg1_length];
+          }
+          java.lang.String[] _result = this.ReverseString(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeStringArray(_result);
+          reply.writeStringArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseByteEnum:
+        {
+          data.enforceInterface(descriptor);
+          byte[] _arg0;
+          _arg0 = data.createByteArray();
+          byte[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new byte[_arg1_length];
+          }
+          byte[] _result = this.ReverseByteEnum(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeByteArray(_result);
+          reply.writeByteArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseIntEnum:
+        {
+          data.enforceInterface(descriptor);
+          int[] _arg0;
+          _arg0 = data.createIntArray();
+          int[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new int[_arg1_length];
+          }
+          int[] _result = this.ReverseIntEnum(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeIntArray(_result);
+          reply.writeIntArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseLongEnum:
+        {
+          data.enforceInterface(descriptor);
+          long[] _arg0;
+          _arg0 = data.createLongArray();
+          long[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new long[_arg1_length];
+          }
+          long[] _result = this.ReverseLongEnum(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeLongArray(_result);
+          reply.writeLongArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_GetOtherTestService:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _arg0;
+          _arg0 = data.readString();
+          android.aidl.tests.INamedCallback _result = this.GetOtherTestService(_arg0);
+          reply.writeNoException();
+          reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
+          return true;
+        }
+        case TRANSACTION_VerifyName:
+        {
+          data.enforceInterface(descriptor);
+          android.aidl.tests.INamedCallback _arg0;
+          _arg0 = android.aidl.tests.INamedCallback.Stub.asInterface(data.readStrongBinder());
+          java.lang.String _arg1;
+          _arg1 = data.readString();
+          boolean _result = this.VerifyName(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeInt(((_result)?(1):(0)));
+          return true;
+        }
+        case TRANSACTION_ReverseStringList:
+        {
+          data.enforceInterface(descriptor);
+          java.util.List<java.lang.String> _arg0;
+          _arg0 = data.createStringArrayList();
+          java.util.List<java.lang.String> _arg1;
+          _arg1 = new java.util.ArrayList<java.lang.String>();
+          java.util.List<java.lang.String> _result = this.ReverseStringList(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeStringList(_result);
+          reply.writeStringList(_arg1);
+          return true;
+        }
+        case TRANSACTION_RepeatParcelFileDescriptor:
+        {
+          data.enforceInterface(descriptor);
+          android.os.ParcelFileDescriptor _arg0;
+          if ((0!=data.readInt())) {
+            _arg0 = android.os.ParcelFileDescriptor.CREATOR.createFromParcel(data);
+          }
+          else {
+            _arg0 = null;
+          }
+          android.os.ParcelFileDescriptor _result = this.RepeatParcelFileDescriptor(_arg0);
+          reply.writeNoException();
+          if ((_result!=null)) {
+            reply.writeInt(1);
+            _result.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+          }
+          else {
+            reply.writeInt(0);
+          }
+          return true;
+        }
+        case TRANSACTION_ReverseParcelFileDescriptorArray:
+        {
+          data.enforceInterface(descriptor);
+          android.os.ParcelFileDescriptor[] _arg0;
+          _arg0 = data.createTypedArray(android.os.ParcelFileDescriptor.CREATOR);
+          android.os.ParcelFileDescriptor[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new android.os.ParcelFileDescriptor[_arg1_length];
+          }
+          android.os.ParcelFileDescriptor[] _result = this.ReverseParcelFileDescriptorArray(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeTypedArray(_result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+          reply.writeTypedArray(_arg1, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+          return true;
+        }
+        case TRANSACTION_ThrowServiceException:
+        {
+          data.enforceInterface(descriptor);
+          int _arg0;
+          _arg0 = data.readInt();
+          this.ThrowServiceException(_arg0);
+          reply.writeNoException();
+          return true;
+        }
+        case TRANSACTION_RepeatNullableIntArray:
+        {
+          data.enforceInterface(descriptor);
+          int[] _arg0;
+          _arg0 = data.createIntArray();
+          int[] _result = this.RepeatNullableIntArray(_arg0);
+          reply.writeNoException();
+          reply.writeIntArray(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableByteEnumArray:
+        {
+          data.enforceInterface(descriptor);
+          byte[] _arg0;
+          _arg0 = data.createByteArray();
+          byte[] _result = this.RepeatNullableByteEnumArray(_arg0);
+          reply.writeNoException();
+          reply.writeByteArray(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableIntEnumArray:
+        {
+          data.enforceInterface(descriptor);
+          int[] _arg0;
+          _arg0 = data.createIntArray();
+          int[] _result = this.RepeatNullableIntEnumArray(_arg0);
+          reply.writeNoException();
+          reply.writeIntArray(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableLongEnumArray:
+        {
+          data.enforceInterface(descriptor);
+          long[] _arg0;
+          _arg0 = data.createLongArray();
+          long[] _result = this.RepeatNullableLongEnumArray(_arg0);
+          reply.writeNoException();
+          reply.writeLongArray(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _arg0;
+          _arg0 = data.readString();
+          java.lang.String _result = this.RepeatNullableString(_arg0);
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableStringList:
+        {
+          data.enforceInterface(descriptor);
+          java.util.List<java.lang.String> _arg0;
+          _arg0 = data.createStringArrayList();
+          java.util.List<java.lang.String> _result = this.RepeatNullableStringList(_arg0);
+          reply.writeNoException();
+          reply.writeStringList(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableParcelable:
+        {
+          data.enforceInterface(descriptor);
+          android.aidl.tests.StructuredParcelable _arg0;
+          if ((0!=data.readInt())) {
+            _arg0 = android.aidl.tests.StructuredParcelable.CREATOR.createFromParcel(data);
+          }
+          else {
+            _arg0 = null;
+          }
+          android.aidl.tests.StructuredParcelable _result = this.RepeatNullableParcelable(_arg0);
+          reply.writeNoException();
+          if ((_result!=null)) {
+            reply.writeInt(1);
+            _result.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+          }
+          else {
+            reply.writeInt(0);
+          }
+          return true;
+        }
+        case TRANSACTION_TakesAnIBinder:
+        {
+          data.enforceInterface(descriptor);
+          android.os.IBinder _arg0;
+          _arg0 = data.readStrongBinder();
+          this.TakesAnIBinder(_arg0);
+          reply.writeNoException();
+          return true;
+        }
+        case TRANSACTION_TakesANullableIBinder:
+        {
+          data.enforceInterface(descriptor);
+          android.os.IBinder _arg0;
+          _arg0 = data.readStrongBinder();
+          this.TakesANullableIBinder(_arg0);
+          reply.writeNoException();
+          return true;
+        }
+        case TRANSACTION_RepeatUtf8CppString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _arg0;
+          _arg0 = data.readString();
+          java.lang.String _result = this.RepeatUtf8CppString(_arg0);
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        case TRANSACTION_RepeatNullableUtf8CppString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String _arg0;
+          _arg0 = data.readString();
+          java.lang.String _result = this.RepeatNullableUtf8CppString(_arg0);
+          reply.writeNoException();
+          reply.writeString(_result);
+          return true;
+        }
+        case TRANSACTION_ReverseUtf8CppString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String[] _arg0;
+          _arg0 = data.createStringArray();
+          java.lang.String[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new java.lang.String[_arg1_length];
+          }
+          java.lang.String[] _result = this.ReverseUtf8CppString(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeStringArray(_result);
+          reply.writeStringArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseNullableUtf8CppString:
+        {
+          data.enforceInterface(descriptor);
+          java.lang.String[] _arg0;
+          _arg0 = data.createStringArray();
+          java.lang.String[] _arg1;
+          int _arg1_length = data.readInt();
+          if ((_arg1_length<0)) {
+            _arg1 = null;
+          }
+          else {
+            _arg1 = new java.lang.String[_arg1_length];
+          }
+          java.lang.String[] _result = this.ReverseNullableUtf8CppString(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeStringArray(_result);
+          reply.writeStringArray(_arg1);
+          return true;
+        }
+        case TRANSACTION_ReverseUtf8CppStringList:
+        {
+          data.enforceInterface(descriptor);
+          java.util.List<java.lang.String> _arg0;
+          _arg0 = data.createStringArrayList();
+          java.util.List<java.lang.String> _arg1;
+          _arg1 = new java.util.ArrayList<java.lang.String>();
+          java.util.List<java.lang.String> _result = this.ReverseUtf8CppStringList(_arg0, _arg1);
+          reply.writeNoException();
+          reply.writeStringList(_result);
+          reply.writeStringList(_arg1);
+          return true;
+        }
+        case TRANSACTION_GetCallback:
+        {
+          data.enforceInterface(descriptor);
+          boolean _arg0;
+          _arg0 = (0!=data.readInt());
+          android.aidl.tests.INamedCallback _result = this.GetCallback(_arg0);
+          reply.writeNoException();
+          reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
+          return true;
+        }
+        case TRANSACTION_FillOutStructuredParcelable:
+        {
+          data.enforceInterface(descriptor);
+          android.aidl.tests.StructuredParcelable _arg0;
+          if ((0!=data.readInt())) {
+            _arg0 = android.aidl.tests.StructuredParcelable.CREATOR.createFromParcel(data);
+          }
+          else {
+            _arg0 = null;
+          }
+          this.FillOutStructuredParcelable(_arg0);
+          reply.writeNoException();
+          if ((_arg0!=null)) {
+            reply.writeInt(1);
+            _arg0.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+          }
+          else {
+            reply.writeInt(0);
+          }
+          return true;
+        }
+        case TRANSACTION_GetOldNameInterface:
+        {
+          data.enforceInterface(descriptor);
+          android.aidl.tests.IOldName _result = this.GetOldNameInterface();
+          reply.writeNoException();
+          reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
+          return true;
+        }
+        case TRANSACTION_GetNewNameInterface:
+        {
+          data.enforceInterface(descriptor);
+          android.aidl.tests.INewName _result = this.GetNewNameInterface();
+          reply.writeNoException();
+          reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
+          return true;
+        }
+        case TRANSACTION_GetCppJavaTests:
+        {
+          data.enforceInterface(descriptor);
+          android.os.IBinder _result = this.GetCppJavaTests();
+          reply.writeNoException();
+          reply.writeStrongBinder(_result);
+          return true;
+        }
+        case TRANSACTION_getBackendType:
+        {
+          data.enforceInterface(descriptor);
+          byte _result = this.getBackendType();
+          reply.writeNoException();
+          reply.writeByte(_result);
+          return true;
+        }
+        default:
+        {
+          return super.onTransact(code, data, reply, flags);
+        }
+      }
+    }
+    private static class Proxy implements android.aidl.tests.ITestService
+    {
+      private android.os.IBinder mRemote;
+      Proxy(android.os.IBinder remote)
+      {
+        mRemote = remote;
+      }
+      @Override public android.os.IBinder asBinder()
+      {
+        return mRemote;
+      }
+      public java.lang.String getInterfaceDescriptor()
+      {
+        return DESCRIPTOR;
+      }
+      // This is to emulate a method that is added after the service is implemented.
+      // So the client cannot assume that a call to this method will be successful
+      // or not. However, inside the test environment, we can't build client and
+      // the server with different version of this AIDL file. So, we let the server
+      // actually implement this and intercept the dispatch to the method
+      // inside onTransact().
+      // WARNING: Must be first method.
+      // This requires hard coding the transaction number. As long as this method is
+      // the first in this interface, it can keep the
+      // "::android::IBinder::FIRST_CALL_TRANSACTION + 0" value and allow
+      // methods to be added and removed.
+      @Override public int UnimplementedMethod(int arg) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(arg);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_UnimplementedMethod, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().UnimplementedMethod(arg);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readInt();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public void TestOneway() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_TestOneway, _data, null, android.os.IBinder.FLAG_ONEWAY | android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().TestOneway();
+              return;
+            }
+          }
+        }
+        finally {
+          _data.recycle();
+        }
+      }
+      // Test that primitives work as parameters and return types.
+      @Override public boolean RepeatBoolean(boolean token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        boolean _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(((token)?(1):(0)));
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatBoolean, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatBoolean(token);
+            }
+          }
+          _reply.readException();
+          _result = (0!=_reply.readInt());
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public byte RepeatByte(byte token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        byte _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeByte(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatByte, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatByte(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readByte();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public char RepeatChar(char token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        char _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(((int)token));
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatChar, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatChar(token);
+            }
+          }
+          _reply.readException();
+          _result = (char)_reply.readInt();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public int RepeatInt(int token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatInt, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatInt(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readInt();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public long RepeatLong(long token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        long _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeLong(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatLong, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatLong(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readLong();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public float RepeatFloat(float token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        float _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeFloat(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatFloat, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatFloat(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readFloat();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public double RepeatDouble(double token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        double _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeDouble(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatDouble, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatDouble(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readDouble();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.lang.String RepeatString(java.lang.String token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeString(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatString(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public byte RepeatByteEnum(byte token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        byte _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeByte(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatByteEnum, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatByteEnum(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readByte();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public int RepeatIntEnum(int token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatIntEnum, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatIntEnum(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readInt();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public long RepeatLongEnum(long token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        long _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeLong(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatLongEnum, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatLongEnum(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readLong();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      // Test that arrays work as parameters and return types.
+      @Override public boolean[] ReverseBoolean(boolean[] input, boolean[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        boolean[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeBooleanArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseBoolean, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseBoolean(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createBooleanArray();
+          _reply.readBooleanArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public byte[] ReverseByte(byte[] input, byte[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        byte[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeByteArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseByte, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseByte(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createByteArray();
+          _reply.readByteArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public char[] ReverseChar(char[] input, char[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        char[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeCharArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseChar, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseChar(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createCharArray();
+          _reply.readCharArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public int[] ReverseInt(int[] input, int[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeIntArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseInt, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseInt(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createIntArray();
+          _reply.readIntArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public long[] ReverseLong(long[] input, long[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        long[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeLongArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseLong, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseLong(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createLongArray();
+          _reply.readLongArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public float[] ReverseFloat(float[] input, float[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        float[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeFloatArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseFloat, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseFloat(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createFloatArray();
+          _reply.readFloatArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public double[] ReverseDouble(double[] input, double[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        double[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeDoubleArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseDouble, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseDouble(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createDoubleArray();
+          _reply.readDoubleArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.lang.String[] ReverseString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStringArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseString(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArray();
+          _reply.readStringArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public byte[] ReverseByteEnum(byte[] input, byte[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        byte[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeByteArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseByteEnum, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseByteEnum(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createByteArray();
+          _reply.readByteArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public int[] ReverseIntEnum(int[] input, int[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeIntArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseIntEnum, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseIntEnum(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createIntArray();
+          _reply.readIntArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public long[] ReverseLongEnum(long[] input, long[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        long[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeLongArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseLongEnum, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseLongEnum(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createLongArray();
+          _reply.readLongArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      // Test that clients can send and receive Binders.
+      @Override public android.aidl.tests.INamedCallback GetOtherTestService(java.lang.String name) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.aidl.tests.INamedCallback _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeString(name);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_GetOtherTestService, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().GetOtherTestService(name);
+            }
+          }
+          _reply.readException();
+          _result = android.aidl.tests.INamedCallback.Stub.asInterface(_reply.readStrongBinder());
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public boolean VerifyName(android.aidl.tests.INamedCallback service, java.lang.String name) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        boolean _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStrongBinder((((service!=null))?(service.asBinder()):(null)));
+          _data.writeString(name);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_VerifyName, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().VerifyName(service, name);
+            }
+          }
+          _reply.readException();
+          _result = (0!=_reply.readInt());
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      // Test that List<T> types work correctly.
+      @Override public java.util.List<java.lang.String> ReverseStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.util.List<java.lang.String> _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStringList(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseStringList, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseStringList(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArrayList();
+          _reply.readStringList(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public android.os.ParcelFileDescriptor RepeatParcelFileDescriptor(android.os.ParcelFileDescriptor read) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.os.ParcelFileDescriptor _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          if ((read!=null)) {
+            _data.writeInt(1);
+            read.writeToParcel(_data, 0);
+          }
+          else {
+            _data.writeInt(0);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatParcelFileDescriptor, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatParcelFileDescriptor(read);
+            }
+          }
+          _reply.readException();
+          if ((0!=_reply.readInt())) {
+            _result = android.os.ParcelFileDescriptor.CREATOR.createFromParcel(_reply);
+          }
+          else {
+            _result = null;
+          }
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public android.os.ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(android.os.ParcelFileDescriptor[] input, android.os.ParcelFileDescriptor[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.os.ParcelFileDescriptor[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeTypedArray(input, 0);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseParcelFileDescriptorArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseParcelFileDescriptorArray(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createTypedArray(android.os.ParcelFileDescriptor.CREATOR);
+          _reply.readTypedArray(repeated, android.os.ParcelFileDescriptor.CREATOR);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      // Test that service specific exceptions work correctly.
+      @Override public void ThrowServiceException(int code) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(code);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ThrowServiceException, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().ThrowServiceException(code);
+              return;
+            }
+          }
+          _reply.readException();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+      }
+      // Test nullability
+      @Override public int[] RepeatNullableIntArray(int[] input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeIntArray(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableIntArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableIntArray(input);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createIntArray();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public byte[] RepeatNullableByteEnumArray(byte[] input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        byte[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeByteArray(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableByteEnumArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableByteEnumArray(input);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createByteArray();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public int[] RepeatNullableIntEnumArray(int[] input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        int[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeIntArray(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableIntEnumArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableIntEnumArray(input);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createIntArray();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public long[] RepeatNullableLongEnumArray(long[] input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        long[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeLongArray(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableLongEnumArray, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableLongEnumArray(input);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createLongArray();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.lang.String RepeatNullableString(java.lang.String input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeString(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableString(input);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.util.List<java.lang.String> RepeatNullableStringList(java.util.List<java.lang.String> input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.util.List<java.lang.String> _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStringList(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableStringList, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableStringList(input);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArrayList();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public android.aidl.tests.StructuredParcelable RepeatNullableParcelable(android.aidl.tests.StructuredParcelable input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.aidl.tests.StructuredParcelable _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          if ((input!=null)) {
+            _data.writeInt(1);
+            input.writeToParcel(_data, 0);
+          }
+          else {
+            _data.writeInt(0);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableParcelable, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableParcelable(input);
+            }
+          }
+          _reply.readException();
+          if ((0!=_reply.readInt())) {
+            _result = android.aidl.tests.StructuredParcelable.CREATOR.createFromParcel(_reply);
+          }
+          else {
+            _result = null;
+          }
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public void TakesAnIBinder(android.os.IBinder input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStrongBinder(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_TakesAnIBinder, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().TakesAnIBinder(input);
+              return;
+            }
+          }
+          _reply.readException();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+      }
+      @Override public void TakesANullableIBinder(android.os.IBinder input) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStrongBinder(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_TakesANullableIBinder, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().TakesANullableIBinder(input);
+              return;
+            }
+          }
+          _reply.readException();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+      }
+      // Test utf8 decoding from utf16 wire format
+      @Override public java.lang.String RepeatUtf8CppString(java.lang.String token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeString(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatUtf8CppString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatUtf8CppString(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.lang.String RepeatNullableUtf8CppString(java.lang.String token) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeString(token);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_RepeatNullableUtf8CppString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().RepeatNullableUtf8CppString(token);
+            }
+          }
+          _reply.readException();
+          _result = _reply.readString();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.lang.String[] ReverseUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStringArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseUtf8CppString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseUtf8CppString(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArray();
+          _reply.readStringArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.lang.String[] ReverseNullableUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String[] _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStringArray(input);
+          if ((repeated==null)) {
+            _data.writeInt(-1);
+          }
+          else {
+            _data.writeInt(repeated.length);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseNullableUtf8CppString, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseNullableUtf8CppString(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArray();
+          _reply.readStringArray(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public java.util.List<java.lang.String> ReverseUtf8CppStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.util.List<java.lang.String> _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeStringList(input);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_ReverseUtf8CppStringList, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().ReverseUtf8CppStringList(input, repeated);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArrayList();
+          _reply.readStringList(repeated);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public android.aidl.tests.INamedCallback GetCallback(boolean return_null) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.aidl.tests.INamedCallback _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(((return_null)?(1):(0)));
+          boolean _status = mRemote.transact(Stub.TRANSACTION_GetCallback, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().GetCallback(return_null);
+            }
+          }
+          _reply.readException();
+          _result = android.aidl.tests.INamedCallback.Stub.asInterface(_reply.readStrongBinder());
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      // Since this paracelable has clearly defined default values, it would be
+      // inefficient to use an IPC to fill it out in practice.
+      @Override public void FillOutStructuredParcelable(android.aidl.tests.StructuredParcelable parcel) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          if ((parcel!=null)) {
+            _data.writeInt(1);
+            parcel.writeToParcel(_data, 0);
+          }
+          else {
+            _data.writeInt(0);
+          }
+          boolean _status = mRemote.transact(Stub.TRANSACTION_FillOutStructuredParcelable, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              getDefaultImpl().FillOutStructuredParcelable(parcel);
+              return;
+            }
+          }
+          _reply.readException();
+          if ((0!=_reply.readInt())) {
+            parcel.readFromParcel(_reply);
+          }
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+      }
+      @Override public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.aidl.tests.IOldName _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_GetOldNameInterface, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().GetOldNameInterface();
+            }
+          }
+          _reply.readException();
+          _result = android.aidl.tests.IOldName.Stub.asInterface(_reply.readStrongBinder());
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.aidl.tests.INewName _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_GetNewNameInterface, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().GetNewNameInterface();
+            }
+          }
+          _reply.readException();
+          _result = android.aidl.tests.INewName.Stub.asInterface(_reply.readStrongBinder());
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      // Retrieve the ICppJavaTests if the server supports it
+      @Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        android.os.IBinder _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_GetCppJavaTests, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().GetCppJavaTests();
+            }
+          }
+          _reply.readException();
+          _result = _reply.readStrongBinder();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      @Override public byte getBackendType() throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        _data.markSensitive();android.os.Parcel _reply = android.os.Parcel.obtain();
+        byte _result;
+        try {
+          _data.writeInterfaceToken(DESCRIPTOR);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_getBackendType, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().getBackendType();
+            }
+          }
+          _reply.readException();
+          _result = _reply.readByte();
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+        }
+        return _result;
+      }
+      public static android.aidl.tests.ITestService sDefaultImpl;
+    }
+    static final int TRANSACTION_UnimplementedMethod = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+    static final int TRANSACTION_TestOneway = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
+    static final int TRANSACTION_RepeatBoolean = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
+    static final int TRANSACTION_RepeatByte = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
+    static final int TRANSACTION_RepeatChar = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
+    static final int TRANSACTION_RepeatInt = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
+    static final int TRANSACTION_RepeatLong = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
+    static final int TRANSACTION_RepeatFloat = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
+    static final int TRANSACTION_RepeatDouble = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
+    static final int TRANSACTION_RepeatString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 9);
+    static final int TRANSACTION_RepeatByteEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 10);
+    static final int TRANSACTION_RepeatIntEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 11);
+    static final int TRANSACTION_RepeatLongEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 12);
+    static final int TRANSACTION_ReverseBoolean = (android.os.IBinder.FIRST_CALL_TRANSACTION + 13);
+    static final int TRANSACTION_ReverseByte = (android.os.IBinder.FIRST_CALL_TRANSACTION + 14);
+    static final int TRANSACTION_ReverseChar = (android.os.IBinder.FIRST_CALL_TRANSACTION + 15);
+    static final int TRANSACTION_ReverseInt = (android.os.IBinder.FIRST_CALL_TRANSACTION + 16);
+    static final int TRANSACTION_ReverseLong = (android.os.IBinder.FIRST_CALL_TRANSACTION + 17);
+    static final int TRANSACTION_ReverseFloat = (android.os.IBinder.FIRST_CALL_TRANSACTION + 18);
+    static final int TRANSACTION_ReverseDouble = (android.os.IBinder.FIRST_CALL_TRANSACTION + 19);
+    static final int TRANSACTION_ReverseString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 20);
+    static final int TRANSACTION_ReverseByteEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 21);
+    static final int TRANSACTION_ReverseIntEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 22);
+    static final int TRANSACTION_ReverseLongEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 23);
+    static final int TRANSACTION_GetOtherTestService = (android.os.IBinder.FIRST_CALL_TRANSACTION + 24);
+    static final int TRANSACTION_VerifyName = (android.os.IBinder.FIRST_CALL_TRANSACTION + 25);
+    static final int TRANSACTION_ReverseStringList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 26);
+    static final int TRANSACTION_RepeatParcelFileDescriptor = (android.os.IBinder.FIRST_CALL_TRANSACTION + 27);
+    static final int TRANSACTION_ReverseParcelFileDescriptorArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 28);
+    static final int TRANSACTION_ThrowServiceException = (android.os.IBinder.FIRST_CALL_TRANSACTION + 29);
+    static final int TRANSACTION_RepeatNullableIntArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 30);
+    static final int TRANSACTION_RepeatNullableByteEnumArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 31);
+    static final int TRANSACTION_RepeatNullableIntEnumArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 32);
+    static final int TRANSACTION_RepeatNullableLongEnumArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 33);
+    static final int TRANSACTION_RepeatNullableString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 34);
+    static final int TRANSACTION_RepeatNullableStringList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 35);
+    static final int TRANSACTION_RepeatNullableParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 36);
+    static final int TRANSACTION_TakesAnIBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 37);
+    static final int TRANSACTION_TakesANullableIBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 38);
+    static final int TRANSACTION_RepeatUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 39);
+    static final int TRANSACTION_RepeatNullableUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 40);
+    static final int TRANSACTION_ReverseUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 41);
+    static final int TRANSACTION_ReverseNullableUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 42);
+    static final int TRANSACTION_ReverseUtf8CppStringList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 43);
+    static final int TRANSACTION_GetCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 44);
+    static final int TRANSACTION_FillOutStructuredParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 45);
+    static final int TRANSACTION_GetOldNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 46);
+    static final int TRANSACTION_GetNewNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 47);
+    static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 48);
+    static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 49);
+    public static boolean setDefaultImpl(android.aidl.tests.ITestService impl) {
+      // Only one user of this interface can use this function
+      // at a time. This is a heuristic to detect if two different
+      // users in the same process use this function.
+      if (Stub.Proxy.sDefaultImpl != null) {
+        throw new IllegalStateException("setDefaultImpl() called twice");
+      }
+      if (impl != null) {
+        Stub.Proxy.sDefaultImpl = impl;
+        return true;
+      }
+      return false;
+    }
+    public static android.aidl.tests.ITestService getDefaultImpl() {
+      return Stub.Proxy.sDefaultImpl;
+    }
+  }
+  public static final java.lang.String DESCRIPTOR = "android$aidl$tests$ITestService".replace('$', '.');
+  // Test that constants are accessible
+  public static final int TEST_CONSTANT = 42;
+  public static final int TEST_CONSTANT2 = -42;
+  public static final int TEST_CONSTANT3 = 42;
+  public static final int TEST_CONSTANT4 = 4;
+  public static final int TEST_CONSTANT5 = -4;
+  public static final int TEST_CONSTANT6 = 0;
+  public static final int TEST_CONSTANT7 = 0;
+  public static final int TEST_CONSTANT8 = 0;
+  public static final int TEST_CONSTANT9 = 86;
+  public static final int TEST_CONSTANT10 = 165;
+  public static final int TEST_CONSTANT11 = 250;
+  public static final int TEST_CONSTANT12 = -1;
+  public static final byte BYTE_TEST_CONSTANT = 17;
+  public static final long LONG_TEST_CONSTANT = 1099511627776L;
+  public static final String STRING_TEST_CONSTANT = "foo";
+  public static final String STRING_TEST_CONSTANT2 = "bar";
+  public static final String STRING_TEST_CONSTANT_UTF8 = "baz";
+  // All these constant expressions should be equal to 1
+  public static final int A1 = 1;
+  public static final int A2 = 1;
+  public static final int A3 = 1;
+  public static final int A4 = 1;
+  public static final int A5 = 1;
+  public static final int A6 = 1;
+  public static final int A7 = 1;
+  public static final int A8 = 1;
+  public static final int A9 = 1;
+  public static final int A10 = 1;
+  public static final int A11 = 1;
+  public static final int A12 = 1;
+  public static final int A13 = 1;
+  public static final int A14 = 1;
+  public static final int A15 = 1;
+  public static final int A16 = 1;
+  public static final int A17 = 1;
+  public static final int A18 = 1;
+  public static final int A19 = 1;
+  public static final int A20 = 1;
+  public static final int A21 = 1;
+  public static final int A22 = 1;
+  public static final int A23 = 1;
+  public static final int A24 = 1;
+  public static final int A25 = 1;
+  public static final int A26 = 1;
+  public static final int A27 = 1;
+  public static final int A28 = 1;
+  public static final int A29 = 1;
+  public static final int A30 = 1;
+  public static final int A31 = 1;
+  public static final int A32 = 1;
+  public static final int A33 = 1;
+  public static final int A34 = 1;
+  public static final int A35 = 1;
+  public static final int A36 = 1;
+  public static final int A37 = 1;
+  public static final int A38 = 1;
+  public static final int A39 = 1;
+  public static final int A40 = 1;
+  public static final int A41 = 1;
+  public static final int A42 = 1;
+  public static final int A43 = 1;
+  public static final int A44 = 1;
+  // && higher than ||
+  public static final int A45 = 1;
+  public static final int A46 = 1;
+  public static final int A47 = 1;
+  public static final int A48 = 1;
+  public static final int A49 = 1;
+  public static final int A50 = 1;
+  public static final int A51 = 1;
+  public static final int A52 = 1;
+  public static final int A53 = 1;
+  // & higher than ^
+  public static final int A54 = 1;
+  public static final int A55 = 1;
+  public static final int A56 = 1;
+  public static final int A57 = 1;
+  // This is to emulate a method that is added after the service is implemented.
+  // So the client cannot assume that a call to this method will be successful
+  // or not. However, inside the test environment, we can't build client and
+  // the server with different version of this AIDL file. So, we let the server
+  // actually implement this and intercept the dispatch to the method
+  // inside onTransact().
+  // WARNING: Must be first method.
+  // This requires hard coding the transaction number. As long as this method is
+  // the first in this interface, it can keep the
+  // "::android::IBinder::FIRST_CALL_TRANSACTION + 0" value and allow
+  // methods to be added and removed.
+  public int UnimplementedMethod(int arg) throws android.os.RemoteException;
+  public void TestOneway() throws android.os.RemoteException;
+  // Test that primitives work as parameters and return types.
+  public boolean RepeatBoolean(boolean token) throws android.os.RemoteException;
+  public byte RepeatByte(byte token) throws android.os.RemoteException;
+  public char RepeatChar(char token) throws android.os.RemoteException;
+  public int RepeatInt(int token) throws android.os.RemoteException;
+  public long RepeatLong(long token) throws android.os.RemoteException;
+  public float RepeatFloat(float token) throws android.os.RemoteException;
+  public double RepeatDouble(double token) throws android.os.RemoteException;
+  public java.lang.String RepeatString(java.lang.String token) throws android.os.RemoteException;
+  public byte RepeatByteEnum(byte token) throws android.os.RemoteException;
+  public int RepeatIntEnum(int token) throws android.os.RemoteException;
+  public long RepeatLongEnum(long token) throws android.os.RemoteException;
+  // Test that arrays work as parameters and return types.
+  public boolean[] ReverseBoolean(boolean[] input, boolean[] repeated) throws android.os.RemoteException;
+  public byte[] ReverseByte(byte[] input, byte[] repeated) throws android.os.RemoteException;
+  public char[] ReverseChar(char[] input, char[] repeated) throws android.os.RemoteException;
+  public int[] ReverseInt(int[] input, int[] repeated) throws android.os.RemoteException;
+  public long[] ReverseLong(long[] input, long[] repeated) throws android.os.RemoteException;
+  public float[] ReverseFloat(float[] input, float[] repeated) throws android.os.RemoteException;
+  public double[] ReverseDouble(double[] input, double[] repeated) throws android.os.RemoteException;
+  public java.lang.String[] ReverseString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException;
+  public byte[] ReverseByteEnum(byte[] input, byte[] repeated) throws android.os.RemoteException;
+  public int[] ReverseIntEnum(int[] input, int[] repeated) throws android.os.RemoteException;
+  public long[] ReverseLongEnum(long[] input, long[] repeated) throws android.os.RemoteException;
+  // Test that clients can send and receive Binders.
+  public android.aidl.tests.INamedCallback GetOtherTestService(java.lang.String name) throws android.os.RemoteException;
+  public boolean VerifyName(android.aidl.tests.INamedCallback service, java.lang.String name) throws android.os.RemoteException;
+  // Test that List<T> types work correctly.
+  public java.util.List<java.lang.String> ReverseStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException;
+  public android.os.ParcelFileDescriptor RepeatParcelFileDescriptor(android.os.ParcelFileDescriptor read) throws android.os.RemoteException;
+  public android.os.ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(android.os.ParcelFileDescriptor[] input, android.os.ParcelFileDescriptor[] repeated) throws android.os.RemoteException;
+  // Test that service specific exceptions work correctly.
+  public void ThrowServiceException(int code) throws android.os.RemoteException;
+  // Test nullability
+  public int[] RepeatNullableIntArray(int[] input) throws android.os.RemoteException;
+  public byte[] RepeatNullableByteEnumArray(byte[] input) throws android.os.RemoteException;
+  public int[] RepeatNullableIntEnumArray(int[] input) throws android.os.RemoteException;
+  public long[] RepeatNullableLongEnumArray(long[] input) throws android.os.RemoteException;
+  public java.lang.String RepeatNullableString(java.lang.String input) throws android.os.RemoteException;
+  public java.util.List<java.lang.String> RepeatNullableStringList(java.util.List<java.lang.String> input) throws android.os.RemoteException;
+  public android.aidl.tests.StructuredParcelable RepeatNullableParcelable(android.aidl.tests.StructuredParcelable input) throws android.os.RemoteException;
+  public void TakesAnIBinder(android.os.IBinder input) throws android.os.RemoteException;
+  public void TakesANullableIBinder(android.os.IBinder input) throws android.os.RemoteException;
+  // Test utf8 decoding from utf16 wire format
+  public java.lang.String RepeatUtf8CppString(java.lang.String token) throws android.os.RemoteException;
+  public java.lang.String RepeatNullableUtf8CppString(java.lang.String token) throws android.os.RemoteException;
+  public java.lang.String[] ReverseUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException;
+  public java.lang.String[] ReverseNullableUtf8CppString(java.lang.String[] input, java.lang.String[] repeated) throws android.os.RemoteException;
+  public java.util.List<java.lang.String> ReverseUtf8CppStringList(java.util.List<java.lang.String> input, java.util.List<java.lang.String> repeated) throws android.os.RemoteException;
+  public android.aidl.tests.INamedCallback GetCallback(boolean return_null) throws android.os.RemoteException;
+  // Since this paracelable has clearly defined default values, it would be
+  // inefficient to use an IPC to fill it out in practice.
+  public void FillOutStructuredParcelable(android.aidl.tests.StructuredParcelable parcel) throws android.os.RemoteException;
+  public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException;
+  public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException;
+  // Retrieve the ICppJavaTests if the server supports it
+  public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException;
+  public byte getBackendType() throws android.os.RemoteException;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d
new file mode 100644
index 0000000..0436762
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d
@@ -0,0 +1,10 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java : \
+  system/tools/aidl/tests/android/aidl/tests/ITestService.aidl \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java
new file mode 100644
index 0000000..64ae00a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java
@@ -0,0 +1,9 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public @interface IntEnum {
+  public static final int FOO = 1000;
+  public static final int BAR = 2000;
+  public static final int BAZ = 2001;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java.d
new file mode 100644
index 0000000..c3c8c4c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/IntEnum.java : \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java
new file mode 100644
index 0000000..da016e5
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java
@@ -0,0 +1,9 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public @interface LongEnum {
+  public static final long FOO = 100000000000L;
+  public static final long BAR = 200000000000L;
+  public static final long BAZ = 200000000001L;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java.d
new file mode 100644
index 0000000..aae0f69
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/LongEnum.java : \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java
new file mode 100644
index 0000000..e0ea075
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java
@@ -0,0 +1,56 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public class OtherParcelableForToString implements android.os.Parcelable
+{
+  public java.lang.String field;
+  public static final android.os.Parcelable.Creator<OtherParcelableForToString> CREATOR = new android.os.Parcelable.Creator<OtherParcelableForToString>() {
+    @Override
+    public OtherParcelableForToString createFromParcel(android.os.Parcel _aidl_source) {
+      OtherParcelableForToString _aidl_out = new OtherParcelableForToString();
+      _aidl_out.readFromParcel(_aidl_source);
+      return _aidl_out;
+    }
+    @Override
+    public OtherParcelableForToString[] newArray(int _aidl_size) {
+      return new OtherParcelableForToString[_aidl_size];
+    }
+  };
+  @Override public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.writeInt(0);
+    _aidl_parcel.writeString(field);
+    int _aidl_end_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.setDataPosition(_aidl_start_pos);
+    _aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
+    _aidl_parcel.setDataPosition(_aidl_end_pos);
+  }
+  public final void readFromParcel(android.os.Parcel _aidl_parcel)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    int _aidl_parcelable_size = _aidl_parcel.readInt();
+    try {
+      if (_aidl_parcelable_size < 0) return;
+      field = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+    } finally {
+      if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {
+        throw new android.os.BadParcelableException("Overflow in the size of parcelable");
+      }
+      _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    }
+  }
+  @Override
+  public String toString() {
+    java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(", ", "{", "}");
+    _aidl_sj.add("field: " + (java.util.Objects.toString(field)));
+    return "android.aidl.tests.OtherParcelableForToString" + _aidl_sj.toString()  ;
+  }
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    return _mask;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java.d
new file mode 100644
index 0000000..a5c675b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/OtherParcelableForToString.java : \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java
new file mode 100644
index 0000000..a44f747
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java
@@ -0,0 +1,218 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public class ParcelableForToString implements android.os.Parcelable
+{
+  public int intValue = 0;
+  public int[] intArray;
+  public long longValue = 0L;
+  public long[] longArray;
+  public double doubleValue = 0.000000;
+  public double[] doubleArray;
+  public float floatValue = 0.000000f;
+  public float[] floatArray;
+  public byte byteValue = 0;
+  public byte[] byteArray;
+  public boolean booleanValue = false;
+  public boolean[] booleanArray;
+  public java.lang.String stringValue;
+  public java.lang.String[] stringArray;
+  public java.util.List<java.lang.String> stringList;
+  public android.aidl.tests.OtherParcelableForToString parcelableValue;
+  public android.aidl.tests.OtherParcelableForToString[] parcelableArray;
+  public int enumValue;
+  public int[] enumArray;
+  public java.lang.String[] nullArray;
+  public java.util.List<java.lang.String> nullList;
+  public android.aidl.tests.GenericStructuredParcelable<Integer,android.aidl.tests.StructuredParcelable,Integer> parcelableGeneric;
+  public android.aidl.tests.Union unionValue;
+  public static final android.os.Parcelable.Creator<ParcelableForToString> CREATOR = new android.os.Parcelable.Creator<ParcelableForToString>() {
+    @Override
+    public ParcelableForToString createFromParcel(android.os.Parcel _aidl_source) {
+      ParcelableForToString _aidl_out = new ParcelableForToString();
+      _aidl_out.readFromParcel(_aidl_source);
+      return _aidl_out;
+    }
+    @Override
+    public ParcelableForToString[] newArray(int _aidl_size) {
+      return new ParcelableForToString[_aidl_size];
+    }
+  };
+  @Override public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.writeInt(0);
+    _aidl_parcel.writeInt(intValue);
+    _aidl_parcel.writeIntArray(intArray);
+    _aidl_parcel.writeLong(longValue);
+    _aidl_parcel.writeLongArray(longArray);
+    _aidl_parcel.writeDouble(doubleValue);
+    _aidl_parcel.writeDoubleArray(doubleArray);
+    _aidl_parcel.writeFloat(floatValue);
+    _aidl_parcel.writeFloatArray(floatArray);
+    _aidl_parcel.writeByte(byteValue);
+    _aidl_parcel.writeByteArray(byteArray);
+    _aidl_parcel.writeInt(((booleanValue)?(1):(0)));
+    _aidl_parcel.writeBooleanArray(booleanArray);
+    _aidl_parcel.writeString(stringValue);
+    _aidl_parcel.writeStringArray(stringArray);
+    _aidl_parcel.writeStringList(stringList);
+    if ((parcelableValue!=null)) {
+      _aidl_parcel.writeInt(1);
+      parcelableValue.writeToParcel(_aidl_parcel, 0);
+    }
+    else {
+      _aidl_parcel.writeInt(0);
+    }
+    _aidl_parcel.writeTypedArray(parcelableArray, 0);
+    _aidl_parcel.writeInt(enumValue);
+    _aidl_parcel.writeIntArray(enumArray);
+    _aidl_parcel.writeStringArray(nullArray);
+    _aidl_parcel.writeStringList(nullList);
+    if ((parcelableGeneric!=null)) {
+      _aidl_parcel.writeInt(1);
+      parcelableGeneric.writeToParcel(_aidl_parcel, 0);
+    }
+    else {
+      _aidl_parcel.writeInt(0);
+    }
+    if ((unionValue!=null)) {
+      _aidl_parcel.writeInt(1);
+      unionValue.writeToParcel(_aidl_parcel, 0);
+    }
+    else {
+      _aidl_parcel.writeInt(0);
+    }
+    int _aidl_end_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.setDataPosition(_aidl_start_pos);
+    _aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
+    _aidl_parcel.setDataPosition(_aidl_end_pos);
+  }
+  public final void readFromParcel(android.os.Parcel _aidl_parcel)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    int _aidl_parcelable_size = _aidl_parcel.readInt();
+    try {
+      if (_aidl_parcelable_size < 0) return;
+      intValue = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      intArray = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      longValue = _aidl_parcel.readLong();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      longArray = _aidl_parcel.createLongArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      doubleValue = _aidl_parcel.readDouble();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      doubleArray = _aidl_parcel.createDoubleArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      floatValue = _aidl_parcel.readFloat();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      floatArray = _aidl_parcel.createFloatArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      byteValue = _aidl_parcel.readByte();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      byteArray = _aidl_parcel.createByteArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      booleanValue = (0!=_aidl_parcel.readInt());
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      booleanArray = _aidl_parcel.createBooleanArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      stringValue = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      stringArray = _aidl_parcel.createStringArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      stringList = _aidl_parcel.createStringArrayList();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      if ((0!=_aidl_parcel.readInt())) {
+        parcelableValue = android.aidl.tests.OtherParcelableForToString.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        parcelableValue = null;
+      }
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      parcelableArray = _aidl_parcel.createTypedArray(android.aidl.tests.OtherParcelableForToString.CREATOR);
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      enumValue = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      enumArray = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      nullArray = _aidl_parcel.createStringArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      nullList = _aidl_parcel.createStringArrayList();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      if ((0!=_aidl_parcel.readInt())) {
+        parcelableGeneric = android.aidl.tests.GenericStructuredParcelable.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        parcelableGeneric = null;
+      }
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      if ((0!=_aidl_parcel.readInt())) {
+        unionValue = android.aidl.tests.Union.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        unionValue = null;
+      }
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+    } finally {
+      if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {
+        throw new android.os.BadParcelableException("Overflow in the size of parcelable");
+      }
+      _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    }
+  }
+  @Override
+  public String toString() {
+    java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(", ", "{", "}");
+    _aidl_sj.add("intValue: " + (intValue));
+    _aidl_sj.add("intArray: " + (java.util.Arrays.toString(intArray)));
+    _aidl_sj.add("longValue: " + (longValue));
+    _aidl_sj.add("longArray: " + (java.util.Arrays.toString(longArray)));
+    _aidl_sj.add("doubleValue: " + (doubleValue));
+    _aidl_sj.add("doubleArray: " + (java.util.Arrays.toString(doubleArray)));
+    _aidl_sj.add("floatValue: " + (floatValue));
+    _aidl_sj.add("floatArray: " + (java.util.Arrays.toString(floatArray)));
+    _aidl_sj.add("byteValue: " + (byteValue));
+    _aidl_sj.add("byteArray: " + (java.util.Arrays.toString(byteArray)));
+    _aidl_sj.add("booleanValue: " + (booleanValue));
+    _aidl_sj.add("booleanArray: " + (java.util.Arrays.toString(booleanArray)));
+    _aidl_sj.add("stringValue: " + (java.util.Objects.toString(stringValue)));
+    _aidl_sj.add("stringArray: " + (java.util.Arrays.toString(stringArray)));
+    _aidl_sj.add("stringList: " + (java.util.Objects.toString(stringList)));
+    _aidl_sj.add("parcelableValue: " + (java.util.Objects.toString(parcelableValue)));
+    _aidl_sj.add("parcelableArray: " + (java.util.Arrays.toString(parcelableArray)));
+    _aidl_sj.add("enumValue: " + (enumValue));
+    _aidl_sj.add("enumArray: " + (java.util.Arrays.toString(enumArray)));
+    _aidl_sj.add("nullArray: " + (java.util.Arrays.toString(nullArray)));
+    _aidl_sj.add("nullList: " + (java.util.Objects.toString(nullList)));
+    _aidl_sj.add("parcelableGeneric: " + (java.util.Objects.toString(parcelableGeneric)));
+    _aidl_sj.add("unionValue: " + (java.util.Objects.toString(unionValue)));
+    return "android.aidl.tests.ParcelableForToString" + _aidl_sj.toString()  ;
+  }
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    _mask |= describeContents(parcelableValue);
+    _mask |= describeContents(parcelableArray);
+    _mask |= describeContents(parcelableGeneric);
+    _mask |= describeContents(unionValue);
+    return _mask;
+  }
+  private int describeContents(Object _v) {
+    if (_v == null) return 0;
+    Class<?> _clazz = _v.getClass();
+    if (_clazz.isArray() && _clazz.getComponentType() == Object.class) {
+      int _mask = 0;
+      for (Object o : (Object[]) _v) {
+        _mask |= describeContents(o);
+      }
+      return _mask;
+    }
+    if (_v instanceof android.os.Parcelable) {
+      return ((android.os.Parcelable) _v).describeContents();
+    }
+    return 0;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java.d
new file mode 100644
index 0000000..0761c0a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/ParcelableForToString.java : \
+  system/tools/aidl/tests/android/aidl/tests/ParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java
new file mode 100644
index 0000000..0359161
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java
@@ -0,0 +1,420 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+public class StructuredParcelable implements android.os.Parcelable
+{
+  public int[] shouldContainThreeFs;
+  public int f = 0;
+  public java.lang.String shouldBeJerry;
+  public byte shouldBeByteBar;
+  public int shouldBeIntBar;
+  public long shouldBeLongBar;
+  public byte[] shouldContainTwoByteFoos;
+  public int[] shouldContainTwoIntFoos;
+  public long[] shouldContainTwoLongFoos;
+  public java.lang.String stringDefaultsToFoo = "foo";
+  public byte byteDefaultsToFour = 4;
+  public int intDefaultsToFive = 5;
+  public long longDefaultsToNegativeSeven = -7L;
+  public boolean booleanDefaultsToTrue = true;
+  public char charDefaultsToC = 'C';
+  public float floatDefaultsToPi = 3.140000f;
+  public double doubleWithDefault = -314000000000000000.000000;
+  public int[] arrayDefaultsTo123 = {1, 2, 3};
+  public int[] arrayDefaultsToEmpty = {};
+  public boolean boolDefault = false;
+  public byte byteDefault = 0;
+  public int intDefault = 0;
+  public long longDefault = 0L;
+  public float floatDefault = 0.000000f;
+  public double doubleDefault = 0.000000;
+  // parse checks only
+  public double checkDoubleFromFloat = 3.140000;
+  public java.lang.String[] checkStringArray1 = {"a", "b"};
+  public java.lang.String[] checkStringArray2 = {"a", "b"};
+  // Add test to verify corner cases
+  public int int32_min = -2147483648;
+  public int int32_max = 2147483647;
+  public long int64_max = 9223372036854775807L;
+  public int hexInt32_neg_1 = -1;
+  public android.os.IBinder ibinder;
+  // Constant expressions that evaluate to 1
+  public int[] int32_1 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+  public long[] int64_1 = {1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L};
+  public int hexInt32_pos_1 = 1;
+  public int hexInt64_pos_1 = 1;
+  public int const_exprs_1;
+  public int const_exprs_2;
+  public int const_exprs_3;
+  public int const_exprs_4;
+  public int const_exprs_5;
+  public int const_exprs_6;
+  public int const_exprs_7;
+  public int const_exprs_8;
+  public int const_exprs_9;
+  public int const_exprs_10;
+  // String expressions
+  public java.lang.String addString1 = "hello world!";
+  public java.lang.String addString2 = "The quick brown fox jumps over the lazy dog.";
+  public int shouldSetBit0AndBit2 = 0;
+  public android.aidl.tests.Union u;
+  public android.aidl.tests.Union shouldBeConstS1;
+  public int defaultWithFoo = android.aidl.tests.IntEnum.FOO;
+  public static final android.os.Parcelable.Creator<StructuredParcelable> CREATOR = new android.os.Parcelable.Creator<StructuredParcelable>() {
+    @Override
+    public StructuredParcelable createFromParcel(android.os.Parcel _aidl_source) {
+      StructuredParcelable _aidl_out = new StructuredParcelable();
+      _aidl_out.readFromParcel(_aidl_source);
+      return _aidl_out;
+    }
+    @Override
+    public StructuredParcelable[] newArray(int _aidl_size) {
+      return new StructuredParcelable[_aidl_size];
+    }
+  };
+  @Override public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.writeInt(0);
+    _aidl_parcel.writeIntArray(shouldContainThreeFs);
+    _aidl_parcel.writeInt(f);
+    _aidl_parcel.writeString(shouldBeJerry);
+    _aidl_parcel.writeByte(shouldBeByteBar);
+    _aidl_parcel.writeInt(shouldBeIntBar);
+    _aidl_parcel.writeLong(shouldBeLongBar);
+    _aidl_parcel.writeByteArray(shouldContainTwoByteFoos);
+    _aidl_parcel.writeIntArray(shouldContainTwoIntFoos);
+    _aidl_parcel.writeLongArray(shouldContainTwoLongFoos);
+    _aidl_parcel.writeString(stringDefaultsToFoo);
+    _aidl_parcel.writeByte(byteDefaultsToFour);
+    _aidl_parcel.writeInt(intDefaultsToFive);
+    _aidl_parcel.writeLong(longDefaultsToNegativeSeven);
+    _aidl_parcel.writeInt(((booleanDefaultsToTrue)?(1):(0)));
+    _aidl_parcel.writeInt(((int)charDefaultsToC));
+    _aidl_parcel.writeFloat(floatDefaultsToPi);
+    _aidl_parcel.writeDouble(doubleWithDefault);
+    _aidl_parcel.writeIntArray(arrayDefaultsTo123);
+    _aidl_parcel.writeIntArray(arrayDefaultsToEmpty);
+    _aidl_parcel.writeInt(((boolDefault)?(1):(0)));
+    _aidl_parcel.writeByte(byteDefault);
+    _aidl_parcel.writeInt(intDefault);
+    _aidl_parcel.writeLong(longDefault);
+    _aidl_parcel.writeFloat(floatDefault);
+    _aidl_parcel.writeDouble(doubleDefault);
+    _aidl_parcel.writeDouble(checkDoubleFromFloat);
+    _aidl_parcel.writeStringArray(checkStringArray1);
+    _aidl_parcel.writeStringArray(checkStringArray2);
+    _aidl_parcel.writeInt(int32_min);
+    _aidl_parcel.writeInt(int32_max);
+    _aidl_parcel.writeLong(int64_max);
+    _aidl_parcel.writeInt(hexInt32_neg_1);
+    _aidl_parcel.writeStrongBinder(ibinder);
+    _aidl_parcel.writeIntArray(int32_1);
+    _aidl_parcel.writeLongArray(int64_1);
+    _aidl_parcel.writeInt(hexInt32_pos_1);
+    _aidl_parcel.writeInt(hexInt64_pos_1);
+    _aidl_parcel.writeInt(const_exprs_1);
+    _aidl_parcel.writeInt(const_exprs_2);
+    _aidl_parcel.writeInt(const_exprs_3);
+    _aidl_parcel.writeInt(const_exprs_4);
+    _aidl_parcel.writeInt(const_exprs_5);
+    _aidl_parcel.writeInt(const_exprs_6);
+    _aidl_parcel.writeInt(const_exprs_7);
+    _aidl_parcel.writeInt(const_exprs_8);
+    _aidl_parcel.writeInt(const_exprs_9);
+    _aidl_parcel.writeInt(const_exprs_10);
+    _aidl_parcel.writeString(addString1);
+    _aidl_parcel.writeString(addString2);
+    _aidl_parcel.writeInt(shouldSetBit0AndBit2);
+    if ((u!=null)) {
+      _aidl_parcel.writeInt(1);
+      u.writeToParcel(_aidl_parcel, 0);
+    }
+    else {
+      _aidl_parcel.writeInt(0);
+    }
+    if ((shouldBeConstS1!=null)) {
+      _aidl_parcel.writeInt(1);
+      shouldBeConstS1.writeToParcel(_aidl_parcel, 0);
+    }
+    else {
+      _aidl_parcel.writeInt(0);
+    }
+    _aidl_parcel.writeInt(defaultWithFoo);
+    int _aidl_end_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.setDataPosition(_aidl_start_pos);
+    _aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
+    _aidl_parcel.setDataPosition(_aidl_end_pos);
+  }
+  public final void readFromParcel(android.os.Parcel _aidl_parcel)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    int _aidl_parcelable_size = _aidl_parcel.readInt();
+    try {
+      if (_aidl_parcelable_size < 0) return;
+      shouldContainThreeFs = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      f = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldBeJerry = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldBeByteBar = _aidl_parcel.readByte();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldBeIntBar = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldBeLongBar = _aidl_parcel.readLong();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldContainTwoByteFoos = _aidl_parcel.createByteArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldContainTwoIntFoos = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldContainTwoLongFoos = _aidl_parcel.createLongArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      stringDefaultsToFoo = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      byteDefaultsToFour = _aidl_parcel.readByte();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      intDefaultsToFive = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      longDefaultsToNegativeSeven = _aidl_parcel.readLong();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      booleanDefaultsToTrue = (0!=_aidl_parcel.readInt());
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      charDefaultsToC = (char)_aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      floatDefaultsToPi = _aidl_parcel.readFloat();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      doubleWithDefault = _aidl_parcel.readDouble();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      arrayDefaultsTo123 = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      arrayDefaultsToEmpty = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      boolDefault = (0!=_aidl_parcel.readInt());
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      byteDefault = _aidl_parcel.readByte();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      intDefault = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      longDefault = _aidl_parcel.readLong();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      floatDefault = _aidl_parcel.readFloat();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      doubleDefault = _aidl_parcel.readDouble();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      checkDoubleFromFloat = _aidl_parcel.readDouble();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      checkStringArray1 = _aidl_parcel.createStringArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      checkStringArray2 = _aidl_parcel.createStringArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      int32_min = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      int32_max = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      int64_max = _aidl_parcel.readLong();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      hexInt32_neg_1 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      ibinder = _aidl_parcel.readStrongBinder();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      int32_1 = _aidl_parcel.createIntArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      int64_1 = _aidl_parcel.createLongArray();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      hexInt32_pos_1 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      hexInt64_pos_1 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_1 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_2 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_3 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_4 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_5 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_6 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_7 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_8 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_9 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      const_exprs_10 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      addString1 = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      addString2 = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      shouldSetBit0AndBit2 = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      if ((0!=_aidl_parcel.readInt())) {
+        u = android.aidl.tests.Union.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        u = null;
+      }
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      if ((0!=_aidl_parcel.readInt())) {
+        shouldBeConstS1 = android.aidl.tests.Union.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        shouldBeConstS1 = null;
+      }
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      defaultWithFoo = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+    } finally {
+      if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {
+        throw new android.os.BadParcelableException("Overflow in the size of parcelable");
+      }
+      _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    }
+  }
+  public static final int BIT0 = 1;
+  public static final int BIT1 = 2;
+  public static final int BIT2 = 4;
+  @Override
+  public String toString() {
+    java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(", ", "{", "}");
+    _aidl_sj.add("shouldContainThreeFs: " + (java.util.Arrays.toString(shouldContainThreeFs)));
+    _aidl_sj.add("f: " + (f));
+    _aidl_sj.add("shouldBeJerry: " + (java.util.Objects.toString(shouldBeJerry)));
+    _aidl_sj.add("shouldBeByteBar: " + (shouldBeByteBar));
+    _aidl_sj.add("shouldBeIntBar: " + (shouldBeIntBar));
+    _aidl_sj.add("shouldBeLongBar: " + (shouldBeLongBar));
+    _aidl_sj.add("shouldContainTwoByteFoos: " + (java.util.Arrays.toString(shouldContainTwoByteFoos)));
+    _aidl_sj.add("shouldContainTwoIntFoos: " + (java.util.Arrays.toString(shouldContainTwoIntFoos)));
+    _aidl_sj.add("shouldContainTwoLongFoos: " + (java.util.Arrays.toString(shouldContainTwoLongFoos)));
+    _aidl_sj.add("stringDefaultsToFoo: " + (java.util.Objects.toString(stringDefaultsToFoo)));
+    _aidl_sj.add("byteDefaultsToFour: " + (byteDefaultsToFour));
+    _aidl_sj.add("intDefaultsToFive: " + (intDefaultsToFive));
+    _aidl_sj.add("longDefaultsToNegativeSeven: " + (longDefaultsToNegativeSeven));
+    _aidl_sj.add("booleanDefaultsToTrue: " + (booleanDefaultsToTrue));
+    _aidl_sj.add("charDefaultsToC: " + (charDefaultsToC));
+    _aidl_sj.add("floatDefaultsToPi: " + (floatDefaultsToPi));
+    _aidl_sj.add("doubleWithDefault: " + (doubleWithDefault));
+    _aidl_sj.add("arrayDefaultsTo123: " + (java.util.Arrays.toString(arrayDefaultsTo123)));
+    _aidl_sj.add("arrayDefaultsToEmpty: " + (java.util.Arrays.toString(arrayDefaultsToEmpty)));
+    _aidl_sj.add("boolDefault: " + (boolDefault));
+    _aidl_sj.add("byteDefault: " + (byteDefault));
+    _aidl_sj.add("intDefault: " + (intDefault));
+    _aidl_sj.add("longDefault: " + (longDefault));
+    _aidl_sj.add("floatDefault: " + (floatDefault));
+    _aidl_sj.add("doubleDefault: " + (doubleDefault));
+    _aidl_sj.add("checkDoubleFromFloat: " + (checkDoubleFromFloat));
+    _aidl_sj.add("checkStringArray1: " + (java.util.Arrays.toString(checkStringArray1)));
+    _aidl_sj.add("checkStringArray2: " + (java.util.Arrays.toString(checkStringArray2)));
+    _aidl_sj.add("int32_min: " + (int32_min));
+    _aidl_sj.add("int32_max: " + (int32_max));
+    _aidl_sj.add("int64_max: " + (int64_max));
+    _aidl_sj.add("hexInt32_neg_1: " + (hexInt32_neg_1));
+    _aidl_sj.add("ibinder: " + (java.util.Objects.toString(ibinder)));
+    _aidl_sj.add("int32_1: " + (java.util.Arrays.toString(int32_1)));
+    _aidl_sj.add("int64_1: " + (java.util.Arrays.toString(int64_1)));
+    _aidl_sj.add("hexInt32_pos_1: " + (hexInt32_pos_1));
+    _aidl_sj.add("hexInt64_pos_1: " + (hexInt64_pos_1));
+    _aidl_sj.add("const_exprs_1: " + (const_exprs_1));
+    _aidl_sj.add("const_exprs_2: " + (const_exprs_2));
+    _aidl_sj.add("const_exprs_3: " + (const_exprs_3));
+    _aidl_sj.add("const_exprs_4: " + (const_exprs_4));
+    _aidl_sj.add("const_exprs_5: " + (const_exprs_5));
+    _aidl_sj.add("const_exprs_6: " + (const_exprs_6));
+    _aidl_sj.add("const_exprs_7: " + (const_exprs_7));
+    _aidl_sj.add("const_exprs_8: " + (const_exprs_8));
+    _aidl_sj.add("const_exprs_9: " + (const_exprs_9));
+    _aidl_sj.add("const_exprs_10: " + (const_exprs_10));
+    _aidl_sj.add("addString1: " + (java.util.Objects.toString(addString1)));
+    _aidl_sj.add("addString2: " + (java.util.Objects.toString(addString2)));
+    _aidl_sj.add("shouldSetBit0AndBit2: " + (shouldSetBit0AndBit2));
+    _aidl_sj.add("u: " + (java.util.Objects.toString(u)));
+    _aidl_sj.add("shouldBeConstS1: " + (java.util.Objects.toString(shouldBeConstS1)));
+    _aidl_sj.add("defaultWithFoo: " + (defaultWithFoo));
+    return "android.aidl.tests.StructuredParcelable" + _aidl_sj.toString()  ;
+  }
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) return true;
+    if (other == null) return false;
+    if (!(other instanceof StructuredParcelable)) return false;
+    StructuredParcelable that = (StructuredParcelable)other;
+    if (!java.util.Objects.deepEquals(shouldContainThreeFs, that.shouldContainThreeFs)) return false;
+    if (!java.util.Objects.deepEquals(f, that.f)) return false;
+    if (!java.util.Objects.deepEquals(shouldBeJerry, that.shouldBeJerry)) return false;
+    if (!java.util.Objects.deepEquals(shouldBeByteBar, that.shouldBeByteBar)) return false;
+    if (!java.util.Objects.deepEquals(shouldBeIntBar, that.shouldBeIntBar)) return false;
+    if (!java.util.Objects.deepEquals(shouldBeLongBar, that.shouldBeLongBar)) return false;
+    if (!java.util.Objects.deepEquals(shouldContainTwoByteFoos, that.shouldContainTwoByteFoos)) return false;
+    if (!java.util.Objects.deepEquals(shouldContainTwoIntFoos, that.shouldContainTwoIntFoos)) return false;
+    if (!java.util.Objects.deepEquals(shouldContainTwoLongFoos, that.shouldContainTwoLongFoos)) return false;
+    if (!java.util.Objects.deepEquals(stringDefaultsToFoo, that.stringDefaultsToFoo)) return false;
+    if (!java.util.Objects.deepEquals(byteDefaultsToFour, that.byteDefaultsToFour)) return false;
+    if (!java.util.Objects.deepEquals(intDefaultsToFive, that.intDefaultsToFive)) return false;
+    if (!java.util.Objects.deepEquals(longDefaultsToNegativeSeven, that.longDefaultsToNegativeSeven)) return false;
+    if (!java.util.Objects.deepEquals(booleanDefaultsToTrue, that.booleanDefaultsToTrue)) return false;
+    if (!java.util.Objects.deepEquals(charDefaultsToC, that.charDefaultsToC)) return false;
+    if (!java.util.Objects.deepEquals(floatDefaultsToPi, that.floatDefaultsToPi)) return false;
+    if (!java.util.Objects.deepEquals(doubleWithDefault, that.doubleWithDefault)) return false;
+    if (!java.util.Objects.deepEquals(arrayDefaultsTo123, that.arrayDefaultsTo123)) return false;
+    if (!java.util.Objects.deepEquals(arrayDefaultsToEmpty, that.arrayDefaultsToEmpty)) return false;
+    if (!java.util.Objects.deepEquals(boolDefault, that.boolDefault)) return false;
+    if (!java.util.Objects.deepEquals(byteDefault, that.byteDefault)) return false;
+    if (!java.util.Objects.deepEquals(intDefault, that.intDefault)) return false;
+    if (!java.util.Objects.deepEquals(longDefault, that.longDefault)) return false;
+    if (!java.util.Objects.deepEquals(floatDefault, that.floatDefault)) return false;
+    if (!java.util.Objects.deepEquals(doubleDefault, that.doubleDefault)) return false;
+    if (!java.util.Objects.deepEquals(checkDoubleFromFloat, that.checkDoubleFromFloat)) return false;
+    if (!java.util.Objects.deepEquals(checkStringArray1, that.checkStringArray1)) return false;
+    if (!java.util.Objects.deepEquals(checkStringArray2, that.checkStringArray2)) return false;
+    if (!java.util.Objects.deepEquals(int32_min, that.int32_min)) return false;
+    if (!java.util.Objects.deepEquals(int32_max, that.int32_max)) return false;
+    if (!java.util.Objects.deepEquals(int64_max, that.int64_max)) return false;
+    if (!java.util.Objects.deepEquals(hexInt32_neg_1, that.hexInt32_neg_1)) return false;
+    if (!java.util.Objects.deepEquals(ibinder, that.ibinder)) return false;
+    if (!java.util.Objects.deepEquals(int32_1, that.int32_1)) return false;
+    if (!java.util.Objects.deepEquals(int64_1, that.int64_1)) return false;
+    if (!java.util.Objects.deepEquals(hexInt32_pos_1, that.hexInt32_pos_1)) return false;
+    if (!java.util.Objects.deepEquals(hexInt64_pos_1, that.hexInt64_pos_1)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_1, that.const_exprs_1)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_2, that.const_exprs_2)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_3, that.const_exprs_3)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_4, that.const_exprs_4)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_5, that.const_exprs_5)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_6, that.const_exprs_6)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_7, that.const_exprs_7)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_8, that.const_exprs_8)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_9, that.const_exprs_9)) return false;
+    if (!java.util.Objects.deepEquals(const_exprs_10, that.const_exprs_10)) return false;
+    if (!java.util.Objects.deepEquals(addString1, that.addString1)) return false;
+    if (!java.util.Objects.deepEquals(addString2, that.addString2)) return false;
+    if (!java.util.Objects.deepEquals(shouldSetBit0AndBit2, that.shouldSetBit0AndBit2)) return false;
+    if (!java.util.Objects.deepEquals(u, that.u)) return false;
+    if (!java.util.Objects.deepEquals(shouldBeConstS1, that.shouldBeConstS1)) return false;
+    if (!java.util.Objects.deepEquals(defaultWithFoo, that.defaultWithFoo)) return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return java.util.Arrays.deepHashCode(java.util.Arrays.asList(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo).toArray());
+  }
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    _mask |= describeContents(u);
+    _mask |= describeContents(shouldBeConstS1);
+    return _mask;
+  }
+  private int describeContents(Object _v) {
+    if (_v == null) return 0;
+    if (_v instanceof android.os.Parcelable) {
+      return ((android.os.Parcelable) _v).describeContents();
+    }
+    return 0;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java.d
new file mode 100644
index 0000000..8215023
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/StructuredParcelable.java : \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java
new file mode 100644
index 0000000..2e1def2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java
@@ -0,0 +1,287 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+
+public final class Union implements android.os.Parcelable {
+  // tags for union fields
+  public final static int ns = 0;  // int[] ns;
+  public final static int n = 1;  // int n;
+  public final static int m = 2;  // int m;
+  public final static int s = 3;  // String s;
+  public final static int ibinder = 4;  // IBinder ibinder;
+  public final static int ss = 5;  // List<String> ss;
+  public final static int be = 6;  // android.aidl.tests.ByteEnum be;
+
+  private int _tag;
+  private Object _value;
+
+  public Union() {
+    int[] _value = {};
+    this._tag = ns;
+    this._value = _value;
+  }
+
+  private Union(android.os.Parcel _aidl_parcel) {
+    readFromParcel(_aidl_parcel);
+  }
+
+  private Union(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+
+  public int getTag() {
+    return _tag;
+  }
+
+  // int[] ns;
+
+  public static Union ns(int[] _value) {
+    return new Union(ns, _value);
+  }
+
+  public int[] getNs() {
+    _assertTag(ns);
+    return (int[]) _value;
+  }
+
+  public void setNs(int[] _value) {
+    _set(ns, _value);
+  }
+
+  // int n;
+
+  public static Union n(int _value) {
+    return new Union(n, _value);
+  }
+
+  public int getN() {
+    _assertTag(n);
+    return (int) _value;
+  }
+
+  public void setN(int _value) {
+    _set(n, _value);
+  }
+
+  // int m;
+
+  public static Union m(int _value) {
+    return new Union(m, _value);
+  }
+
+  public int getM() {
+    _assertTag(m);
+    return (int) _value;
+  }
+
+  public void setM(int _value) {
+    _set(m, _value);
+  }
+
+  // String s;
+
+  public static Union s(java.lang.String _value) {
+    return new Union(s, _value);
+  }
+
+  public java.lang.String getS() {
+    _assertTag(s);
+    return (java.lang.String) _value;
+  }
+
+  public void setS(java.lang.String _value) {
+    _set(s, _value);
+  }
+
+  // IBinder ibinder;
+
+  public static Union ibinder(android.os.IBinder _value) {
+    return new Union(ibinder, _value);
+  }
+
+  public android.os.IBinder getIbinder() {
+    _assertTag(ibinder);
+    return (android.os.IBinder) _value;
+  }
+
+  public void setIbinder(android.os.IBinder _value) {
+    _set(ibinder, _value);
+  }
+
+  // List<String> ss;
+
+  public static Union ss(java.util.List<java.lang.String> _value) {
+    return new Union(ss, _value);
+  }
+
+  @SuppressWarnings("unchecked")
+  public java.util.List<java.lang.String> getSs() {
+    _assertTag(ss);
+    return (java.util.List<java.lang.String>) _value;
+  }
+
+  public void setSs(java.util.List<java.lang.String> _value) {
+    _set(ss, _value);
+  }
+
+  // android.aidl.tests.ByteEnum be;
+
+  public static Union be(byte _value) {
+    return new Union(be, _value);
+  }
+
+  public byte getBe() {
+    _assertTag(be);
+    return (byte) _value;
+  }
+
+  public void setBe(byte _value) {
+    _set(be, _value);
+  }
+
+  public static final android.os.Parcelable.Creator<Union> CREATOR = new android.os.Parcelable.Creator<Union>() {
+    @Override
+    public Union createFromParcel(android.os.Parcel _aidl_source) {
+      return new Union(_aidl_source);
+    }
+    @Override
+    public Union[] newArray(int _aidl_size) {
+      return new Union[_aidl_size];
+    }
+  };
+
+  @Override
+  public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) {
+    _aidl_parcel.writeInt(_tag);
+    switch (_tag) {
+    case ns:
+      _aidl_parcel.writeIntArray(getNs());
+      break;
+    case n:
+      _aidl_parcel.writeInt(getN());
+      break;
+    case m:
+      _aidl_parcel.writeInt(getM());
+      break;
+    case s:
+      _aidl_parcel.writeString(getS());
+      break;
+    case ibinder:
+      _aidl_parcel.writeStrongBinder(getIbinder());
+      break;
+    case ss:
+      _aidl_parcel.writeStringList(getSs());
+      break;
+    case be:
+      _aidl_parcel.writeByte(getBe());
+      break;
+    }
+  }
+
+  public void readFromParcel(android.os.Parcel _aidl_parcel) {
+    int _aidl_tag;
+    _aidl_tag = _aidl_parcel.readInt();
+    switch (_aidl_tag) {
+    case ns: {
+      int[] _aidl_value;
+      _aidl_value = _aidl_parcel.createIntArray();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case n: {
+      int _aidl_value;
+      _aidl_value = _aidl_parcel.readInt();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case m: {
+      int _aidl_value;
+      _aidl_value = _aidl_parcel.readInt();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case s: {
+      java.lang.String _aidl_value;
+      _aidl_value = _aidl_parcel.readString();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case ibinder: {
+      android.os.IBinder _aidl_value;
+      _aidl_value = _aidl_parcel.readStrongBinder();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case ss: {
+      java.util.List<java.lang.String> _aidl_value;
+      _aidl_value = _aidl_parcel.createStringArrayList();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case be: {
+      byte _aidl_value;
+      _aidl_value = _aidl_parcel.readByte();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    }
+    throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag);
+  }
+
+  public static final String S1 = "a string constant in union";
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    switch (getTag()) {
+    }
+    return _mask;
+  }
+
+  @Override
+  public String toString() {
+    switch (_tag) {
+    case ns: return "android.aidl.tests.Union.ns(" + (java.util.Arrays.toString(getNs())) + ")";
+    case n: return "android.aidl.tests.Union.n(" + (getN()) + ")";
+    case m: return "android.aidl.tests.Union.m(" + (getM()) + ")";
+    case s: return "android.aidl.tests.Union.s(" + (java.util.Objects.toString(getS())) + ")";
+    case ibinder: return "android.aidl.tests.Union.ibinder(" + (java.util.Objects.toString(getIbinder())) + ")";
+    case ss: return "android.aidl.tests.Union.ss(" + (java.util.Objects.toString(getSs())) + ")";
+    case be: return "android.aidl.tests.Union.be(" + (getBe()) + ")";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) return true;
+    if (other == null) return false;
+    if (!(other instanceof Union)) return false;
+    Union that = (Union)other;
+    if (_tag != that._tag) return false;
+    if (!java.util.Objects.deepEquals(_value, that._value)) return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return java.util.Arrays.deepHashCode(java.util.Arrays.asList(_tag, _value).toArray());
+  }
+
+  private void _assertTag(int tag) {
+    if (getTag() != tag) {
+      throw new IllegalStateException("bad access: " + _tagString(tag) + ", " + _tagString(getTag()) + " is available.");
+    }
+  }
+
+  private String _tagString(int _tag) {
+    switch (_tag) {
+    case ns: return "ns";
+    case n: return "n";
+    case m: return "m";
+    case s: return "s";
+    case ibinder: return "ibinder";
+    case ss: return "ss";
+    case be: return "be";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+
+  private void _set(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java.d
new file mode 100644
index 0000000..58d449e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java : \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java
new file mode 100644
index 0000000..ba025ad
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java
@@ -0,0 +1,152 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests;
+
+public final class UnionWithFd implements android.os.Parcelable {
+  // tags for union fields
+  public final static int num = 0;  // int num;
+  public final static int pfd = 1;  // ParcelFileDescriptor pfd;
+
+  private int _tag;
+  private Object _value;
+
+  public UnionWithFd() {
+    int _value = 0;
+    this._tag = num;
+    this._value = _value;
+  }
+
+  private UnionWithFd(android.os.Parcel _aidl_parcel) {
+    readFromParcel(_aidl_parcel);
+  }
+
+  private UnionWithFd(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+
+  public int getTag() {
+    return _tag;
+  }
+
+  // int num;
+
+  public static UnionWithFd num(int _value) {
+    return new UnionWithFd(num, _value);
+  }
+
+  public int getNum() {
+    _assertTag(num);
+    return (int) _value;
+  }
+
+  public void setNum(int _value) {
+    _set(num, _value);
+  }
+
+  // ParcelFileDescriptor pfd;
+
+  public static UnionWithFd pfd(android.os.ParcelFileDescriptor _value) {
+    return new UnionWithFd(pfd, _value);
+  }
+
+  public android.os.ParcelFileDescriptor getPfd() {
+    _assertTag(pfd);
+    return (android.os.ParcelFileDescriptor) _value;
+  }
+
+  public void setPfd(android.os.ParcelFileDescriptor _value) {
+    _set(pfd, _value);
+  }
+
+  public static final android.os.Parcelable.Creator<UnionWithFd> CREATOR = new android.os.Parcelable.Creator<UnionWithFd>() {
+    @Override
+    public UnionWithFd createFromParcel(android.os.Parcel _aidl_source) {
+      return new UnionWithFd(_aidl_source);
+    }
+    @Override
+    public UnionWithFd[] newArray(int _aidl_size) {
+      return new UnionWithFd[_aidl_size];
+    }
+  };
+
+  @Override
+  public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) {
+    _aidl_parcel.writeInt(_tag);
+    switch (_tag) {
+    case num:
+      _aidl_parcel.writeInt(getNum());
+      break;
+    case pfd:
+      if ((getPfd()!=null)) {
+        _aidl_parcel.writeInt(1);
+        getPfd().writeToParcel(_aidl_parcel, 0);
+      }
+      else {
+        _aidl_parcel.writeInt(0);
+      }
+      break;
+    }
+  }
+
+  public void readFromParcel(android.os.Parcel _aidl_parcel) {
+    int _aidl_tag;
+    _aidl_tag = _aidl_parcel.readInt();
+    switch (_aidl_tag) {
+    case num: {
+      int _aidl_value;
+      _aidl_value = _aidl_parcel.readInt();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case pfd: {
+      android.os.ParcelFileDescriptor _aidl_value;
+      if ((0!=_aidl_parcel.readInt())) {
+        _aidl_value = android.os.ParcelFileDescriptor.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        _aidl_value = null;
+      }
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    }
+    throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag);
+  }
+
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    switch (getTag()) {
+    case pfd:
+      _mask |= describeContents(getPfd());
+      break;
+    }
+    return _mask;
+  }
+  private int describeContents(Object _v) {
+    if (_v == null) return 0;
+    if (_v instanceof android.os.Parcelable) {
+      return ((android.os.Parcelable) _v).describeContents();
+    }
+    return 0;
+  }
+
+  private void _assertTag(int tag) {
+    if (getTag() != tag) {
+      throw new IllegalStateException("bad access: " + _tagString(tag) + ", " + _tagString(getTag()) + " is available.");
+    }
+  }
+
+  private String _tagString(int _tag) {
+    switch (_tag) {
+    case num: return "num";
+    case pfd: return "pfd";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+
+  private void _set(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java.d
new file mode 100644
index 0000000..2b2d668
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java : \
+  system/tools/aidl/tests/android/aidl/tests/UnionWithFd.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java
new file mode 100644
index 0000000..0e8ac93
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java
@@ -0,0 +1,155 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.tests.unions;
+
+public final class EnumUnion implements android.os.Parcelable {
+  // tags for union fields
+  public final static int intEnum = 0;  // android.aidl.tests.IntEnum intEnum;
+  public final static int longEnum = 1;  // android.aidl.tests.LongEnum longEnum;
+
+  private int _tag;
+  private Object _value;
+
+  public EnumUnion() {
+    int _value = android.aidl.tests.IntEnum.FOO;
+    this._tag = intEnum;
+    this._value = _value;
+  }
+
+  private EnumUnion(android.os.Parcel _aidl_parcel) {
+    readFromParcel(_aidl_parcel);
+  }
+
+  private EnumUnion(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+
+  public int getTag() {
+    return _tag;
+  }
+
+  // android.aidl.tests.IntEnum intEnum;
+
+  public static EnumUnion intEnum(int _value) {
+    return new EnumUnion(intEnum, _value);
+  }
+
+  public int getIntEnum() {
+    _assertTag(intEnum);
+    return (int) _value;
+  }
+
+  public void setIntEnum(int _value) {
+    _set(intEnum, _value);
+  }
+
+  // android.aidl.tests.LongEnum longEnum;
+
+  public static EnumUnion longEnum(long _value) {
+    return new EnumUnion(longEnum, _value);
+  }
+
+  public long getLongEnum() {
+    _assertTag(longEnum);
+    return (long) _value;
+  }
+
+  public void setLongEnum(long _value) {
+    _set(longEnum, _value);
+  }
+
+  public static final android.os.Parcelable.Creator<EnumUnion> CREATOR = new android.os.Parcelable.Creator<EnumUnion>() {
+    @Override
+    public EnumUnion createFromParcel(android.os.Parcel _aidl_source) {
+      return new EnumUnion(_aidl_source);
+    }
+    @Override
+    public EnumUnion[] newArray(int _aidl_size) {
+      return new EnumUnion[_aidl_size];
+    }
+  };
+
+  @Override
+  public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) {
+    _aidl_parcel.writeInt(_tag);
+    switch (_tag) {
+    case intEnum:
+      _aidl_parcel.writeInt(getIntEnum());
+      break;
+    case longEnum:
+      _aidl_parcel.writeLong(getLongEnum());
+      break;
+    }
+  }
+
+  public void readFromParcel(android.os.Parcel _aidl_parcel) {
+    int _aidl_tag;
+    _aidl_tag = _aidl_parcel.readInt();
+    switch (_aidl_tag) {
+    case intEnum: {
+      int _aidl_value;
+      _aidl_value = _aidl_parcel.readInt();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case longEnum: {
+      long _aidl_value;
+      _aidl_value = _aidl_parcel.readLong();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    }
+    throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag);
+  }
+
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    switch (getTag()) {
+    }
+    return _mask;
+  }
+
+  @Override
+  public String toString() {
+    switch (_tag) {
+    case intEnum: return "android.aidl.tests.unions.EnumUnion.intEnum(" + (getIntEnum()) + ")";
+    case longEnum: return "android.aidl.tests.unions.EnumUnion.longEnum(" + (getLongEnum()) + ")";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) return true;
+    if (other == null) return false;
+    if (!(other instanceof EnumUnion)) return false;
+    EnumUnion that = (EnumUnion)other;
+    if (_tag != that._tag) return false;
+    if (!java.util.Objects.deepEquals(_value, that._value)) return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return java.util.Arrays.deepHashCode(java.util.Arrays.asList(_tag, _value).toArray());
+  }
+
+  private void _assertTag(int tag) {
+    if (getTag() != tag) {
+      throw new IllegalStateException("bad access: " + _tagString(tag) + ", " + _tagString(getTag()) + " is available.");
+    }
+  }
+
+  private String _tagString(int _tag) {
+    switch (_tag) {
+    case intEnum: return "intEnum";
+    case longEnum: return "longEnum";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+
+  private void _set(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java.d
new file mode 100644
index 0000000..d7b0669
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java : \
+  system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/timestamp b/tests/golden_output/aidl-test-interface-java-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/timestamp
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp.d
new file mode 100644
index 0000000..74e47f9
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/BackendType.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp.d
new file mode 100644
index 0000000..510012a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ByteEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp.d
new file mode 100644
index 0000000..a195c09
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ConstantExpressionEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp.d
new file mode 100644
index 0000000..10c0013
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp
new file mode 100644
index 0000000..17f6da2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp
@@ -0,0 +1,140 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/tests/BpNamedCallback.h>
+#include <aidl/android/aidl/tests/BnNamedCallback.h>
+#include <aidl/android/aidl/tests/INamedCallback.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+static binder_status_t _aidl_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
+  (void)_aidl_in;
+  (void)_aidl_out;
+  binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
+  std::shared_ptr<BnNamedCallback> _aidl_impl = std::static_pointer_cast<BnNamedCallback>(::ndk::ICInterface::asInterface(_aidl_binder));
+  switch (_aidl_code) {
+    case (FIRST_CALL_TRANSACTION + 0 /*GetName*/): {
+      std::string _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetName(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+  }
+  return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(INamedCallback::descriptor, _aidl_onTransact);
+
+BpNamedCallback::BpNamedCallback(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpNamedCallback::~BpNamedCallback() {}
+
+::ndk::ScopedAStatus BpNamedCallback::GetName(std::string* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 0 /*GetName*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    0
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && INamedCallback::getDefaultImpl()) {
+    _aidl_status = INamedCallback::getDefaultImpl()->GetName(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+// Source for BnNamedCallback
+BnNamedCallback::BnNamedCallback() {}
+BnNamedCallback::~BnNamedCallback() {}
+::ndk::SpAIBinder BnNamedCallback::createBinder() {
+  AIBinder* binder = AIBinder_new(_g_aidl_clazz, static_cast<void*>(this));
+  #ifdef BINDER_STABILITY_SUPPORT
+  AIBinder_markCompilationUnitStability(binder);
+  #endif  // BINDER_STABILITY_SUPPORT
+  return ::ndk::SpAIBinder(binder);
+}
+// Source for INamedCallback
+const char* INamedCallback::descriptor = "android.aidl.tests.INamedCallback";
+INamedCallback::INamedCallback() {}
+INamedCallback::~INamedCallback() {}
+
+
+std::shared_ptr<INamedCallback> INamedCallback::fromBinder(const ::ndk::SpAIBinder& binder) {
+  if (!AIBinder_associateClass(binder.get(), _g_aidl_clazz)) { return nullptr; }
+  std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
+  if (interface) {
+    return std::static_pointer_cast<INamedCallback>(interface);
+  }
+  return ::ndk::SharedRefBase::make<BpNamedCallback>(binder);
+}
+
+binder_status_t INamedCallback::writeToParcel(AParcel* parcel, const std::shared_ptr<INamedCallback>& instance) {
+  return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t INamedCallback::readFromParcel(const AParcel* parcel, std::shared_ptr<INamedCallback>* instance) {
+  ::ndk::SpAIBinder binder;
+  binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+  if (status != STATUS_OK) return status;
+  *instance = INamedCallback::fromBinder(binder);
+  return STATUS_OK;
+}
+bool INamedCallback::setDefaultImpl(const std::shared_ptr<INamedCallback>& impl) {
+  // Only one user of this interface can use this function
+  // at a time. This is a heuristic to detect if two different
+  // users in the same process use this function.
+  assert(!INamedCallback::default_impl);
+  if (impl) {
+    INamedCallback::default_impl = impl;
+    return true;
+  }
+  return false;
+}
+const std::shared_ptr<INamedCallback>& INamedCallback::getDefaultImpl() {
+  return INamedCallback::default_impl;
+}
+std::shared_ptr<INamedCallback> INamedCallback::default_impl = nullptr;
+::ndk::ScopedAStatus INamedCallbackDefault::GetName(std::string* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::SpAIBinder INamedCallbackDefault::asBinder() {
+  return ::ndk::SpAIBinder();
+}
+bool INamedCallbackDefault::isRemote() {
+  return false;
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp.d
new file mode 100644
index 0000000..2eceb33
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INamedCallback.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp
new file mode 100644
index 0000000..8f48442
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp
@@ -0,0 +1,140 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/tests/BpNewName.h>
+#include <aidl/android/aidl/tests/BnNewName.h>
+#include <aidl/android/aidl/tests/INewName.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+static binder_status_t _aidl_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
+  (void)_aidl_in;
+  (void)_aidl_out;
+  binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
+  std::shared_ptr<BnNewName> _aidl_impl = std::static_pointer_cast<BnNewName>(::ndk::ICInterface::asInterface(_aidl_binder));
+  switch (_aidl_code) {
+    case (FIRST_CALL_TRANSACTION + 0 /*RealName*/): {
+      std::string _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RealName(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+  }
+  return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(INewName::descriptor, _aidl_onTransact);
+
+BpNewName::BpNewName(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpNewName::~BpNewName() {}
+
+::ndk::ScopedAStatus BpNewName::RealName(std::string* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 0 /*RealName*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    0
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && INewName::getDefaultImpl()) {
+    _aidl_status = INewName::getDefaultImpl()->RealName(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+// Source for BnNewName
+BnNewName::BnNewName() {}
+BnNewName::~BnNewName() {}
+::ndk::SpAIBinder BnNewName::createBinder() {
+  AIBinder* binder = AIBinder_new(_g_aidl_clazz, static_cast<void*>(this));
+  #ifdef BINDER_STABILITY_SUPPORT
+  AIBinder_markCompilationUnitStability(binder);
+  #endif  // BINDER_STABILITY_SUPPORT
+  return ::ndk::SpAIBinder(binder);
+}
+// Source for INewName
+const char* INewName::descriptor = "android.aidl.tests.IOldName";
+INewName::INewName() {}
+INewName::~INewName() {}
+
+
+std::shared_ptr<INewName> INewName::fromBinder(const ::ndk::SpAIBinder& binder) {
+  if (!AIBinder_associateClass(binder.get(), _g_aidl_clazz)) { return nullptr; }
+  std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
+  if (interface) {
+    return std::static_pointer_cast<INewName>(interface);
+  }
+  return ::ndk::SharedRefBase::make<BpNewName>(binder);
+}
+
+binder_status_t INewName::writeToParcel(AParcel* parcel, const std::shared_ptr<INewName>& instance) {
+  return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t INewName::readFromParcel(const AParcel* parcel, std::shared_ptr<INewName>* instance) {
+  ::ndk::SpAIBinder binder;
+  binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+  if (status != STATUS_OK) return status;
+  *instance = INewName::fromBinder(binder);
+  return STATUS_OK;
+}
+bool INewName::setDefaultImpl(const std::shared_ptr<INewName>& impl) {
+  // Only one user of this interface can use this function
+  // at a time. This is a heuristic to detect if two different
+  // users in the same process use this function.
+  assert(!INewName::default_impl);
+  if (impl) {
+    INewName::default_impl = impl;
+    return true;
+  }
+  return false;
+}
+const std::shared_ptr<INewName>& INewName::getDefaultImpl() {
+  return INewName::default_impl;
+}
+std::shared_ptr<INewName> INewName::default_impl = nullptr;
+::ndk::ScopedAStatus INewNameDefault::RealName(std::string* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::SpAIBinder INewNameDefault::asBinder() {
+  return ::ndk::SpAIBinder();
+}
+bool INewNameDefault::isRemote() {
+  return false;
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp.d
new file mode 100644
index 0000000..0c569c5
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/INewName.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp
new file mode 100644
index 0000000..6f54ec6
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp
@@ -0,0 +1,140 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/tests/BpOldName.h>
+#include <aidl/android/aidl/tests/BnOldName.h>
+#include <aidl/android/aidl/tests/IOldName.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+static binder_status_t _aidl_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
+  (void)_aidl_in;
+  (void)_aidl_out;
+  binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
+  std::shared_ptr<BnOldName> _aidl_impl = std::static_pointer_cast<BnOldName>(::ndk::ICInterface::asInterface(_aidl_binder));
+  switch (_aidl_code) {
+    case (FIRST_CALL_TRANSACTION + 0 /*RealName*/): {
+      std::string _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RealName(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+  }
+  return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(IOldName::descriptor, _aidl_onTransact);
+
+BpOldName::BpOldName(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpOldName::~BpOldName() {}
+
+::ndk::ScopedAStatus BpOldName::RealName(std::string* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 0 /*RealName*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    0
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IOldName::getDefaultImpl()) {
+    _aidl_status = IOldName::getDefaultImpl()->RealName(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+// Source for BnOldName
+BnOldName::BnOldName() {}
+BnOldName::~BnOldName() {}
+::ndk::SpAIBinder BnOldName::createBinder() {
+  AIBinder* binder = AIBinder_new(_g_aidl_clazz, static_cast<void*>(this));
+  #ifdef BINDER_STABILITY_SUPPORT
+  AIBinder_markCompilationUnitStability(binder);
+  #endif  // BINDER_STABILITY_SUPPORT
+  return ::ndk::SpAIBinder(binder);
+}
+// Source for IOldName
+const char* IOldName::descriptor = "android.aidl.tests.IOldName";
+IOldName::IOldName() {}
+IOldName::~IOldName() {}
+
+
+std::shared_ptr<IOldName> IOldName::fromBinder(const ::ndk::SpAIBinder& binder) {
+  if (!AIBinder_associateClass(binder.get(), _g_aidl_clazz)) { return nullptr; }
+  std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
+  if (interface) {
+    return std::static_pointer_cast<IOldName>(interface);
+  }
+  return ::ndk::SharedRefBase::make<BpOldName>(binder);
+}
+
+binder_status_t IOldName::writeToParcel(AParcel* parcel, const std::shared_ptr<IOldName>& instance) {
+  return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t IOldName::readFromParcel(const AParcel* parcel, std::shared_ptr<IOldName>* instance) {
+  ::ndk::SpAIBinder binder;
+  binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+  if (status != STATUS_OK) return status;
+  *instance = IOldName::fromBinder(binder);
+  return STATUS_OK;
+}
+bool IOldName::setDefaultImpl(const std::shared_ptr<IOldName>& impl) {
+  // Only one user of this interface can use this function
+  // at a time. This is a heuristic to detect if two different
+  // users in the same process use this function.
+  assert(!IOldName::default_impl);
+  if (impl) {
+    IOldName::default_impl = impl;
+    return true;
+  }
+  return false;
+}
+const std::shared_ptr<IOldName>& IOldName::getDefaultImpl() {
+  return IOldName::default_impl;
+}
+std::shared_ptr<IOldName> IOldName::default_impl = nullptr;
+::ndk::ScopedAStatus IOldNameDefault::RealName(std::string* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::SpAIBinder IOldNameDefault::asBinder() {
+  return ::ndk::SpAIBinder();
+}
+bool IOldNameDefault::isRemote() {
+  return false;
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp.d
new file mode 100644
index 0000000..8e4435e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IOldName.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp
new file mode 100644
index 0000000..6d00c22
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp
@@ -0,0 +1,3427 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/tests/BpNamedCallback.h>
+#include <aidl/android/aidl/tests/BnNamedCallback.h>
+#include <aidl/android/aidl/tests/INamedCallback.h>
+#include <aidl/android/aidl/tests/BpNewName.h>
+#include <aidl/android/aidl/tests/BnNewName.h>
+#include <aidl/android/aidl/tests/INewName.h>
+#include <aidl/android/aidl/tests/BpOldName.h>
+#include <aidl/android/aidl/tests/BnOldName.h>
+#include <aidl/android/aidl/tests/IOldName.h>
+#include <aidl/android/aidl/tests/BpTestService.h>
+#include <aidl/android/aidl/tests/BnTestService.h>
+#include <aidl/android/aidl/tests/ITestService.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+static binder_status_t _aidl_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
+  (void)_aidl_in;
+  (void)_aidl_out;
+  binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
+  std::shared_ptr<BnTestService> _aidl_impl = std::static_pointer_cast<BnTestService>(::ndk::ICInterface::asInterface(_aidl_binder));
+  switch (_aidl_code) {
+    case (FIRST_CALL_TRANSACTION + 0 /*UnimplementedMethod*/): {
+      int32_t in_arg;
+      int32_t _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt32(_aidl_in, &in_arg);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->UnimplementedMethod(in_arg, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt32(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 1 /*TestOneway*/): {
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->TestOneway();
+      _aidl_ret_status = STATUS_OK;
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 2 /*RepeatBoolean*/): {
+      bool in_token;
+      bool _aidl_return;
+
+      _aidl_ret_status = AParcel_readBool(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatBoolean(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeBool(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 3 /*RepeatByte*/): {
+      int8_t in_token;
+      int8_t _aidl_return;
+
+      _aidl_ret_status = AParcel_readByte(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatByte(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeByte(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 4 /*RepeatChar*/): {
+      char16_t in_token;
+      char16_t _aidl_return;
+
+      _aidl_ret_status = AParcel_readChar(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatChar(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeChar(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 5 /*RepeatInt*/): {
+      int32_t in_token;
+      int32_t _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt32(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatInt(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt32(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 6 /*RepeatLong*/): {
+      int64_t in_token;
+      int64_t _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt64(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatLong(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt64(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 7 /*RepeatFloat*/): {
+      float in_token;
+      float _aidl_return;
+
+      _aidl_ret_status = AParcel_readFloat(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatFloat(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeFloat(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 8 /*RepeatDouble*/): {
+      double in_token;
+      double _aidl_return;
+
+      _aidl_ret_status = AParcel_readDouble(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatDouble(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeDouble(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 9 /*RepeatString*/): {
+      std::string in_token;
+      std::string _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatString(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 10 /*RepeatByteEnum*/): {
+      ::aidl::android::aidl::tests::ByteEnum in_token;
+      ::aidl::android::aidl::tests::ByteEnum _aidl_return;
+
+      _aidl_ret_status = AParcel_readByte(_aidl_in, reinterpret_cast<int8_t*>(&in_token));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatByteEnum(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeByte(_aidl_out, static_cast<int8_t>(_aidl_return));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 11 /*RepeatIntEnum*/): {
+      ::aidl::android::aidl::tests::IntEnum in_token;
+      ::aidl::android::aidl::tests::IntEnum _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt32(_aidl_in, reinterpret_cast<int32_t*>(&in_token));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatIntEnum(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt32(_aidl_out, static_cast<int32_t>(_aidl_return));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 12 /*RepeatLongEnum*/): {
+      ::aidl::android::aidl::tests::LongEnum in_token;
+      ::aidl::android::aidl::tests::LongEnum _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt64(_aidl_in, reinterpret_cast<int64_t*>(&in_token));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatLongEnum(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt64(_aidl_out, static_cast<int64_t>(_aidl_return));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 13 /*ReverseBoolean*/): {
+      std::vector<bool> in_input;
+      std::vector<bool> out_repeated;
+      std::vector<bool> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseBoolean(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 14 /*ReverseByte*/): {
+      std::vector<uint8_t> in_input;
+      std::vector<uint8_t> out_repeated;
+      std::vector<uint8_t> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseByte(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 15 /*ReverseChar*/): {
+      std::vector<char16_t> in_input;
+      std::vector<char16_t> out_repeated;
+      std::vector<char16_t> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseChar(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 16 /*ReverseInt*/): {
+      std::vector<int32_t> in_input;
+      std::vector<int32_t> out_repeated;
+      std::vector<int32_t> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseInt(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 17 /*ReverseLong*/): {
+      std::vector<int64_t> in_input;
+      std::vector<int64_t> out_repeated;
+      std::vector<int64_t> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseLong(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 18 /*ReverseFloat*/): {
+      std::vector<float> in_input;
+      std::vector<float> out_repeated;
+      std::vector<float> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseFloat(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 19 /*ReverseDouble*/): {
+      std::vector<double> in_input;
+      std::vector<double> out_repeated;
+      std::vector<double> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseDouble(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 20 /*ReverseString*/): {
+      std::vector<std::string> in_input;
+      std::vector<std::string> out_repeated;
+      std::vector<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseString(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 21 /*ReverseByteEnum*/): {
+      std::vector<::aidl::android::aidl::tests::ByteEnum> in_input;
+      std::vector<::aidl::android::aidl::tests::ByteEnum> out_repeated;
+      std::vector<::aidl::android::aidl::tests::ByteEnum> _aidl_return;
+
+      _aidl_ret_status = AParcel_readByteArray(_aidl_in, static_cast<void*>(&in_input), ndk::AParcel_stdVectorAllocator<int8_t>);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseByteEnum(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeByteArray(_aidl_out, reinterpret_cast<const int8_t*>(_aidl_return.data()), _aidl_return.size());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_writeByteArray(_aidl_out, reinterpret_cast<const int8_t*>(out_repeated.data()), out_repeated.size());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 22 /*ReverseIntEnum*/): {
+      std::vector<::aidl::android::aidl::tests::IntEnum> in_input;
+      std::vector<::aidl::android::aidl::tests::IntEnum> out_repeated;
+      std::vector<::aidl::android::aidl::tests::IntEnum> _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt32Array(_aidl_in, static_cast<void*>(&in_input), ndk::AParcel_stdVectorAllocator<int32_t>);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseIntEnum(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt32Array(_aidl_out, reinterpret_cast<const int32_t*>(_aidl_return.data()), _aidl_return.size());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_writeInt32Array(_aidl_out, reinterpret_cast<const int32_t*>(out_repeated.data()), out_repeated.size());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 23 /*ReverseLongEnum*/): {
+      std::vector<::aidl::android::aidl::tests::LongEnum> in_input;
+      std::vector<::aidl::android::aidl::tests::LongEnum> out_repeated;
+      std::vector<::aidl::android::aidl::tests::LongEnum> _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt64Array(_aidl_in, static_cast<void*>(&in_input), ndk::AParcel_stdVectorAllocator<int64_t>);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseLongEnum(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt64Array(_aidl_out, reinterpret_cast<const int64_t*>(_aidl_return.data()), _aidl_return.size());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_writeInt64Array(_aidl_out, reinterpret_cast<const int64_t*>(out_repeated.data()), out_repeated.size());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 24 /*GetOtherTestService*/): {
+      std::string in_name;
+      std::shared_ptr<::aidl::android::aidl::tests::INamedCallback> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_name);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetOtherTestService(in_name, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::aidl::android::aidl::tests::INamedCallback::writeToParcel(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 25 /*VerifyName*/): {
+      std::shared_ptr<::aidl::android::aidl::tests::INamedCallback> in_service;
+      std::string in_name;
+      bool _aidl_return;
+
+      _aidl_ret_status = ::aidl::android::aidl::tests::INamedCallback::readFromParcel(_aidl_in, &in_service);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_name);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->VerifyName(in_service, in_name, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeBool(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 26 /*ReverseStringList*/): {
+      std::vector<std::string> in_input;
+      std::vector<std::string> out_repeated;
+      std::vector<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseStringList(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 27 /*RepeatParcelFileDescriptor*/): {
+      ::ndk::ScopedFileDescriptor in_read;
+      ::ndk::ScopedFileDescriptor _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readRequiredParcelFileDescriptor(_aidl_in, &in_read);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatParcelFileDescriptor(in_read, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeRequiredParcelFileDescriptor(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 28 /*ReverseParcelFileDescriptorArray*/): {
+      std::vector<::ndk::ScopedFileDescriptor> in_input;
+      std::vector<::ndk::ScopedFileDescriptor> out_repeated;
+      std::vector<::ndk::ScopedFileDescriptor> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseParcelFileDescriptorArray(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 29 /*ThrowServiceException*/): {
+      int32_t in_code;
+
+      _aidl_ret_status = AParcel_readInt32(_aidl_in, &in_code);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ThrowServiceException(in_code);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 30 /*RepeatNullableIntArray*/): {
+      std::optional<std::vector<int32_t>> in_input;
+      std::optional<std::vector<int32_t>> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableIntArray(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 31 /*RepeatNullableByteEnumArray*/): {
+      std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>> in_input;
+      std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>> _aidl_return;
+
+      _aidl_ret_status = AParcel_readByteArray(_aidl_in, static_cast<void*>(&in_input), ndk::AParcel_nullableStdVectorAllocator<int8_t>);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableByteEnumArray(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeByteArray(_aidl_out, (_aidl_return ? reinterpret_cast<const int8_t*>(_aidl_return->data()) : nullptr), (_aidl_return ? _aidl_return->size() : -1));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 32 /*RepeatNullableIntEnumArray*/): {
+      std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>> in_input;
+      std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>> _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt32Array(_aidl_in, static_cast<void*>(&in_input), ndk::AParcel_nullableStdVectorAllocator<int32_t>);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableIntEnumArray(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt32Array(_aidl_out, (_aidl_return ? reinterpret_cast<const int32_t*>(_aidl_return->data()) : nullptr), (_aidl_return ? _aidl_return->size() : -1));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 33 /*RepeatNullableLongEnumArray*/): {
+      std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>> in_input;
+      std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>> _aidl_return;
+
+      _aidl_ret_status = AParcel_readInt64Array(_aidl_in, static_cast<void*>(&in_input), ndk::AParcel_nullableStdVectorAllocator<int64_t>);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableLongEnumArray(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeInt64Array(_aidl_out, (_aidl_return ? reinterpret_cast<const int64_t*>(_aidl_return->data()) : nullptr), (_aidl_return ? _aidl_return->size() : -1));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 34 /*RepeatNullableString*/): {
+      std::optional<std::string> in_input;
+      std::optional<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableString(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 35 /*RepeatNullableStringList*/): {
+      std::vector<std::string> in_input;
+      std::vector<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableStringList(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 36 /*RepeatNullableParcelable*/): {
+      std::optional<::aidl::android::aidl::tests::StructuredParcelable> in_input;
+      std::optional<::aidl::android::aidl::tests::StructuredParcelable> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readNullableParcelable(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableParcelable(in_input, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeNullableParcelable(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 37 /*TakesAnIBinder*/): {
+      ::ndk::SpAIBinder in_input;
+
+      _aidl_ret_status = ::ndk::AParcel_readRequiredStrongBinder(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->TakesAnIBinder(in_input);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 38 /*TakesANullableIBinder*/): {
+      ::ndk::SpAIBinder in_input;
+
+      _aidl_ret_status = ::ndk::AParcel_readNullableStrongBinder(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->TakesANullableIBinder(in_input);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 39 /*RepeatUtf8CppString*/): {
+      std::string in_token;
+      std::string _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatUtf8CppString(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 40 /*RepeatNullableUtf8CppString*/): {
+      std::optional<std::string> in_token;
+      std::optional<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_token);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->RepeatNullableUtf8CppString(in_token, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 41 /*ReverseUtf8CppString*/): {
+      std::vector<std::string> in_input;
+      std::vector<std::string> out_repeated;
+      std::vector<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseUtf8CppString(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 42 /*ReverseNullableUtf8CppString*/): {
+      std::optional<std::vector<std::optional<std::string>>> in_input;
+      std::optional<std::vector<std::optional<std::string>>> out_repeated;
+      std::optional<std::vector<std::optional<std::string>>> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_resizeVector(_aidl_in, &out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseNullableUtf8CppString(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 43 /*ReverseUtf8CppStringList*/): {
+      std::vector<std::string> in_input;
+      std::vector<std::string> out_repeated;
+      std::vector<std::string> _aidl_return;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_input);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->ReverseUtf8CppStringList(in_input, &out_repeated, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, out_repeated);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 44 /*GetCallback*/): {
+      bool in_return_null;
+      std::shared_ptr<::aidl::android::aidl::tests::INamedCallback> _aidl_return;
+
+      _aidl_ret_status = AParcel_readBool(_aidl_in, &in_return_null);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetCallback(in_return_null, &_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::aidl::android::aidl::tests::INamedCallback::writeToParcel(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 45 /*FillOutStructuredParcelable*/): {
+      ::aidl::android::aidl::tests::StructuredParcelable in_parcel;
+
+      _aidl_ret_status = ::ndk::AParcel_readParcelable(_aidl_in, &in_parcel);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->FillOutStructuredParcelable(&in_parcel);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeParcelable(_aidl_out, in_parcel);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 46 /*GetOldNameInterface*/): {
+      std::shared_ptr<::aidl::android::aidl::tests::IOldName> _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetOldNameInterface(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::aidl::android::aidl::tests::IOldName::writeToParcel(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 47 /*GetNewNameInterface*/): {
+      std::shared_ptr<::aidl::android::aidl::tests::INewName> _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetNewNameInterface(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::aidl::android::aidl::tests::INewName::writeToParcel(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 48 /*GetCppJavaTests*/): {
+      ::ndk::SpAIBinder _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetCppJavaTests(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeNullableStrongBinder(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+    case (FIRST_CALL_TRANSACTION + 49 /*getBackendType*/): {
+      ::aidl::android::aidl::tests::BackendType _aidl_return;
+
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->getBackendType(&_aidl_return);
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = AParcel_writeByte(_aidl_out, static_cast<int8_t>(_aidl_return));
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+  }
+  return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(ITestService::descriptor, _aidl_onTransact);
+
+BpTestService::BpTestService(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpTestService::~BpTestService() {}
+
+::ndk::ScopedAStatus BpTestService::UnimplementedMethod(int32_t in_arg, int32_t* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32(_aidl_in.get(), in_arg);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 0 /*UnimplementedMethod*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->UnimplementedMethod(in_arg, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt32(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::TestOneway() {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 1 /*TestOneway*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_ONEWAY | FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->TestOneway();
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatBoolean(bool in_token, bool* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeBool(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 2 /*RepeatBoolean*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatBoolean(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readBool(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatByte(int8_t in_token, int8_t* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeByte(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 3 /*RepeatByte*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatByte(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readByte(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatChar(char16_t in_token, char16_t* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeChar(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 4 /*RepeatChar*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatChar(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readChar(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatInt(int32_t in_token, int32_t* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 5 /*RepeatInt*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatInt(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt32(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatLong(int64_t in_token, int64_t* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt64(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 6 /*RepeatLong*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatLong(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt64(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatFloat(float in_token, float* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeFloat(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 7 /*RepeatFloat*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatFloat(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readFloat(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatDouble(double in_token, double* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeDouble(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 8 /*RepeatDouble*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatDouble(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readDouble(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatString(const std::string& in_token, std::string* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 9 /*RepeatString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatString(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatByteEnum(::aidl::android::aidl::tests::ByteEnum in_token, ::aidl::android::aidl::tests::ByteEnum* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeByte(_aidl_in.get(), static_cast<int8_t>(in_token));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 10 /*RepeatByteEnum*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatByteEnum(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readByte(_aidl_out.get(), reinterpret_cast<int8_t*>(_aidl_return));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatIntEnum(::aidl::android::aidl::tests::IntEnum in_token, ::aidl::android::aidl::tests::IntEnum* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32(_aidl_in.get(), static_cast<int32_t>(in_token));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 11 /*RepeatIntEnum*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatIntEnum(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt32(_aidl_out.get(), reinterpret_cast<int32_t*>(_aidl_return));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatLongEnum(::aidl::android::aidl::tests::LongEnum in_token, ::aidl::android::aidl::tests::LongEnum* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt64(_aidl_in.get(), static_cast<int64_t>(in_token));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 12 /*RepeatLongEnum*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatLongEnum(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt64(_aidl_out.get(), reinterpret_cast<int64_t*>(_aidl_return));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseBoolean(const std::vector<bool>& in_input, std::vector<bool>* out_repeated, std::vector<bool>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 13 /*ReverseBoolean*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseBoolean(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseByte(const std::vector<uint8_t>& in_input, std::vector<uint8_t>* out_repeated, std::vector<uint8_t>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 14 /*ReverseByte*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseByte(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseChar(const std::vector<char16_t>& in_input, std::vector<char16_t>* out_repeated, std::vector<char16_t>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 15 /*ReverseChar*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseChar(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseInt(const std::vector<int32_t>& in_input, std::vector<int32_t>* out_repeated, std::vector<int32_t>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 16 /*ReverseInt*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseInt(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseLong(const std::vector<int64_t>& in_input, std::vector<int64_t>* out_repeated, std::vector<int64_t>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 17 /*ReverseLong*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseLong(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseFloat(const std::vector<float>& in_input, std::vector<float>* out_repeated, std::vector<float>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 18 /*ReverseFloat*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseFloat(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseDouble(const std::vector<double>& in_input, std::vector<double>* out_repeated, std::vector<double>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 19 /*ReverseDouble*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseDouble(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 20 /*ReverseString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseString(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseByteEnum(const std::vector<::aidl::android::aidl::tests::ByteEnum>& in_input, std::vector<::aidl::android::aidl::tests::ByteEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::ByteEnum>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeByteArray(_aidl_in.get(), reinterpret_cast<const int8_t*>(in_input.data()), in_input.size());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 21 /*ReverseByteEnum*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseByteEnum(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readByteArray(_aidl_out.get(), static_cast<void*>(_aidl_return), ndk::AParcel_stdVectorAllocator<int8_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readByteArray(_aidl_out.get(), static_cast<void*>(out_repeated), ndk::AParcel_stdVectorAllocator<int8_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseIntEnum(const std::vector<::aidl::android::aidl::tests::IntEnum>& in_input, std::vector<::aidl::android::aidl::tests::IntEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::IntEnum>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32Array(_aidl_in.get(), reinterpret_cast<const int32_t*>(in_input.data()), in_input.size());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 22 /*ReverseIntEnum*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseIntEnum(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt32Array(_aidl_out.get(), static_cast<void*>(_aidl_return), ndk::AParcel_stdVectorAllocator<int32_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readInt32Array(_aidl_out.get(), static_cast<void*>(out_repeated), ndk::AParcel_stdVectorAllocator<int32_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseLongEnum(const std::vector<::aidl::android::aidl::tests::LongEnum>& in_input, std::vector<::aidl::android::aidl::tests::LongEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::LongEnum>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt64Array(_aidl_in.get(), reinterpret_cast<const int64_t*>(in_input.data()), in_input.size());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 23 /*ReverseLongEnum*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseLongEnum(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt64Array(_aidl_out.get(), static_cast<void*>(_aidl_return), ndk::AParcel_stdVectorAllocator<int64_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readInt64Array(_aidl_out.get(), static_cast<void*>(out_repeated), ndk::AParcel_stdVectorAllocator<int64_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::GetOtherTestService(const std::string& in_name, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_name);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 24 /*GetOtherTestService*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->GetOtherTestService(in_name, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::aidl::android::aidl::tests::INamedCallback::readFromParcel(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::VerifyName(const std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>& in_service, const std::string& in_name, bool* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::aidl::android::aidl::tests::INamedCallback::writeToParcel(_aidl_in.get(), in_service);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_name);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 25 /*VerifyName*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->VerifyName(in_service, in_name, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readBool(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 26 /*ReverseStringList*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseStringList(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatParcelFileDescriptor(const ::ndk::ScopedFileDescriptor& in_read, ::ndk::ScopedFileDescriptor* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeRequiredParcelFileDescriptor(_aidl_in.get(), in_read);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 27 /*RepeatParcelFileDescriptor*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatParcelFileDescriptor(in_read, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readRequiredParcelFileDescriptor(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseParcelFileDescriptorArray(const std::vector<::ndk::ScopedFileDescriptor>& in_input, std::vector<::ndk::ScopedFileDescriptor>* out_repeated, std::vector<::ndk::ScopedFileDescriptor>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 28 /*ReverseParcelFileDescriptorArray*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseParcelFileDescriptorArray(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ThrowServiceException(int32_t in_code) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32(_aidl_in.get(), in_code);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 29 /*ThrowServiceException*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ThrowServiceException(in_code);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableIntArray(const std::optional<std::vector<int32_t>>& in_input, std::optional<std::vector<int32_t>>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 30 /*RepeatNullableIntArray*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableIntArray(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableByteEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeByteArray(_aidl_in.get(), (in_input ? reinterpret_cast<const int8_t*>(in_input->data()) : nullptr), (in_input ? in_input->size() : -1));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 31 /*RepeatNullableByteEnumArray*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableByteEnumArray(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readByteArray(_aidl_out.get(), static_cast<void*>(_aidl_return), ndk::AParcel_nullableStdVectorAllocator<int8_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableIntEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32Array(_aidl_in.get(), (in_input ? reinterpret_cast<const int32_t*>(in_input->data()) : nullptr), (in_input ? in_input->size() : -1));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 32 /*RepeatNullableIntEnumArray*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableIntEnumArray(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt32Array(_aidl_out.get(), static_cast<void*>(_aidl_return), ndk::AParcel_nullableStdVectorAllocator<int32_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableLongEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt64Array(_aidl_in.get(), (in_input ? reinterpret_cast<const int64_t*>(in_input->data()) : nullptr), (in_input ? in_input->size() : -1));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 33 /*RepeatNullableLongEnumArray*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableLongEnumArray(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readInt64Array(_aidl_out.get(), static_cast<void*>(_aidl_return), ndk::AParcel_nullableStdVectorAllocator<int64_t>);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableString(const std::optional<std::string>& in_input, std::optional<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 34 /*RepeatNullableString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableString(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableStringList(const std::vector<std::string>& in_input, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 35 /*RepeatNullableStringList*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableStringList(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableParcelable(const std::optional<::aidl::android::aidl::tests::StructuredParcelable>& in_input, std::optional<::aidl::android::aidl::tests::StructuredParcelable>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableParcelable(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 36 /*RepeatNullableParcelable*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableParcelable(in_input, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readNullableParcelable(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::TakesAnIBinder(const ::ndk::SpAIBinder& in_input) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeRequiredStrongBinder(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 37 /*TakesAnIBinder*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->TakesAnIBinder(in_input);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::TakesANullableIBinder(const ::ndk::SpAIBinder& in_input) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableStrongBinder(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 38 /*TakesANullableIBinder*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->TakesANullableIBinder(in_input);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatUtf8CppString(const std::string& in_token, std::string* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 39 /*RepeatUtf8CppString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatUtf8CppString(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::RepeatNullableUtf8CppString(const std::optional<std::string>& in_token, std::optional<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_token);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 40 /*RepeatNullableUtf8CppString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->RepeatNullableUtf8CppString(in_token, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readString(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseUtf8CppString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 41 /*ReverseUtf8CppString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseUtf8CppString(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseNullableUtf8CppString(const std::optional<std::vector<std::optional<std::string>>>& in_input, std::optional<std::vector<std::optional<std::string>>>* out_repeated, std::optional<std::vector<std::optional<std::string>>>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVectorSize(_aidl_in.get(), *out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 42 /*ReverseNullableUtf8CppString*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseNullableUtf8CppString(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::ReverseUtf8CppStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), in_input);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 43 /*ReverseUtf8CppStringList*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->ReverseUtf8CppStringList(in_input, out_repeated, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), out_repeated);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::GetCallback(bool in_return_null, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeBool(_aidl_in.get(), in_return_null);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 44 /*GetCallback*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->GetCallback(in_return_null, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::aidl::android::aidl::tests::INamedCallback::readFromParcel(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(_aidl_in.get(), *in_parcel);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 45 /*FillOutStructuredParcelable*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->FillOutStructuredParcelable(in_parcel);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readParcelable(_aidl_out.get(), in_parcel);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 46 /*GetOldNameInterface*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->GetOldNameInterface(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::aidl::android::aidl::tests::IOldName::readFromParcel(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 47 /*GetNewNameInterface*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->GetNewNameInterface(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::aidl::android::aidl::tests::INewName::readFromParcel(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 48 /*GetCppJavaTests*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->GetCppJavaTests(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readNullableStrongBinder(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+::ndk::ScopedAStatus BpTestService::getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  AParcel_markSensitive(_aidl_in.get());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 49 /*getBackendType*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    FLAG_CLEAR_BUF
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
+    _aidl_status = ITestService::getDefaultImpl()->getBackendType(_aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = AParcel_readByte(_aidl_out.get(), reinterpret_cast<int8_t*>(_aidl_return));
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  return _aidl_status;
+}
+// Source for BnTestService
+BnTestService::BnTestService() {}
+BnTestService::~BnTestService() {}
+::ndk::SpAIBinder BnTestService::createBinder() {
+  AIBinder* binder = AIBinder_new(_g_aidl_clazz, static_cast<void*>(this));
+  #ifdef BINDER_STABILITY_SUPPORT
+  AIBinder_markCompilationUnitStability(binder);
+  #endif  // BINDER_STABILITY_SUPPORT
+  return ::ndk::SpAIBinder(binder);
+}
+// Source for ITestService
+const char* ITestService::descriptor = "android.aidl.tests.ITestService";
+ITestService::ITestService() {}
+ITestService::~ITestService() {}
+
+const char* ITestService::STRING_TEST_CONSTANT = "foo";
+const char* ITestService::STRING_TEST_CONSTANT2 = "bar";
+const char* ITestService::STRING_TEST_CONSTANT_UTF8 = "baz";
+
+std::shared_ptr<ITestService> ITestService::fromBinder(const ::ndk::SpAIBinder& binder) {
+  if (!AIBinder_associateClass(binder.get(), _g_aidl_clazz)) { return nullptr; }
+  std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
+  if (interface) {
+    return std::static_pointer_cast<ITestService>(interface);
+  }
+  return ::ndk::SharedRefBase::make<BpTestService>(binder);
+}
+
+binder_status_t ITestService::writeToParcel(AParcel* parcel, const std::shared_ptr<ITestService>& instance) {
+  return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t ITestService::readFromParcel(const AParcel* parcel, std::shared_ptr<ITestService>* instance) {
+  ::ndk::SpAIBinder binder;
+  binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+  if (status != STATUS_OK) return status;
+  *instance = ITestService::fromBinder(binder);
+  return STATUS_OK;
+}
+bool ITestService::setDefaultImpl(const std::shared_ptr<ITestService>& impl) {
+  // Only one user of this interface can use this function
+  // at a time. This is a heuristic to detect if two different
+  // users in the same process use this function.
+  assert(!ITestService::default_impl);
+  if (impl) {
+    ITestService::default_impl = impl;
+    return true;
+  }
+  return false;
+}
+const std::shared_ptr<ITestService>& ITestService::getDefaultImpl() {
+  return ITestService::default_impl;
+}
+std::shared_ptr<ITestService> ITestService::default_impl = nullptr;
+::ndk::ScopedAStatus ITestServiceDefault::UnimplementedMethod(int32_t /*in_arg*/, int32_t* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::TestOneway() {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatBoolean(bool /*in_token*/, bool* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatByte(int8_t /*in_token*/, int8_t* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatChar(char16_t /*in_token*/, char16_t* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatInt(int32_t /*in_token*/, int32_t* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatLong(int64_t /*in_token*/, int64_t* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatFloat(float /*in_token*/, float* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatDouble(double /*in_token*/, double* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatString(const std::string& /*in_token*/, std::string* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatByteEnum(::aidl::android::aidl::tests::ByteEnum /*in_token*/, ::aidl::android::aidl::tests::ByteEnum* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatIntEnum(::aidl::android::aidl::tests::IntEnum /*in_token*/, ::aidl::android::aidl::tests::IntEnum* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatLongEnum(::aidl::android::aidl::tests::LongEnum /*in_token*/, ::aidl::android::aidl::tests::LongEnum* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseBoolean(const std::vector<bool>& /*in_input*/, std::vector<bool>* /*out_repeated*/, std::vector<bool>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseByte(const std::vector<uint8_t>& /*in_input*/, std::vector<uint8_t>* /*out_repeated*/, std::vector<uint8_t>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseChar(const std::vector<char16_t>& /*in_input*/, std::vector<char16_t>* /*out_repeated*/, std::vector<char16_t>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseInt(const std::vector<int32_t>& /*in_input*/, std::vector<int32_t>* /*out_repeated*/, std::vector<int32_t>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseLong(const std::vector<int64_t>& /*in_input*/, std::vector<int64_t>* /*out_repeated*/, std::vector<int64_t>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseFloat(const std::vector<float>& /*in_input*/, std::vector<float>* /*out_repeated*/, std::vector<float>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseDouble(const std::vector<double>& /*in_input*/, std::vector<double>* /*out_repeated*/, std::vector<double>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseString(const std::vector<std::string>& /*in_input*/, std::vector<std::string>* /*out_repeated*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseByteEnum(const std::vector<::aidl::android::aidl::tests::ByteEnum>& /*in_input*/, std::vector<::aidl::android::aidl::tests::ByteEnum>* /*out_repeated*/, std::vector<::aidl::android::aidl::tests::ByteEnum>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseIntEnum(const std::vector<::aidl::android::aidl::tests::IntEnum>& /*in_input*/, std::vector<::aidl::android::aidl::tests::IntEnum>* /*out_repeated*/, std::vector<::aidl::android::aidl::tests::IntEnum>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseLongEnum(const std::vector<::aidl::android::aidl::tests::LongEnum>& /*in_input*/, std::vector<::aidl::android::aidl::tests::LongEnum>* /*out_repeated*/, std::vector<::aidl::android::aidl::tests::LongEnum>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::GetOtherTestService(const std::string& /*in_name*/, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::VerifyName(const std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>& /*in_service*/, const std::string& /*in_name*/, bool* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseStringList(const std::vector<std::string>& /*in_input*/, std::vector<std::string>* /*out_repeated*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatParcelFileDescriptor(const ::ndk::ScopedFileDescriptor& /*in_read*/, ::ndk::ScopedFileDescriptor* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseParcelFileDescriptorArray(const std::vector<::ndk::ScopedFileDescriptor>& /*in_input*/, std::vector<::ndk::ScopedFileDescriptor>* /*out_repeated*/, std::vector<::ndk::ScopedFileDescriptor>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ThrowServiceException(int32_t /*in_code*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableIntArray(const std::optional<std::vector<int32_t>>& /*in_input*/, std::optional<std::vector<int32_t>>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableByteEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>& /*in_input*/, std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableIntEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>& /*in_input*/, std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableLongEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>& /*in_input*/, std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableString(const std::optional<std::string>& /*in_input*/, std::optional<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableStringList(const std::vector<std::string>& /*in_input*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableParcelable(const std::optional<::aidl::android::aidl::tests::StructuredParcelable>& /*in_input*/, std::optional<::aidl::android::aidl::tests::StructuredParcelable>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::TakesAnIBinder(const ::ndk::SpAIBinder& /*in_input*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::TakesANullableIBinder(const ::ndk::SpAIBinder& /*in_input*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatUtf8CppString(const std::string& /*in_token*/, std::string* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::RepeatNullableUtf8CppString(const std::optional<std::string>& /*in_token*/, std::optional<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseUtf8CppString(const std::vector<std::string>& /*in_input*/, std::vector<std::string>* /*out_repeated*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseNullableUtf8CppString(const std::optional<std::vector<std::optional<std::string>>>& /*in_input*/, std::optional<std::vector<std::optional<std::string>>>* /*out_repeated*/, std::optional<std::vector<std::optional<std::string>>>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::ReverseUtf8CppStringList(const std::vector<std::string>& /*in_input*/, std::vector<std::string>* /*out_repeated*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::GetCallback(bool /*in_return_null*/, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* /*in_parcel*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::GetCppJavaTests(::ndk::SpAIBinder* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::ScopedAStatus ITestServiceDefault::getBackendType(::aidl::android::aidl::tests::BackendType* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::SpAIBinder ITestServiceDefault::asBinder() {
+  return ::ndk::SpAIBinder();
+}
+bool ITestServiceDefault::isRemote() {
+  return false;
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp.d
new file mode 100644
index 0000000..1088b3b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp.d
@@ -0,0 +1,10 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ITestService.aidl \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp.d
new file mode 100644
index 0000000..f2b30c3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IntEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp.d
new file mode 100644
index 0000000..f07b41d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/LongEnum.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp
new file mode 100644
index 0000000..857c86e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp
@@ -0,0 +1,48 @@
+#include "aidl/android/aidl/tests/OtherParcelableForToString.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+const char* OtherParcelableForToString::descriptor = "android.aidl.tests.OtherParcelableForToString";
+
+binder_status_t OtherParcelableForToString::readFromParcel(const AParcel* parcel) {
+  int32_t _aidl_parcelable_size;
+  int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);
+  if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;
+  if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &field);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+  return _aidl_ret_status;
+}
+binder_status_t OtherParcelableForToString::writeToParcel(AParcel* parcel) const {
+  binder_status_t _aidl_ret_status;
+  size_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  _aidl_ret_status = AParcel_writeInt32(parcel, 0);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, field);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  size_t _aidl_end_pos = AParcel_getDataPosition(parcel);
+  AParcel_setDataPosition(parcel, _aidl_start_pos);
+  AParcel_writeInt32(parcel, _aidl_end_pos - _aidl_start_pos);
+  AParcel_setDataPosition(parcel, _aidl_end_pos);
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp.d
new file mode 100644
index 0000000..53179cf
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/OtherParcelableForToString.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp
new file mode 100644
index 0000000..3a3cd5e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp
@@ -0,0 +1,268 @@
+#include "aidl/android/aidl/tests/ParcelableForToString.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+const char* ParcelableForToString::descriptor = "android.aidl.tests.ParcelableForToString";
+
+binder_status_t ParcelableForToString::readFromParcel(const AParcel* parcel) {
+  int32_t _aidl_parcelable_size;
+  int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);
+  if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;
+  if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_readInt32(parcel, &intValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &intArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt64(parcel, &longValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &longArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readDouble(parcel, &doubleValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &doubleArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readFloat(parcel, &floatValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &floatArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByte(parcel, &byteValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &byteArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readBool(parcel, &booleanValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &booleanArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &stringValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &stringArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &stringList);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readParcelable(parcel, &parcelableValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &parcelableArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&enumValue));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32Array(parcel, static_cast<void*>(&enumArray), ndk::AParcel_stdVectorAllocator<int32_t>);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &nullArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &nullList);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readParcelable(parcel, &parcelableGeneric);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readParcelable(parcel, &unionValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+  return _aidl_ret_status;
+}
+binder_status_t ParcelableForToString::writeToParcel(AParcel* parcel) const {
+  binder_status_t _aidl_ret_status;
+  size_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  _aidl_ret_status = AParcel_writeInt32(parcel, 0);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, intValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, intArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt64(parcel, longValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, longArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeDouble(parcel, doubleValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, doubleArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeFloat(parcel, floatValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, floatArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByte(parcel, byteValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, byteArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeBool(parcel, booleanValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, booleanArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, stringValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, stringArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, stringList);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(parcel, parcelableValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, parcelableArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(enumValue));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32Array(parcel, reinterpret_cast<const int32_t*>(enumArray.data()), enumArray.size());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, nullArray);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, nullList);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(parcel, parcelableGeneric);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(parcel, unionValue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  size_t _aidl_end_pos = AParcel_getDataPosition(parcel);
+  AParcel_setDataPosition(parcel, _aidl_start_pos);
+  AParcel_writeInt32(parcel, _aidl_end_pos - _aidl_start_pos);
+  AParcel_setDataPosition(parcel, _aidl_end_pos);
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp.d
new file mode 100644
index 0000000..2a2e7f9
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ParcelableForToString.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/ParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp
new file mode 100644
index 0000000..740f16a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp
@@ -0,0 +1,568 @@
+#include "aidl/android/aidl/tests/StructuredParcelable.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+const char* StructuredParcelable::descriptor = "android.aidl.tests.StructuredParcelable";
+
+binder_status_t StructuredParcelable::readFromParcel(const AParcel* parcel) {
+  int32_t _aidl_parcelable_size;
+  int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);
+  if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;
+  if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &shouldContainThreeFs);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &f);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &shouldBeJerry);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByte(parcel, reinterpret_cast<int8_t*>(&shouldBeByteBar));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&shouldBeIntBar));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt64(parcel, reinterpret_cast<int64_t*>(&shouldBeLongBar));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByteArray(parcel, static_cast<void*>(&shouldContainTwoByteFoos), ndk::AParcel_stdVectorAllocator<int8_t>);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32Array(parcel, static_cast<void*>(&shouldContainTwoIntFoos), ndk::AParcel_stdVectorAllocator<int32_t>);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt64Array(parcel, static_cast<void*>(&shouldContainTwoLongFoos), ndk::AParcel_stdVectorAllocator<int64_t>);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &stringDefaultsToFoo);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByte(parcel, &byteDefaultsToFour);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &intDefaultsToFive);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt64(parcel, &longDefaultsToNegativeSeven);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readBool(parcel, &booleanDefaultsToTrue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readChar(parcel, &charDefaultsToC);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readFloat(parcel, &floatDefaultsToPi);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readDouble(parcel, &doubleWithDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &arrayDefaultsTo123);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &arrayDefaultsToEmpty);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readBool(parcel, &boolDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByte(parcel, &byteDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &intDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt64(parcel, &longDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readFloat(parcel, &floatDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readDouble(parcel, &doubleDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readDouble(parcel, &checkDoubleFromFloat);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &checkStringArray1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &checkStringArray2);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &int32_min);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &int32_max);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt64(parcel, &int64_max);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &hexInt32_neg_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readNullableStrongBinder(parcel, &ibinder);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &int32_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readVector(parcel, &int64_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &hexInt32_pos_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &hexInt64_pos_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_1));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_2));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_3));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_4));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_5));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_6));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_7));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_8));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_9));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&const_exprs_10));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &addString1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &addString2);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &shouldSetBit0AndBit2);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readNullableParcelable(parcel, &u);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readNullableParcelable(parcel, &shouldBeConstS1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, reinterpret_cast<int32_t*>(&defaultWithFoo));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+  return _aidl_ret_status;
+}
+binder_status_t StructuredParcelable::writeToParcel(AParcel* parcel) const {
+  binder_status_t _aidl_ret_status;
+  size_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  _aidl_ret_status = AParcel_writeInt32(parcel, 0);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, shouldContainThreeFs);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, f);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, shouldBeJerry);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByte(parcel, static_cast<int8_t>(shouldBeByteBar));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(shouldBeIntBar));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt64(parcel, static_cast<int64_t>(shouldBeLongBar));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByteArray(parcel, reinterpret_cast<const int8_t*>(shouldContainTwoByteFoos.data()), shouldContainTwoByteFoos.size());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32Array(parcel, reinterpret_cast<const int32_t*>(shouldContainTwoIntFoos.data()), shouldContainTwoIntFoos.size());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt64Array(parcel, reinterpret_cast<const int64_t*>(shouldContainTwoLongFoos.data()), shouldContainTwoLongFoos.size());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, stringDefaultsToFoo);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByte(parcel, byteDefaultsToFour);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, intDefaultsToFive);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt64(parcel, longDefaultsToNegativeSeven);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeBool(parcel, booleanDefaultsToTrue);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeChar(parcel, charDefaultsToC);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeFloat(parcel, floatDefaultsToPi);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeDouble(parcel, doubleWithDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, arrayDefaultsTo123);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, arrayDefaultsToEmpty);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeBool(parcel, boolDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByte(parcel, byteDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, intDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt64(parcel, longDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeFloat(parcel, floatDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeDouble(parcel, doubleDefault);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeDouble(parcel, checkDoubleFromFloat);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, checkStringArray1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, checkStringArray2);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, int32_min);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, int32_max);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt64(parcel, int64_max);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, hexInt32_neg_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableStrongBinder(parcel, ibinder);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, int32_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(parcel, int64_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, hexInt32_pos_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, hexInt64_pos_1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_1));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_2));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_3));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_4));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_5));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_6));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_7));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_8));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_9));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(const_exprs_10));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, addString1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, addString2);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, shouldSetBit0AndBit2);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableParcelable(parcel, u);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableParcelable(parcel, shouldBeConstS1);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, static_cast<int32_t>(defaultWithFoo));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  size_t _aidl_end_pos = AParcel_getDataPosition(parcel);
+  AParcel_setDataPosition(parcel, _aidl_start_pos);
+  AParcel_writeInt32(parcel, _aidl_end_pos - _aidl_start_pos);
+  AParcel_setDataPosition(parcel, _aidl_end_pos);
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp.d
new file mode 100644
index 0000000..5ba9e02
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/StructuredParcelable.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp
new file mode 100644
index 0000000..a838fe0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp
@@ -0,0 +1,108 @@
+#include "aidl/android/aidl/tests/Union.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+const char* Union::descriptor = "android.aidl.tests.Union";
+
+const char* Union::S1 = "a string constant in union";
+binder_status_t Union::readFromParcel(const AParcel* _parcel) {
+  binder_status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_tag)) != STATUS_OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case ns: {
+    std::vector<int32_t> _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readVector(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<std::vector<int32_t>>) {
+      set<ns>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<ns>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case n: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<n>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<n>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case m: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<m>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<m>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case s: {
+    std::string _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readString(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<std::string>) {
+      set<s>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<s>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case ibinder: {
+    ::ndk::SpAIBinder _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readNullableStrongBinder(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::ndk::SpAIBinder>) {
+      set<ibinder>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<ibinder>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case ss: {
+    std::vector<std::string> _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readVector(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<std::vector<std::string>>) {
+      set<ss>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<ss>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case be: {
+    ::aidl::android::aidl::tests::ByteEnum _aidl_value;
+    if ((_aidl_ret_status = AParcel_readByte(_parcel, reinterpret_cast<int8_t*>(&_aidl_value))) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::aidl::android::aidl::tests::ByteEnum>) {
+      set<be>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<be>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  }
+  return STATUS_BAD_VALUE;
+}
+binder_status_t Union::writeToParcel(AParcel* _parcel) const {
+  binder_status_t _aidl_ret_status = AParcel_writeInt32(_parcel, getTag());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case ns: return ::ndk::AParcel_writeVector(_parcel, get<ns>());
+  case n: return AParcel_writeInt32(_parcel, get<n>());
+  case m: return AParcel_writeInt32(_parcel, get<m>());
+  case s: return ::ndk::AParcel_writeString(_parcel, get<s>());
+  case ibinder: return ::ndk::AParcel_writeNullableStrongBinder(_parcel, get<ibinder>());
+  case ss: return ::ndk::AParcel_writeVector(_parcel, get<ss>());
+  case be: return AParcel_writeByte(_parcel, static_cast<int8_t>(get<be>()));
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp.d
new file mode 100644
index 0000000..1bddc90
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/Union.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp
new file mode 100644
index 0000000..153cc06
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp
@@ -0,0 +1,52 @@
+#include "aidl/android/aidl/tests/UnionWithFd.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+const char* UnionWithFd::descriptor = "android.aidl.tests.UnionWithFd";
+
+binder_status_t UnionWithFd::readFromParcel(const AParcel* _parcel) {
+  binder_status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_tag)) != STATUS_OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case num: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<num>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<num>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case pfd: {
+    ::ndk::ScopedFileDescriptor _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readRequiredParcelFileDescriptor(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::ndk::ScopedFileDescriptor>) {
+      set<pfd>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<pfd>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  }
+  return STATUS_BAD_VALUE;
+}
+binder_status_t UnionWithFd::writeToParcel(AParcel* _parcel) const {
+  binder_status_t _aidl_ret_status = AParcel_writeInt32(_parcel, getTag());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case num: return AParcel_writeInt32(_parcel, get<num>());
+  case pfd: return ::ndk::AParcel_writeRequiredParcelFileDescriptor(_parcel, get<pfd>());
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp.d
new file mode 100644
index 0000000..5247a74
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/UnionWithFd.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/UnionWithFd.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp
new file mode 100644
index 0000000..25f7c68
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp
@@ -0,0 +1,54 @@
+#include "aidl/android/aidl/tests/unions/EnumUnion.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+const char* EnumUnion::descriptor = "android.aidl.tests.unions.EnumUnion";
+
+binder_status_t EnumUnion::readFromParcel(const AParcel* _parcel) {
+  binder_status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_tag)) != STATUS_OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case intEnum: {
+    ::aidl::android::aidl::tests::IntEnum _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt32(_parcel, reinterpret_cast<int32_t*>(&_aidl_value))) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::aidl::android::aidl::tests::IntEnum>) {
+      set<intEnum>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<intEnum>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case longEnum: {
+    ::aidl::android::aidl::tests::LongEnum _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt64(_parcel, reinterpret_cast<int64_t*>(&_aidl_value))) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::aidl::android::aidl::tests::LongEnum>) {
+      set<longEnum>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<longEnum>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  }
+  return STATUS_BAD_VALUE;
+}
+binder_status_t EnumUnion::writeToParcel(AParcel* _parcel) const {
+  binder_status_t _aidl_ret_status = AParcel_writeInt32(_parcel, getTag());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case intEnum: return AParcel_writeInt32(_parcel, static_cast<int32_t>(get<intEnum>()));
+  case longEnum: return AParcel_writeInt64(_parcel, static_cast<int64_t>(get<longEnum>()));
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace unions
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp.d
new file mode 100644
index 0000000..0781df9
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/EnumUnion.cpp : \
+  system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BackendType.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BackendType.h
new file mode 100644
index 0000000..8f482c5
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BackendType.h
@@ -0,0 +1,55 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+enum class BackendType : int8_t {
+  CPP = 0,
+  JAVA = 1,
+  NDK = 2,
+  RUST = 3,
+};
+
+static inline std::string toString(BackendType val) {
+  switch(val) {
+  case BackendType::CPP:
+    return "CPP";
+  case BackendType::JAVA:
+    return "JAVA";
+  case BackendType::NDK:
+    return "NDK";
+  case BackendType::RUST:
+    return "RUST";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::tests::BackendType, 4> enum_values<aidl::android::aidl::tests::BackendType> = {
+  aidl::android::aidl::tests::BackendType::CPP,
+  aidl::android::aidl::tests::BackendType::JAVA,
+  aidl::android::aidl::tests::BackendType::NDK,
+  aidl::android::aidl::tests::BackendType::RUST,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnBackendType.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnBackendType.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnBackendType.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnByteEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnByteEnum.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnByteEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnConstantExpressionEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnConstantExpressionEnum.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnConstantExpressionEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnGenericStructuredParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnGenericStructuredParcelable.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnGenericStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnIntEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnIntEnum.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnIntEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnLongEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnLongEnum.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnLongEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h
new file mode 100644
index 0000000..6f38a28
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/INamedCallback.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BnNamedCallback : public ::ndk::BnCInterface<INamedCallback> {
+public:
+  BnNamedCallback();
+  virtual ~BnNamedCallback();
+protected:
+  ::ndk::SpAIBinder createBinder() override;
+private:
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnNewName.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnNewName.h
new file mode 100644
index 0000000..32d8a7b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnNewName.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/INewName.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BnNewName : public ::ndk::BnCInterface<INewName> {
+public:
+  BnNewName();
+  virtual ~BnNewName();
+protected:
+  ::ndk::SpAIBinder createBinder() override;
+private:
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnOldName.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnOldName.h
new file mode 100644
index 0000000..e1782d1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnOldName.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/IOldName.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BnOldName : public ::ndk::BnCInterface<IOldName> {
+public:
+  BnOldName();
+  virtual ~BnOldName();
+protected:
+  ::ndk::SpAIBinder createBinder() override;
+private:
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnOtherParcelableForToString.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnOtherParcelableForToString.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnOtherParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnParcelableForToString.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnParcelableForToString.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnStructuredParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnStructuredParcelable.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnTestService.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnTestService.h
new file mode 100644
index 0000000..a33592b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnTestService.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/ITestService.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BnTestService : public ::ndk::BnCInterface<ITestService> {
+public:
+  BnTestService();
+  virtual ~BnTestService();
+protected:
+  ::ndk::SpAIBinder createBinder() override;
+private:
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnUnion.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnUnionWithFd.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnUnionWithFd.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnUnionWithFd.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpBackendType.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpBackendType.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpBackendType.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpByteEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpByteEnum.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpByteEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpConstantExpressionEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpConstantExpressionEnum.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpConstantExpressionEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpGenericStructuredParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpGenericStructuredParcelable.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpGenericStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpIntEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpIntEnum.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpIntEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpLongEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpLongEnum.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpLongEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpNamedCallback.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpNamedCallback.h
new file mode 100644
index 0000000..470c9d0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpNamedCallback.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/INamedCallback.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BpNamedCallback : public ::ndk::BpCInterface<INamedCallback> {
+public:
+  explicit BpNamedCallback(const ::ndk::SpAIBinder& binder);
+  virtual ~BpNamedCallback();
+
+  ::ndk::ScopedAStatus GetName(std::string* _aidl_return) override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpNewName.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpNewName.h
new file mode 100644
index 0000000..4be7376
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpNewName.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/INewName.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BpNewName : public ::ndk::BpCInterface<INewName> {
+public:
+  explicit BpNewName(const ::ndk::SpAIBinder& binder);
+  virtual ~BpNewName();
+
+  ::ndk::ScopedAStatus RealName(std::string* _aidl_return) override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpOldName.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpOldName.h
new file mode 100644
index 0000000..e48d990
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpOldName.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/IOldName.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BpOldName : public ::ndk::BpCInterface<IOldName> {
+public:
+  explicit BpOldName(const ::ndk::SpAIBinder& binder);
+  virtual ~BpOldName();
+
+  ::ndk::ScopedAStatus RealName(std::string* _aidl_return) override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpOtherParcelableForToString.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpOtherParcelableForToString.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpOtherParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpParcelableForToString.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpParcelableForToString.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpParcelableForToString.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpStructuredParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpStructuredParcelable.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpStructuredParcelable.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpTestService.h
new file mode 100644
index 0000000..44d9c73
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpTestService.h
@@ -0,0 +1,70 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/ITestService.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class BpTestService : public ::ndk::BpCInterface<ITestService> {
+public:
+  explicit BpTestService(const ::ndk::SpAIBinder& binder);
+  virtual ~BpTestService();
+
+  ::ndk::ScopedAStatus UnimplementedMethod(int32_t in_arg, int32_t* _aidl_return) override;
+  ::ndk::ScopedAStatus TestOneway() override;
+  ::ndk::ScopedAStatus RepeatBoolean(bool in_token, bool* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatByte(int8_t in_token, int8_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatChar(char16_t in_token, char16_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatInt(int32_t in_token, int32_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatLong(int64_t in_token, int64_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatFloat(float in_token, float* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatDouble(double in_token, double* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatString(const std::string& in_token, std::string* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatByteEnum(::aidl::android::aidl::tests::ByteEnum in_token, ::aidl::android::aidl::tests::ByteEnum* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatIntEnum(::aidl::android::aidl::tests::IntEnum in_token, ::aidl::android::aidl::tests::IntEnum* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatLongEnum(::aidl::android::aidl::tests::LongEnum in_token, ::aidl::android::aidl::tests::LongEnum* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseBoolean(const std::vector<bool>& in_input, std::vector<bool>* out_repeated, std::vector<bool>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseByte(const std::vector<uint8_t>& in_input, std::vector<uint8_t>* out_repeated, std::vector<uint8_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseChar(const std::vector<char16_t>& in_input, std::vector<char16_t>* out_repeated, std::vector<char16_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseInt(const std::vector<int32_t>& in_input, std::vector<int32_t>* out_repeated, std::vector<int32_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseLong(const std::vector<int64_t>& in_input, std::vector<int64_t>* out_repeated, std::vector<int64_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseFloat(const std::vector<float>& in_input, std::vector<float>* out_repeated, std::vector<float>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseDouble(const std::vector<double>& in_input, std::vector<double>* out_repeated, std::vector<double>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseByteEnum(const std::vector<::aidl::android::aidl::tests::ByteEnum>& in_input, std::vector<::aidl::android::aidl::tests::ByteEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::ByteEnum>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseIntEnum(const std::vector<::aidl::android::aidl::tests::IntEnum>& in_input, std::vector<::aidl::android::aidl::tests::IntEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::IntEnum>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseLongEnum(const std::vector<::aidl::android::aidl::tests::LongEnum>& in_input, std::vector<::aidl::android::aidl::tests::LongEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::LongEnum>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetOtherTestService(const std::string& in_name, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) override;
+  ::ndk::ScopedAStatus VerifyName(const std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>& in_service, const std::string& in_name, bool* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatParcelFileDescriptor(const ::ndk::ScopedFileDescriptor& in_read, ::ndk::ScopedFileDescriptor* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseParcelFileDescriptorArray(const std::vector<::ndk::ScopedFileDescriptor>& in_input, std::vector<::ndk::ScopedFileDescriptor>* out_repeated, std::vector<::ndk::ScopedFileDescriptor>* _aidl_return) override;
+  ::ndk::ScopedAStatus ThrowServiceException(int32_t in_code) override;
+  ::ndk::ScopedAStatus RepeatNullableIntArray(const std::optional<std::vector<int32_t>>& in_input, std::optional<std::vector<int32_t>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableByteEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableIntEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableLongEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableString(const std::optional<std::string>& in_input, std::optional<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableStringList(const std::vector<std::string>& in_input, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableParcelable(const std::optional<::aidl::android::aidl::tests::StructuredParcelable>& in_input, std::optional<::aidl::android::aidl::tests::StructuredParcelable>* _aidl_return) override;
+  ::ndk::ScopedAStatus TakesAnIBinder(const ::ndk::SpAIBinder& in_input) override;
+  ::ndk::ScopedAStatus TakesANullableIBinder(const ::ndk::SpAIBinder& in_input) override;
+  ::ndk::ScopedAStatus RepeatUtf8CppString(const std::string& in_token, std::string* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableUtf8CppString(const std::optional<std::string>& in_token, std::optional<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseUtf8CppString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseNullableUtf8CppString(const std::optional<std::vector<std::optional<std::string>>>& in_input, std::optional<std::vector<std::optional<std::string>>>* out_repeated, std::optional<std::vector<std::optional<std::string>>>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseUtf8CppStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetCallback(bool in_return_null, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) override;
+  ::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) override;
+  ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
+  ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpUnion.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpUnionWithFd.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpUnionWithFd.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpUnionWithFd.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ByteEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ByteEnum.h
new file mode 100644
index 0000000..d29f50c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ByteEnum.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+enum class ByteEnum : int8_t {
+  FOO = 1,
+  BAR = 2,
+  BAZ = 3,
+};
+
+static inline std::string toString(ByteEnum val) {
+  switch(val) {
+  case ByteEnum::FOO:
+    return "FOO";
+  case ByteEnum::BAR:
+    return "BAR";
+  case ByteEnum::BAZ:
+    return "BAZ";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::tests::ByteEnum, 3> enum_values<aidl::android::aidl::tests::ByteEnum> = {
+  aidl::android::aidl::tests::ByteEnum::FOO,
+  aidl::android::aidl::tests::ByteEnum::BAR,
+  aidl::android::aidl::tests::ByteEnum::BAZ,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ConstantExpressionEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ConstantExpressionEnum.h
new file mode 100644
index 0000000..c3ce4be
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ConstantExpressionEnum.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+enum class ConstantExpressionEnum : int32_t {
+  decInt32_1 = 1,
+  decInt32_2 = 1,
+  decInt64_1 = 1,
+  decInt64_2 = 1,
+  decInt64_3 = 1,
+  decInt64_4 = 1,
+  hexInt32_1 = 1,
+  hexInt32_2 = 1,
+  hexInt32_3 = 1,
+  hexInt64_1 = 1,
+};
+
+static inline std::string toString(ConstantExpressionEnum val) {
+  switch(val) {
+  case ConstantExpressionEnum::decInt32_1:
+    return "decInt32_1";
+  default:
+    return std::to_string(static_cast<int32_t>(val));
+  }
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::tests::ConstantExpressionEnum, 10> enum_values<aidl::android::aidl::tests::ConstantExpressionEnum> = {
+  aidl::android::aidl::tests::ConstantExpressionEnum::decInt32_1,
+  aidl::android::aidl::tests::ConstantExpressionEnum::decInt32_2,
+  aidl::android::aidl::tests::ConstantExpressionEnum::decInt64_1,
+  aidl::android::aidl::tests::ConstantExpressionEnum::decInt64_2,
+  aidl::android::aidl::tests::ConstantExpressionEnum::decInt64_3,
+  aidl::android::aidl::tests::ConstantExpressionEnum::decInt64_4,
+  aidl::android::aidl::tests::ConstantExpressionEnum::hexInt32_1,
+  aidl::android::aidl::tests::ConstantExpressionEnum::hexInt32_2,
+  aidl::android::aidl::tests::ConstantExpressionEnum::hexInt32_3,
+  aidl::android::aidl::tests::ConstantExpressionEnum::hexInt64_1,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/GenericStructuredParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/GenericStructuredParcelable.h
new file mode 100644
index 0000000..d7b7f9d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/GenericStructuredParcelable.h
@@ -0,0 +1,133 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+template <typename T, typename U, typename B>
+class GenericStructuredParcelable {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  int32_t a = 0;
+  int32_t b = 0;
+
+  binder_status_t readFromParcel(const AParcel* parcel);
+  binder_status_t writeToParcel(AParcel* parcel) const;
+
+  inline bool operator!=(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) != std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator<(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) < std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator<=(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) <= std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator==(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) == std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator>(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) > std::tie(rhs.a, rhs.b);
+  }
+  inline bool operator>=(const GenericStructuredParcelable& rhs) const {
+    return std::tie(a, b) >= std::tie(rhs.a, rhs.b);
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "GenericStructuredParcelable{";
+    os << "a: " << std::to_string(a);
+    os << ", b: " << std::to_string(b);
+    os << "}";
+    return os.str();
+  }
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+#include "aidl/android/aidl/tests/GenericStructuredParcelable.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+template <typename T, typename U, typename B>
+const char* GenericStructuredParcelable<T, U, B>::descriptor = "android.aidl.tests.GenericStructuredParcelable";
+
+template <typename T, typename U, typename B>
+binder_status_t GenericStructuredParcelable<T, U, B>::readFromParcel(const AParcel* parcel) {
+  int32_t _aidl_parcelable_size;
+  int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);
+  if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;
+  if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_readInt32(parcel, &a);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readInt32(parcel, &b);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+  return _aidl_ret_status;
+}
+template <typename T, typename U, typename B>
+binder_status_t GenericStructuredParcelable<T, U, B>::writeToParcel(AParcel* parcel) const {
+  binder_status_t _aidl_ret_status;
+  size_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  _aidl_ret_status = AParcel_writeInt32(parcel, 0);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, a);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, b);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  size_t _aidl_end_pos = AParcel_getDataPosition(parcel);
+  AParcel_setDataPosition(parcel, _aidl_start_pos);
+  AParcel_writeInt32(parcel, _aidl_end_pos - _aidl_start_pos);
+  AParcel_setDataPosition(parcel, _aidl_end_pos);
+  return _aidl_ret_status;
+}
+
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/INamedCallback.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/INamedCallback.h
new file mode 100644
index 0000000..d38c7e1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/INamedCallback.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <android/binder_interface_utils.h>
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class INamedCallback : public ::ndk::ICInterface {
+public:
+  static const char* descriptor;
+  INamedCallback();
+  virtual ~INamedCallback();
+
+  static constexpr uint32_t TRANSACTION_GetName = FIRST_CALL_TRANSACTION + 0;
+
+  static std::shared_ptr<INamedCallback> fromBinder(const ::ndk::SpAIBinder& binder);
+  static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<INamedCallback>& instance);
+  static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<INamedCallback>* instance);
+  static bool setDefaultImpl(const std::shared_ptr<INamedCallback>& impl);
+  static const std::shared_ptr<INamedCallback>& getDefaultImpl();
+  virtual ::ndk::ScopedAStatus GetName(std::string* _aidl_return) = 0;
+private:
+  static std::shared_ptr<INamedCallback> default_impl;
+};
+class INamedCallbackDefault : public INamedCallback {
+public:
+  ::ndk::ScopedAStatus GetName(std::string* _aidl_return) override;
+  ::ndk::SpAIBinder asBinder() override;
+  bool isRemote() override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/INewName.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/INewName.h
new file mode 100644
index 0000000..1f93d5f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/INewName.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <android/binder_interface_utils.h>
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class INewName : public ::ndk::ICInterface {
+public:
+  static const char* descriptor;
+  INewName();
+  virtual ~INewName();
+
+  static constexpr uint32_t TRANSACTION_RealName = FIRST_CALL_TRANSACTION + 0;
+
+  static std::shared_ptr<INewName> fromBinder(const ::ndk::SpAIBinder& binder);
+  static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<INewName>& instance);
+  static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<INewName>* instance);
+  static bool setDefaultImpl(const std::shared_ptr<INewName>& impl);
+  static const std::shared_ptr<INewName>& getDefaultImpl();
+  virtual ::ndk::ScopedAStatus RealName(std::string* _aidl_return) = 0;
+private:
+  static std::shared_ptr<INewName> default_impl;
+};
+class INewNameDefault : public INewName {
+public:
+  ::ndk::ScopedAStatus RealName(std::string* _aidl_return) override;
+  ::ndk::SpAIBinder asBinder() override;
+  bool isRemote() override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IOldName.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IOldName.h
new file mode 100644
index 0000000..c4a4f79
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IOldName.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <android/binder_interface_utils.h>
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class IOldName : public ::ndk::ICInterface {
+public:
+  static const char* descriptor;
+  IOldName();
+  virtual ~IOldName();
+
+  static constexpr uint32_t TRANSACTION_RealName = FIRST_CALL_TRANSACTION + 0;
+
+  static std::shared_ptr<IOldName> fromBinder(const ::ndk::SpAIBinder& binder);
+  static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<IOldName>& instance);
+  static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IOldName>* instance);
+  static bool setDefaultImpl(const std::shared_ptr<IOldName>& impl);
+  static const std::shared_ptr<IOldName>& getDefaultImpl();
+  virtual ::ndk::ScopedAStatus RealName(std::string* _aidl_return) = 0;
+private:
+  static std::shared_ptr<IOldName> default_impl;
+};
+class IOldNameDefault : public IOldName {
+public:
+  ::ndk::ScopedAStatus RealName(std::string* _aidl_return) override;
+  ::ndk::SpAIBinder asBinder() override;
+  bool isRemote() override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ITestService.h
new file mode 100644
index 0000000..fb413d8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -0,0 +1,275 @@
+#pragma once
+
+#include <android/binder_interface_utils.h>
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <android/binder_parcel_platform.h>
+#include <android/binder_ibinder_platform.h>
+#include <aidl/android/aidl/tests/BackendType.h>
+#include <aidl/android/aidl/tests/ByteEnum.h>
+#include <aidl/android/aidl/tests/INamedCallback.h>
+#include <aidl/android/aidl/tests/INewName.h>
+#include <aidl/android/aidl/tests/IOldName.h>
+#include <aidl/android/aidl/tests/IntEnum.h>
+#include <aidl/android/aidl/tests/LongEnum.h>
+#include <aidl/android/aidl/tests/StructuredParcelable.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class ITestService : public ::ndk::ICInterface {
+public:
+  static const char* descriptor;
+  ITestService();
+  virtual ~ITestService();
+
+  enum : int32_t { TEST_CONSTANT = 42 };
+  enum : int32_t { TEST_CONSTANT2 = -42 };
+  enum : int32_t { TEST_CONSTANT3 = 42 };
+  enum : int32_t { TEST_CONSTANT4 = 4 };
+  enum : int32_t { TEST_CONSTANT5 = -4 };
+  enum : int32_t { TEST_CONSTANT6 = 0 };
+  enum : int32_t { TEST_CONSTANT7 = 0 };
+  enum : int32_t { TEST_CONSTANT8 = 0 };
+  enum : int32_t { TEST_CONSTANT9 = 86 };
+  enum : int32_t { TEST_CONSTANT10 = 165 };
+  enum : int32_t { TEST_CONSTANT11 = 250 };
+  enum : int32_t { TEST_CONSTANT12 = -1 };
+  enum : int8_t { BYTE_TEST_CONSTANT = 17 };
+  enum : int64_t { LONG_TEST_CONSTANT = 1099511627776L };
+  static const char* STRING_TEST_CONSTANT;
+  static const char* STRING_TEST_CONSTANT2;
+  static const char* STRING_TEST_CONSTANT_UTF8;
+  enum : int32_t { A1 = 1 };
+  enum : int32_t { A2 = 1 };
+  enum : int32_t { A3 = 1 };
+  enum : int32_t { A4 = 1 };
+  enum : int32_t { A5 = 1 };
+  enum : int32_t { A6 = 1 };
+  enum : int32_t { A7 = 1 };
+  enum : int32_t { A8 = 1 };
+  enum : int32_t { A9 = 1 };
+  enum : int32_t { A10 = 1 };
+  enum : int32_t { A11 = 1 };
+  enum : int32_t { A12 = 1 };
+  enum : int32_t { A13 = 1 };
+  enum : int32_t { A14 = 1 };
+  enum : int32_t { A15 = 1 };
+  enum : int32_t { A16 = 1 };
+  enum : int32_t { A17 = 1 };
+  enum : int32_t { A18 = 1 };
+  enum : int32_t { A19 = 1 };
+  enum : int32_t { A20 = 1 };
+  enum : int32_t { A21 = 1 };
+  enum : int32_t { A22 = 1 };
+  enum : int32_t { A23 = 1 };
+  enum : int32_t { A24 = 1 };
+  enum : int32_t { A25 = 1 };
+  enum : int32_t { A26 = 1 };
+  enum : int32_t { A27 = 1 };
+  enum : int32_t { A28 = 1 };
+  enum : int32_t { A29 = 1 };
+  enum : int32_t { A30 = 1 };
+  enum : int32_t { A31 = 1 };
+  enum : int32_t { A32 = 1 };
+  enum : int32_t { A33 = 1 };
+  enum : int32_t { A34 = 1 };
+  enum : int32_t { A35 = 1 };
+  enum : int32_t { A36 = 1 };
+  enum : int32_t { A37 = 1 };
+  enum : int32_t { A38 = 1 };
+  enum : int32_t { A39 = 1 };
+  enum : int32_t { A40 = 1 };
+  enum : int32_t { A41 = 1 };
+  enum : int32_t { A42 = 1 };
+  enum : int32_t { A43 = 1 };
+  enum : int32_t { A44 = 1 };
+  enum : int32_t { A45 = 1 };
+  enum : int32_t { A46 = 1 };
+  enum : int32_t { A47 = 1 };
+  enum : int32_t { A48 = 1 };
+  enum : int32_t { A49 = 1 };
+  enum : int32_t { A50 = 1 };
+  enum : int32_t { A51 = 1 };
+  enum : int32_t { A52 = 1 };
+  enum : int32_t { A53 = 1 };
+  enum : int32_t { A54 = 1 };
+  enum : int32_t { A55 = 1 };
+  enum : int32_t { A56 = 1 };
+  enum : int32_t { A57 = 1 };
+  static constexpr uint32_t TRANSACTION_UnimplementedMethod = FIRST_CALL_TRANSACTION + 0;
+  static constexpr uint32_t TRANSACTION_TestOneway = FIRST_CALL_TRANSACTION + 1;
+  static constexpr uint32_t TRANSACTION_RepeatBoolean = FIRST_CALL_TRANSACTION + 2;
+  static constexpr uint32_t TRANSACTION_RepeatByte = FIRST_CALL_TRANSACTION + 3;
+  static constexpr uint32_t TRANSACTION_RepeatChar = FIRST_CALL_TRANSACTION + 4;
+  static constexpr uint32_t TRANSACTION_RepeatInt = FIRST_CALL_TRANSACTION + 5;
+  static constexpr uint32_t TRANSACTION_RepeatLong = FIRST_CALL_TRANSACTION + 6;
+  static constexpr uint32_t TRANSACTION_RepeatFloat = FIRST_CALL_TRANSACTION + 7;
+  static constexpr uint32_t TRANSACTION_RepeatDouble = FIRST_CALL_TRANSACTION + 8;
+  static constexpr uint32_t TRANSACTION_RepeatString = FIRST_CALL_TRANSACTION + 9;
+  static constexpr uint32_t TRANSACTION_RepeatByteEnum = FIRST_CALL_TRANSACTION + 10;
+  static constexpr uint32_t TRANSACTION_RepeatIntEnum = FIRST_CALL_TRANSACTION + 11;
+  static constexpr uint32_t TRANSACTION_RepeatLongEnum = FIRST_CALL_TRANSACTION + 12;
+  static constexpr uint32_t TRANSACTION_ReverseBoolean = FIRST_CALL_TRANSACTION + 13;
+  static constexpr uint32_t TRANSACTION_ReverseByte = FIRST_CALL_TRANSACTION + 14;
+  static constexpr uint32_t TRANSACTION_ReverseChar = FIRST_CALL_TRANSACTION + 15;
+  static constexpr uint32_t TRANSACTION_ReverseInt = FIRST_CALL_TRANSACTION + 16;
+  static constexpr uint32_t TRANSACTION_ReverseLong = FIRST_CALL_TRANSACTION + 17;
+  static constexpr uint32_t TRANSACTION_ReverseFloat = FIRST_CALL_TRANSACTION + 18;
+  static constexpr uint32_t TRANSACTION_ReverseDouble = FIRST_CALL_TRANSACTION + 19;
+  static constexpr uint32_t TRANSACTION_ReverseString = FIRST_CALL_TRANSACTION + 20;
+  static constexpr uint32_t TRANSACTION_ReverseByteEnum = FIRST_CALL_TRANSACTION + 21;
+  static constexpr uint32_t TRANSACTION_ReverseIntEnum = FIRST_CALL_TRANSACTION + 22;
+  static constexpr uint32_t TRANSACTION_ReverseLongEnum = FIRST_CALL_TRANSACTION + 23;
+  static constexpr uint32_t TRANSACTION_GetOtherTestService = FIRST_CALL_TRANSACTION + 24;
+  static constexpr uint32_t TRANSACTION_VerifyName = FIRST_CALL_TRANSACTION + 25;
+  static constexpr uint32_t TRANSACTION_ReverseStringList = FIRST_CALL_TRANSACTION + 26;
+  static constexpr uint32_t TRANSACTION_RepeatParcelFileDescriptor = FIRST_CALL_TRANSACTION + 27;
+  static constexpr uint32_t TRANSACTION_ReverseParcelFileDescriptorArray = FIRST_CALL_TRANSACTION + 28;
+  static constexpr uint32_t TRANSACTION_ThrowServiceException = FIRST_CALL_TRANSACTION + 29;
+  static constexpr uint32_t TRANSACTION_RepeatNullableIntArray = FIRST_CALL_TRANSACTION + 30;
+  static constexpr uint32_t TRANSACTION_RepeatNullableByteEnumArray = FIRST_CALL_TRANSACTION + 31;
+  static constexpr uint32_t TRANSACTION_RepeatNullableIntEnumArray = FIRST_CALL_TRANSACTION + 32;
+  static constexpr uint32_t TRANSACTION_RepeatNullableLongEnumArray = FIRST_CALL_TRANSACTION + 33;
+  static constexpr uint32_t TRANSACTION_RepeatNullableString = FIRST_CALL_TRANSACTION + 34;
+  static constexpr uint32_t TRANSACTION_RepeatNullableStringList = FIRST_CALL_TRANSACTION + 35;
+  static constexpr uint32_t TRANSACTION_RepeatNullableParcelable = FIRST_CALL_TRANSACTION + 36;
+  static constexpr uint32_t TRANSACTION_TakesAnIBinder = FIRST_CALL_TRANSACTION + 37;
+  static constexpr uint32_t TRANSACTION_TakesANullableIBinder = FIRST_CALL_TRANSACTION + 38;
+  static constexpr uint32_t TRANSACTION_RepeatUtf8CppString = FIRST_CALL_TRANSACTION + 39;
+  static constexpr uint32_t TRANSACTION_RepeatNullableUtf8CppString = FIRST_CALL_TRANSACTION + 40;
+  static constexpr uint32_t TRANSACTION_ReverseUtf8CppString = FIRST_CALL_TRANSACTION + 41;
+  static constexpr uint32_t TRANSACTION_ReverseNullableUtf8CppString = FIRST_CALL_TRANSACTION + 42;
+  static constexpr uint32_t TRANSACTION_ReverseUtf8CppStringList = FIRST_CALL_TRANSACTION + 43;
+  static constexpr uint32_t TRANSACTION_GetCallback = FIRST_CALL_TRANSACTION + 44;
+  static constexpr uint32_t TRANSACTION_FillOutStructuredParcelable = FIRST_CALL_TRANSACTION + 45;
+  static constexpr uint32_t TRANSACTION_GetOldNameInterface = FIRST_CALL_TRANSACTION + 46;
+  static constexpr uint32_t TRANSACTION_GetNewNameInterface = FIRST_CALL_TRANSACTION + 47;
+  static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 48;
+  static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 49;
+
+  static std::shared_ptr<ITestService> fromBinder(const ::ndk::SpAIBinder& binder);
+  static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<ITestService>& instance);
+  static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<ITestService>* instance);
+  static bool setDefaultImpl(const std::shared_ptr<ITestService>& impl);
+  static const std::shared_ptr<ITestService>& getDefaultImpl();
+  virtual ::ndk::ScopedAStatus UnimplementedMethod(int32_t in_arg, int32_t* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus TestOneway() = 0;
+  virtual ::ndk::ScopedAStatus RepeatBoolean(bool in_token, bool* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatByte(int8_t in_token, int8_t* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatChar(char16_t in_token, char16_t* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatInt(int32_t in_token, int32_t* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatLong(int64_t in_token, int64_t* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatFloat(float in_token, float* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatDouble(double in_token, double* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatString(const std::string& in_token, std::string* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatByteEnum(::aidl::android::aidl::tests::ByteEnum in_token, ::aidl::android::aidl::tests::ByteEnum* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatIntEnum(::aidl::android::aidl::tests::IntEnum in_token, ::aidl::android::aidl::tests::IntEnum* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatLongEnum(::aidl::android::aidl::tests::LongEnum in_token, ::aidl::android::aidl::tests::LongEnum* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseBoolean(const std::vector<bool>& in_input, std::vector<bool>* out_repeated, std::vector<bool>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseByte(const std::vector<uint8_t>& in_input, std::vector<uint8_t>* out_repeated, std::vector<uint8_t>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseChar(const std::vector<char16_t>& in_input, std::vector<char16_t>* out_repeated, std::vector<char16_t>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseInt(const std::vector<int32_t>& in_input, std::vector<int32_t>* out_repeated, std::vector<int32_t>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseLong(const std::vector<int64_t>& in_input, std::vector<int64_t>* out_repeated, std::vector<int64_t>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseFloat(const std::vector<float>& in_input, std::vector<float>* out_repeated, std::vector<float>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseDouble(const std::vector<double>& in_input, std::vector<double>* out_repeated, std::vector<double>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseByteEnum(const std::vector<::aidl::android::aidl::tests::ByteEnum>& in_input, std::vector<::aidl::android::aidl::tests::ByteEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::ByteEnum>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseIntEnum(const std::vector<::aidl::android::aidl::tests::IntEnum>& in_input, std::vector<::aidl::android::aidl::tests::IntEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::IntEnum>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseLongEnum(const std::vector<::aidl::android::aidl::tests::LongEnum>& in_input, std::vector<::aidl::android::aidl::tests::LongEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::LongEnum>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus GetOtherTestService(const std::string& in_name, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus VerifyName(const std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>& in_service, const std::string& in_name, bool* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatParcelFileDescriptor(const ::ndk::ScopedFileDescriptor& in_read, ::ndk::ScopedFileDescriptor* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseParcelFileDescriptorArray(const std::vector<::ndk::ScopedFileDescriptor>& in_input, std::vector<::ndk::ScopedFileDescriptor>* out_repeated, std::vector<::ndk::ScopedFileDescriptor>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ThrowServiceException(int32_t in_code) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableIntArray(const std::optional<std::vector<int32_t>>& in_input, std::optional<std::vector<int32_t>>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableByteEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableIntEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableLongEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableString(const std::optional<std::string>& in_input, std::optional<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableStringList(const std::vector<std::string>& in_input, std::vector<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableParcelable(const std::optional<::aidl::android::aidl::tests::StructuredParcelable>& in_input, std::optional<::aidl::android::aidl::tests::StructuredParcelable>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus TakesAnIBinder(const ::ndk::SpAIBinder& in_input) = 0;
+  virtual ::ndk::ScopedAStatus TakesANullableIBinder(const ::ndk::SpAIBinder& in_input) = 0;
+  virtual ::ndk::ScopedAStatus RepeatUtf8CppString(const std::string& in_token, std::string* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus RepeatNullableUtf8CppString(const std::optional<std::string>& in_token, std::optional<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseUtf8CppString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseNullableUtf8CppString(const std::optional<std::vector<std::optional<std::string>>>& in_input, std::optional<std::vector<std::optional<std::string>>>* out_repeated, std::optional<std::vector<std::optional<std::string>>>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus ReverseUtf8CppStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus GetCallback(bool in_return_null, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) = 0;
+  virtual ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) = 0;
+  virtual ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) = 0;
+private:
+  static std::shared_ptr<ITestService> default_impl;
+};
+class ITestServiceDefault : public ITestService {
+public:
+  ::ndk::ScopedAStatus UnimplementedMethod(int32_t in_arg, int32_t* _aidl_return) override;
+  ::ndk::ScopedAStatus TestOneway() override;
+  ::ndk::ScopedAStatus RepeatBoolean(bool in_token, bool* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatByte(int8_t in_token, int8_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatChar(char16_t in_token, char16_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatInt(int32_t in_token, int32_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatLong(int64_t in_token, int64_t* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatFloat(float in_token, float* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatDouble(double in_token, double* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatString(const std::string& in_token, std::string* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatByteEnum(::aidl::android::aidl::tests::ByteEnum in_token, ::aidl::android::aidl::tests::ByteEnum* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatIntEnum(::aidl::android::aidl::tests::IntEnum in_token, ::aidl::android::aidl::tests::IntEnum* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatLongEnum(::aidl::android::aidl::tests::LongEnum in_token, ::aidl::android::aidl::tests::LongEnum* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseBoolean(const std::vector<bool>& in_input, std::vector<bool>* out_repeated, std::vector<bool>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseByte(const std::vector<uint8_t>& in_input, std::vector<uint8_t>* out_repeated, std::vector<uint8_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseChar(const std::vector<char16_t>& in_input, std::vector<char16_t>* out_repeated, std::vector<char16_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseInt(const std::vector<int32_t>& in_input, std::vector<int32_t>* out_repeated, std::vector<int32_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseLong(const std::vector<int64_t>& in_input, std::vector<int64_t>* out_repeated, std::vector<int64_t>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseFloat(const std::vector<float>& in_input, std::vector<float>* out_repeated, std::vector<float>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseDouble(const std::vector<double>& in_input, std::vector<double>* out_repeated, std::vector<double>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseByteEnum(const std::vector<::aidl::android::aidl::tests::ByteEnum>& in_input, std::vector<::aidl::android::aidl::tests::ByteEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::ByteEnum>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseIntEnum(const std::vector<::aidl::android::aidl::tests::IntEnum>& in_input, std::vector<::aidl::android::aidl::tests::IntEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::IntEnum>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseLongEnum(const std::vector<::aidl::android::aidl::tests::LongEnum>& in_input, std::vector<::aidl::android::aidl::tests::LongEnum>* out_repeated, std::vector<::aidl::android::aidl::tests::LongEnum>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetOtherTestService(const std::string& in_name, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) override;
+  ::ndk::ScopedAStatus VerifyName(const std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>& in_service, const std::string& in_name, bool* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatParcelFileDescriptor(const ::ndk::ScopedFileDescriptor& in_read, ::ndk::ScopedFileDescriptor* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseParcelFileDescriptorArray(const std::vector<::ndk::ScopedFileDescriptor>& in_input, std::vector<::ndk::ScopedFileDescriptor>* out_repeated, std::vector<::ndk::ScopedFileDescriptor>* _aidl_return) override;
+  ::ndk::ScopedAStatus ThrowServiceException(int32_t in_code) override;
+  ::ndk::ScopedAStatus RepeatNullableIntArray(const std::optional<std::vector<int32_t>>& in_input, std::optional<std::vector<int32_t>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableByteEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::ByteEnum>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableIntEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::IntEnum>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableLongEnumArray(const std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>& in_input, std::optional<std::vector<::aidl::android::aidl::tests::LongEnum>>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableString(const std::optional<std::string>& in_input, std::optional<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableStringList(const std::vector<std::string>& in_input, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableParcelable(const std::optional<::aidl::android::aidl::tests::StructuredParcelable>& in_input, std::optional<::aidl::android::aidl::tests::StructuredParcelable>* _aidl_return) override;
+  ::ndk::ScopedAStatus TakesAnIBinder(const ::ndk::SpAIBinder& in_input) override;
+  ::ndk::ScopedAStatus TakesANullableIBinder(const ::ndk::SpAIBinder& in_input) override;
+  ::ndk::ScopedAStatus RepeatUtf8CppString(const std::string& in_token, std::string* _aidl_return) override;
+  ::ndk::ScopedAStatus RepeatNullableUtf8CppString(const std::optional<std::string>& in_token, std::optional<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseUtf8CppString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseNullableUtf8CppString(const std::optional<std::vector<std::optional<std::string>>>& in_input, std::optional<std::vector<std::optional<std::string>>>* out_repeated, std::optional<std::vector<std::optional<std::string>>>* _aidl_return) override;
+  ::ndk::ScopedAStatus ReverseUtf8CppStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetCallback(bool in_return_null, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) override;
+  ::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) override;
+  ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override;
+  ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
+  ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) override;
+  ::ndk::SpAIBinder asBinder() override;
+  bool isRemote() override;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IntEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IntEnum.h
new file mode 100644
index 0000000..fcb0b99
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IntEnum.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+enum class IntEnum : int32_t {
+  FOO = 1000,
+  BAR = 2000,
+  BAZ = 2001,
+};
+
+static inline std::string toString(IntEnum val) {
+  switch(val) {
+  case IntEnum::FOO:
+    return "FOO";
+  case IntEnum::BAR:
+    return "BAR";
+  case IntEnum::BAZ:
+    return "BAZ";
+  default:
+    return std::to_string(static_cast<int32_t>(val));
+  }
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::tests::IntEnum, 3> enum_values<aidl::android::aidl::tests::IntEnum> = {
+  aidl::android::aidl::tests::IntEnum::FOO,
+  aidl::android::aidl::tests::IntEnum::BAR,
+  aidl::android::aidl::tests::IntEnum::BAZ,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/LongEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/LongEnum.h
new file mode 100644
index 0000000..b43062d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/LongEnum.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+enum class LongEnum : int64_t {
+  FOO = 100000000000L,
+  BAR = 200000000000L,
+  BAZ = 200000000001L,
+};
+
+static inline std::string toString(LongEnum val) {
+  switch(val) {
+  case LongEnum::FOO:
+    return "FOO";
+  case LongEnum::BAR:
+    return "BAR";
+  case LongEnum::BAZ:
+    return "BAZ";
+  default:
+    return std::to_string(static_cast<int64_t>(val));
+  }
+}
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::tests::LongEnum, 3> enum_values<aidl::android::aidl::tests::LongEnum> = {
+  aidl::android::aidl::tests::LongEnum::FOO,
+  aidl::android::aidl::tests::LongEnum::BAR,
+  aidl::android::aidl::tests::LongEnum::BAZ,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/OtherParcelableForToString.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/OtherParcelableForToString.h
new file mode 100644
index 0000000..a67565e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/OtherParcelableForToString.h
@@ -0,0 +1,69 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class OtherParcelableForToString {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  std::string field;
+
+  binder_status_t readFromParcel(const AParcel* parcel);
+  binder_status_t writeToParcel(AParcel* parcel) const;
+
+  inline bool operator!=(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) != std::tie(rhs.field);
+  }
+  inline bool operator<(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) < std::tie(rhs.field);
+  }
+  inline bool operator<=(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) <= std::tie(rhs.field);
+  }
+  inline bool operator==(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) == std::tie(rhs.field);
+  }
+  inline bool operator>(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) > std::tie(rhs.field);
+  }
+  inline bool operator>=(const OtherParcelableForToString& rhs) const {
+    return std::tie(field) >= std::tie(rhs.field);
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "OtherParcelableForToString{";
+    os << "field: " << (std::ostringstream() << field).str();
+    os << "}";
+    return os.str();
+  }
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ParcelableForToString.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ParcelableForToString.h
new file mode 100644
index 0000000..9a9d87c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ParcelableForToString.h
@@ -0,0 +1,118 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/tests/GenericStructuredParcelable.h>
+#include <aidl/android/aidl/tests/IntEnum.h>
+#include <aidl/android/aidl/tests/OtherParcelableForToString.h>
+#include <aidl/android/aidl/tests/StructuredParcelable.h>
+#include <aidl/android/aidl/tests/Union.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class ParcelableForToString {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  int32_t intValue = 0;
+  std::vector<int32_t> intArray;
+  int64_t longValue = 0L;
+  std::vector<int64_t> longArray;
+  double doubleValue = 0.000000;
+  std::vector<double> doubleArray;
+  float floatValue = 0.000000f;
+  std::vector<float> floatArray;
+  int8_t byteValue = 0;
+  std::vector<uint8_t> byteArray;
+  bool booleanValue = false;
+  std::vector<bool> booleanArray;
+  std::string stringValue;
+  std::vector<std::string> stringArray;
+  std::vector<std::string> stringList;
+  ::aidl::android::aidl::tests::OtherParcelableForToString parcelableValue;
+  std::vector<::aidl::android::aidl::tests::OtherParcelableForToString> parcelableArray;
+  ::aidl::android::aidl::tests::IntEnum enumValue;
+  std::vector<::aidl::android::aidl::tests::IntEnum> enumArray;
+  std::vector<std::string> nullArray;
+  std::vector<std::string> nullList;
+  ::aidl::android::aidl::tests::GenericStructuredParcelable<int32_t, ::aidl::android::aidl::tests::StructuredParcelable, ::aidl::android::aidl::tests::IntEnum> parcelableGeneric;
+  ::aidl::android::aidl::tests::Union unionValue;
+
+  binder_status_t readFromParcel(const AParcel* parcel);
+  binder_status_t writeToParcel(AParcel* parcel) const;
+
+  inline bool operator!=(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) != std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator<(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) < std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator<=(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) <= std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator==(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) == std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator>(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) > std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+  inline bool operator>=(const ParcelableForToString& rhs) const {
+    return std::tie(intValue, intArray, longValue, longArray, doubleValue, doubleArray, floatValue, floatArray, byteValue, byteArray, booleanValue, booleanArray, stringValue, stringArray, stringList, parcelableValue, parcelableArray, enumValue, enumArray, nullArray, nullList, parcelableGeneric, unionValue) >= std::tie(rhs.intValue, rhs.intArray, rhs.longValue, rhs.longArray, rhs.doubleValue, rhs.doubleArray, rhs.floatValue, rhs.floatArray, rhs.byteValue, rhs.byteArray, rhs.booleanValue, rhs.booleanArray, rhs.stringValue, rhs.stringArray, rhs.stringList, rhs.parcelableValue, rhs.parcelableArray, rhs.enumValue, rhs.enumArray, rhs.nullArray, rhs.nullList, rhs.parcelableGeneric, rhs.unionValue);
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "ParcelableForToString{";
+    os << "intValue: " << std::to_string(intValue);
+    os << ", intArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", longValue: " << std::to_string(longValue);
+    os << ", longArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", doubleValue: " << std::to_string(doubleValue);
+    os << ", doubleArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", floatValue: " << std::to_string(floatValue);
+    os << ", floatArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", byteValue: " << std::to_string(byteValue);
+    os << ", byteArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", booleanValue: " << (booleanValue?"true":"false");
+    os << ", booleanArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: booleanArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }();
+    os << ", stringValue: " << (std::ostringstream() << stringValue).str();
+    os << ", stringArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", stringList: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: stringList) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", parcelableValue: " << _call_toString(parcelableValue);
+    os << ", parcelableArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: parcelableArray) { (void)v; if (first) first = false; else o << ", "; o << _call_toString(v); }; o << "]"; return o.str(); }();
+    os << ", enumValue: " << android::aidl::tests::toString(enumValue);
+    os << ", enumArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: enumArray) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", nullArray: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: nullArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", nullList: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: nullList) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", parcelableGeneric: " << _call_toString(parcelableGeneric);
+    os << ", unionValue: " << _call_toString(unionValue);
+    os << "}";
+    return os.str();
+  }
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/StructuredParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/StructuredParcelable.h
new file mode 100644
index 0000000..c3da4c2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/StructuredParcelable.h
@@ -0,0 +1,181 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/tests/ByteEnum.h>
+#include <aidl/android/aidl/tests/ConstantExpressionEnum.h>
+#include <aidl/android/aidl/tests/IntEnum.h>
+#include <aidl/android/aidl/tests/LongEnum.h>
+#include <aidl/android/aidl/tests/Union.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class StructuredParcelable {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  std::vector<int32_t> shouldContainThreeFs;
+  int32_t f = 0;
+  std::string shouldBeJerry;
+  ::aidl::android::aidl::tests::ByteEnum shouldBeByteBar;
+  ::aidl::android::aidl::tests::IntEnum shouldBeIntBar;
+  ::aidl::android::aidl::tests::LongEnum shouldBeLongBar;
+  std::vector<::aidl::android::aidl::tests::ByteEnum> shouldContainTwoByteFoos;
+  std::vector<::aidl::android::aidl::tests::IntEnum> shouldContainTwoIntFoos;
+  std::vector<::aidl::android::aidl::tests::LongEnum> shouldContainTwoLongFoos;
+  std::string stringDefaultsToFoo = "foo";
+  int8_t byteDefaultsToFour = 4;
+  int32_t intDefaultsToFive = 5;
+  int64_t longDefaultsToNegativeSeven = -7L;
+  bool booleanDefaultsToTrue = true;
+  char16_t charDefaultsToC = 'C';
+  float floatDefaultsToPi = 3.140000f;
+  double doubleWithDefault = -314000000000000000.000000;
+  std::vector<int32_t> arrayDefaultsTo123 = {1, 2, 3};
+  std::vector<int32_t> arrayDefaultsToEmpty = {};
+  bool boolDefault = false;
+  int8_t byteDefault = 0;
+  int32_t intDefault = 0;
+  int64_t longDefault = 0L;
+  float floatDefault = 0.000000f;
+  double doubleDefault = 0.000000;
+  double checkDoubleFromFloat = 3.140000;
+  std::vector<std::string> checkStringArray1 = {"a", "b"};
+  std::vector<std::string> checkStringArray2 = {"a", "b"};
+  int32_t int32_min = -2147483648;
+  int32_t int32_max = 2147483647;
+  int64_t int64_max = 9223372036854775807L;
+  int32_t hexInt32_neg_1 = -1;
+  ::ndk::SpAIBinder ibinder;
+  std::vector<int32_t> int32_1 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+  std::vector<int64_t> int64_1 = {1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L};
+  int32_t hexInt32_pos_1 = 1;
+  int32_t hexInt64_pos_1 = 1;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_1;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_2;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_3;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_4;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_5;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_6;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_7;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_8;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_9;
+  ::aidl::android::aidl::tests::ConstantExpressionEnum const_exprs_10;
+  std::string addString1 = "hello world!";
+  std::string addString2 = "The quick brown fox jumps over the lazy dog.";
+  int32_t shouldSetBit0AndBit2 = 0;
+  std::optional<::aidl::android::aidl::tests::Union> u;
+  std::optional<::aidl::android::aidl::tests::Union> shouldBeConstS1;
+  ::aidl::android::aidl::tests::IntEnum defaultWithFoo = ::aidl::android::aidl::tests::IntEnum::FOO;
+
+  binder_status_t readFromParcel(const AParcel* parcel);
+  binder_status_t writeToParcel(AParcel* parcel) const;
+
+  inline bool operator!=(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) != std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator<(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) < std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator<=(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) <= std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator==(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) == std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator>(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) > std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+  inline bool operator>=(const StructuredParcelable& rhs) const {
+    return std::tie(shouldContainThreeFs, f, shouldBeJerry, shouldBeByteBar, shouldBeIntBar, shouldBeLongBar, shouldContainTwoByteFoos, shouldContainTwoIntFoos, shouldContainTwoLongFoos, stringDefaultsToFoo, byteDefaultsToFour, intDefaultsToFive, longDefaultsToNegativeSeven, booleanDefaultsToTrue, charDefaultsToC, floatDefaultsToPi, doubleWithDefault, arrayDefaultsTo123, arrayDefaultsToEmpty, boolDefault, byteDefault, intDefault, longDefault, floatDefault, doubleDefault, checkDoubleFromFloat, checkStringArray1, checkStringArray2, int32_min, int32_max, int64_max, hexInt32_neg_1, ibinder, int32_1, int64_1, hexInt32_pos_1, hexInt64_pos_1, const_exprs_1, const_exprs_2, const_exprs_3, const_exprs_4, const_exprs_5, const_exprs_6, const_exprs_7, const_exprs_8, const_exprs_9, const_exprs_10, addString1, addString2, shouldSetBit0AndBit2, u, shouldBeConstS1, defaultWithFoo) >= std::tie(rhs.shouldContainThreeFs, rhs.f, rhs.shouldBeJerry, rhs.shouldBeByteBar, rhs.shouldBeIntBar, rhs.shouldBeLongBar, rhs.shouldContainTwoByteFoos, rhs.shouldContainTwoIntFoos, rhs.shouldContainTwoLongFoos, rhs.stringDefaultsToFoo, rhs.byteDefaultsToFour, rhs.intDefaultsToFive, rhs.longDefaultsToNegativeSeven, rhs.booleanDefaultsToTrue, rhs.charDefaultsToC, rhs.floatDefaultsToPi, rhs.doubleWithDefault, rhs.arrayDefaultsTo123, rhs.arrayDefaultsToEmpty, rhs.boolDefault, rhs.byteDefault, rhs.intDefault, rhs.longDefault, rhs.floatDefault, rhs.doubleDefault, rhs.checkDoubleFromFloat, rhs.checkStringArray1, rhs.checkStringArray2, rhs.int32_min, rhs.int32_max, rhs.int64_max, rhs.hexInt32_neg_1, rhs.ibinder, rhs.int32_1, rhs.int64_1, rhs.hexInt32_pos_1, rhs.hexInt64_pos_1, rhs.const_exprs_1, rhs.const_exprs_2, rhs.const_exprs_3, rhs.const_exprs_4, rhs.const_exprs_5, rhs.const_exprs_6, rhs.const_exprs_7, rhs.const_exprs_8, rhs.const_exprs_9, rhs.const_exprs_10, rhs.addString1, rhs.addString2, rhs.shouldSetBit0AndBit2, rhs.u, rhs.shouldBeConstS1, rhs.defaultWithFoo);
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  enum : int32_t { BIT0 = 1 };
+  enum : int32_t { BIT1 = 2 };
+  enum : int32_t { BIT2 = 4 };
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "StructuredParcelable{";
+    os << "shouldContainThreeFs: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainThreeFs) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", f: " << std::to_string(f);
+    os << ", shouldBeJerry: " << (std::ostringstream() << shouldBeJerry).str();
+    os << ", shouldBeByteBar: " << android::aidl::tests::toString(shouldBeByteBar);
+    os << ", shouldBeIntBar: " << android::aidl::tests::toString(shouldBeIntBar);
+    os << ", shouldBeLongBar: " << android::aidl::tests::toString(shouldBeLongBar);
+    os << ", shouldContainTwoByteFoos: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainTwoByteFoos) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", shouldContainTwoIntFoos: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainTwoIntFoos) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", shouldContainTwoLongFoos: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: shouldContainTwoLongFoos) { (void)v; if (first) first = false; else o << ", "; o << android::aidl::tests::toString(v); }; o << "]"; return o.str(); }();
+    os << ", stringDefaultsToFoo: " << (std::ostringstream() << stringDefaultsToFoo).str();
+    os << ", byteDefaultsToFour: " << std::to_string(byteDefaultsToFour);
+    os << ", intDefaultsToFive: " << std::to_string(intDefaultsToFive);
+    os << ", longDefaultsToNegativeSeven: " << std::to_string(longDefaultsToNegativeSeven);
+    os << ", booleanDefaultsToTrue: " << (booleanDefaultsToTrue?"true":"false");
+    os << ", charDefaultsToC: " << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(charDefaultsToC);
+    os << ", floatDefaultsToPi: " << std::to_string(floatDefaultsToPi);
+    os << ", doubleWithDefault: " << std::to_string(doubleWithDefault);
+    os << ", arrayDefaultsTo123: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: arrayDefaultsTo123) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", arrayDefaultsToEmpty: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: arrayDefaultsToEmpty) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", boolDefault: " << (boolDefault?"true":"false");
+    os << ", byteDefault: " << std::to_string(byteDefault);
+    os << ", intDefault: " << std::to_string(intDefault);
+    os << ", longDefault: " << std::to_string(longDefault);
+    os << ", floatDefault: " << std::to_string(floatDefault);
+    os << ", doubleDefault: " << std::to_string(doubleDefault);
+    os << ", checkDoubleFromFloat: " << std::to_string(checkDoubleFromFloat);
+    os << ", checkStringArray1: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: checkStringArray1) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", checkStringArray2: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: checkStringArray2) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    os << ", int32_min: " << std::to_string(int32_min);
+    os << ", int32_max: " << std::to_string(int32_max);
+    os << ", int64_max: " << std::to_string(int64_max);
+    os << ", hexInt32_neg_1: " << std::to_string(hexInt32_neg_1);
+    os << ", ibinder: " << "";
+    os << ", int32_1: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: int32_1) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", int64_1: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: int64_1) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }();
+    os << ", hexInt32_pos_1: " << std::to_string(hexInt32_pos_1);
+    os << ", hexInt64_pos_1: " << std::to_string(hexInt64_pos_1);
+    os << ", const_exprs_1: " << android::aidl::tests::toString(const_exprs_1);
+    os << ", const_exprs_2: " << android::aidl::tests::toString(const_exprs_2);
+    os << ", const_exprs_3: " << android::aidl::tests::toString(const_exprs_3);
+    os << ", const_exprs_4: " << android::aidl::tests::toString(const_exprs_4);
+    os << ", const_exprs_5: " << android::aidl::tests::toString(const_exprs_5);
+    os << ", const_exprs_6: " << android::aidl::tests::toString(const_exprs_6);
+    os << ", const_exprs_7: " << android::aidl::tests::toString(const_exprs_7);
+    os << ", const_exprs_8: " << android::aidl::tests::toString(const_exprs_8);
+    os << ", const_exprs_9: " << android::aidl::tests::toString(const_exprs_9);
+    os << ", const_exprs_10: " << android::aidl::tests::toString(const_exprs_10);
+    os << ", addString1: " << (std::ostringstream() << addString1).str();
+    os << ", addString2: " << (std::ostringstream() << addString2).str();
+    os << ", shouldSetBit0AndBit2: " << std::to_string(shouldSetBit0AndBit2);
+    os << ", u: " << ((u) ? _call_toString(*u): "(null)");
+    os << ", shouldBeConstS1: " << ((shouldBeConstS1) ? _call_toString(*shouldBeConstS1): "(null)");
+    os << ", defaultWithFoo: " << android::aidl::tests::toString(defaultWithFoo);
+    os << "}";
+    return os.str();
+  }
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/Union.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/Union.h
new file mode 100644
index 0000000..0e83dbd
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/Union.h
@@ -0,0 +1,148 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+
+#include <cassert>
+#include <type_traits>
+#include <utility>
+#include <variant>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/tests/ByteEnum.h>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class Union {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  enum Tag : int32_t {
+    ns = 0,  // int[] ns;
+    n,  // int n;
+    m,  // int m;
+    s,  // String s;
+    ibinder,  // IBinder ibinder;
+    ss,  // List<String> ss;
+    be,  // android.aidl.tests.ByteEnum be;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
+
+  Union() : _value(std::in_place_index<ns>, std::vector<int32_t>({})) { }
+  Union(const Union&) = default;
+  Union(Union&&) = default;
+  Union& operator=(const Union&) = default;
+  Union& operator=(Union&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr Union(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit Union(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static Union make(_Tp&&... _args) {
+    return Union(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static Union make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return Union(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  binder_status_t readFromParcel(const AParcel* _parcel);
+  binder_status_t writeToParcel(AParcel* _parcel) const;
+
+  inline bool operator!=(const Union& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const Union& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const Union& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const Union& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const Union& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const Union& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  static const char* S1;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Union{";
+    switch (getTag()) {
+    case ns: os << "ns: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: get<ns>()) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }(); break;
+    case n: os << "n: " << std::to_string(get<n>()); break;
+    case m: os << "m: " << std::to_string(get<m>()); break;
+    case s: os << "s: " << (std::ostringstream() << get<s>()).str(); break;
+    case ibinder: os << "ibinder: " << ""; break;
+    case ss: os << "ss: " << [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: get<ss>()) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }(); break;
+    case be: os << "be: " << android::aidl::tests::toString(get<be>()); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<std::vector<int32_t>, int32_t, int32_t, std::string, ::ndk::SpAIBinder, std::vector<std::string>, ::aidl::android::aidl::tests::ByteEnum> _value;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
new file mode 100644
index 0000000..f0fc84d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
@@ -0,0 +1,136 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+
+#include <cassert>
+#include <type_traits>
+#include <utility>
+#include <variant>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class UnionWithFd {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    pfd,  // ParcelFileDescriptor pfd;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>;
+
+  UnionWithFd() : _value(std::in_place_index<num>, int32_t(0)) { }
+  UnionWithFd(const UnionWithFd&) = default;
+  UnionWithFd(UnionWithFd&&) = default;
+  UnionWithFd& operator=(const UnionWithFd&) = default;
+  UnionWithFd& operator=(UnionWithFd&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr UnionWithFd(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit UnionWithFd(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static UnionWithFd make(_Tp&&... _args) {
+    return UnionWithFd(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static UnionWithFd make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return UnionWithFd(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  binder_status_t readFromParcel(const AParcel* _parcel);
+  binder_status_t writeToParcel(AParcel* _parcel) const;
+
+  inline bool operator!=(const UnionWithFd& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const UnionWithFd& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const UnionWithFd& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const UnionWithFd& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const UnionWithFd& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const UnionWithFd& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "UnionWithFd{";
+    switch (getTag()) {
+    case num: os << "num: " << std::to_string(get<num>()); break;
+    case pfd: os << "pfd: " << ""; break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<int32_t, ::ndk::ScopedFileDescriptor> _value;
+};
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BnEnumUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BnEnumUnion.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BnEnumUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BpEnumUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BpEnumUnion.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BpEnumUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
new file mode 100644
index 0000000..a8aa49a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
@@ -0,0 +1,140 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+
+#include <cassert>
+#include <type_traits>
+#include <utility>
+#include <variant>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/tests/IntEnum.h>
+#include <aidl/android/aidl/tests/LongEnum.h>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+class EnumUnion {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  enum Tag : int32_t {
+    intEnum = 0,  // android.aidl.tests.IntEnum intEnum;
+    longEnum,  // android.aidl.tests.LongEnum longEnum;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>;
+
+  EnumUnion() : _value(std::in_place_index<intEnum>, ::aidl::android::aidl::tests::IntEnum(::aidl::android::aidl::tests::IntEnum::FOO)) { }
+  EnumUnion(const EnumUnion&) = default;
+  EnumUnion(EnumUnion&&) = default;
+  EnumUnion& operator=(const EnumUnion&) = default;
+  EnumUnion& operator=(EnumUnion&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr EnumUnion(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit EnumUnion(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static EnumUnion make(_Tp&&... _args) {
+    return EnumUnion(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static EnumUnion make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return EnumUnion(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  binder_status_t readFromParcel(const AParcel* _parcel);
+  binder_status_t writeToParcel(AParcel* _parcel) const;
+
+  inline bool operator!=(const EnumUnion& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const EnumUnion& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const EnumUnion& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const EnumUnion& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const EnumUnion& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const EnumUnion& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "EnumUnion{";
+    switch (getTag()) {
+    case intEnum: os << "intEnum: " << android::aidl::tests::toString(get<intEnum>()); break;
+    case longEnum: os << "longEnum: " << android::aidl::tests::toString(get<longEnum>()); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<::aidl::android::aidl::tests::IntEnum, ::aidl::android::aidl::tests::LongEnum> _value;
+};
+}  // namespace unions
+}  // namespace tests
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/timestamp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/timestamp
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs
new file mode 100644
index 0000000..5d8d059
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs
@@ -0,0 +1,9 @@
+#![allow(non_upper_case_globals)]
+use binder::declare_binder_enum;
+declare_binder_enum! { BackendType : i8 {
+  CPP = 0,
+  JAVA = 1,
+  NDK = 2,
+  RUST = 3,
+} }
+pub(crate) mod mangled { pub use super::BackendType as _7_android_4_aidl_5_tests_11_BackendType; }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs.d
new file mode 100644
index 0000000..065463e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/BackendType.rs : \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs
new file mode 100644
index 0000000..7961532
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs
@@ -0,0 +1,8 @@
+#![allow(non_upper_case_globals)]
+use binder::declare_binder_enum;
+declare_binder_enum! { ByteEnum : i8 {
+  FOO = 1,
+  BAR = 2,
+  BAZ = 3,
+} }
+pub(crate) mod mangled { pub use super::ByteEnum as _7_android_4_aidl_5_tests_8_ByteEnum; }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs.d
new file mode 100644
index 0000000..f91b6e9
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/ByteEnum.rs : \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs
new file mode 100644
index 0000000..e1dae7d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs
@@ -0,0 +1,15 @@
+#![allow(non_upper_case_globals)]
+use binder::declare_binder_enum;
+declare_binder_enum! { ConstantExpressionEnum : i32 {
+  decInt32_1 = 1,
+  decInt32_2 = 1,
+  decInt64_1 = 1,
+  decInt64_2 = 1,
+  decInt64_3 = 1,
+  decInt64_4 = 1,
+  hexInt32_1 = 1,
+  hexInt32_2 = 1,
+  hexInt32_3 = 1,
+  hexInt64_1 = 1,
+} }
+pub(crate) mod mangled { pub use super::ConstantExpressionEnum as _7_android_4_aidl_5_tests_22_ConstantExpressionEnum; }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs.d
new file mode 100644
index 0000000..bd22319
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/ConstantExpressionEnum.rs : \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs
new file mode 100644
index 0000000..b98ba2e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs
@@ -0,0 +1,62 @@
+#[derive(Debug)]
+pub struct GenericStructuredParcelable {
+  pub a: i32,
+  pub b: i32,
+}
+pub(crate) mod mangled { pub use super::GenericStructuredParcelable as _7_android_4_aidl_5_tests_27_GenericStructuredParcelable; }
+impl Default for GenericStructuredParcelable {
+  fn default() -> Self {
+    Self {
+      a: 0,
+      b: 0,
+    }
+  }
+}
+impl binder::parcel::Serialize for GenericStructuredParcelable {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for GenericStructuredParcelable {}
+impl binder::parcel::SerializeOption for GenericStructuredParcelable {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    parcel.sized_write(|subparcel| {
+      subparcel.write(&this.a)?;
+      subparcel.write(&this.b)?;
+      Ok(())
+    })
+  }
+}
+impl binder::parcel::Deserialize for GenericStructuredParcelable {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for GenericStructuredParcelable {}
+impl binder::parcel::DeserializeOption for GenericStructuredParcelable {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let start_pos = parcel.get_data_position();
+    let parcelable_size: i32 = parcel.read()?;
+    if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+    let mut result = Self::default();
+    result.a = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.b = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    Ok(Some(result))
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs.d
new file mode 100644
index 0000000..01507cd
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs : \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs
new file mode 100644
index 0000000..f05693a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs
@@ -0,0 +1,72 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinder;
+use binder::declare_binder_interface;
+declare_binder_interface! {
+  INamedCallback["android.aidl.tests.INamedCallback"] {
+    native: BnNamedCallback(on_transact),
+    proxy: BpNamedCallback {
+    },
+  }
+}
+pub trait INamedCallback: binder::Interface + Send {
+  fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.INamedCallback" }
+  fn GetName(&self) -> binder::public_api::Result<String>;
+  fn getDefaultImpl() -> INamedCallbackDefaultRef where Self: Sized {
+    DEFAULT_IMPL.lock().unwrap().clone()
+  }
+  fn setDefaultImpl(d: INamedCallbackDefaultRef) -> INamedCallbackDefaultRef where Self: Sized {
+    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+  }
+}
+pub trait INamedCallbackDefault: Send + Sync {
+  fn GetName(&self) -> binder::public_api::Result<String> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+}
+pub mod transactions {
+  #[allow(unused_imports)] use binder::IBinder;
+  pub const GetName: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+}
+pub type INamedCallbackDefaultRef = Option<std::sync::Arc<dyn INamedCallbackDefault>>;
+use lazy_static::lazy_static;
+lazy_static! {
+  static ref DEFAULT_IMPL: std::sync::Mutex<INamedCallbackDefaultRef> = std::sync::Mutex::new(None);
+}
+pub(crate) mod mangled { pub use super::INamedCallback as _7_android_4_aidl_5_tests_14_INamedCallback; }
+impl INamedCallback for BpNamedCallback {
+  fn GetName(&self) -> binder::public_api::Result<String> {
+    let _aidl_reply = self.binder.transact(transactions::GetName, 0, |_aidl_data| {
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as INamedCallback>::getDefaultImpl() {
+        return _aidl_default_impl.GetName();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: String = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+}
+impl INamedCallback for binder::Binder<BnNamedCallback> {
+  fn GetName(&self) -> binder::public_api::Result<String> { self.0.GetName() }
+}
+fn on_transact(_aidl_service: &dyn INamedCallback, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+  match _aidl_code {
+    transactions::GetName => {
+      let _aidl_return = _aidl_service.GetName();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs.d
new file mode 100644
index 0000000..eea0b4d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs : \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs
new file mode 100644
index 0000000..ebfb429
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs
@@ -0,0 +1,72 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinder;
+use binder::declare_binder_interface;
+declare_binder_interface! {
+  INewName["android.aidl.tests.IOldName"] {
+    native: BnNewName(on_transact),
+    proxy: BpNewName {
+    },
+  }
+}
+pub trait INewName: binder::Interface + Send {
+  fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.IOldName" }
+  fn RealName(&self) -> binder::public_api::Result<String>;
+  fn getDefaultImpl() -> INewNameDefaultRef where Self: Sized {
+    DEFAULT_IMPL.lock().unwrap().clone()
+  }
+  fn setDefaultImpl(d: INewNameDefaultRef) -> INewNameDefaultRef where Self: Sized {
+    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+  }
+}
+pub trait INewNameDefault: Send + Sync {
+  fn RealName(&self) -> binder::public_api::Result<String> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+}
+pub mod transactions {
+  #[allow(unused_imports)] use binder::IBinder;
+  pub const RealName: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+}
+pub type INewNameDefaultRef = Option<std::sync::Arc<dyn INewNameDefault>>;
+use lazy_static::lazy_static;
+lazy_static! {
+  static ref DEFAULT_IMPL: std::sync::Mutex<INewNameDefaultRef> = std::sync::Mutex::new(None);
+}
+pub(crate) mod mangled { pub use super::INewName as _7_android_4_aidl_5_tests_8_INewName; }
+impl INewName for BpNewName {
+  fn RealName(&self) -> binder::public_api::Result<String> {
+    let _aidl_reply = self.binder.transact(transactions::RealName, 0, |_aidl_data| {
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as INewName>::getDefaultImpl() {
+        return _aidl_default_impl.RealName();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: String = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+}
+impl INewName for binder::Binder<BnNewName> {
+  fn RealName(&self) -> binder::public_api::Result<String> { self.0.RealName() }
+}
+fn on_transact(_aidl_service: &dyn INewName, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+  match _aidl_code {
+    transactions::RealName => {
+      let _aidl_return = _aidl_service.RealName();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs.d
new file mode 100644
index 0000000..978238f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs : \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs
new file mode 100644
index 0000000..8998366
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs
@@ -0,0 +1,72 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinder;
+use binder::declare_binder_interface;
+declare_binder_interface! {
+  IOldName["android.aidl.tests.IOldName"] {
+    native: BnOldName(on_transact),
+    proxy: BpOldName {
+    },
+  }
+}
+pub trait IOldName: binder::Interface + Send {
+  fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.IOldName" }
+  fn RealName(&self) -> binder::public_api::Result<String>;
+  fn getDefaultImpl() -> IOldNameDefaultRef where Self: Sized {
+    DEFAULT_IMPL.lock().unwrap().clone()
+  }
+  fn setDefaultImpl(d: IOldNameDefaultRef) -> IOldNameDefaultRef where Self: Sized {
+    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+  }
+}
+pub trait IOldNameDefault: Send + Sync {
+  fn RealName(&self) -> binder::public_api::Result<String> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+}
+pub mod transactions {
+  #[allow(unused_imports)] use binder::IBinder;
+  pub const RealName: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+}
+pub type IOldNameDefaultRef = Option<std::sync::Arc<dyn IOldNameDefault>>;
+use lazy_static::lazy_static;
+lazy_static! {
+  static ref DEFAULT_IMPL: std::sync::Mutex<IOldNameDefaultRef> = std::sync::Mutex::new(None);
+}
+pub(crate) mod mangled { pub use super::IOldName as _7_android_4_aidl_5_tests_8_IOldName; }
+impl IOldName for BpOldName {
+  fn RealName(&self) -> binder::public_api::Result<String> {
+    let _aidl_reply = self.binder.transact(transactions::RealName, 0, |_aidl_data| {
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as IOldName>::getDefaultImpl() {
+        return _aidl_default_impl.RealName();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: String = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+}
+impl IOldName for binder::Binder<BnOldName> {
+  fn RealName(&self) -> binder::public_api::Result<String> { self.0.RealName() }
+}
+fn on_transact(_aidl_service: &dyn IOldName, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+  match _aidl_code {
+    transactions::RealName => {
+      let _aidl_return = _aidl_service.RealName();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs.d
new file mode 100644
index 0000000..77773e8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs : \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
new file mode 100644
index 0000000..f9d28aa
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
@@ -0,0 +1,1917 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinder;
+use binder::declare_binder_interface;
+declare_binder_interface! {
+  ITestService["android.aidl.tests.ITestService"] {
+    native: BnTestService(on_transact),
+    proxy: BpTestService {
+    },
+  }
+}
+pub trait ITestService: binder::Interface + Send {
+  fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.ITestService" }
+  fn UnimplementedMethod(&self, _arg_arg: i32) -> binder::public_api::Result<i32>;
+  fn TestOneway(&self) -> binder::public_api::Result<()>;
+  fn RepeatBoolean(&self, _arg_token: bool) -> binder::public_api::Result<bool>;
+  fn RepeatByte(&self, _arg_token: i8) -> binder::public_api::Result<i8>;
+  fn RepeatChar(&self, _arg_token: u16) -> binder::public_api::Result<u16>;
+  fn RepeatInt(&self, _arg_token: i32) -> binder::public_api::Result<i32>;
+  fn RepeatLong(&self, _arg_token: i64) -> binder::public_api::Result<i64>;
+  fn RepeatFloat(&self, _arg_token: f32) -> binder::public_api::Result<f32>;
+  fn RepeatDouble(&self, _arg_token: f64) -> binder::public_api::Result<f64>;
+  fn RepeatString(&self, _arg_token: &str) -> binder::public_api::Result<String>;
+  fn RepeatByteEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>;
+  fn RepeatIntEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>;
+  fn RepeatLongEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>;
+  fn ReverseBoolean(&self, _arg_input: &[bool], _arg_repeated: &mut Vec<bool>) -> binder::public_api::Result<Vec<bool>>;
+  fn ReverseByte(&self, _arg_input: &[u8], _arg_repeated: &mut Vec<u8>) -> binder::public_api::Result<Vec<u8>>;
+  fn ReverseChar(&self, _arg_input: &[u16], _arg_repeated: &mut Vec<u16>) -> binder::public_api::Result<Vec<u16>>;
+  fn ReverseInt(&self, _arg_input: &[i32], _arg_repeated: &mut Vec<i32>) -> binder::public_api::Result<Vec<i32>>;
+  fn ReverseLong(&self, _arg_input: &[i64], _arg_repeated: &mut Vec<i64>) -> binder::public_api::Result<Vec<i64>>;
+  fn ReverseFloat(&self, _arg_input: &[f32], _arg_repeated: &mut Vec<f32>) -> binder::public_api::Result<Vec<f32>>;
+  fn ReverseDouble(&self, _arg_input: &[f64], _arg_repeated: &mut Vec<f64>) -> binder::public_api::Result<Vec<f64>>;
+  fn ReverseString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>>;
+  fn ReverseByteEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>>;
+  fn ReverseIntEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>>;
+  fn ReverseLongEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>>;
+  fn GetOtherTestService(&self, _arg_name: &str) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>;
+  fn VerifyName(&self, _arg_service: &dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback, _arg_name: &str) -> binder::public_api::Result<bool>;
+  fn ReverseStringList(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>>;
+  fn RepeatParcelFileDescriptor(&self, _arg_read: &binder::parcel::ParcelFileDescriptor) -> binder::public_api::Result<binder::parcel::ParcelFileDescriptor>;
+  fn ReverseParcelFileDescriptorArray(&self, _arg_input: &[binder::parcel::ParcelFileDescriptor], _arg_repeated: &mut Vec<Option<binder::parcel::ParcelFileDescriptor>>) -> binder::public_api::Result<Vec<binder::parcel::ParcelFileDescriptor>>;
+  fn ThrowServiceException(&self, _arg_code: i32) -> binder::public_api::Result<()>;
+  fn RepeatNullableIntArray(&self, _arg_input: Option<&[i32]>) -> binder::public_api::Result<Option<Vec<i32>>>;
+  fn RepeatNullableByteEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>>>;
+  fn RepeatNullableIntEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>>>;
+  fn RepeatNullableLongEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>>>;
+  fn RepeatNullableString(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>>;
+  fn RepeatNullableStringList(&self, _arg_input: Option<&[Option<String>]>) -> binder::public_api::Result<Option<Vec<Option<String>>>>;
+  fn RepeatNullableParcelable(&self, _arg_input: Option<&crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>) -> binder::public_api::Result<Option<crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>>;
+  fn TakesAnIBinder(&self, _arg_input: &binder::SpIBinder) -> binder::public_api::Result<()>;
+  fn TakesANullableIBinder(&self, _arg_input: Option<&binder::SpIBinder>) -> binder::public_api::Result<()>;
+  fn RepeatUtf8CppString(&self, _arg_token: &str) -> binder::public_api::Result<String>;
+  fn RepeatNullableUtf8CppString(&self, _arg_token: Option<&str>) -> binder::public_api::Result<Option<String>>;
+  fn ReverseUtf8CppString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>>;
+  fn ReverseNullableUtf8CppString(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>>;
+  fn ReverseUtf8CppStringList(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>>;
+  fn GetCallback(&self, _arg_return_null: bool) -> binder::public_api::Result<Option<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>>;
+  fn FillOutStructuredParcelable(&self, _arg_parcel: &mut crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable) -> binder::public_api::Result<()>;
+  fn GetOldNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
+  fn GetNewNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>;
+  fn GetCppJavaTests(&self) -> binder::public_api::Result<Option<binder::SpIBinder>>;
+  fn getBackendType(&self) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>;
+  fn getDefaultImpl() -> ITestServiceDefaultRef where Self: Sized {
+    DEFAULT_IMPL.lock().unwrap().clone()
+  }
+  fn setDefaultImpl(d: ITestServiceDefaultRef) -> ITestServiceDefaultRef where Self: Sized {
+    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+  }
+}
+pub trait ITestServiceDefault: Send + Sync {
+  fn UnimplementedMethod(&self, _arg_arg: i32) -> binder::public_api::Result<i32> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn TestOneway(&self) -> binder::public_api::Result<()> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatBoolean(&self, _arg_token: bool) -> binder::public_api::Result<bool> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatByte(&self, _arg_token: i8) -> binder::public_api::Result<i8> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatChar(&self, _arg_token: u16) -> binder::public_api::Result<u16> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatInt(&self, _arg_token: i32) -> binder::public_api::Result<i32> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatLong(&self, _arg_token: i64) -> binder::public_api::Result<i64> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatFloat(&self, _arg_token: f32) -> binder::public_api::Result<f32> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatDouble(&self, _arg_token: f64) -> binder::public_api::Result<f64> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatString(&self, _arg_token: &str) -> binder::public_api::Result<String> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatByteEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatIntEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatLongEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseBoolean(&self, _arg_input: &[bool], _arg_repeated: &mut Vec<bool>) -> binder::public_api::Result<Vec<bool>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseByte(&self, _arg_input: &[u8], _arg_repeated: &mut Vec<u8>) -> binder::public_api::Result<Vec<u8>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseChar(&self, _arg_input: &[u16], _arg_repeated: &mut Vec<u16>) -> binder::public_api::Result<Vec<u16>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseInt(&self, _arg_input: &[i32], _arg_repeated: &mut Vec<i32>) -> binder::public_api::Result<Vec<i32>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseLong(&self, _arg_input: &[i64], _arg_repeated: &mut Vec<i64>) -> binder::public_api::Result<Vec<i64>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseFloat(&self, _arg_input: &[f32], _arg_repeated: &mut Vec<f32>) -> binder::public_api::Result<Vec<f32>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseDouble(&self, _arg_input: &[f64], _arg_repeated: &mut Vec<f64>) -> binder::public_api::Result<Vec<f64>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseByteEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseIntEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseLongEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn GetOtherTestService(&self, _arg_name: &str) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn VerifyName(&self, _arg_service: &dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback, _arg_name: &str) -> binder::public_api::Result<bool> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseStringList(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatParcelFileDescriptor(&self, _arg_read: &binder::parcel::ParcelFileDescriptor) -> binder::public_api::Result<binder::parcel::ParcelFileDescriptor> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseParcelFileDescriptorArray(&self, _arg_input: &[binder::parcel::ParcelFileDescriptor], _arg_repeated: &mut Vec<Option<binder::parcel::ParcelFileDescriptor>>) -> binder::public_api::Result<Vec<binder::parcel::ParcelFileDescriptor>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ThrowServiceException(&self, _arg_code: i32) -> binder::public_api::Result<()> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableIntArray(&self, _arg_input: Option<&[i32]>) -> binder::public_api::Result<Option<Vec<i32>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableByteEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableIntEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableLongEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableString(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableStringList(&self, _arg_input: Option<&[Option<String>]>) -> binder::public_api::Result<Option<Vec<Option<String>>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableParcelable(&self, _arg_input: Option<&crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>) -> binder::public_api::Result<Option<crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn TakesAnIBinder(&self, _arg_input: &binder::SpIBinder) -> binder::public_api::Result<()> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn TakesANullableIBinder(&self, _arg_input: Option<&binder::SpIBinder>) -> binder::public_api::Result<()> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatUtf8CppString(&self, _arg_token: &str) -> binder::public_api::Result<String> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn RepeatNullableUtf8CppString(&self, _arg_token: Option<&str>) -> binder::public_api::Result<Option<String>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseUtf8CppString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseNullableUtf8CppString(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn ReverseUtf8CppStringList(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn GetCallback(&self, _arg_return_null: bool) -> binder::public_api::Result<Option<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn FillOutStructuredParcelable(&self, _arg_parcel: &mut crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable) -> binder::public_api::Result<()> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn GetOldNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn GetNewNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn GetCppJavaTests(&self) -> binder::public_api::Result<Option<binder::SpIBinder>> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+  fn getBackendType(&self) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType> {
+    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+  }
+}
+pub mod transactions {
+  #[allow(unused_imports)] use binder::IBinder;
+  pub const UnimplementedMethod: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+  pub const TestOneway: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
+  pub const RepeatBoolean: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
+  pub const RepeatByte: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
+  pub const RepeatChar: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 4;
+  pub const RepeatInt: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 5;
+  pub const RepeatLong: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 6;
+  pub const RepeatFloat: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 7;
+  pub const RepeatDouble: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 8;
+  pub const RepeatString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 9;
+  pub const RepeatByteEnum: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 10;
+  pub const RepeatIntEnum: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 11;
+  pub const RepeatLongEnum: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 12;
+  pub const ReverseBoolean: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 13;
+  pub const ReverseByte: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 14;
+  pub const ReverseChar: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 15;
+  pub const ReverseInt: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16;
+  pub const ReverseLong: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 17;
+  pub const ReverseFloat: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 18;
+  pub const ReverseDouble: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 19;
+  pub const ReverseString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 20;
+  pub const ReverseByteEnum: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 21;
+  pub const ReverseIntEnum: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 22;
+  pub const ReverseLongEnum: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 23;
+  pub const GetOtherTestService: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 24;
+  pub const VerifyName: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 25;
+  pub const ReverseStringList: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 26;
+  pub const RepeatParcelFileDescriptor: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 27;
+  pub const ReverseParcelFileDescriptorArray: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 28;
+  pub const ThrowServiceException: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 29;
+  pub const RepeatNullableIntArray: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 30;
+  pub const RepeatNullableByteEnumArray: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 31;
+  pub const RepeatNullableIntEnumArray: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 32;
+  pub const RepeatNullableLongEnumArray: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 33;
+  pub const RepeatNullableString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 34;
+  pub const RepeatNullableStringList: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 35;
+  pub const RepeatNullableParcelable: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 36;
+  pub const TakesAnIBinder: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 37;
+  pub const TakesANullableIBinder: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 38;
+  pub const RepeatUtf8CppString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 39;
+  pub const RepeatNullableUtf8CppString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 40;
+  pub const ReverseUtf8CppString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 41;
+  pub const ReverseNullableUtf8CppString: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 42;
+  pub const ReverseUtf8CppStringList: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 43;
+  pub const GetCallback: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 44;
+  pub const FillOutStructuredParcelable: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 45;
+  pub const GetOldNameInterface: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 46;
+  pub const GetNewNameInterface: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 47;
+  pub const GetCppJavaTests: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 48;
+  pub const getBackendType: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 49;
+}
+pub type ITestServiceDefaultRef = Option<std::sync::Arc<dyn ITestServiceDefault>>;
+use lazy_static::lazy_static;
+lazy_static! {
+  static ref DEFAULT_IMPL: std::sync::Mutex<ITestServiceDefaultRef> = std::sync::Mutex::new(None);
+}
+pub const TEST_CONSTANT: i32 = 42;
+pub const TEST_CONSTANT2: i32 = -42;
+pub const TEST_CONSTANT3: i32 = 42;
+pub const TEST_CONSTANT4: i32 = 4;
+pub const TEST_CONSTANT5: i32 = -4;
+pub const TEST_CONSTANT6: i32 = 0;
+pub const TEST_CONSTANT7: i32 = 0;
+pub const TEST_CONSTANT8: i32 = 0;
+pub const TEST_CONSTANT9: i32 = 86;
+pub const TEST_CONSTANT10: i32 = 165;
+pub const TEST_CONSTANT11: i32 = 250;
+pub const TEST_CONSTANT12: i32 = -1;
+pub const BYTE_TEST_CONSTANT: i8 = 17;
+pub const LONG_TEST_CONSTANT: i64 = 1099511627776;
+pub const STRING_TEST_CONSTANT: &str = "foo";
+pub const STRING_TEST_CONSTANT2: &str = "bar";
+pub const STRING_TEST_CONSTANT_UTF8: &str = "baz";
+pub const A1: i32 = 1;
+pub const A2: i32 = 1;
+pub const A3: i32 = 1;
+pub const A4: i32 = 1;
+pub const A5: i32 = 1;
+pub const A6: i32 = 1;
+pub const A7: i32 = 1;
+pub const A8: i32 = 1;
+pub const A9: i32 = 1;
+pub const A10: i32 = 1;
+pub const A11: i32 = 1;
+pub const A12: i32 = 1;
+pub const A13: i32 = 1;
+pub const A14: i32 = 1;
+pub const A15: i32 = 1;
+pub const A16: i32 = 1;
+pub const A17: i32 = 1;
+pub const A18: i32 = 1;
+pub const A19: i32 = 1;
+pub const A20: i32 = 1;
+pub const A21: i32 = 1;
+pub const A22: i32 = 1;
+pub const A23: i32 = 1;
+pub const A24: i32 = 1;
+pub const A25: i32 = 1;
+pub const A26: i32 = 1;
+pub const A27: i32 = 1;
+pub const A28: i32 = 1;
+pub const A29: i32 = 1;
+pub const A30: i32 = 1;
+pub const A31: i32 = 1;
+pub const A32: i32 = 1;
+pub const A33: i32 = 1;
+pub const A34: i32 = 1;
+pub const A35: i32 = 1;
+pub const A36: i32 = 1;
+pub const A37: i32 = 1;
+pub const A38: i32 = 1;
+pub const A39: i32 = 1;
+pub const A40: i32 = 1;
+pub const A41: i32 = 1;
+pub const A42: i32 = 1;
+pub const A43: i32 = 1;
+pub const A44: i32 = 1;
+pub const A45: i32 = 1;
+pub const A46: i32 = 1;
+pub const A47: i32 = 1;
+pub const A48: i32 = 1;
+pub const A49: i32 = 1;
+pub const A50: i32 = 1;
+pub const A51: i32 = 1;
+pub const A52: i32 = 1;
+pub const A53: i32 = 1;
+pub const A54: i32 = 1;
+pub const A55: i32 = 1;
+pub const A56: i32 = 1;
+pub const A57: i32 = 1;
+pub(crate) mod mangled { pub use super::ITestService as _7_android_4_aidl_5_tests_12_ITestService; }
+impl ITestService for BpTestService {
+  fn UnimplementedMethod(&self, _arg_arg: i32) -> binder::public_api::Result<i32> {
+    let _aidl_reply = self.binder.transact(transactions::UnimplementedMethod, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_arg)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.UnimplementedMethod(_arg_arg);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: i32 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn TestOneway(&self) -> binder::public_api::Result<()> {
+    let _aidl_reply = self.binder.transact(transactions::TestOneway, binder::SpIBinder::FLAG_ONEWAY | binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.TestOneway();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    Ok(())
+  }
+  fn RepeatBoolean(&self, _arg_token: bool) -> binder::public_api::Result<bool> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatBoolean, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatBoolean(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: bool = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatByte(&self, _arg_token: i8) -> binder::public_api::Result<i8> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatByte, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatByte(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: i8 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatChar(&self, _arg_token: u16) -> binder::public_api::Result<u16> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatChar, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatChar(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: u16 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatInt(&self, _arg_token: i32) -> binder::public_api::Result<i32> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatInt, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatInt(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: i32 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatLong(&self, _arg_token: i64) -> binder::public_api::Result<i64> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatLong, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatLong(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: i64 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatFloat(&self, _arg_token: f32) -> binder::public_api::Result<f32> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatFloat, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatFloat(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: f32 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatDouble(&self, _arg_token: f64) -> binder::public_api::Result<f64> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatDouble, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatDouble(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: f64 = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatString(&self, _arg_token: &str) -> binder::public_api::Result<String> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatString(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: String = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatByteEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatByteEnum, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatByteEnum(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatIntEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatIntEnum, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatIntEnum(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatLongEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatLongEnum, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatLongEnum(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseBoolean(&self, _arg_input: &[bool], _arg_repeated: &mut Vec<bool>) -> binder::public_api::Result<Vec<bool>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseBoolean, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseBoolean(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<bool> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseByte(&self, _arg_input: &[u8], _arg_repeated: &mut Vec<u8>) -> binder::public_api::Result<Vec<u8>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseByte, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseByte(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<u8> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseChar(&self, _arg_input: &[u16], _arg_repeated: &mut Vec<u16>) -> binder::public_api::Result<Vec<u16>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseChar, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseChar(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<u16> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseInt(&self, _arg_input: &[i32], _arg_repeated: &mut Vec<i32>) -> binder::public_api::Result<Vec<i32>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseInt, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseInt(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<i32> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseLong(&self, _arg_input: &[i64], _arg_repeated: &mut Vec<i64>) -> binder::public_api::Result<Vec<i64>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseLong, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseLong(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<i64> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseFloat(&self, _arg_input: &[f32], _arg_repeated: &mut Vec<f32>) -> binder::public_api::Result<Vec<f32>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseFloat, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseFloat(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<f32> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseDouble(&self, _arg_input: &[f64], _arg_repeated: &mut Vec<f64>) -> binder::public_api::Result<Vec<f64>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseDouble, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseDouble(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<f64> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseString(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<String> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseByteEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseByteEnum, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseByteEnum(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseIntEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseIntEnum, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseIntEnum(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseLongEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseLongEnum, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseLongEnum(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn GetOtherTestService(&self, _arg_name: &str) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> {
+    let _aidl_reply = self.binder.transact(transactions::GetOtherTestService, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_name)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.GetOtherTestService(_arg_name);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn VerifyName(&self, _arg_service: &dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback, _arg_name: &str) -> binder::public_api::Result<bool> {
+    let _aidl_reply = self.binder.transact(transactions::VerifyName, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_service)?;
+      _aidl_data.write(_arg_name)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.VerifyName(_arg_service, _arg_name);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: bool = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseStringList(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseStringList, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseStringList(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<String> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatParcelFileDescriptor(&self, _arg_read: &binder::parcel::ParcelFileDescriptor) -> binder::public_api::Result<binder::parcel::ParcelFileDescriptor> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatParcelFileDescriptor, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_read)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatParcelFileDescriptor(_arg_read);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: binder::parcel::ParcelFileDescriptor = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseParcelFileDescriptorArray(&self, _arg_input: &[binder::parcel::ParcelFileDescriptor], _arg_repeated: &mut Vec<Option<binder::parcel::ParcelFileDescriptor>>) -> binder::public_api::Result<Vec<binder::parcel::ParcelFileDescriptor>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseParcelFileDescriptorArray, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseParcelFileDescriptorArray(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<binder::parcel::ParcelFileDescriptor> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ThrowServiceException(&self, _arg_code: i32) -> binder::public_api::Result<()> {
+    let _aidl_reply = self.binder.transact(transactions::ThrowServiceException, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_code)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ThrowServiceException(_arg_code);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    Ok(())
+  }
+  fn RepeatNullableIntArray(&self, _arg_input: Option<&[i32]>) -> binder::public_api::Result<Option<Vec<i32>>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableIntArray, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableIntArray(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<i32>> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableByteEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableByteEnumArray, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableByteEnumArray(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableIntEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableIntEnumArray, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableIntEnumArray(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableLongEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableLongEnumArray, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableLongEnumArray(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableString(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableString(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<String> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableStringList(&self, _arg_input: Option<&[Option<String>]>) -> binder::public_api::Result<Option<Vec<Option<String>>>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableStringList, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableStringList(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<Option<String>>> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableParcelable(&self, _arg_input: Option<&crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>) -> binder::public_api::Result<Option<crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableParcelable, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableParcelable(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn TakesAnIBinder(&self, _arg_input: &binder::SpIBinder) -> binder::public_api::Result<()> {
+    let _aidl_reply = self.binder.transact(transactions::TakesAnIBinder, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.TakesAnIBinder(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    Ok(())
+  }
+  fn TakesANullableIBinder(&self, _arg_input: Option<&binder::SpIBinder>) -> binder::public_api::Result<()> {
+    let _aidl_reply = self.binder.transact(transactions::TakesANullableIBinder, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.TakesANullableIBinder(_arg_input);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    Ok(())
+  }
+  fn RepeatUtf8CppString(&self, _arg_token: &str) -> binder::public_api::Result<String> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatUtf8CppString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatUtf8CppString(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: String = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn RepeatNullableUtf8CppString(&self, _arg_token: Option<&str>) -> binder::public_api::Result<Option<String>> {
+    let _aidl_reply = self.binder.transact(transactions::RepeatNullableUtf8CppString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_token)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.RepeatNullableUtf8CppString(_arg_token);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<String> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseUtf8CppString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseUtf8CppString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_input)?;
+      _aidl_data.write_slice_size(Some(_arg_repeated))?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseUtf8CppString(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Vec<String> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseNullableUtf8CppString(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseNullableUtf8CppString, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      _aidl_data.write_slice_size(_arg_repeated.as_deref())?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseNullableUtf8CppString(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<Option<String>>> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn ReverseUtf8CppStringList(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>> {
+    let _aidl_reply = self.binder.transact(transactions::ReverseUtf8CppStringList, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_input)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.ReverseUtf8CppStringList(_arg_input, _arg_repeated);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Vec<Option<String>>> = _aidl_reply.read()?;
+    *_arg_repeated = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn GetCallback(&self, _arg_return_null: bool) -> binder::public_api::Result<Option<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>> {
+    let _aidl_reply = self.binder.transact(transactions::GetCallback, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(&_arg_return_null)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.GetCallback(_arg_return_null);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn FillOutStructuredParcelable(&self, _arg_parcel: &mut crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable) -> binder::public_api::Result<()> {
+    let _aidl_reply = self.binder.transact(transactions::FillOutStructuredParcelable, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      _aidl_data.write(_arg_parcel)?;
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.FillOutStructuredParcelable(_arg_parcel);
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    *_arg_parcel = _aidl_reply.read()?;
+    Ok(())
+  }
+  fn GetOldNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> {
+    let _aidl_reply = self.binder.transact(transactions::GetOldNameInterface, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.GetOldNameInterface();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn GetNewNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
+    let _aidl_reply = self.binder.transact(transactions::GetNewNameInterface, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.GetNewNameInterface();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn GetCppJavaTests(&self) -> binder::public_api::Result<Option<binder::SpIBinder>> {
+    let _aidl_reply = self.binder.transact(transactions::GetCppJavaTests, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.GetCppJavaTests();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: Option<binder::SpIBinder> = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+  fn getBackendType(&self) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType> {
+    let _aidl_reply = self.binder.transact(transactions::getBackendType, binder::SpIBinder::FLAG_CLEAR_BUF, |_aidl_data| {
+      _aidl_data.mark_sensitive();
+      Ok(())
+    });
+    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+        return _aidl_default_impl.getBackendType();
+      }
+    }
+    let _aidl_reply = _aidl_reply?;
+    let _aidl_status: binder::Status = _aidl_reply.read()?;
+    if !_aidl_status.is_ok() { return Err(_aidl_status); }
+    let _aidl_return: crate::mangled::_7_android_4_aidl_5_tests_11_BackendType = _aidl_reply.read()?;
+    Ok(_aidl_return)
+  }
+}
+impl ITestService for binder::Binder<BnTestService> {
+  fn UnimplementedMethod(&self, _arg_arg: i32) -> binder::public_api::Result<i32> { self.0.UnimplementedMethod(_arg_arg) }
+  fn TestOneway(&self) -> binder::public_api::Result<()> { self.0.TestOneway() }
+  fn RepeatBoolean(&self, _arg_token: bool) -> binder::public_api::Result<bool> { self.0.RepeatBoolean(_arg_token) }
+  fn RepeatByte(&self, _arg_token: i8) -> binder::public_api::Result<i8> { self.0.RepeatByte(_arg_token) }
+  fn RepeatChar(&self, _arg_token: u16) -> binder::public_api::Result<u16> { self.0.RepeatChar(_arg_token) }
+  fn RepeatInt(&self, _arg_token: i32) -> binder::public_api::Result<i32> { self.0.RepeatInt(_arg_token) }
+  fn RepeatLong(&self, _arg_token: i64) -> binder::public_api::Result<i64> { self.0.RepeatLong(_arg_token) }
+  fn RepeatFloat(&self, _arg_token: f32) -> binder::public_api::Result<f32> { self.0.RepeatFloat(_arg_token) }
+  fn RepeatDouble(&self, _arg_token: f64) -> binder::public_api::Result<f64> { self.0.RepeatDouble(_arg_token) }
+  fn RepeatString(&self, _arg_token: &str) -> binder::public_api::Result<String> { self.0.RepeatString(_arg_token) }
+  fn RepeatByteEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum> { self.0.RepeatByteEnum(_arg_token) }
+  fn RepeatIntEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum> { self.0.RepeatIntEnum(_arg_token) }
+  fn RepeatLongEnum(&self, _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum> { self.0.RepeatLongEnum(_arg_token) }
+  fn ReverseBoolean(&self, _arg_input: &[bool], _arg_repeated: &mut Vec<bool>) -> binder::public_api::Result<Vec<bool>> { self.0.ReverseBoolean(_arg_input, _arg_repeated) }
+  fn ReverseByte(&self, _arg_input: &[u8], _arg_repeated: &mut Vec<u8>) -> binder::public_api::Result<Vec<u8>> { self.0.ReverseByte(_arg_input, _arg_repeated) }
+  fn ReverseChar(&self, _arg_input: &[u16], _arg_repeated: &mut Vec<u16>) -> binder::public_api::Result<Vec<u16>> { self.0.ReverseChar(_arg_input, _arg_repeated) }
+  fn ReverseInt(&self, _arg_input: &[i32], _arg_repeated: &mut Vec<i32>) -> binder::public_api::Result<Vec<i32>> { self.0.ReverseInt(_arg_input, _arg_repeated) }
+  fn ReverseLong(&self, _arg_input: &[i64], _arg_repeated: &mut Vec<i64>) -> binder::public_api::Result<Vec<i64>> { self.0.ReverseLong(_arg_input, _arg_repeated) }
+  fn ReverseFloat(&self, _arg_input: &[f32], _arg_repeated: &mut Vec<f32>) -> binder::public_api::Result<Vec<f32>> { self.0.ReverseFloat(_arg_input, _arg_repeated) }
+  fn ReverseDouble(&self, _arg_input: &[f64], _arg_repeated: &mut Vec<f64>) -> binder::public_api::Result<Vec<f64>> { self.0.ReverseDouble(_arg_input, _arg_repeated) }
+  fn ReverseString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> { self.0.ReverseString(_arg_input, _arg_repeated) }
+  fn ReverseByteEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>> { self.0.ReverseByteEnum(_arg_input, _arg_repeated) }
+  fn ReverseIntEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>> { self.0.ReverseIntEnum(_arg_input, _arg_repeated) }
+  fn ReverseLongEnum(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum], _arg_repeated: &mut Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>) -> binder::public_api::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>> { self.0.ReverseLongEnum(_arg_input, _arg_repeated) }
+  fn GetOtherTestService(&self, _arg_name: &str) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> { self.0.GetOtherTestService(_arg_name) }
+  fn VerifyName(&self, _arg_service: &dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback, _arg_name: &str) -> binder::public_api::Result<bool> { self.0.VerifyName(_arg_service, _arg_name) }
+  fn ReverseStringList(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> { self.0.ReverseStringList(_arg_input, _arg_repeated) }
+  fn RepeatParcelFileDescriptor(&self, _arg_read: &binder::parcel::ParcelFileDescriptor) -> binder::public_api::Result<binder::parcel::ParcelFileDescriptor> { self.0.RepeatParcelFileDescriptor(_arg_read) }
+  fn ReverseParcelFileDescriptorArray(&self, _arg_input: &[binder::parcel::ParcelFileDescriptor], _arg_repeated: &mut Vec<Option<binder::parcel::ParcelFileDescriptor>>) -> binder::public_api::Result<Vec<binder::parcel::ParcelFileDescriptor>> { self.0.ReverseParcelFileDescriptorArray(_arg_input, _arg_repeated) }
+  fn ThrowServiceException(&self, _arg_code: i32) -> binder::public_api::Result<()> { self.0.ThrowServiceException(_arg_code) }
+  fn RepeatNullableIntArray(&self, _arg_input: Option<&[i32]>) -> binder::public_api::Result<Option<Vec<i32>>> { self.0.RepeatNullableIntArray(_arg_input) }
+  fn RepeatNullableByteEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>>> { self.0.RepeatNullableByteEnumArray(_arg_input) }
+  fn RepeatNullableIntEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>>> { self.0.RepeatNullableIntEnumArray(_arg_input) }
+  fn RepeatNullableLongEnumArray(&self, _arg_input: Option<&[crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum]>) -> binder::public_api::Result<Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>>> { self.0.RepeatNullableLongEnumArray(_arg_input) }
+  fn RepeatNullableString(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> { self.0.RepeatNullableString(_arg_input) }
+  fn RepeatNullableStringList(&self, _arg_input: Option<&[Option<String>]>) -> binder::public_api::Result<Option<Vec<Option<String>>>> { self.0.RepeatNullableStringList(_arg_input) }
+  fn RepeatNullableParcelable(&self, _arg_input: Option<&crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>) -> binder::public_api::Result<Option<crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable>> { self.0.RepeatNullableParcelable(_arg_input) }
+  fn TakesAnIBinder(&self, _arg_input: &binder::SpIBinder) -> binder::public_api::Result<()> { self.0.TakesAnIBinder(_arg_input) }
+  fn TakesANullableIBinder(&self, _arg_input: Option<&binder::SpIBinder>) -> binder::public_api::Result<()> { self.0.TakesANullableIBinder(_arg_input) }
+  fn RepeatUtf8CppString(&self, _arg_token: &str) -> binder::public_api::Result<String> { self.0.RepeatUtf8CppString(_arg_token) }
+  fn RepeatNullableUtf8CppString(&self, _arg_token: Option<&str>) -> binder::public_api::Result<Option<String>> { self.0.RepeatNullableUtf8CppString(_arg_token) }
+  fn ReverseUtf8CppString(&self, _arg_input: &[String], _arg_repeated: &mut Vec<String>) -> binder::public_api::Result<Vec<String>> { self.0.ReverseUtf8CppString(_arg_input, _arg_repeated) }
+  fn ReverseNullableUtf8CppString(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>> { self.0.ReverseNullableUtf8CppString(_arg_input, _arg_repeated) }
+  fn ReverseUtf8CppStringList(&self, _arg_input: Option<&[Option<String>]>, _arg_repeated: &mut Option<Vec<Option<String>>>) -> binder::public_api::Result<Option<Vec<Option<String>>>> { self.0.ReverseUtf8CppStringList(_arg_input, _arg_repeated) }
+  fn GetCallback(&self, _arg_return_null: bool) -> binder::public_api::Result<Option<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>> { self.0.GetCallback(_arg_return_null) }
+  fn FillOutStructuredParcelable(&self, _arg_parcel: &mut crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable) -> binder::public_api::Result<()> { self.0.FillOutStructuredParcelable(_arg_parcel) }
+  fn GetOldNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> { self.0.GetOldNameInterface() }
+  fn GetNewNameInterface(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> { self.0.GetNewNameInterface() }
+  fn GetCppJavaTests(&self) -> binder::public_api::Result<Option<binder::SpIBinder>> { self.0.GetCppJavaTests() }
+  fn getBackendType(&self) -> binder::public_api::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType> { self.0.getBackendType() }
+}
+fn on_transact(_aidl_service: &dyn ITestService, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+  match _aidl_code {
+    transactions::UnimplementedMethod => {
+      let _arg_arg: i32 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.UnimplementedMethod(_arg_arg);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::TestOneway => {
+      let _aidl_return = _aidl_service.TestOneway();
+      Ok(())
+    }
+    transactions::RepeatBoolean => {
+      let _arg_token: bool = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatBoolean(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatByte => {
+      let _arg_token: i8 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatByte(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatChar => {
+      let _arg_token: u16 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatChar(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatInt => {
+      let _arg_token: i32 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatInt(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatLong => {
+      let _arg_token: i64 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatLong(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatFloat => {
+      let _arg_token: f32 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatFloat(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatDouble => {
+      let _arg_token: f64 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatDouble(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatString => {
+      let _arg_token: String = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatString(&_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatByteEnum => {
+      let _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatByteEnum(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatIntEnum => {
+      let _arg_token: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatIntEnum(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatLongEnum => {
+      let _arg_token: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatLongEnum(_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseBoolean => {
+      let _arg_input: Vec<bool> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<bool> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseBoolean(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseByte => {
+      let _arg_input: Vec<u8> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<u8> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseByte(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseChar => {
+      let _arg_input: Vec<u16> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<u16> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseChar(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseInt => {
+      let _arg_input: Vec<i32> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<i32> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseInt(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseLong => {
+      let _arg_input: Vec<i64> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<i64> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseLong(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseFloat => {
+      let _arg_input: Vec<f32> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<f32> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseFloat(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseDouble => {
+      let _arg_input: Vec<f64> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<f64> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseDouble(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseString => {
+      let _arg_input: Vec<String> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<String> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseString(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseByteEnum => {
+      let _arg_input: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseByteEnum(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseIntEnum => {
+      let _arg_input: Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseIntEnum(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseLongEnum => {
+      let _arg_input: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseLongEnum(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::GetOtherTestService => {
+      let _arg_name: String = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.GetOtherTestService(&_arg_name);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::VerifyName => {
+      let _arg_service: Box<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback> = _aidl_data.read()?;
+      let _arg_name: String = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.VerifyName(&*_arg_service, &_arg_name);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseStringList => {
+      let _arg_input: Vec<String> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<String> = Default::default();
+      let _aidl_return = _aidl_service.ReverseStringList(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatParcelFileDescriptor => {
+      let _arg_read: binder::parcel::ParcelFileDescriptor = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatParcelFileDescriptor(&_arg_read);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseParcelFileDescriptorArray => {
+      let _arg_input: Vec<binder::parcel::ParcelFileDescriptor> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<Option<binder::parcel::ParcelFileDescriptor>> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseParcelFileDescriptorArray(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          if _arg_repeated.iter().any(Option::is_none) { return Err(binder::StatusCode::UNEXPECTED_NULL); }
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ThrowServiceException => {
+      let _arg_code: i32 = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.ThrowServiceException(_arg_code);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableIntArray => {
+      let _arg_input: Option<Vec<i32>> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableIntArray(_arg_input.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableByteEnumArray => {
+      let _arg_input: Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableByteEnumArray(_arg_input.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableIntEnumArray => {
+      let _arg_input: Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableIntEnumArray(_arg_input.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableLongEnumArray => {
+      let _arg_input: Option<Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableLongEnumArray(_arg_input.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableString => {
+      let _arg_input: Option<String> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableString(_arg_input.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableStringList => {
+      let _arg_input: Option<Vec<Option<String>>> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableStringList(_arg_input.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableParcelable => {
+      let _arg_input: Option<crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableParcelable(_arg_input.as_ref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::TakesAnIBinder => {
+      let _arg_input: binder::SpIBinder = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.TakesAnIBinder(&_arg_input);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::TakesANullableIBinder => {
+      let _arg_input: Option<binder::SpIBinder> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.TakesANullableIBinder(_arg_input.as_ref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatUtf8CppString => {
+      let _arg_token: String = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatUtf8CppString(&_arg_token);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::RepeatNullableUtf8CppString => {
+      let _arg_token: Option<String> = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.RepeatNullableUtf8CppString(_arg_token.as_deref());
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseUtf8CppString => {
+      let _arg_input: Vec<String> = _aidl_data.read()?;
+      let mut _arg_repeated: Vec<String> = Default::default();
+      _aidl_data.resize_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseUtf8CppString(&_arg_input, &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseNullableUtf8CppString => {
+      let _arg_input: Option<Vec<Option<String>>> = _aidl_data.read()?;
+      let mut _arg_repeated: Option<Vec<Option<String>>> = Default::default();
+      _aidl_data.resize_nullable_out_vec(&mut _arg_repeated)?;
+      let _aidl_return = _aidl_service.ReverseNullableUtf8CppString(_arg_input.as_deref(), &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::ReverseUtf8CppStringList => {
+      let _arg_input: Option<Vec<Option<String>>> = _aidl_data.read()?;
+      let mut _arg_repeated: Option<Vec<Option<String>>> = Default::default();
+      let _aidl_return = _aidl_service.ReverseUtf8CppStringList(_arg_input.as_deref(), &mut _arg_repeated);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+          _aidl_reply.write(&_arg_repeated)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::GetCallback => {
+      let _arg_return_null: bool = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.GetCallback(_arg_return_null);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::FillOutStructuredParcelable => {
+      let mut _arg_parcel: crate::mangled::_7_android_4_aidl_5_tests_20_StructuredParcelable = _aidl_data.read()?;
+      let _aidl_return = _aidl_service.FillOutStructuredParcelable(&mut _arg_parcel);
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(&_arg_parcel)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::GetOldNameInterface => {
+      let _aidl_return = _aidl_service.GetOldNameInterface();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::GetNewNameInterface => {
+      let _aidl_return = _aidl_service.GetNewNameInterface();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::GetCppJavaTests => {
+      let _aidl_return = _aidl_service.GetCppJavaTests();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    transactions::getBackendType => {
+      let _aidl_return = _aidl_service.getBackendType();
+      match &_aidl_return {
+        Ok(_aidl_return) => {
+          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+          _aidl_reply.write(_aidl_return)?;
+        }
+        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+      }
+      Ok(())
+    }
+    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d
new file mode 100644
index 0000000..59f4705
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d
@@ -0,0 +1,10 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs : \
+  system/tools/aidl/tests/android/aidl/tests/ITestService.aidl \
+  system/tools/aidl/tests/android/aidl/tests/BackendType.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INamedCallback.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IOldName.aidl \
+  system/tools/aidl/tests/android/aidl/tests/INewName.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs
new file mode 100644
index 0000000..ff9c6a9
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs
@@ -0,0 +1,8 @@
+#![allow(non_upper_case_globals)]
+use binder::declare_binder_enum;
+declare_binder_enum! { IntEnum : i32 {
+  FOO = 1000,
+  BAR = 2000,
+  BAZ = 2001,
+} }
+pub(crate) mod mangled { pub use super::IntEnum as _7_android_4_aidl_5_tests_7_IntEnum; }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs.d
new file mode 100644
index 0000000..f90d6ac
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/IntEnum.rs : \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs
new file mode 100644
index 0000000..548b711
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs
@@ -0,0 +1,8 @@
+#![allow(non_upper_case_globals)]
+use binder::declare_binder_enum;
+declare_binder_enum! { LongEnum : i64 {
+  FOO = 100000000000,
+  BAR = 200000000000,
+  BAZ = 200000000001,
+} }
+pub(crate) mod mangled { pub use super::LongEnum as _7_android_4_aidl_5_tests_8_LongEnum; }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs.d
new file mode 100644
index 0000000..41f9bc3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/LongEnum.rs : \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs
new file mode 100644
index 0000000..d6e9016
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs
@@ -0,0 +1,55 @@
+#[derive(Debug)]
+pub struct OtherParcelableForToString {
+  pub field: String,
+}
+pub(crate) mod mangled { pub use super::OtherParcelableForToString as _7_android_4_aidl_5_tests_26_OtherParcelableForToString; }
+impl Default for OtherParcelableForToString {
+  fn default() -> Self {
+    Self {
+      field: Default::default(),
+    }
+  }
+}
+impl binder::parcel::Serialize for OtherParcelableForToString {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for OtherParcelableForToString {}
+impl binder::parcel::SerializeOption for OtherParcelableForToString {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    parcel.sized_write(|subparcel| {
+      subparcel.write(&this.field)?;
+      Ok(())
+    })
+  }
+}
+impl binder::parcel::Deserialize for OtherParcelableForToString {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for OtherParcelableForToString {}
+impl binder::parcel::DeserializeOption for OtherParcelableForToString {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let start_pos = parcel.get_data_position();
+    let parcelable_size: i32 = parcel.read()?;
+    if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+    let mut result = Self::default();
+    result.field = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    Ok(Some(result))
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs.d
new file mode 100644
index 0000000..cc95ae1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs : \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs
new file mode 100644
index 0000000..67ae728
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs
@@ -0,0 +1,209 @@
+#[derive(Debug)]
+pub struct ParcelableForToString {
+  pub intValue: i32,
+  pub intArray: Vec<i32>,
+  pub longValue: i64,
+  pub longArray: Vec<i64>,
+  pub doubleValue: f64,
+  pub doubleArray: Vec<f64>,
+  pub floatValue: f32,
+  pub floatArray: Vec<f32>,
+  pub byteValue: i8,
+  pub byteArray: Vec<u8>,
+  pub booleanValue: bool,
+  pub booleanArray: Vec<bool>,
+  pub stringValue: String,
+  pub stringArray: Vec<String>,
+  pub stringList: Vec<String>,
+  pub parcelableValue: crate::mangled::_7_android_4_aidl_5_tests_26_OtherParcelableForToString,
+  pub parcelableArray: Vec<crate::mangled::_7_android_4_aidl_5_tests_26_OtherParcelableForToString>,
+  pub enumValue: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum,
+  pub enumArray: Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>,
+  pub nullArray: Vec<String>,
+  pub nullList: Vec<String>,
+  pub parcelableGeneric: i32,
+  pub unionValue: crate::mangled::_7_android_4_aidl_5_tests_5_Union,
+}
+pub(crate) mod mangled { pub use super::ParcelableForToString as _7_android_4_aidl_5_tests_21_ParcelableForToString; }
+impl Default for ParcelableForToString {
+  fn default() -> Self {
+    Self {
+      intValue: 0,
+      intArray: Default::default(),
+      longValue: 0,
+      longArray: Default::default(),
+      doubleValue: 0.000000f64,
+      doubleArray: Default::default(),
+      floatValue: 0.000000f32,
+      floatArray: Default::default(),
+      byteValue: 0,
+      byteArray: Default::default(),
+      booleanValue: false,
+      booleanArray: Default::default(),
+      stringValue: Default::default(),
+      stringArray: Default::default(),
+      stringList: Default::default(),
+      parcelableValue: Default::default(),
+      parcelableArray: Default::default(),
+      enumValue: Default::default(),
+      enumArray: Default::default(),
+      nullArray: Default::default(),
+      nullList: Default::default(),
+      parcelableGeneric: Default::default(),
+      unionValue: Default::default(),
+    }
+  }
+}
+impl binder::parcel::Serialize for ParcelableForToString {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for ParcelableForToString {}
+impl binder::parcel::SerializeOption for ParcelableForToString {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    parcel.sized_write(|subparcel| {
+      subparcel.write(&this.intValue)?;
+      subparcel.write(&this.intArray)?;
+      subparcel.write(&this.longValue)?;
+      subparcel.write(&this.longArray)?;
+      subparcel.write(&this.doubleValue)?;
+      subparcel.write(&this.doubleArray)?;
+      subparcel.write(&this.floatValue)?;
+      subparcel.write(&this.floatArray)?;
+      subparcel.write(&this.byteValue)?;
+      subparcel.write(&this.byteArray)?;
+      subparcel.write(&this.booleanValue)?;
+      subparcel.write(&this.booleanArray)?;
+      subparcel.write(&this.stringValue)?;
+      subparcel.write(&this.stringArray)?;
+      subparcel.write(&this.stringList)?;
+      subparcel.write(&this.parcelableValue)?;
+      subparcel.write(&this.parcelableArray)?;
+      subparcel.write(&this.enumValue)?;
+      subparcel.write(&this.enumArray)?;
+      subparcel.write(&this.nullArray)?;
+      subparcel.write(&this.nullList)?;
+      subparcel.write(&this.parcelableGeneric)?;
+      subparcel.write(&this.unionValue)?;
+      Ok(())
+    })
+  }
+}
+impl binder::parcel::Deserialize for ParcelableForToString {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for ParcelableForToString {}
+impl binder::parcel::DeserializeOption for ParcelableForToString {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let start_pos = parcel.get_data_position();
+    let parcelable_size: i32 = parcel.read()?;
+    if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+    let mut result = Self::default();
+    result.intValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.intArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.longValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.longArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.doubleValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.doubleArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.floatValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.floatArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.byteValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.byteArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.booleanValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.booleanArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.stringValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.stringArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.stringList = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.parcelableValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.parcelableArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.enumValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.enumArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.nullArray = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.nullList = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.parcelableGeneric = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.unionValue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    Ok(Some(result))
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs.d
new file mode 100644
index 0000000..b0db709
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs : \
+  system/tools/aidl/tests/android/aidl/tests/ParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/GenericStructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs
new file mode 100644
index 0000000..f46149d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs
@@ -0,0 +1,422 @@
+#[derive(Debug, Clone, PartialEq)]
+pub struct StructuredParcelable {
+  pub shouldContainThreeFs: Vec<i32>,
+  pub f: i32,
+  pub shouldBeJerry: String,
+  pub shouldBeByteBar: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum,
+  pub shouldBeIntBar: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum,
+  pub shouldBeLongBar: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum,
+  pub shouldContainTwoByteFoos: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum>,
+  pub shouldContainTwoIntFoos: Vec<crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum>,
+  pub shouldContainTwoLongFoos: Vec<crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum>,
+  pub stringDefaultsToFoo: String,
+  pub byteDefaultsToFour: i8,
+  pub intDefaultsToFive: i32,
+  pub longDefaultsToNegativeSeven: i64,
+  pub booleanDefaultsToTrue: bool,
+  pub charDefaultsToC: u16,
+  pub floatDefaultsToPi: f32,
+  pub doubleWithDefault: f64,
+  pub arrayDefaultsTo123: Vec<i32>,
+  pub arrayDefaultsToEmpty: Vec<i32>,
+  pub boolDefault: bool,
+  pub byteDefault: i8,
+  pub intDefault: i32,
+  pub longDefault: i64,
+  pub floatDefault: f32,
+  pub doubleDefault: f64,
+  pub checkDoubleFromFloat: f64,
+  pub checkStringArray1: Vec<String>,
+  pub checkStringArray2: Vec<String>,
+  pub int32_min: i32,
+  pub int32_max: i32,
+  pub int64_max: i64,
+  pub hexInt32_neg_1: i32,
+  pub ibinder: Option<binder::SpIBinder>,
+  pub int32_1: Vec<i32>,
+  pub int64_1: Vec<i64>,
+  pub hexInt32_pos_1: i32,
+  pub hexInt64_pos_1: i32,
+  pub const_exprs_1: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_2: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_3: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_4: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_5: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_6: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_7: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_8: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_9: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub const_exprs_10: crate::mangled::_7_android_4_aidl_5_tests_22_ConstantExpressionEnum,
+  pub addString1: String,
+  pub addString2: String,
+  pub shouldSetBit0AndBit2: i32,
+  pub u: Option<crate::mangled::_7_android_4_aidl_5_tests_5_Union>,
+  pub shouldBeConstS1: Option<crate::mangled::_7_android_4_aidl_5_tests_5_Union>,
+  pub defaultWithFoo: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum,
+}
+pub const BIT0: i32 = 1;
+pub const BIT1: i32 = 2;
+pub const BIT2: i32 = 4;
+pub(crate) mod mangled { pub use super::StructuredParcelable as _7_android_4_aidl_5_tests_20_StructuredParcelable; }
+impl Default for StructuredParcelable {
+  fn default() -> Self {
+    Self {
+      shouldContainThreeFs: Default::default(),
+      f: 0,
+      shouldBeJerry: Default::default(),
+      shouldBeByteBar: Default::default(),
+      shouldBeIntBar: Default::default(),
+      shouldBeLongBar: Default::default(),
+      shouldContainTwoByteFoos: Default::default(),
+      shouldContainTwoIntFoos: Default::default(),
+      shouldContainTwoLongFoos: Default::default(),
+      stringDefaultsToFoo: "foo".into(),
+      byteDefaultsToFour: 4,
+      intDefaultsToFive: 5,
+      longDefaultsToNegativeSeven: -7,
+      booleanDefaultsToTrue: true,
+      charDefaultsToC: 'C' as u16,
+      floatDefaultsToPi: 3.140000f32,
+      doubleWithDefault: -314000000000000000.000000f64,
+      arrayDefaultsTo123: vec!{1, 2, 3},
+      arrayDefaultsToEmpty: vec!{},
+      boolDefault: false,
+      byteDefault: 0,
+      intDefault: 0,
+      longDefault: 0,
+      floatDefault: 0.000000f32,
+      doubleDefault: 0.000000f64,
+      checkDoubleFromFloat: 3.140000f64,
+      checkStringArray1: vec!{"a".into(), "b".into()},
+      checkStringArray2: vec!{"a".into(), "b".into()},
+      int32_min: -2147483648,
+      int32_max: 2147483647,
+      int64_max: 9223372036854775807,
+      hexInt32_neg_1: -1,
+      ibinder: Default::default(),
+      int32_1: vec!{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+      int64_1: vec!{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+      hexInt32_pos_1: 1,
+      hexInt64_pos_1: 1,
+      const_exprs_1: Default::default(),
+      const_exprs_2: Default::default(),
+      const_exprs_3: Default::default(),
+      const_exprs_4: Default::default(),
+      const_exprs_5: Default::default(),
+      const_exprs_6: Default::default(),
+      const_exprs_7: Default::default(),
+      const_exprs_8: Default::default(),
+      const_exprs_9: Default::default(),
+      const_exprs_10: Default::default(),
+      addString1: "hello world!".into(),
+      addString2: "The quick brown fox jumps over the lazy dog.".into(),
+      shouldSetBit0AndBit2: 0,
+      u: Default::default(),
+      shouldBeConstS1: Default::default(),
+      defaultWithFoo: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum::FOO,
+    }
+  }
+}
+impl binder::parcel::Serialize for StructuredParcelable {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for StructuredParcelable {}
+impl binder::parcel::SerializeOption for StructuredParcelable {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    parcel.sized_write(|subparcel| {
+      subparcel.write(&this.shouldContainThreeFs)?;
+      subparcel.write(&this.f)?;
+      subparcel.write(&this.shouldBeJerry)?;
+      subparcel.write(&this.shouldBeByteBar)?;
+      subparcel.write(&this.shouldBeIntBar)?;
+      subparcel.write(&this.shouldBeLongBar)?;
+      subparcel.write(&this.shouldContainTwoByteFoos)?;
+      subparcel.write(&this.shouldContainTwoIntFoos)?;
+      subparcel.write(&this.shouldContainTwoLongFoos)?;
+      subparcel.write(&this.stringDefaultsToFoo)?;
+      subparcel.write(&this.byteDefaultsToFour)?;
+      subparcel.write(&this.intDefaultsToFive)?;
+      subparcel.write(&this.longDefaultsToNegativeSeven)?;
+      subparcel.write(&this.booleanDefaultsToTrue)?;
+      subparcel.write(&this.charDefaultsToC)?;
+      subparcel.write(&this.floatDefaultsToPi)?;
+      subparcel.write(&this.doubleWithDefault)?;
+      subparcel.write(&this.arrayDefaultsTo123)?;
+      subparcel.write(&this.arrayDefaultsToEmpty)?;
+      subparcel.write(&this.boolDefault)?;
+      subparcel.write(&this.byteDefault)?;
+      subparcel.write(&this.intDefault)?;
+      subparcel.write(&this.longDefault)?;
+      subparcel.write(&this.floatDefault)?;
+      subparcel.write(&this.doubleDefault)?;
+      subparcel.write(&this.checkDoubleFromFloat)?;
+      subparcel.write(&this.checkStringArray1)?;
+      subparcel.write(&this.checkStringArray2)?;
+      subparcel.write(&this.int32_min)?;
+      subparcel.write(&this.int32_max)?;
+      subparcel.write(&this.int64_max)?;
+      subparcel.write(&this.hexInt32_neg_1)?;
+      subparcel.write(&this.ibinder)?;
+      subparcel.write(&this.int32_1)?;
+      subparcel.write(&this.int64_1)?;
+      subparcel.write(&this.hexInt32_pos_1)?;
+      subparcel.write(&this.hexInt64_pos_1)?;
+      subparcel.write(&this.const_exprs_1)?;
+      subparcel.write(&this.const_exprs_2)?;
+      subparcel.write(&this.const_exprs_3)?;
+      subparcel.write(&this.const_exprs_4)?;
+      subparcel.write(&this.const_exprs_5)?;
+      subparcel.write(&this.const_exprs_6)?;
+      subparcel.write(&this.const_exprs_7)?;
+      subparcel.write(&this.const_exprs_8)?;
+      subparcel.write(&this.const_exprs_9)?;
+      subparcel.write(&this.const_exprs_10)?;
+      subparcel.write(&this.addString1)?;
+      subparcel.write(&this.addString2)?;
+      subparcel.write(&this.shouldSetBit0AndBit2)?;
+      subparcel.write(&this.u)?;
+      subparcel.write(&this.shouldBeConstS1)?;
+      subparcel.write(&this.defaultWithFoo)?;
+      Ok(())
+    })
+  }
+}
+impl binder::parcel::Deserialize for StructuredParcelable {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for StructuredParcelable {}
+impl binder::parcel::DeserializeOption for StructuredParcelable {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let start_pos = parcel.get_data_position();
+    let parcelable_size: i32 = parcel.read()?;
+    if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+    let mut result = Self::default();
+    result.shouldContainThreeFs = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.f = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldBeJerry = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldBeByteBar = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldBeIntBar = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldBeLongBar = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldContainTwoByteFoos = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldContainTwoIntFoos = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldContainTwoLongFoos = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.stringDefaultsToFoo = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.byteDefaultsToFour = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.intDefaultsToFive = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.longDefaultsToNegativeSeven = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.booleanDefaultsToTrue = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.charDefaultsToC = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.floatDefaultsToPi = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.doubleWithDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.arrayDefaultsTo123 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.arrayDefaultsToEmpty = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.boolDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.byteDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.intDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.longDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.floatDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.doubleDefault = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.checkDoubleFromFloat = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.checkStringArray1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.checkStringArray2 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.int32_min = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.int32_max = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.int64_max = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.hexInt32_neg_1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.ibinder = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.int32_1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.int64_1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.hexInt32_pos_1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.hexInt64_pos_1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_2 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_3 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_4 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_5 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_6 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_7 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_8 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_9 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.const_exprs_10 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.addString1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.addString2 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldSetBit0AndBit2 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.u = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.shouldBeConstS1 = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    result.defaultWithFoo = parcel.read()?;
+    if (parcel.get_data_position() - start_pos) == parcelable_size {
+      return Ok(Some(result));
+    }
+    Ok(Some(result))
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs.d
new file mode 100644
index 0000000..4a4a062
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs.d
@@ -0,0 +1,7 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs : \
+  system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
new file mode 100644
index 0000000..fbb8a35
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
@@ -0,0 +1,111 @@
+#[derive(Debug, Clone, PartialEq)]
+pub enum Union {
+  Ns(Vec<i32>),
+  N(i32),
+  M(i32),
+  S(String),
+  Ibinder(Option<binder::SpIBinder>),
+  Ss(Vec<String>),
+  Be(crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum),
+}
+pub const S1: &str = "a string constant in union";
+pub(crate) mod mangled { pub use super::Union as _7_android_4_aidl_5_tests_5_Union; }
+impl Default for Union {
+  fn default() -> Self {
+    Self::Ns(vec!{})
+  }
+}
+impl binder::parcel::Serialize for Union {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for Union {}
+impl binder::parcel::SerializeOption for Union {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    match this {
+      Self::Ns(v) => {
+        parcel.write(&0i32)?;
+        parcel.write(v)
+      }
+      Self::N(v) => {
+        parcel.write(&1i32)?;
+        parcel.write(v)
+      }
+      Self::M(v) => {
+        parcel.write(&2i32)?;
+        parcel.write(v)
+      }
+      Self::S(v) => {
+        parcel.write(&3i32)?;
+        parcel.write(v)
+      }
+      Self::Ibinder(v) => {
+        parcel.write(&4i32)?;
+        parcel.write(v)
+      }
+      Self::Ss(v) => {
+        parcel.write(&5i32)?;
+        parcel.write(v)
+      }
+      Self::Be(v) => {
+        parcel.write(&6i32)?;
+        parcel.write(v)
+      }
+    }
+  }
+}
+impl binder::parcel::Deserialize for Union {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for Union {}
+impl binder::parcel::DeserializeOption for Union {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let tag: i32 = parcel.read()?;
+    match tag {
+      0 => {
+        let value: Vec<i32> = parcel.read()?;
+        Ok(Some(Self::Ns(value)))
+      }
+      1 => {
+        let value: i32 = parcel.read()?;
+        Ok(Some(Self::N(value)))
+      }
+      2 => {
+        let value: i32 = parcel.read()?;
+        Ok(Some(Self::M(value)))
+      }
+      3 => {
+        let value: String = parcel.read()?;
+        Ok(Some(Self::S(value)))
+      }
+      4 => {
+        let value: Option<binder::SpIBinder> = parcel.read()?;
+        Ok(Some(Self::Ibinder(value)))
+      }
+      5 => {
+        let value: Vec<String> = parcel.read()?;
+        Ok(Some(Self::Ss(value)))
+      }
+      6 => {
+        let value: crate::mangled::_7_android_4_aidl_5_tests_8_ByteEnum = parcel.read()?;
+        Ok(Some(Self::Be(value)))
+      }
+      _ => {
+        Err(binder::StatusCode::BAD_VALUE)
+      }
+    }
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs.d
new file mode 100644
index 0000000..1519482
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs : \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
+  system/tools/aidl/tests/android/aidl/tests/ByteEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
new file mode 100644
index 0000000..501e00c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
@@ -0,0 +1,66 @@
+#[derive(Debug)]
+pub enum UnionWithFd {
+  Num(i32),
+  Pfd(Option<binder::parcel::ParcelFileDescriptor>),
+}
+pub(crate) mod mangled { pub use super::UnionWithFd as _7_android_4_aidl_5_tests_11_UnionWithFd; }
+impl Default for UnionWithFd {
+  fn default() -> Self {
+    Self::Num(0)
+  }
+}
+impl binder::parcel::Serialize for UnionWithFd {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for UnionWithFd {}
+impl binder::parcel::SerializeOption for UnionWithFd {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    match this {
+      Self::Num(v) => {
+        parcel.write(&0i32)?;
+        parcel.write(v)
+      }
+      Self::Pfd(v) => {
+        parcel.write(&1i32)?;
+        let __field_ref = v.as_ref().ok_or(binder::StatusCode::UNEXPECTED_NULL)?;
+        parcel.write(__field_ref)
+      }
+    }
+  }
+}
+impl binder::parcel::Deserialize for UnionWithFd {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for UnionWithFd {}
+impl binder::parcel::DeserializeOption for UnionWithFd {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let tag: i32 = parcel.read()?;
+    match tag {
+      0 => {
+        let value: i32 = parcel.read()?;
+        Ok(Some(Self::Num(value)))
+      }
+      1 => {
+        let value: Option<binder::parcel::ParcelFileDescriptor> = Some(parcel.read()?);
+        Ok(Some(Self::Pfd(value)))
+      }
+      _ => {
+        Err(binder::StatusCode::BAD_VALUE)
+      }
+    }
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs.d
new file mode 100644
index 0000000..f8e20d7
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs : \
+  system/tools/aidl/tests/android/aidl/tests/UnionWithFd.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
new file mode 100644
index 0000000..426b9d2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
@@ -0,0 +1,65 @@
+#[derive(Debug, Clone, PartialEq)]
+pub enum EnumUnion {
+  IntEnum(crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum),
+  LongEnum(crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum),
+}
+pub(crate) mod mangled { pub use super::EnumUnion as _7_android_4_aidl_5_tests_6_unions_9_EnumUnion; }
+impl Default for EnumUnion {
+  fn default() -> Self {
+    Self::IntEnum(crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum::FOO)
+  }
+}
+impl binder::parcel::Serialize for EnumUnion {
+  fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+  }
+}
+impl binder::parcel::SerializeArray for EnumUnion {}
+impl binder::parcel::SerializeOption for EnumUnion {
+  fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+    let this = if let Some(this) = this {
+      parcel.write(&1i32)?;
+      this
+    } else {
+      return parcel.write(&0i32);
+    };
+    match this {
+      Self::IntEnum(v) => {
+        parcel.write(&0i32)?;
+        parcel.write(v)
+      }
+      Self::LongEnum(v) => {
+        parcel.write(&1i32)?;
+        parcel.write(v)
+      }
+    }
+  }
+}
+impl binder::parcel::Deserialize for EnumUnion {
+  fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+    <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+       .transpose()
+       .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+  }
+}
+impl binder::parcel::DeserializeArray for EnumUnion {}
+impl binder::parcel::DeserializeOption for EnumUnion {
+  fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+    let status: i32 = parcel.read()?;
+    if status == 0 { return Ok(None); }
+    let tag: i32 = parcel.read()?;
+    match tag {
+      0 => {
+        let value: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum = parcel.read()?;
+        Ok(Some(Self::IntEnum(value)))
+      }
+      1 => {
+        let value: crate::mangled::_7_android_4_aidl_5_tests_8_LongEnum = parcel.read()?;
+        Ok(Some(Self::LongEnum(value)))
+      }
+      _ => {
+        Err(binder::StatusCode::BAD_VALUE)
+      }
+    }
+  }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs.d
new file mode 100644
index 0000000..40e3a24
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs : \
+  system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.aidl \
+  system/tools/aidl/tests/android/aidl/tests/IntEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/timestamp b/tests/golden_output/aidl-test-interface-rust-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/timestamp
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp
new file mode 100644
index 0000000..b6c8f30
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp
@@ -0,0 +1,83 @@
+#include <android/aidl/loggable/Data.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+::android::status_t Data::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  [[maybe_unused]] size_t _aidl_start_pos = _aidl_parcel->dataPosition();
+  int32_t _aidl_parcelable_raw_size = _aidl_parcel->readInt32();
+  if (_aidl_parcelable_raw_size < 0) return ::android::BAD_VALUE;
+  [[maybe_unused]] size_t _aidl_parcelable_size = static_cast<size_t>(_aidl_parcelable_raw_size);
+  if (_aidl_start_pos > SIZE_MAX - _aidl_parcelable_size) return ::android::BAD_VALUE;
+  ;
+  _aidl_ret_status = _aidl_parcel->readInt32(&num);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readUtf8FromUtf16(&str);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readParcelable(&nestedUnion);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  _aidl_ret_status = _aidl_parcel->readByte(reinterpret_cast<int8_t *>(&nestedEnum));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {
+    _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  };
+  return _aidl_ret_status;
+}
+
+::android::status_t Data::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  auto _aidl_start_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->writeInt32(0);;
+  _aidl_ret_status = _aidl_parcel->writeInt32(num);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeUtf8AsUtf16(str);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeParcelable(nestedUnion);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = _aidl_parcel->writeByte(static_cast<int8_t>(nestedEnum));
+  if (((_aidl_ret_status) != (::android::OK))) {
+    return _aidl_ret_status;
+  }
+  auto _aidl_end_pos = _aidl_parcel->dataPosition();
+  _aidl_parcel->setDataPosition(_aidl_start_pos);
+  _aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);
+  _aidl_parcel->setDataPosition(_aidl_end_pos);;
+  return _aidl_ret_status;
+}
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp.d b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp.d
new file mode 100644
index 0000000..7397bf0
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Data.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp.d b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp.d
new file mode 100644
index 0000000..56840c6
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Enum.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp
new file mode 100644
index 0000000..4efa783
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp
@@ -0,0 +1,511 @@
+#include <android/aidl/loggable/ILoggableInterface.h>
+#include <android/aidl/loggable/BpLoggableInterface.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(LoggableInterface, "android.aidl.loggable.ILoggableInterface")
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/loggable/BpLoggableInterface.h>
+#include <android/aidl/loggable/BnLoggableInterface.h>
+#include <binder/Parcel.h>
+#include <android-base/macros.h>
+#include <chrono>
+#include <functional>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+BpLoggableInterface::BpLoggableInterface(const ::android::sp<::android::IBinder>& _aidl_impl)
+    : BpInterface<ILoggableInterface>(_aidl_impl){
+}
+
+std::function<void(const BpLoggableInterface::TransactionLog&)> BpLoggableInterface::logFunc;
+
+::android::binder::Status BpLoggableInterface::LogThis(bool boolValue, ::std::vector<bool>* boolArray, int8_t byteValue, ::std::vector<uint8_t>* byteArray, char16_t charValue, ::std::vector<char16_t>* charArray, int32_t intValue, ::std::vector<int32_t>* intArray, int64_t longValue, ::std::vector<int64_t>* longArray, float floatValue, ::std::vector<float>* floatArray, double doubleValue, ::std::vector<double>* doubleArray, const ::android::String16& stringValue, ::std::vector<::android::String16>* stringArray, ::std::vector<::android::String16>* listValue, const ::android::aidl::loggable::Data& dataValue, const ::android::sp<::android::IBinder>& binderValue, ::std::optional<::android::os::ParcelFileDescriptor>* pfdValue, ::std::vector<::android::os::ParcelFileDescriptor>* pfdArray, ::std::vector<::android::String16>* _aidl_return) {
+  ::android::Parcel _aidl_data;
+  ::android::Parcel _aidl_reply;
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  ::android::binder::Status _aidl_status;
+  ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::ILoggableInterface::LogThis::cppClient");
+  BpLoggableInterface::TransactionLog _transaction_log;
+  if (BpLoggableInterface::logFunc != nullptr) {
+    _transaction_log.input_args.emplace_back("boolValue", (boolValue?"true":"false"));
+    _transaction_log.input_args.emplace_back("boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("byteValue", std::to_string(byteValue));
+    _transaction_log.input_args.emplace_back("byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("charValue", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(charValue));
+    _transaction_log.input_args.emplace_back("charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("intValue", std::to_string(intValue));
+    _transaction_log.input_args.emplace_back("intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("longValue", std::to_string(longValue));
+    _transaction_log.input_args.emplace_back("longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("floatValue", std::to_string(floatValue));
+    _transaction_log.input_args.emplace_back("floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("doubleValue", std::to_string(doubleValue));
+    _transaction_log.input_args.emplace_back("doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("stringValue", (std::ostringstream() << stringValue).str());
+    _transaction_log.input_args.emplace_back("stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("dataValue", _call_toString(dataValue));
+    _transaction_log.input_args.emplace_back("binderValue", "");
+    _transaction_log.input_args.emplace_back("pfdValue", "");
+    _transaction_log.input_args.emplace_back("pfdArray", "");
+  }
+  auto _log_start = std::chrono::steady_clock::now();
+  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeBool(boolValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeBoolVector(*boolArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeByte(byteValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeByteVector(*byteArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeChar(charValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeCharVector(*charArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32(intValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt32Vector(*intArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt64(longValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeInt64Vector(*longArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeFloat(floatValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeFloatVector(*floatArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeDouble(doubleValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeDoubleVector(*doubleArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16(stringValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16Vector(*stringArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeString16Vector(*listValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeParcelable(dataValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeStrongBinder(binderValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeNullableParcelable(*pfdValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_data.writeParcelableVector(*pfdArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = remote()->transact(BnLoggableInterface::TRANSACTION_LogThis, _aidl_data, &_aidl_reply, 0);
+  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ILoggableInterface::getDefaultImpl())) {
+     return ILoggableInterface::getDefaultImpl()->LogThis(boolValue, boolArray, byteValue, byteArray, charValue, charArray, intValue, intArray, longValue, longArray, floatValue, floatArray, doubleValue, doubleArray, stringValue, stringArray, listValue, dataValue, binderValue, pfdValue, pfdArray, _aidl_return);
+  }
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  if (!_aidl_status.isOk()) {
+    return _aidl_status;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readBoolVector(boolArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readByteVector(byteArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readCharVector(charArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readInt32Vector(intArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readInt64Vector(longArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readFloatVector(floatArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readDoubleVector(doubleArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(stringArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readString16Vector(listValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelable(pfdValue);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_ret_status = _aidl_reply.readParcelableVector(pfdArray);
+  if (((_aidl_ret_status) != (::android::OK))) {
+    goto _aidl_error;
+  }
+  _aidl_error:
+  _aidl_status.setFromStatusT(_aidl_ret_status);
+  if (BpLoggableInterface::logFunc != nullptr) {
+    auto _log_end = std::chrono::steady_clock::now();
+    _transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end - _log_start).count();
+    _transaction_log.interface_name = "android.aidl.loggable.ILoggableInterface";
+    _transaction_log.method_name = "LogThis";
+    _transaction_log.stub_address = nullptr;
+    _transaction_log.proxy_address = static_cast<const void*>(this);
+    _transaction_log.exception_code = _aidl_status.exceptionCode();
+    _transaction_log.exception_message = _aidl_status.exceptionMessage();
+    _transaction_log.transaction_error = _aidl_status.transactionError();
+    _transaction_log.service_specific_error_code = _aidl_status.serviceSpecificErrorCode();
+    _transaction_log.output_args.emplace_back("boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("pfdValue", "");
+    _transaction_log.output_args.emplace_back("pfdArray", "");
+    _transaction_log.result = [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *_aidl_return) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    BpLoggableInterface::logFunc(_transaction_log);
+  }
+  return _aidl_status;
+}
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
+#include <android/aidl/loggable/BnLoggableInterface.h>
+#include <binder/Parcel.h>
+#include <binder/Stability.h>
+#include <chrono>
+#include <functional>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+BnLoggableInterface::BnLoggableInterface()
+{
+  ::android::internal::Stability::markCompilationUnit(this);
+}
+
+::android::status_t BnLoggableInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
+  ::android::status_t _aidl_ret_status = ::android::OK;
+  switch (_aidl_code) {
+  case BnLoggableInterface::TRANSACTION_LogThis:
+  {
+    bool in_boolValue;
+    ::std::vector<bool> in_boolArray;
+    int8_t in_byteValue;
+    ::std::vector<uint8_t> in_byteArray;
+    char16_t in_charValue;
+    ::std::vector<char16_t> in_charArray;
+    int32_t in_intValue;
+    ::std::vector<int32_t> in_intArray;
+    int64_t in_longValue;
+    ::std::vector<int64_t> in_longArray;
+    float in_floatValue;
+    ::std::vector<float> in_floatArray;
+    double in_doubleValue;
+    ::std::vector<double> in_doubleArray;
+    ::android::String16 in_stringValue;
+    ::std::vector<::android::String16> in_stringArray;
+    ::std::vector<::android::String16> in_listValue;
+    ::android::aidl::loggable::Data in_dataValue;
+    ::android::sp<::android::IBinder> in_binderValue;
+    ::std::optional<::android::os::ParcelFileDescriptor> in_pfdValue;
+    ::std::vector<::android::os::ParcelFileDescriptor> in_pfdArray;
+    ::std::vector<::android::String16> _aidl_return;
+    if (!(_aidl_data.checkInterface(this))) {
+      _aidl_ret_status = ::android::BAD_TYPE;
+      break;
+    }
+    ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::ILoggableInterface::LogThis::cppServer");
+    _aidl_ret_status = _aidl_data.readBool(&in_boolValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readBoolVector(&in_boolArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readByte(&in_byteValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readByteVector(&in_byteArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readChar(&in_charValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readCharVector(&in_charArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32(&in_intValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt32Vector(&in_intArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt64(&in_longValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readInt64Vector(&in_longArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readFloat(&in_floatValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readFloatVector(&in_floatArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readDouble(&in_doubleValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readDoubleVector(&in_doubleArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16(&in_stringValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16Vector(&in_stringArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readString16Vector(&in_listValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelable(&in_dataValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readNullableStrongBinder(&in_binderValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelable(&in_pfdValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_data.readParcelableVector(&in_pfdArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    BnLoggableInterface::TransactionLog _transaction_log;
+    if (BnLoggableInterface::logFunc != nullptr) {
+      _transaction_log.input_args.emplace_back("in_boolValue", (in_boolValue?"true":"false"));
+      _transaction_log.input_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_byteValue", std::to_string(in_byteValue));
+      _transaction_log.input_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_charValue", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(in_charValue));
+      _transaction_log.input_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_intValue", std::to_string(in_intValue));
+      _transaction_log.input_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_longValue", std::to_string(in_longValue));
+      _transaction_log.input_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_floatValue", std::to_string(in_floatValue));
+      _transaction_log.input_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_doubleValue", std::to_string(in_doubleValue));
+      _transaction_log.input_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_stringValue", (std::ostringstream() << in_stringValue).str());
+      _transaction_log.input_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+      _transaction_log.input_args.emplace_back("in_dataValue", _call_toString(in_dataValue));
+      _transaction_log.input_args.emplace_back("in_binderValue", "");
+      _transaction_log.input_args.emplace_back("in_pfdValue", "");
+      _transaction_log.input_args.emplace_back("in_pfdArray", "");
+    }
+    auto _log_start = std::chrono::steady_clock::now();
+    ::android::binder::Status _aidl_status(LogThis(in_boolValue, &in_boolArray, in_byteValue, &in_byteArray, in_charValue, &in_charArray, in_intValue, &in_intArray, in_longValue, &in_longArray, in_floatValue, &in_floatArray, in_doubleValue, &in_doubleArray, in_stringValue, &in_stringArray, &in_listValue, in_dataValue, in_binderValue, &in_pfdValue, &in_pfdArray, &_aidl_return));
+    if (BnLoggableInterface::logFunc != nullptr) {
+      auto _log_end = std::chrono::steady_clock::now();
+      _transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end - _log_start).count();
+      _transaction_log.interface_name = "android.aidl.loggable.ILoggableInterface";
+      _transaction_log.method_name = "LogThis";
+      _transaction_log.stub_address = static_cast<const void*>(this);
+      _transaction_log.proxy_address = nullptr;
+      _transaction_log.exception_code = _aidl_status.exceptionCode();
+      _transaction_log.exception_message = _aidl_status.exceptionMessage();
+      _transaction_log.transaction_error = _aidl_status.transactionError();
+      _transaction_log.service_specific_error_code = _aidl_status.serviceSpecificErrorCode();
+      _transaction_log.output_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+      _transaction_log.output_args.emplace_back("in_pfdValue", "");
+      _transaction_log.output_args.emplace_back("in_pfdArray", "");
+      _transaction_log.result = [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: _aidl_return) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+      BnLoggableInterface::logFunc(_transaction_log);
+    }
+    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    if (!_aidl_status.isOk()) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeBoolVector(in_boolArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeByteVector(in_byteArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeCharVector(in_charArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt32Vector(in_intArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeInt64Vector(in_longArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeFloatVector(in_floatArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeDoubleVector(in_doubleArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(in_stringArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeString16Vector(in_listValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeNullableParcelable(in_pfdValue);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+    _aidl_ret_status = _aidl_reply->writeParcelableVector(in_pfdArray);
+    if (((_aidl_ret_status) != (::android::OK))) {
+      break;
+    }
+  }
+  break;
+  default:
+  {
+    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
+  }
+  break;
+  }
+  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
+    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
+  }
+  return _aidl_ret_status;
+}
+
+std::function<void(const BnLoggableInterface::TransactionLog&)> BnLoggableInterface::logFunc;
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d
new file mode 100644
index 0000000..4f7a25f
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/ILoggableInterface.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp
new file mode 100644
index 0000000..4ec0683
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp
@@ -0,0 +1,52 @@
+#include <android/aidl/loggable/Union.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+::android::status_t Union::readFromParcel(const ::android::Parcel* _aidl_parcel) {
+  ::android::status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_tag)) != ::android::OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case num: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readInt32(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<num>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<num>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  case str: {
+    ::std::string _aidl_value;
+    if ((_aidl_ret_status = _aidl_parcel->readUtf8FromUtf16(&_aidl_value)) != ::android::OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<::std::string>) {
+      set<str>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<str>(std::move(_aidl_value));
+    }
+    return ::android::OK; }
+  }
+  return ::android::BAD_VALUE;
+}
+
+::android::status_t Union::writeToParcel(::android::Parcel* _aidl_parcel) const {
+  ::android::status_t _aidl_ret_status = _aidl_parcel->writeInt32(getTag());
+  if (_aidl_ret_status != ::android::OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case num: return _aidl_parcel->writeInt32(get<num>());
+  case str: return _aidl_parcel->writeUtf8AsUtf16(get<str>());
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp.d b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp.d
new file mode 100644
index 0000000..b8cc8a5
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/Union.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnData.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnData.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnData.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnEnum.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnEnum.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnLoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnLoggableInterface.h
new file mode 100644
index 0000000..3cb8738
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnLoggableInterface.h
@@ -0,0 +1,49 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/loggable/ILoggableInterface.h>
+#include <functional>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+class BnLoggableInterface : public ::android::BnInterface<ILoggableInterface> {
+public:
+  static constexpr uint32_t TRANSACTION_LogThis = ::android::IBinder::FIRST_CALL_TRANSACTION + 0;
+  explicit BnLoggableInterface();
+  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
+  struct TransactionLog {
+    double duration_ms;
+    std::string interface_name;
+    std::string method_name;
+    const void* proxy_address;
+    const void* stub_address;
+    std::vector<std::pair<std::string, std::string>> input_args;
+    std::vector<std::pair<std::string, std::string>> output_args;
+    std::string result;
+    std::string exception_message;
+    int32_t exception_code;
+    int32_t transaction_error;
+    int32_t service_specific_error_code;
+  };
+  static std::function<void(const TransactionLog&)> logFunc;
+private:
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+};  // class BnLoggableInterface
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnUnion.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnUnion.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bn classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpData.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpData.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpData.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpEnum.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpEnum.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpLoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpLoggableInterface.h
new file mode 100644
index 0000000..3d31378
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpLoggableInterface.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/loggable/ILoggableInterface.h>
+#include <functional>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+class BpLoggableInterface : public ::android::BpInterface<ILoggableInterface> {
+public:
+  explicit BpLoggableInterface(const ::android::sp<::android::IBinder>& _aidl_impl);
+  virtual ~BpLoggableInterface() = default;
+  ::android::binder::Status LogThis(bool boolValue, ::std::vector<bool>* boolArray, int8_t byteValue, ::std::vector<uint8_t>* byteArray, char16_t charValue, ::std::vector<char16_t>* charArray, int32_t intValue, ::std::vector<int32_t>* intArray, int64_t longValue, ::std::vector<int64_t>* longArray, float floatValue, ::std::vector<float>* floatArray, double doubleValue, ::std::vector<double>* doubleArray, const ::android::String16& stringValue, ::std::vector<::android::String16>* stringArray, ::std::vector<::android::String16>* listValue, const ::android::aidl::loggable::Data& dataValue, const ::android::sp<::android::IBinder>& binderValue, ::std::optional<::android::os::ParcelFileDescriptor>* pfdValue, ::std::vector<::android::os::ParcelFileDescriptor>* pfdArray, ::std::vector<::android::String16>* _aidl_return) override;
+  struct TransactionLog {
+    double duration_ms;
+    std::string interface_name;
+    std::string method_name;
+    const void* proxy_address;
+    const void* stub_address;
+    std::vector<std::pair<std::string, std::string>> input_args;
+    std::vector<std::pair<std::string, std::string>> output_args;
+    std::string result;
+    std::string exception_message;
+    int32_t exception_code;
+    int32_t transaction_error;
+    int32_t service_specific_error_code;
+  };
+  static std::function<void(const TransactionLog&)> logFunc;
+private:
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+};  // class BpLoggableInterface
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpUnion.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpUnion.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) parcelables do not have bp classes
\ No newline at end of file
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Data.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Data.h
new file mode 100644
index 0000000..c3a1dfb
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Data.h
@@ -0,0 +1,77 @@
+#pragma once
+
+#include <android/aidl/loggable/Enum.h>
+#include <android/aidl/loggable/Union.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <sstream>
+#include <string>
+#include <tuple>
+#include <utils/String16.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+class Data : public ::android::Parcelable {
+public:
+  inline bool operator!=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) != std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator<(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) < std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator<=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) <= std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator==(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) == std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator>(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) > std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator>=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) >= std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+
+  int32_t num = int32_t(0);
+  ::std::string str;
+  ::android::aidl::loggable::Union nestedUnion;
+  ::android::aidl::loggable::Enum nestedEnum;
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.loggable.Data");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Data{";
+    os << "num: " << std::to_string(num);
+    os << ", str: " << (std::ostringstream() << str).str();
+    os << ", nestedUnion: " << _call_toString(nestedUnion);
+    os << ", nestedEnum: " << android::aidl::loggable::toString(nestedEnum);
+    os << "}";
+    return os.str();
+  }
+};  // class Data
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Enum.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Enum.h
new file mode 100644
index 0000000..0b97075
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Enum.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <array>
+#include <binder/Enums.h>
+#include <cstdint>
+#include <string>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+enum class Enum : int8_t {
+  FOO = 42,
+};
+
+static inline std::string toString(Enum val) {
+  switch(val) {
+  case Enum::FOO:
+    return "FOO";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
+namespace android {
+
+namespace internal {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<::android::aidl::loggable::Enum, 1> enum_values<::android::aidl::loggable::Enum> = {
+  ::android::aidl::loggable::Enum::FOO,
+};
+#pragma clang diagnostic pop
+
+}  // namespace internal
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/ILoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/ILoggableInterface.h
new file mode 100644
index 0000000..c532e3d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/ILoggableInterface.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include <android/aidl/loggable/Data.h>
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/ParcelFileDescriptor.h>
+#include <binder/Status.h>
+#include <cstdint>
+#include <optional>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+#include <utils/Trace.h>
+#include <vector>
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+class ILoggableInterface : public ::android::IInterface {
+public:
+  DECLARE_META_INTERFACE(LoggableInterface)
+  virtual ::android::binder::Status LogThis(bool boolValue, ::std::vector<bool>* boolArray, int8_t byteValue, ::std::vector<uint8_t>* byteArray, char16_t charValue, ::std::vector<char16_t>* charArray, int32_t intValue, ::std::vector<int32_t>* intArray, int64_t longValue, ::std::vector<int64_t>* longArray, float floatValue, ::std::vector<float>* floatArray, double doubleValue, ::std::vector<double>* doubleArray, const ::android::String16& stringValue, ::std::vector<::android::String16>* stringArray, ::std::vector<::android::String16>* listValue, const ::android::aidl::loggable::Data& dataValue, const ::android::sp<::android::IBinder>& binderValue, ::std::optional<::android::os::ParcelFileDescriptor>* pfdValue, ::std::vector<::android::os::ParcelFileDescriptor>* pfdArray, ::std::vector<::android::String16>* _aidl_return) = 0;
+};  // class ILoggableInterface
+
+class ILoggableInterfaceDefault : public ILoggableInterface {
+public:
+  ::android::IBinder* onAsBinder() override {
+    return nullptr;
+  }
+  ::android::binder::Status LogThis(bool, ::std::vector<bool>*, int8_t, ::std::vector<uint8_t>*, char16_t, ::std::vector<char16_t>*, int32_t, ::std::vector<int32_t>*, int64_t, ::std::vector<int64_t>*, float, ::std::vector<float>*, double, ::std::vector<double>*, const ::android::String16&, ::std::vector<::android::String16>*, ::std::vector<::android::String16>*, const ::android::aidl::loggable::Data&, const ::android::sp<::android::IBinder>&, ::std::optional<::android::os::ParcelFileDescriptor>*, ::std::vector<::android::os::ParcelFileDescriptor>*, ::std::vector<::android::String16>*) override {
+    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+  }
+};  // class ILoggableInterfaceDefault
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h
new file mode 100644
index 0000000..adf3866
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h
@@ -0,0 +1,134 @@
+#pragma once
+
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <codecvt>
+#include <cstdint>
+#include <locale>
+#include <sstream>
+#include <string>
+#include <type_traits>
+#include <utility>
+#include <utils/String16.h>
+#include <variant>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace android {
+
+namespace aidl {
+
+namespace loggable {
+
+class Union : public ::android::Parcelable {
+public:
+  inline bool operator!=(const Union& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const Union& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const Union& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const Union& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const Union& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const Union& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    str,  // String str;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
+
+  Union() : _value(std::in_place_index<num>, int32_t(43)) { }
+  Union(const Union&) = default;
+  Union(Union&&) = default;
+  Union& operator=(const Union&) = default;
+  Union& operator=(Union&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr Union(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit Union(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static Union make(_Tp&&... _args) {
+    return Union(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static Union make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return Union(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) override final;
+  ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const override final;
+  static const ::android::String16& getParcelableDescriptor() {
+    static const ::android::StaticString16 DESCIPTOR (u"android.aidl.loggable.Union");
+    return DESCIPTOR;
+  }
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Union{";
+    switch (getTag()) {
+    case num: os << "num: " << std::to_string(get<num>()); break;
+    case str: os << "str: " << (std::ostringstream() << get<str>()).str(); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<int32_t, ::std::string> _value;
+};  // class Union
+
+}  // namespace loggable
+
+}  // namespace aidl
+
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/timestamp b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/timestamp
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java
new file mode 100644
index 0000000..3b2483b
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java
@@ -0,0 +1,81 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.loggable;
+public class Data implements android.os.Parcelable
+{
+  public int num = 0;
+  public java.lang.String str;
+  public android.aidl.loggable.Union nestedUnion;
+  public byte nestedEnum;
+  public static final android.os.Parcelable.Creator<Data> CREATOR = new android.os.Parcelable.Creator<Data>() {
+    @Override
+    public Data createFromParcel(android.os.Parcel _aidl_source) {
+      Data _aidl_out = new Data();
+      _aidl_out.readFromParcel(_aidl_source);
+      return _aidl_out;
+    }
+    @Override
+    public Data[] newArray(int _aidl_size) {
+      return new Data[_aidl_size];
+    }
+  };
+  @Override public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.writeInt(0);
+    _aidl_parcel.writeInt(num);
+    _aidl_parcel.writeString(str);
+    if ((nestedUnion!=null)) {
+      _aidl_parcel.writeInt(1);
+      nestedUnion.writeToParcel(_aidl_parcel, 0);
+    }
+    else {
+      _aidl_parcel.writeInt(0);
+    }
+    _aidl_parcel.writeByte(nestedEnum);
+    int _aidl_end_pos = _aidl_parcel.dataPosition();
+    _aidl_parcel.setDataPosition(_aidl_start_pos);
+    _aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
+    _aidl_parcel.setDataPosition(_aidl_end_pos);
+  }
+  public final void readFromParcel(android.os.Parcel _aidl_parcel)
+  {
+    int _aidl_start_pos = _aidl_parcel.dataPosition();
+    int _aidl_parcelable_size = _aidl_parcel.readInt();
+    try {
+      if (_aidl_parcelable_size < 0) return;
+      num = _aidl_parcel.readInt();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      str = _aidl_parcel.readString();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      if ((0!=_aidl_parcel.readInt())) {
+        nestedUnion = android.aidl.loggable.Union.CREATOR.createFromParcel(_aidl_parcel);
+      }
+      else {
+        nestedUnion = null;
+      }
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+      nestedEnum = _aidl_parcel.readByte();
+      if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+    } finally {
+      if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {
+        throw new android.os.BadParcelableException("Overflow in the size of parcelable");
+      }
+      _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+    }
+  }
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    _mask |= describeContents(nestedUnion);
+    return _mask;
+  }
+  private int describeContents(Object _v) {
+    if (_v == null) return 0;
+    if (_v instanceof android.os.Parcelable) {
+      return ((android.os.Parcelable) _v).describeContents();
+    }
+    return 0;
+  }
+}
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java.d b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java.d
new file mode 100644
index 0000000..61f3c1e
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Data.java : \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java
new file mode 100644
index 0000000..b808a40
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java
@@ -0,0 +1,7 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.loggable;
+public @interface Enum {
+  public static final byte FOO = 42;
+}
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java.d b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java.d
new file mode 100644
index 0000000..0f2fb6f
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Enum.java : \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java
new file mode 100644
index 0000000..bcb8001
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java
@@ -0,0 +1,255 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.loggable;
+public interface ILoggableInterface extends android.os.IInterface
+{
+  /** Default implementation for ILoggableInterface. */
+  public static class Default implements android.aidl.loggable.ILoggableInterface
+  {
+    @Override public java.lang.String[] LogThis(boolean boolValue, boolean[] boolArray, byte byteValue, byte[] byteArray, char charValue, char[] charArray, int intValue, int[] intArray, long longValue, long[] longArray, float floatValue, float[] floatArray, double doubleValue, double[] doubleArray, java.lang.String stringValue, java.lang.String[] stringArray, java.util.List<java.lang.String> listValue, android.aidl.loggable.Data dataValue, android.os.IBinder binderValue, android.os.ParcelFileDescriptor pfdValue, android.os.ParcelFileDescriptor[] pfdArray) throws android.os.RemoteException
+    {
+      return null;
+    }
+    @Override
+    public android.os.IBinder asBinder() {
+      return null;
+    }
+  }
+  /** Local-side IPC implementation stub class. */
+  public static abstract class Stub extends android.os.Binder implements android.aidl.loggable.ILoggableInterface
+  {
+    /** Construct the stub at attach it to the interface. */
+    public Stub()
+    {
+      this.attachInterface(this, DESCRIPTOR);
+    }
+    /**
+     * Cast an IBinder object into an android.aidl.loggable.ILoggableInterface interface,
+     * generating a proxy if needed.
+     */
+    public static android.aidl.loggable.ILoggableInterface asInterface(android.os.IBinder obj)
+    {
+      if ((obj==null)) {
+        return null;
+      }
+      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
+      if (((iin!=null)&&(iin instanceof android.aidl.loggable.ILoggableInterface))) {
+        return ((android.aidl.loggable.ILoggableInterface)iin);
+      }
+      return new android.aidl.loggable.ILoggableInterface.Stub.Proxy(obj);
+    }
+    @Override public android.os.IBinder asBinder()
+    {
+      return this;
+    }
+    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
+    {
+      java.lang.String descriptor = DESCRIPTOR;
+      switch (code)
+      {
+        case INTERFACE_TRANSACTION:
+        {
+          reply.writeString(descriptor);
+          return true;
+        }
+      }
+      switch (code)
+      {
+        case TRANSACTION_LogThis:
+        {
+          try {
+            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::ILoggableInterface::LogThis::server");
+            data.enforceInterface(descriptor);
+            boolean _arg0;
+            _arg0 = (0!=data.readInt());
+            boolean[] _arg1;
+            _arg1 = data.createBooleanArray();
+            byte _arg2;
+            _arg2 = data.readByte();
+            byte[] _arg3;
+            _arg3 = data.createByteArray();
+            char _arg4;
+            _arg4 = (char)data.readInt();
+            char[] _arg5;
+            _arg5 = data.createCharArray();
+            int _arg6;
+            _arg6 = data.readInt();
+            int[] _arg7;
+            _arg7 = data.createIntArray();
+            long _arg8;
+            _arg8 = data.readLong();
+            long[] _arg9;
+            _arg9 = data.createLongArray();
+            float _arg10;
+            _arg10 = data.readFloat();
+            float[] _arg11;
+            _arg11 = data.createFloatArray();
+            double _arg12;
+            _arg12 = data.readDouble();
+            double[] _arg13;
+            _arg13 = data.createDoubleArray();
+            java.lang.String _arg14;
+            _arg14 = data.readString();
+            java.lang.String[] _arg15;
+            _arg15 = data.createStringArray();
+            java.util.List<java.lang.String> _arg16;
+            _arg16 = data.createStringArrayList();
+            android.aidl.loggable.Data _arg17;
+            if ((0!=data.readInt())) {
+              _arg17 = android.aidl.loggable.Data.CREATOR.createFromParcel(data);
+            }
+            else {
+              _arg17 = null;
+            }
+            android.os.IBinder _arg18;
+            _arg18 = data.readStrongBinder();
+            android.os.ParcelFileDescriptor _arg19;
+            if ((0!=data.readInt())) {
+              _arg19 = android.os.ParcelFileDescriptor.CREATOR.createFromParcel(data);
+            }
+            else {
+              _arg19 = null;
+            }
+            android.os.ParcelFileDescriptor[] _arg20;
+            _arg20 = data.createTypedArray(android.os.ParcelFileDescriptor.CREATOR);
+            java.lang.String[] _result = this.LogThis(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11, _arg12, _arg13, _arg14, _arg15, _arg16, _arg17, _arg18, _arg19, _arg20);
+            reply.writeNoException();
+            reply.writeStringArray(_result);
+            reply.writeBooleanArray(_arg1);
+            reply.writeByteArray(_arg3);
+            reply.writeCharArray(_arg5);
+            reply.writeIntArray(_arg7);
+            reply.writeLongArray(_arg9);
+            reply.writeFloatArray(_arg11);
+            reply.writeDoubleArray(_arg13);
+            reply.writeStringArray(_arg15);
+            reply.writeStringList(_arg16);
+            if ((_arg19!=null)) {
+              reply.writeInt(1);
+              _arg19.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+            }
+            else {
+              reply.writeInt(0);
+            }
+            reply.writeTypedArray(_arg20, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+            return true;
+          }
+          finally {
+            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
+          }
+        }
+        default:
+        {
+          return super.onTransact(code, data, reply, flags);
+        }
+      }
+    }
+    private static class Proxy implements android.aidl.loggable.ILoggableInterface
+    {
+      private android.os.IBinder mRemote;
+      Proxy(android.os.IBinder remote)
+      {
+        mRemote = remote;
+      }
+      @Override public android.os.IBinder asBinder()
+      {
+        return mRemote;
+      }
+      public java.lang.String getInterfaceDescriptor()
+      {
+        return DESCRIPTOR;
+      }
+      @Override public java.lang.String[] LogThis(boolean boolValue, boolean[] boolArray, byte byteValue, byte[] byteArray, char charValue, char[] charArray, int intValue, int[] intArray, long longValue, long[] longArray, float floatValue, float[] floatArray, double doubleValue, double[] doubleArray, java.lang.String stringValue, java.lang.String[] stringArray, java.util.List<java.lang.String> listValue, android.aidl.loggable.Data dataValue, android.os.IBinder binderValue, android.os.ParcelFileDescriptor pfdValue, android.os.ParcelFileDescriptor[] pfdArray) throws android.os.RemoteException
+      {
+        android.os.Parcel _data = android.os.Parcel.obtain();
+        android.os.Parcel _reply = android.os.Parcel.obtain();
+        java.lang.String[] _result;
+        try {
+          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::ILoggableInterface::LogThis::client");
+          _data.writeInterfaceToken(DESCRIPTOR);
+          _data.writeInt(((boolValue)?(1):(0)));
+          _data.writeBooleanArray(boolArray);
+          _data.writeByte(byteValue);
+          _data.writeByteArray(byteArray);
+          _data.writeInt(((int)charValue));
+          _data.writeCharArray(charArray);
+          _data.writeInt(intValue);
+          _data.writeIntArray(intArray);
+          _data.writeLong(longValue);
+          _data.writeLongArray(longArray);
+          _data.writeFloat(floatValue);
+          _data.writeFloatArray(floatArray);
+          _data.writeDouble(doubleValue);
+          _data.writeDoubleArray(doubleArray);
+          _data.writeString(stringValue);
+          _data.writeStringArray(stringArray);
+          _data.writeStringList(listValue);
+          if ((dataValue!=null)) {
+            _data.writeInt(1);
+            dataValue.writeToParcel(_data, 0);
+          }
+          else {
+            _data.writeInt(0);
+          }
+          _data.writeStrongBinder(binderValue);
+          if ((pfdValue!=null)) {
+            _data.writeInt(1);
+            pfdValue.writeToParcel(_data, 0);
+          }
+          else {
+            _data.writeInt(0);
+          }
+          _data.writeTypedArray(pfdArray, 0);
+          boolean _status = mRemote.transact(Stub.TRANSACTION_LogThis, _data, _reply, 0);
+          if (!_status) {
+            if (getDefaultImpl() != null) {
+              return getDefaultImpl().LogThis(boolValue, boolArray, byteValue, byteArray, charValue, charArray, intValue, intArray, longValue, longArray, floatValue, floatArray, doubleValue, doubleArray, stringValue, stringArray, listValue, dataValue, binderValue, pfdValue, pfdArray);
+            }
+          }
+          _reply.readException();
+          _result = _reply.createStringArray();
+          _reply.readBooleanArray(boolArray);
+          _reply.readByteArray(byteArray);
+          _reply.readCharArray(charArray);
+          _reply.readIntArray(intArray);
+          _reply.readLongArray(longArray);
+          _reply.readFloatArray(floatArray);
+          _reply.readDoubleArray(doubleArray);
+          _reply.readStringArray(stringArray);
+          _reply.readStringList(listValue);
+          if ((0!=_reply.readInt())) {
+            pfdValue = android.os.ParcelFileDescriptor.CREATOR.createFromParcel(_reply);
+          }
+          _reply.readTypedArray(pfdArray, android.os.ParcelFileDescriptor.CREATOR);
+        }
+        finally {
+          _reply.recycle();
+          _data.recycle();
+          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
+        }
+        return _result;
+      }
+      public static android.aidl.loggable.ILoggableInterface sDefaultImpl;
+    }
+    static final int TRANSACTION_LogThis = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+    public static boolean setDefaultImpl(android.aidl.loggable.ILoggableInterface impl) {
+      // Only one user of this interface can use this function
+      // at a time. This is a heuristic to detect if two different
+      // users in the same process use this function.
+      if (Stub.Proxy.sDefaultImpl != null) {
+        throw new IllegalStateException("setDefaultImpl() called twice");
+      }
+      if (impl != null) {
+        Stub.Proxy.sDefaultImpl = impl;
+        return true;
+      }
+      return false;
+    }
+    public static android.aidl.loggable.ILoggableInterface getDefaultImpl() {
+      return Stub.Proxy.sDefaultImpl;
+    }
+  }
+  public static final java.lang.String DESCRIPTOR = "android$aidl$loggable$ILoggableInterface".replace('$', '.');
+  public java.lang.String[] LogThis(boolean boolValue, boolean[] boolArray, byte byteValue, byte[] byteArray, char charValue, char[] charArray, int intValue, int[] intArray, long longValue, long[] longArray, float floatValue, float[] floatArray, double doubleValue, double[] doubleArray, java.lang.String stringValue, java.lang.String[] stringArray, java.util.List<java.lang.String> listValue, android.aidl.loggable.Data dataValue, android.os.IBinder binderValue, android.os.ParcelFileDescriptor pfdValue, android.os.ParcelFileDescriptor[] pfdArray) throws android.os.RemoteException;
+}
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java.d b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java.d
new file mode 100644
index 0000000..3563433
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/ILoggableInterface.java : \
+  system/tools/aidl/tests/android/aidl/loggable/ILoggableInterface.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java
new file mode 100644
index 0000000..2126c93
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java
@@ -0,0 +1,131 @@
+/*
+ * This file is auto-generated.  DO NOT MODIFY.
+ */
+package android.aidl.loggable;
+
+public final class Union implements android.os.Parcelable {
+  // tags for union fields
+  public final static int num = 0;  // int num;
+  public final static int str = 1;  // String str;
+
+  private int _tag;
+  private Object _value;
+
+  public Union() {
+    int _value = 43;
+    this._tag = num;
+    this._value = _value;
+  }
+
+  private Union(android.os.Parcel _aidl_parcel) {
+    readFromParcel(_aidl_parcel);
+  }
+
+  private Union(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+
+  public int getTag() {
+    return _tag;
+  }
+
+  // int num;
+
+  public static Union num(int _value) {
+    return new Union(num, _value);
+  }
+
+  public int getNum() {
+    _assertTag(num);
+    return (int) _value;
+  }
+
+  public void setNum(int _value) {
+    _set(num, _value);
+  }
+
+  // String str;
+
+  public static Union str(java.lang.String _value) {
+    return new Union(str, _value);
+  }
+
+  public java.lang.String getStr() {
+    _assertTag(str);
+    return (java.lang.String) _value;
+  }
+
+  public void setStr(java.lang.String _value) {
+    _set(str, _value);
+  }
+
+  public static final android.os.Parcelable.Creator<Union> CREATOR = new android.os.Parcelable.Creator<Union>() {
+    @Override
+    public Union createFromParcel(android.os.Parcel _aidl_source) {
+      return new Union(_aidl_source);
+    }
+    @Override
+    public Union[] newArray(int _aidl_size) {
+      return new Union[_aidl_size];
+    }
+  };
+
+  @Override
+  public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) {
+    _aidl_parcel.writeInt(_tag);
+    switch (_tag) {
+    case num:
+      _aidl_parcel.writeInt(getNum());
+      break;
+    case str:
+      _aidl_parcel.writeString(getStr());
+      break;
+    }
+  }
+
+  public void readFromParcel(android.os.Parcel _aidl_parcel) {
+    int _aidl_tag;
+    _aidl_tag = _aidl_parcel.readInt();
+    switch (_aidl_tag) {
+    case num: {
+      int _aidl_value;
+      _aidl_value = _aidl_parcel.readInt();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    case str: {
+      java.lang.String _aidl_value;
+      _aidl_value = _aidl_parcel.readString();
+      _set(_aidl_tag, _aidl_value);
+      return; }
+    }
+    throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag);
+  }
+
+  @Override
+  public int describeContents() {
+    int _mask = 0;
+    switch (getTag()) {
+    }
+    return _mask;
+  }
+
+  private void _assertTag(int tag) {
+    if (getTag() != tag) {
+      throw new IllegalStateException("bad access: " + _tagString(tag) + ", " + _tagString(getTag()) + " is available.");
+    }
+  }
+
+  private String _tagString(int _tag) {
+    switch (_tag) {
+    case num: return "num";
+    case str: return "str";
+    }
+    throw new IllegalStateException("unknown field: " + _tag);
+  }
+
+  private void _set(int _tag, Object _value) {
+    this._tag = _tag;
+    this._value = _value;
+  }
+}
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java.d b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java.d
new file mode 100644
index 0000000..2059f00
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java : \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/timestamp b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/timestamp
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp
new file mode 100644
index 0000000..fb30496
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp
@@ -0,0 +1,78 @@
+#include "aidl/android/aidl/loggable/Data.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+const char* Data::descriptor = "android.aidl.loggable.Data";
+
+binder_status_t Data::readFromParcel(const AParcel* parcel) {
+  int32_t _aidl_parcelable_size;
+  int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);
+  if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;
+  if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_readInt32(parcel, &num);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &str);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readParcelable(parcel, &nestedUnion);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByte(parcel, reinterpret_cast<int8_t*>(&nestedEnum));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+  return _aidl_ret_status;
+}
+binder_status_t Data::writeToParcel(AParcel* parcel) const {
+  binder_status_t _aidl_ret_status;
+  size_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  _aidl_ret_status = AParcel_writeInt32(parcel, 0);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, num);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, str);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(parcel, nestedUnion);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByte(parcel, static_cast<int8_t>(nestedEnum));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  size_t _aidl_end_pos = AParcel_getDataPosition(parcel);
+  AParcel_setDataPosition(parcel, _aidl_start_pos);
+  AParcel_writeInt32(parcel, _aidl_end_pos - _aidl_start_pos);
+  AParcel_setDataPosition(parcel, _aidl_end_pos);
+  return _aidl_ret_status;
+}
+
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp.d
new file mode 100644
index 0000000..fbb8a7e
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Data.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp.d
new file mode 100644
index 0000000..2060e60
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Enum.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp
new file mode 100644
index 0000000..746013f
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp
@@ -0,0 +1,475 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/loggable/BpLoggableInterface.h>
+#include <aidl/android/aidl/loggable/BnLoggableInterface.h>
+#include <aidl/android/aidl/loggable/ILoggableInterface.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+template <typename _T> class _has_toString {
+  template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+  template <typename _U> static std::false_type __has_toString(...);
+  public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+};
+template <typename _T> inline static std::string _call_toString(const _T& t) {
+  if constexpr (_has_toString<_T>::value) return t.toString();
+  return "{no toString() implemented}";
+}
+class ScopedTrace {
+  public:
+  inline explicit ScopedTrace(const char* name) {
+  ATrace_beginSection(name);
+  }
+  inline ~ScopedTrace() {
+  ATrace_endSection();
+  }
+};
+static binder_status_t _aidl_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
+  (void)_aidl_in;
+  (void)_aidl_out;
+  binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
+  std::shared_ptr<BnLoggableInterface> _aidl_impl = std::static_pointer_cast<BnLoggableInterface>(::ndk::ICInterface::asInterface(_aidl_binder));
+  switch (_aidl_code) {
+    case (FIRST_CALL_TRANSACTION + 0 /*LogThis*/): {
+      bool in_boolValue;
+      std::vector<bool> in_boolArray;
+      int8_t in_byteValue;
+      std::vector<uint8_t> in_byteArray;
+      char16_t in_charValue;
+      std::vector<char16_t> in_charArray;
+      int32_t in_intValue;
+      std::vector<int32_t> in_intArray;
+      int64_t in_longValue;
+      std::vector<int64_t> in_longArray;
+      float in_floatValue;
+      std::vector<float> in_floatArray;
+      double in_doubleValue;
+      std::vector<double> in_doubleArray;
+      std::string in_stringValue;
+      std::vector<std::string> in_stringArray;
+      std::vector<std::string> in_listValue;
+      ::aidl::android::aidl::loggable::Data in_dataValue;
+      ::ndk::SpAIBinder in_binderValue;
+      ::ndk::ScopedFileDescriptor in_pfdValue;
+      std::vector<::ndk::ScopedFileDescriptor> in_pfdArray;
+      std::vector<std::string> _aidl_return;
+
+      ScopedTrace _aidl_trace("AIDL::ndk::ILoggableInterface::LogThis::server");
+      _aidl_ret_status = AParcel_readBool(_aidl_in, &in_boolValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_boolArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readByte(_aidl_in, &in_byteValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_byteArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readChar(_aidl_in, &in_charValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_charArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readInt32(_aidl_in, &in_intValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_intArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readInt64(_aidl_in, &in_longValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_longArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readFloat(_aidl_in, &in_floatValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_floatArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readDouble(_aidl_in, &in_doubleValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_doubleArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_stringValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_stringArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_listValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readParcelable(_aidl_in, &in_dataValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readNullableStrongBinder(_aidl_in, &in_binderValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readNullableParcelFileDescriptor(_aidl_in, &in_pfdValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_pfdArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      BnLoggableInterface::TransactionLog _transaction_log;
+      if (BnLoggableInterface::logFunc != nullptr) {
+        _transaction_log.input_args.emplace_back("in_boolValue", (in_boolValue?"true":"false"));
+        _transaction_log.input_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_byteValue", std::to_string(in_byteValue));
+        _transaction_log.input_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_charValue", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(in_charValue));
+        _transaction_log.input_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_intValue", std::to_string(in_intValue));
+        _transaction_log.input_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_longValue", std::to_string(in_longValue));
+        _transaction_log.input_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_floatValue", std::to_string(in_floatValue));
+        _transaction_log.input_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_doubleValue", std::to_string(in_doubleValue));
+        _transaction_log.input_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_stringValue", (std::ostringstream() << in_stringValue).str());
+        _transaction_log.input_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_dataValue", _call_toString(in_dataValue));
+        _transaction_log.input_args.emplace_back("in_binderValue", "");
+        _transaction_log.input_args.emplace_back("in_pfdValue", "");
+        _transaction_log.input_args.emplace_back("in_pfdArray", "");
+      }
+      auto _log_start = std::chrono::steady_clock::now();
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->LogThis(in_boolValue, &in_boolArray, in_byteValue, &in_byteArray, in_charValue, &in_charArray, in_intValue, &in_intArray, in_longValue, &in_longArray, in_floatValue, &in_floatArray, in_doubleValue, &in_doubleArray, in_stringValue, &in_stringArray, &in_listValue, in_dataValue, in_binderValue, &in_pfdValue, &in_pfdArray, &_aidl_return);
+      if (BnLoggableInterface::logFunc != nullptr) {
+        auto _log_end = std::chrono::steady_clock::now();
+        _transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end - _log_start).count();
+        _transaction_log.interface_name = "android.aidl.loggable.ILoggableInterface";
+        _transaction_log.method_name = "LogThis";
+        _transaction_log.stub_address = _aidl_impl.get();
+        _transaction_log.proxy_address = nullptr;
+        _transaction_log.exception_code = AStatus_getExceptionCode(_aidl_status.get());
+        _transaction_log.exception_message = AStatus_getMessage(_aidl_status.get());
+        _transaction_log.transaction_error = AStatus_getStatus(_aidl_status.get());
+        _transaction_log.service_specific_error_code = AStatus_getServiceSpecificError(_aidl_status.get());
+        _transaction_log.output_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_pfdValue", "");
+        _transaction_log.output_args.emplace_back("in_pfdArray", "");
+        _transaction_log.result = [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: _aidl_return) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+        BnLoggableInterface::logFunc(_transaction_log);
+      }
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_boolArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_byteArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_charArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_intArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_longArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_floatArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_doubleArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_stringArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_listValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeNullableParcelFileDescriptor(_aidl_out, in_pfdValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_pfdArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+  }
+  return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(ILoggableInterface::descriptor, _aidl_onTransact);
+
+BpLoggableInterface::BpLoggableInterface(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpLoggableInterface::~BpLoggableInterface() {}
+std::function<void(const BpLoggableInterface::TransactionLog&)> BpLoggableInterface::logFunc;
+
+::ndk::ScopedAStatus BpLoggableInterface::LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  BpLoggableInterface::TransactionLog _transaction_log;
+  if (BpLoggableInterface::logFunc != nullptr) {
+    _transaction_log.input_args.emplace_back("in_boolValue", (in_boolValue?"true":"false"));
+    _transaction_log.input_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_byteValue", std::to_string(in_byteValue));
+    _transaction_log.input_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_charValue", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(in_charValue));
+    _transaction_log.input_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_intValue", std::to_string(in_intValue));
+    _transaction_log.input_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_longValue", std::to_string(in_longValue));
+    _transaction_log.input_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_floatValue", std::to_string(in_floatValue));
+    _transaction_log.input_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_doubleValue", std::to_string(in_doubleValue));
+    _transaction_log.input_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_stringValue", (std::ostringstream() << in_stringValue).str());
+    _transaction_log.input_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_dataValue", _call_toString(in_dataValue));
+    _transaction_log.input_args.emplace_back("in_binderValue", "");
+    _transaction_log.input_args.emplace_back("in_pfdValue", "");
+    _transaction_log.input_args.emplace_back("in_pfdArray", "");
+  }
+  auto _log_start = std::chrono::steady_clock::now();
+  ScopedTrace _aidl_trace("AIDL::ndk::ILoggableInterface::LogThis::client");
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeBool(_aidl_in.get(), in_boolValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_boolArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeByte(_aidl_in.get(), in_byteValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_byteArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeChar(_aidl_in.get(), in_charValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_charArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32(_aidl_in.get(), in_intValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_intArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt64(_aidl_in.get(), in_longValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_longArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeFloat(_aidl_in.get(), in_floatValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_floatArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeDouble(_aidl_in.get(), in_doubleValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_doubleArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_stringValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_stringArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_listValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(_aidl_in.get(), in_dataValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableStrongBinder(_aidl_in.get(), in_binderValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableParcelFileDescriptor(_aidl_in.get(), *in_pfdValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_pfdArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 0 /*LogThis*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    0
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ILoggableInterface::getDefaultImpl()) {
+    _aidl_status = ILoggableInterface::getDefaultImpl()->LogThis(in_boolValue, in_boolArray, in_byteValue, in_byteArray, in_charValue, in_charArray, in_intValue, in_intArray, in_longValue, in_longArray, in_floatValue, in_floatArray, in_doubleValue, in_doubleArray, in_stringValue, in_stringArray, in_listValue, in_dataValue, in_binderValue, in_pfdValue, in_pfdArray, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_boolArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_byteArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_charArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_intArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_longArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_floatArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_doubleArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_stringArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_listValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readNullableParcelFileDescriptor(_aidl_out.get(), in_pfdValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_pfdArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  if (BpLoggableInterface::logFunc != nullptr) {
+    auto _log_end = std::chrono::steady_clock::now();
+    _transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end - _log_start).count();
+    _transaction_log.interface_name = "android.aidl.loggable.ILoggableInterface";
+    _transaction_log.method_name = "LogThis";
+    _transaction_log.stub_address = nullptr;
+    _transaction_log.proxy_address = static_cast<const void*>(this);
+    _transaction_log.exception_code = AStatus_getExceptionCode(_aidl_status.get());
+    _transaction_log.exception_message = AStatus_getMessage(_aidl_status.get());
+    _transaction_log.transaction_error = AStatus_getStatus(_aidl_status.get());
+    _transaction_log.service_specific_error_code = AStatus_getServiceSpecificError(_aidl_status.get());
+    _transaction_log.output_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_pfdValue", "");
+    _transaction_log.output_args.emplace_back("in_pfdArray", "");
+    _transaction_log.result = [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *_aidl_return) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    BpLoggableInterface::logFunc(_transaction_log);
+  }
+  return _aidl_status;
+}
+// Source for BnLoggableInterface
+BnLoggableInterface::BnLoggableInterface() {}
+BnLoggableInterface::~BnLoggableInterface() {}
+std::function<void(const BnLoggableInterface::TransactionLog&)> BnLoggableInterface::logFunc;
+::ndk::SpAIBinder BnLoggableInterface::createBinder() {
+  AIBinder* binder = AIBinder_new(_g_aidl_clazz, static_cast<void*>(this));
+  #ifdef BINDER_STABILITY_SUPPORT
+  AIBinder_markCompilationUnitStability(binder);
+  #endif  // BINDER_STABILITY_SUPPORT
+  return ::ndk::SpAIBinder(binder);
+}
+// Source for ILoggableInterface
+const char* ILoggableInterface::descriptor = "android.aidl.loggable.ILoggableInterface";
+ILoggableInterface::ILoggableInterface() {}
+ILoggableInterface::~ILoggableInterface() {}
+
+
+std::shared_ptr<ILoggableInterface> ILoggableInterface::fromBinder(const ::ndk::SpAIBinder& binder) {
+  if (!AIBinder_associateClass(binder.get(), _g_aidl_clazz)) { return nullptr; }
+  std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
+  if (interface) {
+    return std::static_pointer_cast<ILoggableInterface>(interface);
+  }
+  return ::ndk::SharedRefBase::make<BpLoggableInterface>(binder);
+}
+
+binder_status_t ILoggableInterface::writeToParcel(AParcel* parcel, const std::shared_ptr<ILoggableInterface>& instance) {
+  return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t ILoggableInterface::readFromParcel(const AParcel* parcel, std::shared_ptr<ILoggableInterface>* instance) {
+  ::ndk::SpAIBinder binder;
+  binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+  if (status != STATUS_OK) return status;
+  *instance = ILoggableInterface::fromBinder(binder);
+  return STATUS_OK;
+}
+bool ILoggableInterface::setDefaultImpl(const std::shared_ptr<ILoggableInterface>& impl) {
+  // Only one user of this interface can use this function
+  // at a time. This is a heuristic to detect if two different
+  // users in the same process use this function.
+  assert(!ILoggableInterface::default_impl);
+  if (impl) {
+    ILoggableInterface::default_impl = impl;
+    return true;
+  }
+  return false;
+}
+const std::shared_ptr<ILoggableInterface>& ILoggableInterface::getDefaultImpl() {
+  return ILoggableInterface::default_impl;
+}
+std::shared_ptr<ILoggableInterface> ILoggableInterface::default_impl = nullptr;
+::ndk::ScopedAStatus ILoggableInterfaceDefault::LogThis(bool /*in_boolValue*/, std::vector<bool>* /*in_boolArray*/, int8_t /*in_byteValue*/, std::vector<uint8_t>* /*in_byteArray*/, char16_t /*in_charValue*/, std::vector<char16_t>* /*in_charArray*/, int32_t /*in_intValue*/, std::vector<int32_t>* /*in_intArray*/, int64_t /*in_longValue*/, std::vector<int64_t>* /*in_longArray*/, float /*in_floatValue*/, std::vector<float>* /*in_floatArray*/, double /*in_doubleValue*/, std::vector<double>* /*in_doubleArray*/, const std::string& /*in_stringValue*/, std::vector<std::string>* /*in_stringArray*/, std::vector<std::string>* /*in_listValue*/, const ::aidl::android::aidl::loggable::Data& /*in_dataValue*/, const ::ndk::SpAIBinder& /*in_binderValue*/, ::ndk::ScopedFileDescriptor* /*in_pfdValue*/, std::vector<::ndk::ScopedFileDescriptor>* /*in_pfdArray*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::SpAIBinder ILoggableInterfaceDefault::asBinder() {
+  return ::ndk::SpAIBinder();
+}
+bool ILoggableInterfaceDefault::isRemote() {
+  return false;
+}
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d
new file mode 100644
index 0000000..f5c556d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/ILoggableInterface.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp
new file mode 100644
index 0000000..7d02d4d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp
@@ -0,0 +1,52 @@
+#include "aidl/android/aidl/loggable/Union.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+const char* Union::descriptor = "android.aidl.loggable.Union";
+
+binder_status_t Union::readFromParcel(const AParcel* _parcel) {
+  binder_status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_tag)) != STATUS_OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case num: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<num>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<num>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case str: {
+    std::string _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readString(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<std::string>) {
+      set<str>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<str>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  }
+  return STATUS_BAD_VALUE;
+}
+binder_status_t Union::writeToParcel(AParcel* _parcel) const {
+  binder_status_t _aidl_ret_status = AParcel_writeInt32(_parcel, getTag());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case num: return AParcel_writeInt32(_parcel, get<num>());
+  case str: return ::ndk::AParcel_writeString(_parcel, get<str>());
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp.d
new file mode 100644
index 0000000..2dba0dc
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/Union.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnData.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnData.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnData.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnEnum.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnEnum.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnLoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnLoggableInterface.h
new file mode 100644
index 0000000..650ca86
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnLoggableInterface.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "aidl/android/aidl/loggable/ILoggableInterface.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class BnLoggableInterface : public ::ndk::BnCInterface<ILoggableInterface> {
+public:
+  BnLoggableInterface();
+  virtual ~BnLoggableInterface();
+  struct TransactionLog {
+    double duration_ms;
+    std::string interface_name;
+    std::string method_name;
+    const void* proxy_address;
+    const void* stub_address;
+    std::vector<std::pair<std::string, std::string>> input_args;
+    std::vector<std::pair<std::string, std::string>> output_args;
+    std::string result;
+    std::string exception_message;
+    int32_t exception_code;
+    int32_t transaction_error;
+    int32_t service_specific_error_code;
+  };
+  static std::function<void(const TransactionLog&)> logFunc;
+protected:
+  ::ndk::SpAIBinder createBinder() override;
+private:
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnUnion.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnUnion.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BnUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpData.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpData.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpData.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpEnum.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpEnum.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpLoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpLoggableInterface.h
new file mode 100644
index 0000000..f7fc576
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpLoggableInterface.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "aidl/android/aidl/loggable/ILoggableInterface.h"
+
+#include <android/binder_ibinder.h>
+#include <functional>
+#include <chrono>
+#include <sstream>
+#include <android/trace.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class BpLoggableInterface : public ::ndk::BpCInterface<ILoggableInterface> {
+public:
+  explicit BpLoggableInterface(const ::ndk::SpAIBinder& binder);
+  virtual ~BpLoggableInterface();
+
+  ::ndk::ScopedAStatus LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) override;
+  struct TransactionLog {
+    double duration_ms;
+    std::string interface_name;
+    std::string method_name;
+    const void* proxy_address;
+    const void* stub_address;
+    std::vector<std::pair<std::string, std::string>> input_args;
+    std::vector<std::pair<std::string, std::string>> output_args;
+    std::string result;
+    std::string exception_message;
+    int32_t exception_code;
+    int32_t transaction_error;
+    int32_t service_specific_error_code;
+  };
+  static std::function<void(const TransactionLog&)> logFunc;
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpUnion.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpUnion.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/BpUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Data.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Data.h
new file mode 100644
index 0000000..b82bad6
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Data.h
@@ -0,0 +1,77 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/loggable/Enum.h>
+#include <aidl/android/aidl/loggable/Union.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class Data {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  int32_t num = 0;
+  std::string str;
+  ::aidl::android::aidl::loggable::Union nestedUnion;
+  ::aidl::android::aidl::loggable::Enum nestedEnum;
+
+  binder_status_t readFromParcel(const AParcel* parcel);
+  binder_status_t writeToParcel(AParcel* parcel) const;
+
+  inline bool operator!=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) != std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator<(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) < std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator<=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) <= std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator==(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) == std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator>(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) > std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator>=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) >= std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Data{";
+    os << "num: " << std::to_string(num);
+    os << ", str: " << (std::ostringstream() << str).str();
+    os << ", nestedUnion: " << _call_toString(nestedUnion);
+    os << ", nestedEnum: " << android::aidl::loggable::toString(nestedEnum);
+    os << "}";
+    return os.str();
+  }
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Enum.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Enum.h
new file mode 100644
index 0000000..0959460
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Enum.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+enum class Enum : int8_t {
+  FOO = 42,
+};
+
+static inline std::string toString(Enum val) {
+  switch(val) {
+  case Enum::FOO:
+    return "FOO";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::loggable::Enum, 1> enum_values<aidl::android::aidl::loggable::Enum> = {
+  aidl::android::aidl::loggable::Enum::FOO,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/ILoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/ILoggableInterface.h
new file mode 100644
index 0000000..33c79e1
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/ILoggableInterface.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#include <android/binder_interface_utils.h>
+#include <functional>
+#include <chrono>
+#include <sstream>
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/loggable/Data.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class ILoggableInterface : public ::ndk::ICInterface {
+public:
+  static const char* descriptor;
+  ILoggableInterface();
+  virtual ~ILoggableInterface();
+
+  static constexpr uint32_t TRANSACTION_LogThis = FIRST_CALL_TRANSACTION + 0;
+
+  static std::shared_ptr<ILoggableInterface> fromBinder(const ::ndk::SpAIBinder& binder);
+  static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<ILoggableInterface>& instance);
+  static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<ILoggableInterface>* instance);
+  static bool setDefaultImpl(const std::shared_ptr<ILoggableInterface>& impl);
+  static const std::shared_ptr<ILoggableInterface>& getDefaultImpl();
+  virtual ::ndk::ScopedAStatus LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) = 0;
+private:
+  static std::shared_ptr<ILoggableInterface> default_impl;
+};
+class ILoggableInterfaceDefault : public ILoggableInterface {
+public:
+  ::ndk::ScopedAStatus LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) override;
+  ::ndk::SpAIBinder asBinder() override;
+  bool isRemote() override;
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h
new file mode 100644
index 0000000..ef9f05c
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h
@@ -0,0 +1,136 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+
+#include <cassert>
+#include <type_traits>
+#include <utility>
+#include <variant>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class Union {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    str,  // String str;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
+
+  Union() : _value(std::in_place_index<num>, int32_t(43)) { }
+  Union(const Union&) = default;
+  Union(Union&&) = default;
+  Union& operator=(const Union&) = default;
+  Union& operator=(Union&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr Union(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit Union(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static Union make(_Tp&&... _args) {
+    return Union(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static Union make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return Union(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  binder_status_t readFromParcel(const AParcel* _parcel);
+  binder_status_t writeToParcel(AParcel* _parcel) const;
+
+  inline bool operator!=(const Union& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const Union& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const Union& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const Union& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const Union& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const Union& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Union{";
+    switch (getTag()) {
+    case num: os << "num: " << std::to_string(get<num>()); break;
+    case str: os << "str: " << (std::ostringstream() << get<str>()).str(); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<int32_t, std::string> _value;
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/timestamp b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/timestamp
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp
new file mode 100644
index 0000000..fb30496
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp
@@ -0,0 +1,78 @@
+#include "aidl/android/aidl/loggable/Data.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+const char* Data::descriptor = "android.aidl.loggable.Data";
+
+binder_status_t Data::readFromParcel(const AParcel* parcel) {
+  int32_t _aidl_parcelable_size;
+  int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);
+  if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;
+  if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_readInt32(parcel, &num);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readString(parcel, &str);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = ::ndk::AParcel_readParcelable(parcel, &nestedUnion);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  _aidl_ret_status = AParcel_readByte(parcel, reinterpret_cast<int8_t*>(&nestedEnum));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {
+    AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+    return _aidl_ret_status;
+  }
+  AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+  return _aidl_ret_status;
+}
+binder_status_t Data::writeToParcel(AParcel* parcel) const {
+  binder_status_t _aidl_ret_status;
+  size_t _aidl_start_pos = AParcel_getDataPosition(parcel);
+  _aidl_ret_status = AParcel_writeInt32(parcel, 0);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeInt32(parcel, num);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(parcel, str);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(parcel, nestedUnion);
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  _aidl_ret_status = AParcel_writeByte(parcel, static_cast<int8_t>(nestedEnum));
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+
+  size_t _aidl_end_pos = AParcel_getDataPosition(parcel);
+  AParcel_setDataPosition(parcel, _aidl_start_pos);
+  AParcel_writeInt32(parcel, _aidl_end_pos - _aidl_start_pos);
+  AParcel_setDataPosition(parcel, _aidl_end_pos);
+  return _aidl_ret_status;
+}
+
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp.d
new file mode 100644
index 0000000..490370d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp.d
@@ -0,0 +1,4 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Data.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp
@@ -0,0 +1 @@
+// This file is intentionally left blank as placeholder for enum declaration.
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp.d
new file mode 100644
index 0000000..ea5065b
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Enum.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Enum.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp
new file mode 100644
index 0000000..746013f
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp
@@ -0,0 +1,475 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/loggable/BpLoggableInterface.h>
+#include <aidl/android/aidl/loggable/BnLoggableInterface.h>
+#include <aidl/android/aidl/loggable/ILoggableInterface.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+template <typename _T> class _has_toString {
+  template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+  template <typename _U> static std::false_type __has_toString(...);
+  public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+};
+template <typename _T> inline static std::string _call_toString(const _T& t) {
+  if constexpr (_has_toString<_T>::value) return t.toString();
+  return "{no toString() implemented}";
+}
+class ScopedTrace {
+  public:
+  inline explicit ScopedTrace(const char* name) {
+  ATrace_beginSection(name);
+  }
+  inline ~ScopedTrace() {
+  ATrace_endSection();
+  }
+};
+static binder_status_t _aidl_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
+  (void)_aidl_in;
+  (void)_aidl_out;
+  binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
+  std::shared_ptr<BnLoggableInterface> _aidl_impl = std::static_pointer_cast<BnLoggableInterface>(::ndk::ICInterface::asInterface(_aidl_binder));
+  switch (_aidl_code) {
+    case (FIRST_CALL_TRANSACTION + 0 /*LogThis*/): {
+      bool in_boolValue;
+      std::vector<bool> in_boolArray;
+      int8_t in_byteValue;
+      std::vector<uint8_t> in_byteArray;
+      char16_t in_charValue;
+      std::vector<char16_t> in_charArray;
+      int32_t in_intValue;
+      std::vector<int32_t> in_intArray;
+      int64_t in_longValue;
+      std::vector<int64_t> in_longArray;
+      float in_floatValue;
+      std::vector<float> in_floatArray;
+      double in_doubleValue;
+      std::vector<double> in_doubleArray;
+      std::string in_stringValue;
+      std::vector<std::string> in_stringArray;
+      std::vector<std::string> in_listValue;
+      ::aidl::android::aidl::loggable::Data in_dataValue;
+      ::ndk::SpAIBinder in_binderValue;
+      ::ndk::ScopedFileDescriptor in_pfdValue;
+      std::vector<::ndk::ScopedFileDescriptor> in_pfdArray;
+      std::vector<std::string> _aidl_return;
+
+      ScopedTrace _aidl_trace("AIDL::ndk::ILoggableInterface::LogThis::server");
+      _aidl_ret_status = AParcel_readBool(_aidl_in, &in_boolValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_boolArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readByte(_aidl_in, &in_byteValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_byteArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readChar(_aidl_in, &in_charValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_charArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readInt32(_aidl_in, &in_intValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_intArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readInt64(_aidl_in, &in_longValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_longArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readFloat(_aidl_in, &in_floatValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_floatArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = AParcel_readDouble(_aidl_in, &in_doubleValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_doubleArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readString(_aidl_in, &in_stringValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_stringArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_listValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readParcelable(_aidl_in, &in_dataValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readNullableStrongBinder(_aidl_in, &in_binderValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readNullableParcelFileDescriptor(_aidl_in, &in_pfdValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_in, &in_pfdArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      BnLoggableInterface::TransactionLog _transaction_log;
+      if (BnLoggableInterface::logFunc != nullptr) {
+        _transaction_log.input_args.emplace_back("in_boolValue", (in_boolValue?"true":"false"));
+        _transaction_log.input_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_byteValue", std::to_string(in_byteValue));
+        _transaction_log.input_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_charValue", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(in_charValue));
+        _transaction_log.input_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_intValue", std::to_string(in_intValue));
+        _transaction_log.input_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_longValue", std::to_string(in_longValue));
+        _transaction_log.input_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_floatValue", std::to_string(in_floatValue));
+        _transaction_log.input_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_doubleValue", std::to_string(in_doubleValue));
+        _transaction_log.input_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_stringValue", (std::ostringstream() << in_stringValue).str());
+        _transaction_log.input_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.input_args.emplace_back("in_dataValue", _call_toString(in_dataValue));
+        _transaction_log.input_args.emplace_back("in_binderValue", "");
+        _transaction_log.input_args.emplace_back("in_pfdValue", "");
+        _transaction_log.input_args.emplace_back("in_pfdArray", "");
+      }
+      auto _log_start = std::chrono::steady_clock::now();
+      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->LogThis(in_boolValue, &in_boolArray, in_byteValue, &in_byteArray, in_charValue, &in_charArray, in_intValue, &in_intArray, in_longValue, &in_longArray, in_floatValue, &in_floatArray, in_doubleValue, &in_doubleArray, in_stringValue, &in_stringArray, &in_listValue, in_dataValue, in_binderValue, &in_pfdValue, &in_pfdArray, &_aidl_return);
+      if (BnLoggableInterface::logFunc != nullptr) {
+        auto _log_end = std::chrono::steady_clock::now();
+        _transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end - _log_start).count();
+        _transaction_log.interface_name = "android.aidl.loggable.ILoggableInterface";
+        _transaction_log.method_name = "LogThis";
+        _transaction_log.stub_address = _aidl_impl.get();
+        _transaction_log.proxy_address = nullptr;
+        _transaction_log.exception_code = AStatus_getExceptionCode(_aidl_status.get());
+        _transaction_log.exception_message = AStatus_getMessage(_aidl_status.get());
+        _transaction_log.transaction_error = AStatus_getStatus(_aidl_status.get());
+        _transaction_log.service_specific_error_code = AStatus_getServiceSpecificError(_aidl_status.get());
+        _transaction_log.output_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+        _transaction_log.output_args.emplace_back("in_pfdValue", "");
+        _transaction_log.output_args.emplace_back("in_pfdArray", "");
+        _transaction_log.result = [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: _aidl_return) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+        BnLoggableInterface::logFunc(_transaction_log);
+      }
+      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      if (!AStatus_isOk(_aidl_status.get())) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, _aidl_return);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_boolArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_byteArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_charArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_intArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_longArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_floatArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_doubleArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_stringArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_listValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeNullableParcelFileDescriptor(_aidl_out, in_pfdValue);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_out, in_pfdArray);
+      if (_aidl_ret_status != STATUS_OK) break;
+
+      break;
+    }
+  }
+  return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(ILoggableInterface::descriptor, _aidl_onTransact);
+
+BpLoggableInterface::BpLoggableInterface(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpLoggableInterface::~BpLoggableInterface() {}
+std::function<void(const BpLoggableInterface::TransactionLog&)> BpLoggableInterface::logFunc;
+
+::ndk::ScopedAStatus BpLoggableInterface::LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) {
+  binder_status_t _aidl_ret_status = STATUS_OK;
+  ::ndk::ScopedAStatus _aidl_status;
+  ::ndk::ScopedAParcel _aidl_in;
+  ::ndk::ScopedAParcel _aidl_out;
+
+  BpLoggableInterface::TransactionLog _transaction_log;
+  if (BpLoggableInterface::logFunc != nullptr) {
+    _transaction_log.input_args.emplace_back("in_boolValue", (in_boolValue?"true":"false"));
+    _transaction_log.input_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_byteValue", std::to_string(in_byteValue));
+    _transaction_log.input_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_charValue", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(in_charValue));
+    _transaction_log.input_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_intValue", std::to_string(in_intValue));
+    _transaction_log.input_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_longValue", std::to_string(in_longValue));
+    _transaction_log.input_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_floatValue", std::to_string(in_floatValue));
+    _transaction_log.input_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_doubleValue", std::to_string(in_doubleValue));
+    _transaction_log.input_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_stringValue", (std::ostringstream() << in_stringValue).str());
+    _transaction_log.input_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.input_args.emplace_back("in_dataValue", _call_toString(in_dataValue));
+    _transaction_log.input_args.emplace_back("in_binderValue", "");
+    _transaction_log.input_args.emplace_back("in_pfdValue", "");
+    _transaction_log.input_args.emplace_back("in_pfdArray", "");
+  }
+  auto _log_start = std::chrono::steady_clock::now();
+  ScopedTrace _aidl_trace("AIDL::ndk::ILoggableInterface::LogThis::client");
+  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeBool(_aidl_in.get(), in_boolValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_boolArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeByte(_aidl_in.get(), in_byteValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_byteArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeChar(_aidl_in.get(), in_charValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_charArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt32(_aidl_in.get(), in_intValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_intArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeInt64(_aidl_in.get(), in_longValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_longArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeFloat(_aidl_in.get(), in_floatValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_floatArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_writeDouble(_aidl_in.get(), in_doubleValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_doubleArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeString(_aidl_in.get(), in_stringValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_stringArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_listValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeParcelable(_aidl_in.get(), in_dataValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableStrongBinder(_aidl_in.get(), in_binderValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeNullableParcelFileDescriptor(_aidl_in.get(), *in_pfdValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_writeVector(_aidl_in.get(), *in_pfdArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AIBinder_transact(
+    asBinder().get(),
+    (FIRST_CALL_TRANSACTION + 0 /*LogThis*/),
+    _aidl_in.getR(),
+    _aidl_out.getR(),
+    0
+    #ifdef BINDER_STABILITY_SUPPORT
+    | FLAG_PRIVATE_LOCAL
+    #endif  // BINDER_STABILITY_SUPPORT
+    );
+  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ILoggableInterface::getDefaultImpl()) {
+    _aidl_status = ILoggableInterface::getDefaultImpl()->LogThis(in_boolValue, in_boolArray, in_byteValue, in_byteArray, in_charValue, in_charArray, in_intValue, in_intArray, in_longValue, in_longArray, in_floatValue, in_floatArray, in_doubleValue, in_doubleArray, in_stringValue, in_stringArray, in_listValue, in_dataValue, in_binderValue, in_pfdValue, in_pfdArray, _aidl_return);
+    goto _aidl_status_return;
+  }
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), _aidl_return);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_boolArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_byteArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_charArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_intArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_longArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_floatArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_doubleArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_stringArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_listValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readNullableParcelFileDescriptor(_aidl_out.get(), in_pfdValue);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_ret_status = ::ndk::AParcel_readVector(_aidl_out.get(), in_pfdArray);
+  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+  _aidl_error:
+  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
+  _aidl_status_return:
+  if (BpLoggableInterface::logFunc != nullptr) {
+    auto _log_end = std::chrono::steady_clock::now();
+    _transaction_log.duration_ms = std::chrono::duration<double, std::milli>(_log_end - _log_start).count();
+    _transaction_log.interface_name = "android.aidl.loggable.ILoggableInterface";
+    _transaction_log.method_name = "LogThis";
+    _transaction_log.stub_address = nullptr;
+    _transaction_log.proxy_address = static_cast<const void*>(this);
+    _transaction_log.exception_code = AStatus_getExceptionCode(_aidl_status.get());
+    _transaction_log.exception_message = AStatus_getMessage(_aidl_status.get());
+    _transaction_log.transaction_error = AStatus_getStatus(_aidl_status.get());
+    _transaction_log.service_specific_error_code = AStatus_getServiceSpecificError(_aidl_status.get());
+    _transaction_log.output_args.emplace_back("in_boolArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_boolArray) { (void)v; if (first) first = false; else o << ", "; o << (v?"true":"false"); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_byteArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_byteArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_charArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_charArray) { (void)v; if (first) first = false; else o << ", "; o << std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_intArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_intArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_longArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_longArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_floatArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_floatArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_doubleArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_doubleArray) { (void)v; if (first) first = false; else o << ", "; o << std::to_string(v); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_stringArray", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_stringArray) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_listValue", [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *in_listValue) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }());
+    _transaction_log.output_args.emplace_back("in_pfdValue", "");
+    _transaction_log.output_args.emplace_back("in_pfdArray", "");
+    _transaction_log.result = [&](){ std::ostringstream o; o << "["; bool first = true; for (const auto& v: *_aidl_return) { (void)v; if (first) first = false; else o << ", "; o << (std::ostringstream() << v).str(); }; o << "]"; return o.str(); }();
+    BpLoggableInterface::logFunc(_transaction_log);
+  }
+  return _aidl_status;
+}
+// Source for BnLoggableInterface
+BnLoggableInterface::BnLoggableInterface() {}
+BnLoggableInterface::~BnLoggableInterface() {}
+std::function<void(const BnLoggableInterface::TransactionLog&)> BnLoggableInterface::logFunc;
+::ndk::SpAIBinder BnLoggableInterface::createBinder() {
+  AIBinder* binder = AIBinder_new(_g_aidl_clazz, static_cast<void*>(this));
+  #ifdef BINDER_STABILITY_SUPPORT
+  AIBinder_markCompilationUnitStability(binder);
+  #endif  // BINDER_STABILITY_SUPPORT
+  return ::ndk::SpAIBinder(binder);
+}
+// Source for ILoggableInterface
+const char* ILoggableInterface::descriptor = "android.aidl.loggable.ILoggableInterface";
+ILoggableInterface::ILoggableInterface() {}
+ILoggableInterface::~ILoggableInterface() {}
+
+
+std::shared_ptr<ILoggableInterface> ILoggableInterface::fromBinder(const ::ndk::SpAIBinder& binder) {
+  if (!AIBinder_associateClass(binder.get(), _g_aidl_clazz)) { return nullptr; }
+  std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
+  if (interface) {
+    return std::static_pointer_cast<ILoggableInterface>(interface);
+  }
+  return ::ndk::SharedRefBase::make<BpLoggableInterface>(binder);
+}
+
+binder_status_t ILoggableInterface::writeToParcel(AParcel* parcel, const std::shared_ptr<ILoggableInterface>& instance) {
+  return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t ILoggableInterface::readFromParcel(const AParcel* parcel, std::shared_ptr<ILoggableInterface>* instance) {
+  ::ndk::SpAIBinder binder;
+  binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+  if (status != STATUS_OK) return status;
+  *instance = ILoggableInterface::fromBinder(binder);
+  return STATUS_OK;
+}
+bool ILoggableInterface::setDefaultImpl(const std::shared_ptr<ILoggableInterface>& impl) {
+  // Only one user of this interface can use this function
+  // at a time. This is a heuristic to detect if two different
+  // users in the same process use this function.
+  assert(!ILoggableInterface::default_impl);
+  if (impl) {
+    ILoggableInterface::default_impl = impl;
+    return true;
+  }
+  return false;
+}
+const std::shared_ptr<ILoggableInterface>& ILoggableInterface::getDefaultImpl() {
+  return ILoggableInterface::default_impl;
+}
+std::shared_ptr<ILoggableInterface> ILoggableInterface::default_impl = nullptr;
+::ndk::ScopedAStatus ILoggableInterfaceDefault::LogThis(bool /*in_boolValue*/, std::vector<bool>* /*in_boolArray*/, int8_t /*in_byteValue*/, std::vector<uint8_t>* /*in_byteArray*/, char16_t /*in_charValue*/, std::vector<char16_t>* /*in_charArray*/, int32_t /*in_intValue*/, std::vector<int32_t>* /*in_intArray*/, int64_t /*in_longValue*/, std::vector<int64_t>* /*in_longArray*/, float /*in_floatValue*/, std::vector<float>* /*in_floatArray*/, double /*in_doubleValue*/, std::vector<double>* /*in_doubleArray*/, const std::string& /*in_stringValue*/, std::vector<std::string>* /*in_stringArray*/, std::vector<std::string>* /*in_listValue*/, const ::aidl::android::aidl::loggable::Data& /*in_dataValue*/, const ::ndk::SpAIBinder& /*in_binderValue*/, ::ndk::ScopedFileDescriptor* /*in_pfdValue*/, std::vector<::ndk::ScopedFileDescriptor>* /*in_pfdArray*/, std::vector<std::string>* /*_aidl_return*/) {
+  ::ndk::ScopedAStatus _aidl_status;
+  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
+  return _aidl_status;
+}
+::ndk::SpAIBinder ILoggableInterfaceDefault::asBinder() {
+  return ::ndk::SpAIBinder();
+}
+bool ILoggableInterfaceDefault::isRemote() {
+  return false;
+}
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d
new file mode 100644
index 0000000..2816dc0
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/ILoggableInterface.aidl \
+  system/tools/aidl/tests/android/aidl/loggable/Data.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp
new file mode 100644
index 0000000..7d02d4d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp
@@ -0,0 +1,52 @@
+#include "aidl/android/aidl/loggable/Union.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+const char* Union::descriptor = "android.aidl.loggable.Union";
+
+binder_status_t Union::readFromParcel(const AParcel* _parcel) {
+  binder_status_t _aidl_ret_status;
+  int32_t _aidl_tag;
+  if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_tag)) != STATUS_OK) return _aidl_ret_status;
+  switch (_aidl_tag) {
+  case num: {
+    int32_t _aidl_value;
+    if ((_aidl_ret_status = AParcel_readInt32(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<int32_t>) {
+      set<num>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<num>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  case str: {
+    std::string _aidl_value;
+    if ((_aidl_ret_status = ::ndk::AParcel_readString(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+    if constexpr (std::is_trivially_copyable_v<std::string>) {
+      set<str>(_aidl_value);
+    } else {
+      // NOLINTNEXTLINE(performance-move-const-arg)
+      set<str>(std::move(_aidl_value));
+    }
+    return STATUS_OK; }
+  }
+  return STATUS_BAD_VALUE;
+}
+binder_status_t Union::writeToParcel(AParcel* _parcel) const {
+  binder_status_t _aidl_ret_status = AParcel_writeInt32(_parcel, getTag());
+  if (_aidl_ret_status != STATUS_OK) return _aidl_ret_status;
+  switch (getTag()) {
+  case num: return AParcel_writeInt32(_parcel, get<num>());
+  case str: return ::ndk::AParcel_writeString(_parcel, get<str>());
+  }
+  __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
+}
+
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp.d b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp.d
new file mode 100644
index 0000000..0968751
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/Union.cpp : \
+  system/tools/aidl/tests/android/aidl/loggable/Union.aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnData.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnData.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnData.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnEnum.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnEnum.h
new file mode 100644
index 0000000..e85bbc8
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bn classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnLoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnLoggableInterface.h
new file mode 100644
index 0000000..650ca86
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnLoggableInterface.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "aidl/android/aidl/loggable/ILoggableInterface.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class BnLoggableInterface : public ::ndk::BnCInterface<ILoggableInterface> {
+public:
+  BnLoggableInterface();
+  virtual ~BnLoggableInterface();
+  struct TransactionLog {
+    double duration_ms;
+    std::string interface_name;
+    std::string method_name;
+    const void* proxy_address;
+    const void* stub_address;
+    std::vector<std::pair<std::string, std::string>> input_args;
+    std::vector<std::pair<std::string, std::string>> output_args;
+    std::string result;
+    std::string exception_message;
+    int32_t exception_code;
+    int32_t transaction_error;
+    int32_t service_specific_error_code;
+  };
+  static std::function<void(const TransactionLog&)> logFunc;
+protected:
+  ::ndk::SpAIBinder createBinder() override;
+private:
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnUnion.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnUnion.h
new file mode 100644
index 0000000..4291108
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BnUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bn classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpData.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpData.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpData.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpEnum.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpEnum.h
new file mode 100644
index 0000000..74a2c6d
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpEnum.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) enums do not have bp classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpLoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpLoggableInterface.h
new file mode 100644
index 0000000..f7fc576
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpLoggableInterface.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "aidl/android/aidl/loggable/ILoggableInterface.h"
+
+#include <android/binder_ibinder.h>
+#include <functional>
+#include <chrono>
+#include <sstream>
+#include <android/trace.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class BpLoggableInterface : public ::ndk::BpCInterface<ILoggableInterface> {
+public:
+  explicit BpLoggableInterface(const ::ndk::SpAIBinder& binder);
+  virtual ~BpLoggableInterface();
+
+  ::ndk::ScopedAStatus LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) override;
+  struct TransactionLog {
+    double duration_ms;
+    std::string interface_name;
+    std::string method_name;
+    const void* proxy_address;
+    const void* stub_address;
+    std::vector<std::pair<std::string, std::string>> input_args;
+    std::vector<std::pair<std::string, std::string>> output_args;
+    std::string result;
+    std::string exception_message;
+    int32_t exception_code;
+    int32_t transaction_error;
+    int32_t service_specific_error_code;
+  };
+  static std::function<void(const TransactionLog&)> logFunc;
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpUnion.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpUnion.h
new file mode 100644
index 0000000..e8a0db3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/BpUnion.h
@@ -0,0 +1 @@
+#error TODO(b/111362593) defined_types do not have bp classes
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Data.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Data.h
new file mode 100644
index 0000000..b82bad6
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Data.h
@@ -0,0 +1,77 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/loggable/Enum.h>
+#include <aidl/android/aidl/loggable/Union.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class Data {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  int32_t num = 0;
+  std::string str;
+  ::aidl::android::aidl::loggable::Union nestedUnion;
+  ::aidl::android::aidl::loggable::Enum nestedEnum;
+
+  binder_status_t readFromParcel(const AParcel* parcel);
+  binder_status_t writeToParcel(AParcel* parcel) const;
+
+  inline bool operator!=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) != std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator<(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) < std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator<=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) <= std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator==(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) == std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator>(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) > std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+  inline bool operator>=(const Data& rhs) const {
+    return std::tie(num, str, nestedUnion, nestedEnum) >= std::tie(rhs.num, rhs.str, rhs.nestedUnion, rhs.nestedEnum);
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Data{";
+    os << "num: " << std::to_string(num);
+    os << ", str: " << (std::ostringstream() << str).str();
+    os << ", nestedUnion: " << _call_toString(nestedUnion);
+    os << ", nestedEnum: " << android::aidl::loggable::toString(nestedEnum);
+    os << "}";
+    return os.str();
+  }
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Enum.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Enum.h
new file mode 100644
index 0000000..0959460
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Enum.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <array>
+#include <android/binder_enums.h>
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+enum class Enum : int8_t {
+  FOO = 42,
+};
+
+static inline std::string toString(Enum val) {
+  switch(val) {
+  case Enum::FOO:
+    return "FOO";
+  default:
+    return std::to_string(static_cast<int8_t>(val));
+  }
+}
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+template <>
+constexpr inline std::array<aidl::android::aidl::loggable::Enum, 1> enum_values<aidl::android::aidl::loggable::Enum> = {
+  aidl::android::aidl::loggable::Enum::FOO,
+};
+#pragma clang diagnostic pop
+}  // namespace internal
+}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/ILoggableInterface.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/ILoggableInterface.h
new file mode 100644
index 0000000..33c79e1
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/ILoggableInterface.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#include <android/binder_interface_utils.h>
+#include <functional>
+#include <chrono>
+#include <sstream>
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+#include <aidl/android/aidl/loggable/Data.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class ILoggableInterface : public ::ndk::ICInterface {
+public:
+  static const char* descriptor;
+  ILoggableInterface();
+  virtual ~ILoggableInterface();
+
+  static constexpr uint32_t TRANSACTION_LogThis = FIRST_CALL_TRANSACTION + 0;
+
+  static std::shared_ptr<ILoggableInterface> fromBinder(const ::ndk::SpAIBinder& binder);
+  static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<ILoggableInterface>& instance);
+  static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<ILoggableInterface>* instance);
+  static bool setDefaultImpl(const std::shared_ptr<ILoggableInterface>& impl);
+  static const std::shared_ptr<ILoggableInterface>& getDefaultImpl();
+  virtual ::ndk::ScopedAStatus LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) = 0;
+private:
+  static std::shared_ptr<ILoggableInterface> default_impl;
+};
+class ILoggableInterfaceDefault : public ILoggableInterface {
+public:
+  ::ndk::ScopedAStatus LogThis(bool in_boolValue, std::vector<bool>* in_boolArray, int8_t in_byteValue, std::vector<uint8_t>* in_byteArray, char16_t in_charValue, std::vector<char16_t>* in_charArray, int32_t in_intValue, std::vector<int32_t>* in_intArray, int64_t in_longValue, std::vector<int64_t>* in_longArray, float in_floatValue, std::vector<float>* in_floatArray, double in_doubleValue, std::vector<double>* in_doubleArray, const std::string& in_stringValue, std::vector<std::string>* in_stringArray, std::vector<std::string>* in_listValue, const ::aidl::android::aidl::loggable::Data& in_dataValue, const ::ndk::SpAIBinder& in_binderValue, ::ndk::ScopedFileDescriptor* in_pfdValue, std::vector<::ndk::ScopedFileDescriptor>* in_pfdArray, std::vector<std::string>* _aidl_return) override;
+  ::ndk::SpAIBinder asBinder() override;
+  bool isRemote() override;
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Union.h b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Union.h
new file mode 100644
index 0000000..ef9f05c
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Union.h
@@ -0,0 +1,136 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <codecvt>
+#include <locale>
+#include <sstream>
+
+#include <cassert>
+#include <type_traits>
+#include <utility>
+#include <variant>
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+#ifdef BINDER_STABILITY_SUPPORT
+#include <android/binder_stability.h>
+#endif  // BINDER_STABILITY_SUPPORT
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+class Union {
+public:
+  typedef std::false_type fixed_size;
+  static const char* descriptor;
+
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    str,  // String str;
+  };
+
+  template<typename _Tp>
+  static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
+
+  Union() : _value(std::in_place_index<num>, int32_t(43)) { }
+  Union(const Union&) = default;
+  Union(Union&&) = default;
+  Union& operator=(const Union&) = default;
+  Union& operator=(Union&&) = default;
+
+  template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+  // NOLINTNEXTLINE(google-explicit-constructor)
+  constexpr Union(_Tp&& _arg)
+      : _value(std::forward<_Tp>(_arg)) {}
+
+  template <typename... _Tp>
+  constexpr explicit Union(_Tp&&... _args)
+      : _value(std::forward<_Tp>(_args)...) {}
+
+  template <Tag _tag, typename... _Tp>
+  static Union make(_Tp&&... _args) {
+    return Union(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+  }
+
+  template <Tag _tag, typename _Tp, typename... _Up>
+  static Union make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+    return Union(std::in_place_index<_tag>, std::move(_il), std::forward<_Up>(_args)...);
+  }
+
+  Tag getTag() const {
+    return static_cast<Tag>(_value.index());
+  }
+
+  template <Tag _tag>
+  const auto& get() const {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag>
+  auto& get() {
+    if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
+    return std::get<_tag>(_value);
+  }
+
+  template <Tag _tag, typename... _Tp>
+  void set(_Tp&&... _args) {
+    _value.emplace<_tag>(std::forward<_Tp>(_args)...);
+  }
+
+  binder_status_t readFromParcel(const AParcel* _parcel);
+  binder_status_t writeToParcel(AParcel* _parcel) const;
+
+  inline bool operator!=(const Union& rhs) const {
+    return _value != rhs._value;
+  }
+  inline bool operator<(const Union& rhs) const {
+    return _value < rhs._value;
+  }
+  inline bool operator<=(const Union& rhs) const {
+    return _value <= rhs._value;
+  }
+  inline bool operator==(const Union& rhs) const {
+    return _value == rhs._value;
+  }
+  inline bool operator>(const Union& rhs) const {
+    return _value > rhs._value;
+  }
+  inline bool operator>=(const Union& rhs) const {
+    return _value >= rhs._value;
+  }
+
+  static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+  template <typename _T> class _has_toString {
+    template <typename _U> static std::true_type __has_toString(decltype(&_U::toString));
+    template <typename _U> static std::false_type __has_toString(...);
+    public: enum { value = decltype(__has_toString<_T>(nullptr))::value };
+  };
+  template <typename _T> inline static std::string _call_toString(const _T& t) {
+    if constexpr (_has_toString<_T>::value) return t.toString();
+    return "{no toString() implemented}";
+  }
+  inline std::string toString() const {
+    std::ostringstream os;
+    os << "Union{";
+    switch (getTag()) {
+    case num: os << "num: " << std::to_string(get<num>()); break;
+    case str: os << "str: " << (std::ostringstream() << get<str>()).str(); break;
+    }
+    os << "}";
+    return os.str();
+  }
+private:
+  std::variant<int32_t, std::string> _value;
+};
+}  // namespace loggable
+}  // namespace aidl
+}  // namespace android
+}  // namespace aidl
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/timestamp b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/timestamp
diff --git a/tests/golden_test.sh b/tests/golden_test.sh
new file mode 100755
index 0000000..826eba3
--- /dev/null
+++ b/tests/golden_test.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+if [ $# != 1 ]; then
+  echo "Usage: golden_test.sh [check|update]"
+fi
+
+function _golden_test() {
+  local update=0
+  case $1 in
+    check)
+      update=0
+      ;;
+    update)
+      update=1
+      ;;
+    *)
+      echo "Argument must be 'check' or 'update'"
+      exit 1
+      ;;
+  esac
+
+  # warning: this list must be kept in sync with system/tools/aidl/Android.bp
+  modules=(
+    "aidl-test-interface-cpp-source"
+    "aidl-test-interface-java-source"
+    "aidl-test-interface-ndk_platform-source"
+    "aidl-test-interface-rust-source"
+    "aidl_test_loggable_interface-cpp-source"
+    "aidl_test_loggable_interface-java-source"
+    "aidl_test_loggable_interface-ndk_platform-source"
+    "aidl_test_loggable_interface-ndk-source"
+  )
+
+  local root="."
+  if [ "$ANDROID_BUILD_TOP" != "" ]; then
+    root="$ANDROID_BUILD_TOP"
+  fi
+
+  if [ "$update" = 1 ]; then
+    "$root"/build/soong/soong_ui.bash --make-mode \
+      $(for i in "${modules[@]}"; do
+          echo "$i" | sed 's/-source//'
+        done)
+  fi
+
+  local e=0
+  for module in "${modules[@]}"; do
+    local built="$root/out/soong/.intermediates/system/tools/aidl/$module/"
+    local golden="$root/system/tools/aidl/tests/golden_output/$module/"
+
+    if [ "$update" = 1 ]; then
+      rm -rf "$golden"
+      mkdir -p "$golden"
+      cp -r "$built" "$golden/.."
+    else
+      diff -r "$built" "$golden" || e=1
+    fi
+  done
+
+  if [ "$e" = 1 ]; then
+    echo "ERROR: The AIDL compiler is outputting files in an unknown way."
+    echo "ERROR: to accept these changes, please run:"
+    echo "ERROR:     \$ANDROID_BUILD_TOP/system/tools/aidl/tests/golden_test.sh update"
+    exit 1
+  else
+    if [ "$update" = 1 ]; then
+      echo "UPDATE GOLDEN TEST SUCCESS"
+    fi
+  fi
+}
+
+_golden_test "$@"
diff --git a/tests/java/src/android/aidl/tests/AidlJavaTests.java b/tests/java/src/android/aidl/tests/AidlJavaTests.java
new file mode 100644
index 0000000..b53c96f
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/AidlJavaTests.java
@@ -0,0 +1,18 @@
+package android.aidl.tests;
+
+import org.junit.internal.TextListener;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+
+public class AidlJavaTests {
+
+    public static void main(String[] args) {
+        JUnitCore junit = new JUnitCore();
+        junit.addListener(new TextListener(System.out));
+        Result result = junit.run(ExtensionTests.class, GenericTests.class,
+            JavaOnlyImmutableAnnotationTests.class, MapTests.class, NullableTests.class,
+            TestServiceClient.class, TestVersionedInterface.class, UnionTests.class);
+
+        System.out.println(result.wasSuccessful() ? "TEST SUCCESS" : "TEST FAILURE");
+    }
+}
diff --git a/tests/java_app/src/android/aidl/tests/ExtensionTests.java b/tests/java/src/android/aidl/tests/ExtensionTests.java
similarity index 74%
rename from tests/java_app/src/android/aidl/tests/ExtensionTests.java
rename to tests/java/src/android/aidl/tests/ExtensionTests.java
index edfb3fe..3f06276 100644
--- a/tests/java_app/src/android/aidl/tests/ExtensionTests.java
+++ b/tests/java/src/android/aidl/tests/ExtensionTests.java
@@ -20,6 +20,8 @@
 import static org.hamcrest.core.IsNull.nullValue;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeTrue;
+import static org.testng.Assert.assertThrows;
 
 import android.aidl.tests.extension.ExtendableParcelable;
 import android.aidl.tests.extension.MyExt;
@@ -31,6 +33,7 @@
 import android.aidl.tests.unstable.UnstableParcelable;
 import android.aidl.tests.vintf.VintfExtendableParcelable;
 import android.aidl.tests.vintf.VintfParcelable;
+import android.os.BadParcelableException;
 import android.os.IBinder;
 import android.os.Parcel;
 import android.os.ParcelableHolder;
@@ -55,14 +58,20 @@
     private UnstableParcelable up;
 
     private ITestService mService;
+    private ICppJavaTests mCppJavaTests;
 
     @Before
-    public void setUp() {
+    public void setUp() throws RemoteException {
       IBinder binder = ServiceManager.getService(ITestService.class.getName());
       assertNotNull(binder);
       mService = ITestService.Stub.asInterface(binder);
       assertNotNull(mService);
 
+      IBinder binder2 = mService.GetCppJavaTests();
+      if (binder2 != null) {
+        mCppJavaTests = ICppJavaTests.Stub.asInterface(binder2);
+      }
+
       vep = new VintfExtendableParcelable();
       vp = new VintfParcelable();
 
@@ -75,6 +84,8 @@
 
     @Test
     public void testRepeatExtendableParcelable() throws RemoteException {
+      assumeTrue(mCppJavaTests != null);
+
       MyExt ext = new MyExt();
       ext.a = 42;
       ext.b = "EXT";
@@ -87,7 +98,7 @@
       ep.ext.setParcelable(ext);
 
       ExtendableParcelable ep2 = new ExtendableParcelable();
-      mService.RepeatExtendableParcelable(ep, ep2);
+      mCppJavaTests.RepeatExtendableParcelable(ep, ep2);
       assertThat(ep2.a, is(2));
       assertThat(ep2.b, is("aBAR"));
 
@@ -98,56 +109,56 @@
 
     @Test
     public void testVintfParcelableHolderCanContainVintfParcelable() {
-        assertThat(vep.ext.setParcelable(vp), is(true));
-        assertThat(vep.ext.getParcelable(VintfParcelable.class), is(vp));
+      vep.ext.setParcelable(vp);
+      assertThat(vep.ext.getParcelable(VintfParcelable.class), is(vp));
     }
 
     @Test
     public void testVintfParcelableHolderCannotContainNonVintfParcelable() {
-        assertThat(vep.ext.setParcelable(sp), is(false));
-        assertThat(vep.ext.getParcelable(VintfParcelable.class), is(nullValue()));
+      assertThrows(BadParcelableException.class, () -> { vep.ext.setParcelable(sp); });
+      assertThat(vep.ext.getParcelable(VintfParcelable.class), is(nullValue()));
     }
 
     @Test
     public void testVintfParcelableHolderCannotContainUnstableParcelable() {
-        assertThat(vep.ext.setParcelable(up), is(false));
-        assertThat(vep.ext.getParcelable(UnstableParcelable.class), is(nullValue()));
+      assertThrows(BadParcelableException.class, () -> { vep.ext.setParcelable(up); });
+      assertThat(vep.ext.getParcelable(UnstableParcelable.class), is(nullValue()));
     }
 
     @Test
     public void testStableParcelableHolderCanContainVintfParcelable() {
-        assertThat(sep.ext.setParcelable(vp), is(true));
-        assertThat(sep.ext.getParcelable(VintfParcelable.class), is(vp));
+      sep.ext.setParcelable(vp);
+      assertThat(sep.ext.getParcelable(VintfParcelable.class), is(vp));
     }
 
     @Test
     public void testStableParcelableHolderCanContainNonVintfParcelable() {
-        assertThat(sep.ext.setParcelable(sp), is(true));
-        assertThat(sep.ext.getParcelable(NonVintfParcelable.class), is(sp));
+      sep.ext.setParcelable(sp);
+      assertThat(sep.ext.getParcelable(NonVintfParcelable.class), is(sp));
     }
 
     @Test
     public void testStableParcelableHolderCanContainUnstableParcelable() {
-        assertThat(sep.ext.setParcelable(up), is(true));
-        assertThat(sep.ext.getParcelable(UnstableParcelable.class), is(up));
+      sep.ext.setParcelable(up);
+      assertThat(sep.ext.getParcelable(UnstableParcelable.class), is(up));
     }
 
     @Test
     public void testUnstableParcelableHolderCanContainVintfParcelable() {
-        assertThat(uep.ext.setParcelable(vp), is(true));
-        assertThat(uep.ext.getParcelable(VintfParcelable.class), is(vp));
+      uep.ext.setParcelable(vp);
+      assertThat(uep.ext.getParcelable(VintfParcelable.class), is(vp));
     }
 
     @Test
     public void testUnstableParcelableHolderCanContainNonVintfParcelable() {
-        assertThat(uep.ext.setParcelable(sp), is(true));
-        assertThat(uep.ext.getParcelable(NonVintfParcelable.class), is(sp));
+      uep.ext.setParcelable(sp);
+      assertThat(uep.ext.getParcelable(NonVintfParcelable.class), is(sp));
     }
 
     @Test
     public void testUnstableParcelableHolderCanContainUnstableParcelable() {
-        assertThat(uep.ext.setParcelable(up), is(true));
-        assertThat(uep.ext.getParcelable(UnstableParcelable.class), is(up));
+      uep.ext.setParcelable(up);
+      assertThat(uep.ext.getParcelable(UnstableParcelable.class), is(up));
     }
 
     @Test
@@ -173,9 +184,10 @@
             ep.ext.setParcelable(ext);
 
             ep.ext2.setParcelable(ext2);
-            MyExtLike extLike = ep.ext.<MyExtLike>getParcelable(MyExtLike.class);
-            assertThat("The extension type must be MyExt, so it has to fail even though " +
-                    "MyExtLike has the same structure as MyExt.", extLike, is(nullValue()));
+            // The extension type must be MyExt, so it has to fail
+            // even though MyExtLike has the same structure as MyExt.
+            assertThrows(BadParcelableException.class,
+                () -> { MyExtLike extLike = ep.ext.<MyExtLike>getParcelable(MyExtLike.class); });
 
             MyExt actualExt = ep.ext.getParcelable(MyExt.class);
             MyExt2 actualExt2 = ep.ext2.getParcelable(MyExt2.class);
@@ -198,9 +210,10 @@
 
             ep2.readFromParcel(parcel);
 
-            MyExtLike extLike = ep2.ext.<MyExtLike>getParcelable(MyExtLike.class);
-            assertThat("The extension type must be MyExt, so it has to fail even though " +
-                "MyExtLike has the same structure as MyExt.", extLike, is(nullValue()));
+            // The extension type must be MyExt, so it has to fail
+            // even though MyExtLike has the same structure as MyExt.
+            assertThrows(BadParcelableException.class,
+                () -> { MyExtLike extLike = ep2.ext.<MyExtLike>getParcelable(MyExtLike.class); });
 
             MyExt actualExt = ep2.ext.getParcelable(MyExt.class);
 
diff --git a/tests/java_app/src/android/aidl/tests/GenericTests.java b/tests/java/src/android/aidl/tests/GenericTests.java
similarity index 100%
rename from tests/java_app/src/android/aidl/tests/GenericTests.java
rename to tests/java/src/android/aidl/tests/GenericTests.java
diff --git a/tests/java_app/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java b/tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
similarity index 82%
rename from tests/java_app/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
rename to tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
index 4fd4b90..a4ea0e4 100644
--- a/tests/java_app/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
+++ b/tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
@@ -22,6 +22,7 @@
 
 import android.aidl.tests.immutable.Bar;
 import android.aidl.tests.immutable.Foo;
+import android.aidl.tests.immutable.Union;
 import android.os.Parcel;
 import android.os.RemoteException;
 import java.lang.UnsupportedOperationException;
@@ -49,7 +50,7 @@
     array[1] = new Bar("one");
     array[2] = new Bar("two");
 
-    Foo foo = new Foo(7, new Bar("my"), list, map, array);
+    Foo foo = new Foo(7, new Bar("my"), list, map, array, Union.num(42));
     foo.writeToParcel(parcel, 0);
     parcel.setDataPosition(0);
     Foo foo2 = Foo.CREATOR.createFromParcel(parcel);
@@ -65,6 +66,8 @@
     for (int i = 0; i < foo.e.length; i++) {
       assertThat(foo.e[i].s, is(foo2.e[i].s));
     }
+
+    assertThat(foo.u.getNum(), is(foo2.u.getNum()));
   }
 
   @Test
@@ -78,8 +81,8 @@
 
   @Test(expected = UnsupportedOperationException.class)
   public void testListIsUnmodifiable() {
-    Foo foo =
-        new Foo(7, new Bar("my"), new ArrayList<Bar>(), new HashMap<String, Bar>(), new Bar[5]);
+    Foo foo = new Foo(7, new Bar("my"), new ArrayList<Bar>(), new HashMap<String, Bar>(),
+        new Bar[5], Union.num(42));
     foo.c.add(new Bar("hi"));
     // It is supposed to fail.
     fail("A List in an immutable parcelable isn't modifiable.");
@@ -87,8 +90,8 @@
 
   @Test(expected = UnsupportedOperationException.class)
   public void testMapIsUnmodifiable() {
-    Foo foo =
-        new Foo(7, new Bar("my"), new ArrayList<Bar>(), new HashMap<String, Bar>(), new Bar[5]);
+    Foo foo = new Foo(7, new Bar("my"), new ArrayList<Bar>(), new HashMap<String, Bar>(),
+        new Bar[5], Union.num(42));
     foo.d.put("key", new Bar("value"));
     // It is supposed to fail.
     fail("A Map in an immutable parcelable isn't modifiable.");
@@ -112,8 +115,15 @@
     array[1] = new Bar("one");
     array[2] = new Bar("two");
 
-    Foo foo = new Foo(7, b, list, map, array);
-    Foo foo2 = new Foo.Builder().setA(7).setB(b).setC(list).setD(map).setE(array).build();
+    Foo foo = new Foo(7, b, list, map, array, Union.num(42));
+    Foo foo2 = new Foo.Builder()
+                   .setA(7)
+                   .setB(b)
+                   .setC(list)
+                   .setD(map)
+                   .setE(array)
+                   .setU(Union.num(42))
+                   .build();
 
     assertThat(foo.a, is(foo2.a));
     assertThat(foo.b.s, is(foo2.b.s));
@@ -126,5 +136,7 @@
     for (int i = 0; i < foo.e.length; i++) {
       assertThat(foo.e[i].s, is(foo2.e[i].s));
     }
+
+    assertThat(foo.u.getNum(), is(foo2.u.getNum()));
   }
 }
diff --git a/tests/java_app/src/android/aidl/tests/MapTests.java b/tests/java/src/android/aidl/tests/MapTests.java
similarity index 100%
rename from tests/java_app/src/android/aidl/tests/MapTests.java
rename to tests/java/src/android/aidl/tests/MapTests.java
diff --git a/tests/java_app/src/android/aidl/tests/NullableTests.java b/tests/java/src/android/aidl/tests/NullableTests.java
similarity index 86%
rename from tests/java_app/src/android/aidl/tests/NullableTests.java
rename to tests/java/src/android/aidl/tests/NullableTests.java
index ae5e283..2df6260 100644
--- a/tests/java_app/src/android/aidl/tests/NullableTests.java
+++ b/tests/java/src/android/aidl/tests/NullableTests.java
@@ -19,6 +19,7 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsNull.nullValue;
 import static org.hamcrest.core.IsNull.notNullValue;
@@ -37,13 +38,19 @@
 @RunWith(JUnit4.class)
 public class NullableTests {
     private ITestService mService;
+    private ICppJavaTests mCppJavaTests;
 
     @Before
-    public void setUp() {
+    public void setUp() throws RemoteException {
         IBinder binder = ServiceManager.getService(ITestService.class.getName());
         assertNotNull(binder);
         mService = ITestService.Stub.asInterface(binder);
         assertNotNull(mService);
+
+        IBinder binder2 = mService.GetCppJavaTests();
+        if (binder2 != null) {
+            mCppJavaTests = ICppJavaTests.Stub.asInterface(binder2);
+        }
     }
 
     @Test
@@ -68,10 +75,12 @@
 
     @Test
     public void testExpectNpeWithNullBinderList() throws RemoteException {
+        assumeTrue(mCppJavaTests != null);
+
         List<IBinder> listWithNulls = new ArrayList<IBinder>();
         listWithNulls.add(null);
         try {
-            mService.TakesAnIBinderList(listWithNulls);
+            mCppJavaTests.TakesAnIBinderList(listWithNulls);
         } catch (NullPointerException ex) {
             return;
         }
diff --git a/tests/java_app/src/android/aidl/tests/SimpleParcelable.java b/tests/java/src/android/aidl/tests/SimpleParcelable.java
similarity index 100%
rename from tests/java_app/src/android/aidl/tests/SimpleParcelable.java
rename to tests/java/src/android/aidl/tests/SimpleParcelable.java
diff --git a/tests/java_app/src/android/aidl/tests/TestServiceClient.java b/tests/java/src/android/aidl/tests/TestServiceClient.java
similarity index 80%
rename from tests/java_app/src/android/aidl/tests/TestServiceClient.java
rename to tests/java/src/android/aidl/tests/TestServiceClient.java
index 5b6cd8b..e4e4edf 100644
--- a/tests/java_app/src/android/aidl/tests/TestServiceClient.java
+++ b/tests/java/src/android/aidl/tests/TestServiceClient.java
@@ -21,6 +21,8 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assume.assumeTrue;
 
 import android.aidl.tests.ByteEnum;
 import android.aidl.tests.GenericStructuredParcelable;
@@ -30,7 +32,7 @@
 import android.aidl.tests.LongEnum;
 import android.aidl.tests.SimpleParcelable;
 import android.aidl.tests.StructuredParcelable;
-import android.aidl.tests.TestFailException;
+import android.aidl.tests.Union;
 import android.aidl.versioned.tests.IFooInterface;
 import android.app.Activity;
 import android.content.Context;
@@ -43,7 +45,6 @@
 import android.os.ServiceManager;
 import android.os.ServiceSpecificException;
 import android.util.Log;
-import androidx.test.core.app.ApplicationProvider;
 import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileInputStream;
@@ -63,13 +64,24 @@
 @RunWith(JUnit4.class)
 public class TestServiceClient {
     private ITestService service;
+    private ICppJavaTests cpp_java_tests;
 
     @Before
-    public void setUp() {
+    public void setUp() throws RemoteException {
         IBinder binder = ServiceManager.getService(ITestService.class.getName());
         assertNotNull(binder);
         service = ITestService.Stub.asInterface(binder);
         assertNotNull(service);
+
+        IBinder binder2 = service.GetCppJavaTests();
+        if (binder2 != null) {
+            cpp_java_tests = ICppJavaTests.Stub.asInterface(binder2);
+        }
+    }
+
+    @Test
+    public void testOneway() throws RemoteException {
+      service.TestOneway();
     }
 
     @Test
@@ -283,6 +295,8 @@
 
     @Test
     public void testRepeatGenericParcelable() throws RemoteException {
+      assumeTrue(cpp_java_tests != null);
+
       GenericStructuredParcelable<Integer, StructuredParcelable, Integer> input =
           new GenericStructuredParcelable<Integer, StructuredParcelable, Integer>();
       GenericStructuredParcelable<Integer, StructuredParcelable, Integer> out_param =
@@ -292,7 +306,7 @@
       GenericStructuredParcelable<Integer, StructuredParcelable, Integer> testing = input;
       assertThat(testing, is(input));
       GenericStructuredParcelable<Integer, StructuredParcelable, Integer> returned =
-          service.RepeatGenericParcelable(input, out_param);
+          cpp_java_tests.RepeatGenericParcelable(input, out_param);
       assertThat(out_param.a, is(input.a));
       assertThat(out_param.b, is(input.b));
       assertThat(returned.a, is(input.a));
@@ -301,21 +315,25 @@
 
     @Test
     public void testRepeatParcelable() throws RemoteException {
+        assumeTrue(cpp_java_tests != null);
+
         SimpleParcelable input = new SimpleParcelable("foo", 42);
         SimpleParcelable out_param = new SimpleParcelable();
-        SimpleParcelable returned = service.RepeatSimpleParcelable(input, out_param);
+        SimpleParcelable returned = cpp_java_tests.RepeatSimpleParcelable(input, out_param);
         assertThat(out_param, is(input));
         assertThat(returned, is(input));
     }
 
     @Test
     public void testReverseParcelable() throws RemoteException {
+        assumeTrue(cpp_java_tests != null);
+
         SimpleParcelable[] input = new SimpleParcelable[3];
         input[0] = new SimpleParcelable("a", 1);
         input[1] = new SimpleParcelable("b", 2);
         input[2] = new SimpleParcelable("c", 3);
         SimpleParcelable[] repeated = new SimpleParcelable[3];
-        SimpleParcelable[] reversed = service.ReverseSimpleParcelables(input, repeated);
+        SimpleParcelable[] reversed = cpp_java_tests.ReverseSimpleParcelables(input, repeated);
         assertThat(repeated, is(input));
         assertThat(reversed.length, is(input.length));
         for (int i = 0, k = input.length - 1; i < input.length; ++i, --k) {
@@ -325,14 +343,18 @@
 
     @Test
     public void testRepeatEmptyPersistableBundle() throws RemoteException {
+        assumeTrue(cpp_java_tests != null);
+
         PersistableBundle emptyBundle = new PersistableBundle();
-        PersistableBundle returned = service.RepeatPersistableBundle(emptyBundle);
+        PersistableBundle returned = cpp_java_tests.RepeatPersistableBundle(emptyBundle);
         assertThat(returned.size(), is(emptyBundle.size()));
         assertThat(returned.toString(), is(emptyBundle.toString()));
     }
 
     @Test
     public void testRepeatNonEmptyPersistableBundle() throws RemoteException {
+        assumeTrue(cpp_java_tests != null);
+
         PersistableBundle pb = new PersistableBundle();
 
         final String testBoolKey = "testBool";
@@ -362,7 +384,7 @@
         testNestedPersistableBundle.putInt(testNestedIntKey, 345);
         pb.putPersistableBundle(testPersistableBundleKey, testNestedPersistableBundle);
 
-        PersistableBundle ret = service.RepeatPersistableBundle(pb);
+        PersistableBundle ret = cpp_java_tests.RepeatPersistableBundle(pb);
 
         assertThat(ret.size(), is(pb.size()));
         assertThat(ret.getBoolean(testBoolKey), is(pb.getBoolean(testBoolKey)));
@@ -383,6 +405,8 @@
 
     @Test
     public void testReversePersistableBundleArray() throws RemoteException {
+        assumeTrue(cpp_java_tests != null);
+
         PersistableBundle[] input = new PersistableBundle[3];
         PersistableBundle first = new PersistableBundle();
         PersistableBundle second = new PersistableBundle();
@@ -399,7 +423,7 @@
         final int original_input_size = input.length;
 
         PersistableBundle[] repeated = new PersistableBundle[input.length];
-        PersistableBundle[] reversed = service.ReversePersistableBundles(input, repeated);
+        PersistableBundle[] reversed = cpp_java_tests.ReversePersistableBundles(input, repeated);
 
         assertThat(repeated.length, is(input.length));
         assertThat(input.length, is(original_input_size));
@@ -415,11 +439,13 @@
 
     @Test
     public void testFileDescriptorPassing() throws RemoteException, IOException {
-        Context context = ApplicationProvider.getApplicationContext();
-        FileOutputStream fos = context.openFileOutput("test-dummy", Context.MODE_PRIVATE);
+        assumeTrue(cpp_java_tests != null);
+
+        String file = "/data/local/tmp/aidl-test-file";
+        FileOutputStream fos = new FileOutputStream(file, false /*append*/);
 
         FileDescriptor descriptor = fos.getFD();
-        FileDescriptor journeyed = service.RepeatFileDescriptor(descriptor);
+        FileDescriptor journeyed = cpp_java_tests.RepeatFileDescriptor(descriptor);
         fos.close();
 
         FileOutputStream journeyedStream = new FileOutputStream(journeyed);
@@ -429,7 +455,7 @@
         journeyedStream.write(output);
         journeyedStream.close();
 
-        FileInputStream fis = context.openFileInput("test-dummy");
+        FileInputStream fis = new FileInputStream(file);
         byte[] input = new byte[output.length];
 
         assertThat(fis.read(input), is(input.length));
@@ -438,9 +464,9 @@
 
     @Test
     public void testParcelFileDescriptorPassing() throws RemoteException, IOException {
-        Context context = ApplicationProvider.getApplicationContext();
+        String file = "/data/local/tmp/aidl-test-file";
         ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(
-                context.getFileStreamPath("test-dummy"), ParcelFileDescriptor.MODE_CREATE |
+                new File(file), ParcelFileDescriptor.MODE_CREATE |
                     ParcelFileDescriptor.MODE_WRITE_ONLY);
         ParcelFileDescriptor journeyed = service.RepeatParcelFileDescriptor(descriptor);
 
@@ -451,7 +477,7 @@
         journeyedStream.write(output);
         journeyedStream.close();
 
-        FileInputStream fis = context.openFileInput("test-dummy");
+        FileInputStream fis = new FileInputStream(file);
         byte[] input = new byte[output.length];
 
         assertThat(fis.read(input), is(input.length));
@@ -525,6 +551,42 @@
         }
     }
 
+    private void shouldBeTheSame(StructuredParcelable a, StructuredParcelable b) {
+        assertTrue(a.equals(b));
+        assertTrue(b.equals(a));
+        assertTrue(a.equals(a));
+        assertTrue(b.equals(b));
+        assertTrue(a.hashCode() == b.hashCode());
+    }
+
+    private void shouldBeDifferent(StructuredParcelable a, StructuredParcelable b) {
+        assertFalse(a.equals(b));
+        assertFalse(b.equals(a));
+        assertFalse(a.hashCode() == b.hashCode());
+    }
+
+    @Test
+    public void testStructurecParcelableEquality() {
+        StructuredParcelable p = new StructuredParcelable();
+        p.shouldContainThreeFs = new int[] {1, 2, 3};
+        p.shouldBeJerry = "Jerry";
+
+        StructuredParcelable p2 = new StructuredParcelable();
+        p2.shouldContainThreeFs = new int[] {1, 2, 3};
+        p2.shouldBeJerry = "Jerry";
+        shouldBeTheSame(p, p2);
+
+        StructuredParcelable p3 = new StructuredParcelable();
+        p3.shouldContainThreeFs = new int[] {1, 2, 3, 4};
+        p3.shouldBeJerry = "Jerry";
+        shouldBeDifferent(p, p3);
+
+        StructuredParcelable p4 = new StructuredParcelable();
+        p4.shouldContainThreeFs = new int[] {1, 2, 3};
+        p4.shouldBeJerry = "Tom";
+        shouldBeDifferent(p, p4);
+    }
+
     @Test
     public void testStrucuturedParcelable() throws RemoteException {
         final int kDesiredFValue = 17;
@@ -549,6 +611,7 @@
         assertThat(p.doubleWithDefault, is(-3.14e17));
         assertThat(p.arrayDefaultsTo123, is(new int[] {1, 2, 3}));
         assertThat(p.arrayDefaultsToEmpty.length, is(0));
+        assertThat(p.defaultWithFoo, is(IntEnum.FOO));
 
         service.FillOutStructuredParcelable(p);
 
@@ -584,59 +647,69 @@
         assertThat(p.const_exprs_9, is(1));
         assertThat(p.const_exprs_10, is(1));
 
-        final String expected = "android.aidl.tests.StructuredParcelable{" +
-            "shouldContainThreeFs: [17, 17, 17], " +
-            "f: 17, " +
-            "shouldBeJerry: Jerry, " +
-            "shouldBeByteBar: 2, " +
-            "shouldBeIntBar: 2000, " +
-            "shouldBeLongBar: 200000000000, " +
-            "shouldContainTwoByteFoos: [1, 1], " +
-            "shouldContainTwoIntFoos: [1000, 1000], " +
-            "shouldContainTwoLongFoos: [100000000000, 100000000000], " +
-            "stringDefaultsToFoo: foo, " +
-            "byteDefaultsToFour: 4, " +
-            "intDefaultsToFive: 5, " +
-            "longDefaultsToNegativeSeven: -7, " +
-            "booleanDefaultsToTrue: true, " +
-            "charDefaultsToC: C, " +
-            "floatDefaultsToPi: 3.14, " +
-            "doubleWithDefault: -3.14E17, " +
-            "arrayDefaultsTo123: [1, 2, 3], " +
-            "arrayDefaultsToEmpty: [], " +
-            "boolDefault: false, " +
-            "byteDefault: 0, " +
-            "intDefault: 0, " +
-            "longDefault: 0, " +
-            "floatDefault: 0.0, " +
-            "doubleDefault: 0.0, " +
-            "checkDoubleFromFloat: 3.14, " +
-            "checkStringArray1: [a, b], " +
-            "checkStringArray2: [a, b], " +
-            "int32_min: -2147483648, " +
-            "int32_max: 2147483647, " +
-            "int64_max: 9223372036854775807, " +
-            "hexInt32_neg_1: -1, " +
-            "ibinder: null, " +
-            "int32_1: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, " +
-            "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, " +
-            "1, 1, 1, 1], " +
-            "int64_1: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], " +
-            "hexInt32_pos_1: 1, " +
-            "hexInt64_pos_1: 1, " +
-            "const_exprs_1: 1, " +
-            "const_exprs_2: 1, " +
-            "const_exprs_3: 1, " +
-            "const_exprs_4: 1, " +
-            "const_exprs_5: 1, " +
-            "const_exprs_6: 1, " +
-            "const_exprs_7: 1, " +
-            "const_exprs_8: 1, " +
-            "const_exprs_9: 1, " +
-            "const_exprs_10: 1, " +
-            "addString1: hello world!, " +
-            "addString2: The quick brown fox jumps over the lazy dog." +
-            "}";
+        assertThat(
+            p.shouldSetBit0AndBit2, is(StructuredParcelable.BIT0 | StructuredParcelable.BIT2));
+
+        assertThat(p.u.getNs(), is(new int[] {1, 2, 3}));
+        assertThat(p.shouldBeConstS1.getS(), is(Union.S1));
+
+        final String expected = "android.aidl.tests.StructuredParcelable{"
+            + "shouldContainThreeFs: [17, 17, 17], "
+            + "f: 17, "
+            + "shouldBeJerry: Jerry, "
+            + "shouldBeByteBar: 2, "
+            + "shouldBeIntBar: 2000, "
+            + "shouldBeLongBar: 200000000000, "
+            + "shouldContainTwoByteFoos: [1, 1], "
+            + "shouldContainTwoIntFoos: [1000, 1000], "
+            + "shouldContainTwoLongFoos: [100000000000, 100000000000], "
+            + "stringDefaultsToFoo: foo, "
+            + "byteDefaultsToFour: 4, "
+            + "intDefaultsToFive: 5, "
+            + "longDefaultsToNegativeSeven: -7, "
+            + "booleanDefaultsToTrue: true, "
+            + "charDefaultsToC: C, "
+            + "floatDefaultsToPi: 3.14, "
+            + "doubleWithDefault: -3.14E17, "
+            + "arrayDefaultsTo123: [1, 2, 3], "
+            + "arrayDefaultsToEmpty: [], "
+            + "boolDefault: false, "
+            + "byteDefault: 0, "
+            + "intDefault: 0, "
+            + "longDefault: 0, "
+            + "floatDefault: 0.0, "
+            + "doubleDefault: 0.0, "
+            + "checkDoubleFromFloat: 3.14, "
+            + "checkStringArray1: [a, b], "
+            + "checkStringArray2: [a, b], "
+            + "int32_min: -2147483648, "
+            + "int32_max: 2147483647, "
+            + "int64_max: 9223372036854775807, "
+            + "hexInt32_neg_1: -1, "
+            + "ibinder: null, "
+            + "int32_1: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "
+            + "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "
+            + "1, 1, 1, 1], "
+            + "int64_1: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "
+            + "hexInt32_pos_1: 1, "
+            + "hexInt64_pos_1: 1, "
+            + "const_exprs_1: 1, "
+            + "const_exprs_2: 1, "
+            + "const_exprs_3: 1, "
+            + "const_exprs_4: 1, "
+            + "const_exprs_5: 1, "
+            + "const_exprs_6: 1, "
+            + "const_exprs_7: 1, "
+            + "const_exprs_8: 1, "
+            + "const_exprs_9: 1, "
+            + "const_exprs_10: 1, "
+            + "addString1: hello world!, "
+            + "addString2: The quick brown fox jumps over the lazy dog., "
+            + "shouldSetBit0AndBit2: 5, "
+            + "u: android.aidl.tests.Union.ns([1, 2, 3]), "
+            + "shouldBeConstS1: android.aidl.tests.Union.s(a string constant in union), "
+            + "defaultWithFoo: 1000"
+            + "}";
         assertThat(p.toString(), is(expected));
     }
 
@@ -692,6 +765,7 @@
         gen.a = 1;
         gen.b = 2;
         p.parcelableGeneric = gen;
+        p.unionValue = null; // for testing even though it is not @nullable in .aidl
 
         final String expected = "android.aidl.tests.ParcelableForToString{"
             + "intValue: 10, "
@@ -717,7 +791,8 @@
             + "enumArray: [1000, 2000], "
             + "nullArray: null, "
             + "nullList: null, "
-            + "parcelableGeneric: android.aidl.tests.GenericStructuredParcelable{a: 1, b: 2}"
+            + "parcelableGeneric: android.aidl.tests.GenericStructuredParcelable{a: 1, b: 2}, "
+            + "unionValue: null"
             + "}";
 
         assertThat(p.toString(), is(expected));
@@ -745,4 +820,18 @@
       assertThat(oldAsNew.DESCRIPTOR, is("android.aidl.tests.IOldName"));
       assertThat(oldAsNew.RealName(), is("OldName"));
     }
+
+    @Test
+    public void testReverseUnion() throws RemoteException {
+      assumeTrue(cpp_java_tests != null);
+
+      Union original = Union.ns(new int[] {1, 2, 3});
+      Union repeated = new Union();
+
+      Union reversed = cpp_java_tests.ReverseUnion(original, repeated);
+
+      assertNotNull(reversed);
+      assertThat(repeated.getNs(), is(new int[] {1, 2, 3}));
+      assertThat(reversed.getNs(), is(new int[] {3, 2, 1}));
+    }
 }
diff --git a/tests/java_app/src/android/aidl/tests/TestVersionedInterface.java b/tests/java/src/android/aidl/tests/TestVersionedInterface.java
similarity index 75%
rename from tests/java_app/src/android/aidl/tests/TestVersionedInterface.java
rename to tests/java/src/android/aidl/tests/TestVersionedInterface.java
index c08f206..29d1421 100644
--- a/tests/java_app/src/android/aidl/tests/TestVersionedInterface.java
+++ b/tests/java/src/android/aidl/tests/TestVersionedInterface.java
@@ -21,11 +21,11 @@
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
+import android.aidl.versioned.tests.BazUnion;
 import android.aidl.versioned.tests.IFooInterface;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.ServiceManager;
-import androidx.test.core.app.ApplicationProvider;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -52,7 +52,7 @@
 
     @Test
     public void testGetInterfaceHash() throws RemoteException {
-        assertThat(service.getInterfaceHash(), is("fcd4f9c806cbc8af3694d569fd1de1ecc8cf7d22"));
+      assertThat(service.getInterfaceHash(), is("796b4ab269d476662bed4ab57092ed000e48d5d7"));
     }
 
     @Rule public ExpectedException expectedException = ExpectedException.none();
@@ -60,8 +60,20 @@
     @Test
     public void testUnimplementedMethodTriggersException() throws RemoteException {
       expectedException.expect(RemoteException.class);
-      expectedException.expectMessage("Method bar is unimplemented.");
+      expectedException.expectMessage("Method newApi is unimplemented.");
 
-      service.bar();
+      service.newApi();
+    }
+
+    @Test
+    public void testOldServerAcceptsUnionWithOldField() throws RemoteException {
+      assertThat(service.acceptUnionAndReturnString(BazUnion.intNum(42)), is("42"));
+    }
+
+    @Test
+    public void testUnknownUnionFieldTriggersException() throws RemoteException {
+      expectedException.expect(IllegalArgumentException.class);
+
+      service.acceptUnionAndReturnString(BazUnion.longNum(42L));
     }
 }
diff --git a/tests/java/src/android/aidl/tests/UnionTests.java b/tests/java/src/android/aidl/tests/UnionTests.java
new file mode 100644
index 0000000..11f4115
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/UnionTests.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aidl.tests;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import android.aidl.tests.Union;
+import android.aidl.tests.UnionWithFd;
+import android.aidl.tests.unions.EnumUnion;
+import android.os.Parcel;
+import android.os.ParcelFileDescriptor;
+import android.os.Parcelable;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class UnionTests {
+  @Test
+  public void defaultConstructorInitsWithFirstField() {
+    assertThat(new Union(), is(Union.ns(new int[] {}))); // int[] ns = {}
+    assertThat(
+        new EnumUnion(), is(EnumUnion.intEnum(IntEnum.FOO))); // IntEnum intEnum = IntEnum.FOO
+  }
+
+  @Test
+  public void updatesUnionWithSetter() {
+    Union u = new Union();
+    u.setNs(new int[] {1, 2, 3});
+    assertThat(u.getTag(), is(Union.ns));
+    assertThat(u.getNs(), is(new int[] {1, 2, 3}));
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void gettingWrongFieldThrowsException() {
+    Union u = new Union();
+    u.getSs();
+  }
+
+  @Test
+  public void readWriteViaParcel() {
+    List<String> ss = Arrays.asList("hello", "world");
+
+    Union u = Union.ss(ss);
+    Parcel parcel = Parcel.obtain();
+    u.writeToParcel(parcel, 0);
+    parcel.setDataPosition(0);
+
+    Union v = Union.CREATOR.createFromParcel(parcel);
+
+    assertThat(v.getTag(), is(Union.ss));
+    assertThat(v.getSs(), is(ss));
+
+    parcel.recycle();
+  }
+
+  @Test
+  public void unionDescribeContents() {
+    UnionWithFd u = UnionWithFd.num(0);
+    assertTrue((u.describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) == 0);
+
+    final Parcel parcel = Parcel.obtain();
+    try {
+      u.setPfd(ParcelFileDescriptor.open(new File("/system"), ParcelFileDescriptor.MODE_READ_ONLY));
+    } catch (FileNotFoundException e) {
+      throw new RuntimeException("can't open /system", e);
+    }
+    assertTrue((u.describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0);
+
+    u.writeToParcel(parcel, 0);
+
+    UnionWithFd v = UnionWithFd.num(0);
+    parcel.setDataPosition(0);
+    v.readFromParcel(parcel);
+    assertTrue((v.describeContents() & Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0);
+
+    parcel.recycle();
+  }
+
+  private void shouldBeTheSame(Union a, Union b) {
+    assertTrue(a.equals(b));
+    assertTrue(b.equals(a));
+    assertTrue(a.equals(a));
+    assertTrue(b.equals(b));
+    assertTrue(a.hashCode() == b.hashCode());
+  }
+
+  private void shouldBeDifferent(Union a, Union b) {
+    assertFalse(a.equals(b));
+    assertFalse(b.equals(a));
+    assertFalse(a.hashCode() == b.hashCode());
+  }
+
+  @Test
+  public void equalsAndHashCode() {
+    // same tag, same value
+    shouldBeTheSame(Union.s("hello"), Union.s("hello"));
+
+    // different tag, same value
+    shouldBeDifferent(Union.m(10), Union.n(10));
+
+    // same tag, different value
+    shouldBeDifferent(Union.s("hello"), Union.s("world"));
+
+    // with array
+    shouldBeTheSame(Union.ns(new int[]{1, 2, 3}),Union.ns(new int[]{1, 2, 3}));
+    shouldBeDifferent(Union.ns(new int[]{1, 2, 3}), Union.ns(new int[]{1, 2, 4}));
+  }
+}
diff --git a/tests/java_app/src/android/aidl/tests/generic/Pair.java b/tests/java/src/android/aidl/tests/generic/Pair.java
similarity index 100%
rename from tests/java_app/src/android/aidl/tests/generic/Pair.java
rename to tests/java/src/android/aidl/tests/generic/Pair.java
diff --git a/tests/java_app/AndroidManifest.xml b/tests/java_app/AndroidManifest.xml
deleted file mode 100644
index e29a029..0000000
--- a/tests/java_app/AndroidManifest.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<manifest
-  xmlns:android="http://schemas.android.com/apk/res/android"
-  package="android.aidl.tests">
-
-  <uses-sdk android:targetSdkVersion="30"/>
-
-  <application>
-    <uses-library android:name="android.test.runner"/>
-  </application>
-
-  <instrumentation
-    android:exported="true"
-    android:name="androidx.test.runner.AndroidJUnitRunner"
-    android:targetPackage="android.aidl.tests"
-    android:label="AIDL integration test" />
-</manifest>
diff --git a/tests/java_app/README b/tests/java_app/README
deleted file mode 100644
index a3dfceb..0000000
--- a/tests/java_app/README
+++ /dev/null
@@ -1,17 +0,0 @@
-To use this APK do something like:
-
-1) Build your favorite AOSP flavor.
-2) Start an emulator:
-    $ emulator
-3) Push over hellod binary:
-    $ adb remount && adb sync
-4) Install the Java client:
-    $ adb install -r <path-to-APK-in-out-directory>
-5) Put selinux in permissive mode.
-6) Start hellod:
-    $ adb shell "(hellod ) </dev/null >/dev/null 2>&1 &"
-7) Start Java client:
-    $ adb shell am start -S -a android.intent.action.MAIN \
-                           -n "android.aidl.tests/.TestServiceClient"
-8) Watch output on logcat:
-    $ adb logcat -s TestServiceClient hellod
diff --git a/tests/java_app/resources/values/strings.xml b/tests/java_app/resources/values/strings.xml
deleted file mode 100644
index d5ee63e..0000000
--- a/tests/java_app/resources/values/strings.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Strictly speaking, we don't need this. However, without something in
-     resources/ the build rebuilds the APK despite having no changes to the
-     source code.  This seems to be because it fails to generate some
-     resources metafile (R.stamp?) -->
-<resources>
-  <string
-    name="application_title"
-    >AIDL Test Services</string>
-</resources>
diff --git a/tests/lazy_test/ILazyTestService.aidl b/tests/lazy_test/ILazyTestService.aidl
index 9cafdd1..d2c4053 100644
--- a/tests/lazy_test/ILazyTestService.aidl
+++ b/tests/lazy_test/ILazyTestService.aidl
@@ -16,4 +16,11 @@
 
 interface ILazyTestService {
     void forcePersist(boolean persist);
+    /**
+     * Ask the process hosting the service to install a callback that notifies if there are
+     * services with clients.
+     * For testing purposes, this callback exercises the code to unregister/re-register
+     * the services and eventually shuts down the process.
+     */
+    void setCustomActiveServicesCallback();
 }
diff --git a/tests/lazy_test/LazyTestService.cpp b/tests/lazy_test/LazyTestService.cpp
index d6a5cd3..ce8b406 100644
--- a/tests/lazy_test/LazyTestService.cpp
+++ b/tests/lazy_test/LazyTestService.cpp
@@ -27,5 +27,34 @@
   return Status::ok();
 }
 
+Status LazyTestService::setCustomActiveServicesCallback() {
+  auto lazyRegistrar = LazyServiceRegistrar::getInstance();
+  lazyRegistrar.setActiveServicesCallback([lazyRegistrar](bool hasClients) mutable -> bool {
+    if (hasClients) {
+      return false;
+    }
+
+    // Unregister all services
+    if (!lazyRegistrar.tryUnregister()) {
+      // Prevent shutdown (test will fail)
+      return true;
+    }
+
+    // Re-register all services
+    lazyRegistrar.reRegister();
+
+    // Unregister again before shutdown
+    if (!lazyRegistrar.tryUnregister()) {
+      // Prevent shutdown (test will fail)
+      return true;
+    }
+
+    exit(EXIT_SUCCESS);
+    // Unreachable
+  });
+
+  return Status::ok();
+}
+
 }  // namespace binder
 }  // namespace android
diff --git a/tests/lazy_test/LazyTestService.h b/tests/lazy_test/LazyTestService.h
index 31d1155..fbab1f5 100644
--- a/tests/lazy_test/LazyTestService.h
+++ b/tests/lazy_test/LazyTestService.h
@@ -28,6 +28,7 @@
   virtual ~LazyTestService() {}
 
   ::android::binder::Status forcePersist(bool persist);
+  ::android::binder::Status setCustomActiveServicesCallback();
 };
 
 }  // namespace binder
diff --git a/tests/lazy_test/main.cpp b/tests/lazy_test/main.cpp
index 1a0683f..e1fa5f1 100644
--- a/tests/lazy_test/main.cpp
+++ b/tests/lazy_test/main.cpp
@@ -192,6 +192,20 @@
   }
 }
 
+TEST_F(AidlLazyRegistrarTest, ActiveServicesCountCallbackTest) {
+  sp<ILazyTestService> service;
+  service = waitForLazyTestService(serviceName);
+  ASSERT_TRUE(service->setCustomActiveServicesCallback().isOk());
+  service = nullptr;
+
+  std::cout << "Waiting " << SHUTDOWN_WAIT_TIME << " seconds before checking whether the "
+            << "service is still running." << std::endl;
+  IPCThreadState::self()->flushCommands();
+  sleep(SHUTDOWN_WAIT_TIME);
+
+  ASSERT_FALSE(isServiceRunning(serviceName)) << "Service failed to shut down.";
+}
+
 int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
 
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
new file mode 100644
index 0000000..97c39d6
--- /dev/null
+++ b/tests/rust/test_client.rs
@@ -0,0 +1,680 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//! Test Rust client for the AIDL compiler.
+
+use aidl_test_interface::aidl::android::aidl::tests::INewName::{self, BpNewName};
+use aidl_test_interface::aidl::android::aidl::tests::IOldName::{self, BpOldName};
+use aidl_test_interface::aidl::android::aidl::tests::ITestService::{
+    self, BpTestService, ITestServiceDefault, ITestServiceDefaultRef,
+};
+use aidl_test_interface::aidl::android::aidl::tests::{
+    ByteEnum::ByteEnum, IntEnum::IntEnum, LongEnum::LongEnum, StructuredParcelable, Union,
+};
+use aidl_test_interface::aidl::android::aidl::tests::unions::{
+    EnumUnion::EnumUnion,
+};
+use aidl_test_interface::binder;
+use aidl_test_versioned_interface::aidl::android::aidl::versioned::tests::{
+    IFooInterface, IFooInterface::BpFooInterface, BazUnion::BazUnion,
+};
+use std::fs::File;
+use std::io::{Read, Write};
+use std::os::unix::io::FromRawFd;
+use std::sync::Arc;
+
+fn get_test_service() -> Box<dyn ITestService::ITestService> {
+    binder::get_interface(<BpTestService as ITestService::ITestService>::get_descriptor())
+        .expect("did not get binder service")
+}
+
+#[test]
+fn test_constants() {
+    assert_eq!(ITestService::A1, 1);
+    assert_eq!(ITestService::A2, 1);
+    assert_eq!(ITestService::A3, 1);
+    assert_eq!(ITestService::A4, 1);
+    assert_eq!(ITestService::A5, 1);
+    assert_eq!(ITestService::A6, 1);
+    assert_eq!(ITestService::A7, 1);
+    assert_eq!(ITestService::A8, 1);
+    assert_eq!(ITestService::A9, 1);
+    assert_eq!(ITestService::A10, 1);
+    assert_eq!(ITestService::A11, 1);
+    assert_eq!(ITestService::A12, 1);
+    assert_eq!(ITestService::A13, 1);
+    assert_eq!(ITestService::A14, 1);
+    assert_eq!(ITestService::A15, 1);
+    assert_eq!(ITestService::A16, 1);
+    assert_eq!(ITestService::A17, 1);
+    assert_eq!(ITestService::A18, 1);
+    assert_eq!(ITestService::A19, 1);
+    assert_eq!(ITestService::A20, 1);
+    assert_eq!(ITestService::A21, 1);
+    assert_eq!(ITestService::A22, 1);
+    assert_eq!(ITestService::A23, 1);
+    assert_eq!(ITestService::A24, 1);
+    assert_eq!(ITestService::A25, 1);
+    assert_eq!(ITestService::A26, 1);
+    assert_eq!(ITestService::A27, 1);
+    assert_eq!(ITestService::A28, 1);
+    assert_eq!(ITestService::A29, 1);
+    assert_eq!(ITestService::A30, 1);
+    assert_eq!(ITestService::A31, 1);
+    assert_eq!(ITestService::A32, 1);
+    assert_eq!(ITestService::A33, 1);
+    assert_eq!(ITestService::A34, 1);
+    assert_eq!(ITestService::A35, 1);
+    assert_eq!(ITestService::A36, 1);
+    assert_eq!(ITestService::A37, 1);
+    assert_eq!(ITestService::A38, 1);
+    assert_eq!(ITestService::A39, 1);
+    assert_eq!(ITestService::A40, 1);
+    assert_eq!(ITestService::A41, 1);
+    assert_eq!(ITestService::A42, 1);
+    assert_eq!(ITestService::A43, 1);
+    assert_eq!(ITestService::A44, 1);
+    assert_eq!(ITestService::A45, 1);
+    assert_eq!(ITestService::A46, 1);
+    assert_eq!(ITestService::A47, 1);
+    assert_eq!(ITestService::A48, 1);
+    assert_eq!(ITestService::A49, 1);
+    assert_eq!(ITestService::A50, 1);
+    assert_eq!(ITestService::A51, 1);
+    assert_eq!(ITestService::A52, 1);
+    assert_eq!(ITestService::A53, 1);
+    assert_eq!(ITestService::A54, 1);
+    assert_eq!(ITestService::A55, 1);
+    assert_eq!(ITestService::A56, 1);
+    assert_eq!(ITestService::A57, 1);
+}
+
+#[test]
+fn test_oneway() {
+    let result = get_test_service().TestOneway();
+    assert_eq!(result, Ok(()));
+}
+
+macro_rules! test_primitive {
+    ($test:ident, $func:ident, $value:expr) => {
+        #[test]
+        fn $test() {
+            let value = $value;
+            let result = get_test_service().$func(value);
+            assert_eq!(result, Ok(value));
+        }
+    };
+}
+
+test_primitive! {test_primitive_bool_false, RepeatBoolean, false}
+test_primitive! {test_primitive_bool_true, RepeatBoolean, true}
+test_primitive! {test_primitive_byte, RepeatByte, -128i8}
+test_primitive! {test_primitive_char, RepeatChar, 'A' as u16}
+test_primitive! {test_primitive_int, RepeatInt, 1i32 << 30}
+test_primitive! {test_primitive_long, RepeatLong, 1i64 << 60}
+test_primitive! {test_primitive_float, RepeatFloat, 1.0f32 / 3.0f32}
+test_primitive! {test_primitive_double, RepeatDouble, 1.0f64 / 3.0f64}
+test_primitive! {test_primitive_byte_constant, RepeatByte, ITestService::BYTE_TEST_CONSTANT}
+test_primitive! {test_primitive_constant1, RepeatInt, ITestService::TEST_CONSTANT}
+test_primitive! {test_primitive_constant2, RepeatInt, ITestService::TEST_CONSTANT2}
+test_primitive! {test_primitive_constant3, RepeatInt, ITestService::TEST_CONSTANT3}
+test_primitive! {test_primitive_constant4, RepeatInt, ITestService::TEST_CONSTANT4}
+test_primitive! {test_primitive_constant5, RepeatInt, ITestService::TEST_CONSTANT5}
+test_primitive! {test_primitive_constant6, RepeatInt, ITestService::TEST_CONSTANT6}
+test_primitive! {test_primitive_constant7, RepeatInt, ITestService::TEST_CONSTANT7}
+test_primitive! {test_primitive_constant8, RepeatInt, ITestService::TEST_CONSTANT8}
+test_primitive! {test_primitive_constant9, RepeatInt, ITestService::TEST_CONSTANT9}
+test_primitive! {test_primitive_constant10, RepeatInt, ITestService::TEST_CONSTANT10}
+test_primitive! {test_primitive_constant11, RepeatInt, ITestService::TEST_CONSTANT11}
+test_primitive! {test_primitive_constant12, RepeatInt, ITestService::TEST_CONSTANT12}
+test_primitive! {test_primitive_long_constant, RepeatLong, ITestService::LONG_TEST_CONSTANT}
+test_primitive! {test_primitive_byte_enum, RepeatByteEnum, ByteEnum::FOO}
+test_primitive! {test_primitive_int_enum, RepeatIntEnum, IntEnum::BAR}
+test_primitive! {test_primitive_long_enum, RepeatLongEnum, LongEnum::FOO}
+
+#[test]
+fn test_repeat_string() {
+    let service = get_test_service();
+    let inputs = [
+        "typical string".into(),
+        String::new(),
+        "\0\0".into(),
+        // This is actually two unicode code points:
+        //   U+10437: The 'small letter yee' character in the deseret alphabet
+        //   U+20AC: A euro sign
+        String::from_utf16(&[0xD801, 0xDC37, 0x20AC]).expect("error converting string"),
+        ITestService::STRING_TEST_CONSTANT.into(),
+        ITestService::STRING_TEST_CONSTANT2.into(),
+    ];
+    for input in &inputs {
+        let result = service.RepeatString(&input);
+        assert_eq!(result.as_ref(), Ok(input));
+    }
+}
+
+macro_rules! test_reverse_array {
+    ($test:ident, $func:ident, $array:expr) => {
+        #[test]
+        fn $test() {
+            let mut array = $array;
+            let mut repeated = vec![];
+            let result = get_test_service().$func(&array, &mut repeated);
+            assert_eq!(repeated, array);
+            array.reverse();
+            assert_eq!(result, Ok(array));
+        }
+    };
+}
+
+test_reverse_array! {test_array_boolean, ReverseBoolean, vec![true, false, false]}
+test_reverse_array! {test_array_byte, ReverseByte, vec![255u8, 0u8, 127u8]}
+test_reverse_array! {
+    service,
+    ReverseChar,
+    vec!['A' as u16, 'B' as u16, 'C' as u16]
+}
+test_reverse_array! {test_array_int, ReverseInt, vec![1, 2, 3]}
+test_reverse_array! {test_array_long, ReverseLong, vec![-1i64, 0i64, 1i64 << 60]}
+test_reverse_array! {test_array_float, ReverseFloat, vec![-0.3f32, -0.7f32, 8.0f32]}
+test_reverse_array! {
+    test_array_double,
+    ReverseDouble,
+    vec![1.0f64 / 3.0f64, 1.0f64 / 7.0f64, 42.0f64]
+}
+test_reverse_array! {
+    test_array_string,
+    ReverseString,
+    vec!["f".into(), "a".into(), "b".into()]
+}
+test_reverse_array! {
+    test_array_byte_enum,
+    ReverseByteEnum,
+    vec![ByteEnum::FOO, ByteEnum::BAR, ByteEnum::BAR]
+}
+test_reverse_array! {
+    test_array_byte_enum_v2,
+    ReverseByteEnum,
+    vec![ByteEnum::FOO, ByteEnum::BAR, ByteEnum::BAZ]
+}
+test_reverse_array! {
+    test_array_int_enum,
+    ReverseIntEnum,
+    vec![IntEnum::FOO, IntEnum::BAR, IntEnum::BAR]
+}
+test_reverse_array! {
+    test_array_long_enum,
+    ReverseLongEnum,
+    vec![LongEnum::FOO, LongEnum::BAR, LongEnum::BAR]
+}
+test_reverse_array! {
+    test_array_string_list,
+    ReverseStringList,
+    vec!["f".into(), "a".into(), "b".into()]
+}
+test_reverse_array! {
+    test_array_utf8_string,
+    ReverseUtf8CppString,
+    vec![
+        "a".into(),
+        String::new(),
+        std::str::from_utf8(&[0xC3, 0xB8])
+            .expect("error converting string")
+            .into(),
+    ]
+}
+
+#[test]
+fn test_binder_exchange() {
+    const NAME: &str = "Smythe";
+    let service = get_test_service();
+    let got = service
+        .GetOtherTestService(NAME)
+        .expect("error calling GetOtherTestService");
+    assert_eq!(got.GetName().as_ref().map(String::as_ref), Ok(NAME));
+    assert_eq!(service.VerifyName(&*got, NAME), Ok(true));
+}
+
+fn build_pipe() -> (File, File) {
+    // Safety: we get two file descriptors from pipe()
+    // and pass them after checking if the function returned
+    // without an error, so the descriptors should be valid
+    // by that point
+    unsafe {
+        let mut fds = [0, 0];
+        if libc::pipe(fds.as_mut_ptr()) != 0 {
+            panic!("pipe() error");
+        }
+        (File::from_raw_fd(fds[0]), File::from_raw_fd(fds[1]))
+    }
+}
+
+#[test]
+fn test_parcel_file_descriptor() {
+    let service = get_test_service();
+    let (mut read_file, write_file) = build_pipe();
+
+    let write_pfd = binder::ParcelFileDescriptor::new(write_file);
+    let result_pfd = service
+        .RepeatParcelFileDescriptor(&write_pfd)
+        .expect("error calling RepeatParcelFileDescriptor");
+
+    const TEST_DATA: &[u8] = b"FrazzleSnazzleFlimFlamFlibbityGumboChops";
+    result_pfd
+        .as_ref()
+        .write_all(TEST_DATA)
+        .expect("error writing to pipe");
+
+    let mut buf = [0u8; TEST_DATA.len()];
+    read_file
+        .read_exact(&mut buf)
+        .expect("error reading from pipe");
+    assert_eq!(&buf[..], TEST_DATA);
+}
+
+#[test]
+fn test_parcel_file_descriptor_array() {
+    let service = get_test_service();
+    let (read_file, write_file) = build_pipe();
+    let input = vec![
+        binder::ParcelFileDescriptor::new(read_file),
+        binder::ParcelFileDescriptor::new(write_file),
+    ];
+
+    let mut repeated = vec![];
+    let result = service
+        .ReverseParcelFileDescriptorArray(&input[..], &mut repeated)
+        .expect("error calling ReverseParcelFileDescriptorArray");
+
+    input[1]
+        .as_ref()
+        .write_all(b"First")
+        .expect("error writing to pipe");
+    repeated[1]
+        .as_mut()
+        .expect("received None for ParcelFileDescriptor")
+        .as_ref()
+        .write_all(b"Second")
+        .expect("error writing to pipe");
+    result[0]
+        .as_ref()
+        .write_all(b"Third")
+        .expect("error writing to pipe");
+
+    const TEST_DATA: &[u8] = b"FirstSecondThird";
+    let mut buf = [0u8; TEST_DATA.len()];
+    input[0]
+        .as_ref()
+        .read_exact(&mut buf)
+        .expect("error reading from pipe");
+    assert_eq!(&buf[..], TEST_DATA);
+}
+
+#[test]
+fn test_service_specific_exception() {
+    let service = get_test_service();
+    for i in -1..2 {
+        let result = service.ThrowServiceException(i);
+        assert!(result.is_err());
+
+        let status = result.unwrap_err();
+        assert_eq!(
+            status.exception_code(),
+            binder::ExceptionCode::SERVICE_SPECIFIC
+        );
+        assert_eq!(status.service_specific_error(), i);
+    }
+}
+
+macro_rules! test_nullable {
+    ($test:ident, $func:ident, $value:expr) => {
+        #[test]
+        fn $test() {
+            let service = get_test_service();
+            let value = Some($value);
+            let result = service.$func(value.as_deref());
+            assert_eq!(result, Ok(value));
+
+            let result = service.$func(None);
+            assert_eq!(result, Ok(None));
+        }
+    };
+}
+
+test_nullable! {test_nullable_array_int, RepeatNullableIntArray, vec![1, 2, 3]}
+test_nullable! {
+    test_nullable_array_byte_enum,
+    RepeatNullableByteEnumArray,
+    vec![ByteEnum::FOO, ByteEnum::BAR]
+}
+test_nullable! {
+    test_nullable_array_int_enum,
+    RepeatNullableIntEnumArray,
+    vec![IntEnum::FOO, IntEnum::BAR]
+}
+test_nullable! {
+    test_nullable_array_long_enum,
+    RepeatNullableLongEnumArray,
+    vec![LongEnum::FOO, LongEnum::BAR]
+}
+test_nullable! {test_nullable_string, RepeatNullableString, "Blooob".into()}
+test_nullable! {
+    test_nullable_string_list,
+    RepeatNullableStringList,
+    vec![
+        Some("Wat".into()),
+        Some("Blooob".into()),
+        Some("Wat".into()),
+        None,
+        Some("YEAH".into()),
+        Some("OKAAAAY".into()),
+    ]
+}
+
+#[test]
+fn test_nullable_parcelable() {
+    let value = StructuredParcelable::StructuredParcelable{
+        f: 42,
+        ..Default::default()
+    };
+
+    let service = get_test_service();
+    let value = Some(value);
+    let result = service.RepeatNullableParcelable(value.as_ref());
+    assert_eq!(result, Ok(value));
+
+    let result = service.RepeatNullableParcelable(None);
+    assert_eq!(result, Ok(None));
+}
+
+#[test]
+fn test_binder() {
+    let service = get_test_service();
+    assert!(service
+        .GetCallback(true)
+        .expect("error calling GetCallback")
+        .is_none());
+    let callback = service
+        .GetCallback(false)
+        .expect("error calling GetCallback")
+        .expect("expected Some from GetCallback");
+
+    // We don't have any place to get a fresh `SpIBinder`, so we
+    // reuse the interface for the binder tests
+    let binder = callback.as_binder();
+    assert_eq!(service.TakesAnIBinder(&binder), Ok(()));
+    assert_eq!(service.TakesANullableIBinder(None), Ok(()));
+    assert_eq!(service.TakesANullableIBinder(Some(&binder)), Ok(()));
+}
+
+macro_rules! test_reverse_nullable_array {
+    ($service:expr, $func:ident, $array:expr) => {{
+        let mut repeated = None;
+        let result = $service.$func(None, &mut repeated);
+        assert_eq!(repeated, None);
+        assert_eq!(result, Ok(None));
+
+        let mut array = $array;
+        let result = $service.$func(Some(&array[..]), &mut repeated);
+        assert_eq!(repeated.as_ref(), Some(&array));
+        array.reverse();
+        assert_eq!(result, Ok(Some(array)));
+    }};
+}
+
+#[test]
+fn test_utf8_string() {
+    let service = get_test_service();
+    let inputs = [
+        "typical string",
+        "",
+        "\0\0",
+        std::str::from_utf8(&[0xF0, 0x90, 0x90, 0xB7, 0xE2, 0x82, 0xAC])
+            .expect("error converting string"),
+        ITestService::STRING_TEST_CONSTANT_UTF8,
+    ];
+    for input in &inputs {
+        let result = service.RepeatUtf8CppString(input);
+        assert_eq!(result.as_ref().map(String::as_str), Ok(*input));
+
+        let result = service.RepeatNullableUtf8CppString(Some(input));
+        assert_eq!(result.as_ref().map(Option::as_deref), Ok(Some(*input)));
+    }
+
+    let result = service.RepeatNullableUtf8CppString(None);
+    assert_eq!(result, Ok(None));
+
+    let inputs = vec![
+        Some("typical string".into()),
+        Some(String::new()),
+        None,
+        Some(
+            std::str::from_utf8(&[0xF0, 0x90, 0x90, 0xB7, 0xE2, 0x82, 0xAC])
+                .expect("error converting string")
+                .into(),
+        ),
+        Some(ITestService::STRING_TEST_CONSTANT_UTF8.into()),
+    ];
+    test_reverse_nullable_array!(service, ReverseUtf8CppStringList, inputs.clone());
+    test_reverse_nullable_array!(service, ReverseNullableUtf8CppString, inputs);
+}
+
+#[allow(clippy::approx_constant)]
+#[allow(clippy::float_cmp)]
+#[test]
+fn test_parcelable() {
+    let service = get_test_service();
+    let mut parcelable = StructuredParcelable::StructuredParcelable::default();
+
+    const DESIRED_VALUE: i32 = 23;
+    parcelable.f = DESIRED_VALUE;
+
+    assert_eq!(parcelable.stringDefaultsToFoo, "foo");
+    assert_eq!(parcelable.byteDefaultsToFour, 4);
+    assert_eq!(parcelable.intDefaultsToFive, 5);
+    assert_eq!(parcelable.longDefaultsToNegativeSeven, -7);
+    assert_eq!(parcelable.booleanDefaultsToTrue, true);
+    assert_eq!(parcelable.charDefaultsToC, 'C' as u16);
+    assert_eq!(parcelable.floatDefaultsToPi, 3.14f32);
+    assert_eq!(parcelable.doubleWithDefault, -3.14e17f64);
+    assert_eq!(parcelable.boolDefault, false);
+    assert_eq!(parcelable.byteDefault, 0);
+    assert_eq!(parcelable.intDefault, 0);
+    assert_eq!(parcelable.longDefault, 0);
+    assert_eq!(parcelable.floatDefault, 0.0f32);
+    assert_eq!(parcelable.doubleDefault, 0.0f64);
+    assert_eq!(parcelable.arrayDefaultsTo123, &[1, 2, 3]);
+    assert!(parcelable.arrayDefaultsToEmpty.is_empty());
+
+    let result = service.FillOutStructuredParcelable(&mut parcelable);
+    assert_eq!(result, Ok(()));
+
+    assert_eq!(
+        parcelable.shouldContainThreeFs,
+        [DESIRED_VALUE, DESIRED_VALUE, DESIRED_VALUE]
+    );
+    assert_eq!(parcelable.shouldBeJerry, "Jerry");
+    assert_eq!(parcelable.int32_min, i32::MIN);
+    assert_eq!(parcelable.int32_max, i32::MAX);
+    assert_eq!(parcelable.int64_max, i64::MAX);
+    assert_eq!(parcelable.hexInt32_neg_1, -1);
+    for i in parcelable.int32_1 {
+        assert_eq!(i, 1);
+    }
+    for i in parcelable.int64_1 {
+        assert_eq!(i, 1);
+    }
+    assert_eq!(parcelable.hexInt32_pos_1, 1);
+    assert_eq!(parcelable.hexInt64_pos_1, 1);
+    assert_eq!(parcelable.const_exprs_1.0, 1);
+    assert_eq!(parcelable.const_exprs_2.0, 1);
+    assert_eq!(parcelable.const_exprs_3.0, 1);
+    assert_eq!(parcelable.const_exprs_4.0, 1);
+    assert_eq!(parcelable.const_exprs_5.0, 1);
+    assert_eq!(parcelable.const_exprs_6.0, 1);
+    assert_eq!(parcelable.const_exprs_7.0, 1);
+    assert_eq!(parcelable.const_exprs_8.0, 1);
+    assert_eq!(parcelable.const_exprs_9.0, 1);
+    assert_eq!(parcelable.const_exprs_10.0, 1);
+    assert_eq!(parcelable.addString1, "hello world!");
+    assert_eq!(
+        parcelable.addString2,
+        "The quick brown fox jumps over the lazy dog."
+    );
+
+    assert_eq!(parcelable.shouldSetBit0AndBit2, StructuredParcelable::BIT0 | StructuredParcelable::BIT2);
+
+    assert_eq!(parcelable.u, Some(Union::Union::Ns(vec![1, 2, 3])));
+    assert_eq!(parcelable.shouldBeConstS1, Some(Union::Union::S(Union::S1.to_string())))
+}
+
+#[test]
+fn test_unions() {
+    assert_eq!(Union::Union::default(), Union::Union::Ns(vec![]));
+    assert_eq!(EnumUnion::default(), EnumUnion::IntEnum(IntEnum::FOO));
+}
+
+const EXPECTED_ARG_VALUE: i32 = 100;
+const EXPECTED_RETURN_VALUE: i32 = 200;
+
+struct TestDefaultImpl;
+
+impl binder::Interface for TestDefaultImpl {}
+
+impl ITestServiceDefault for TestDefaultImpl {
+    fn UnimplementedMethod(&self, arg: i32) -> binder::Result<i32> {
+        assert_eq!(arg, EXPECTED_ARG_VALUE);
+        Ok(EXPECTED_RETURN_VALUE)
+    }
+}
+
+#[test]
+fn test_default_impl() {
+    let service = get_test_service();
+    let di: ITestServiceDefaultRef = Some(Arc::new(TestDefaultImpl));
+    <BpTestService as ITestService::ITestService>::setDefaultImpl(di);
+
+    let result = service.UnimplementedMethod(EXPECTED_ARG_VALUE);
+    assert_eq!(result, Ok(EXPECTED_RETURN_VALUE));
+}
+
+#[test]
+fn test_versioned_interface_version() {
+    let service: Box<dyn IFooInterface::IFooInterface> =
+        binder::get_interface(<BpFooInterface as IFooInterface::IFooInterface>::get_descriptor())
+            .expect("did not get binder service");
+
+    let version = service.getInterfaceVersion();
+    assert_eq!(version, Ok(1));
+}
+
+#[test]
+fn test_versioned_interface_hash() {
+    let service: Box<dyn IFooInterface::IFooInterface> =
+        binder::get_interface(<BpFooInterface as IFooInterface::IFooInterface>::get_descriptor())
+            .expect("did not get binder service");
+
+    let hash = service.getInterfaceHash();
+    assert_eq!(
+        hash.as_ref().map(String::as_str),
+        Ok("796b4ab269d476662bed4ab57092ed000e48d5d7")
+    );
+}
+
+#[test]
+fn test_versioned_known_union_field_is_ok() {
+    let service: Box<dyn IFooInterface::IFooInterface> =
+        binder::get_interface(<BpFooInterface as IFooInterface::IFooInterface>::get_descriptor())
+            .expect("did not get binder service");
+
+    assert_eq!(service.acceptUnionAndReturnString(&BazUnion::IntNum(42)), Ok(String::from("42")));
+}
+
+#[test]
+fn test_versioned_unknown_union_field_triggers_error() {
+    let service: Box<dyn IFooInterface::IFooInterface> =
+        binder::get_interface(<BpFooInterface as IFooInterface::IFooInterface>::get_descriptor())
+            .expect("did not get binder service");
+
+    let ret = service.acceptUnionAndReturnString(&BazUnion::LongNum(42));
+    assert!(!ret.is_ok());
+    assert_eq!(ret.unwrap_err().transaction_error(), binder::StatusCode::BAD_VALUE);
+}
+
+fn test_renamed_interface<F>(f: F)
+where
+    F: FnOnce(Box<dyn IOldName::IOldName>, Box<dyn INewName::INewName>),
+{
+    let service = get_test_service();
+    let old_name = service.GetOldNameInterface();
+    assert!(old_name.is_ok());
+
+    let new_name = service.GetNewNameInterface();
+    assert!(new_name.is_ok());
+
+    f(old_name.unwrap(), new_name.unwrap());
+}
+
+#[test]
+fn test_renamed_interface_old_as_old() {
+    test_renamed_interface(|old_name, _| {
+        assert_eq!(
+            <BpOldName as IOldName::IOldName>::get_descriptor(),
+            "android.aidl.tests.IOldName"
+        );
+
+        let real_name = old_name.RealName();
+        assert_eq!(real_name.as_ref().map(String::as_str), Ok("OldName"));
+    });
+}
+
+#[test]
+fn test_renamed_interface_new_as_new() {
+    test_renamed_interface(|_, new_name| {
+        assert_eq!(
+            <BpNewName as INewName::INewName>::get_descriptor(),
+            "android.aidl.tests.IOldName"
+        );
+
+        let real_name = new_name.RealName();
+        assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName"));
+    });
+}
+
+#[test]
+fn test_renamed_interface_old_as_new() {
+    test_renamed_interface(|old_name, _| {
+        let new_name = old_name
+            .as_binder()
+            .into_interface::<dyn INewName::INewName>();
+        assert!(new_name.is_ok());
+
+        let real_name = new_name.unwrap().RealName();
+        assert_eq!(real_name.as_ref().map(String::as_str), Ok("OldName"));
+    });
+}
+
+#[test]
+fn test_renamed_interface_new_as_old() {
+    test_renamed_interface(|_, new_name| {
+        let old_name = new_name
+            .as_binder()
+            .into_interface::<dyn IOldName::IOldName>();
+        assert!(old_name.is_ok());
+
+        let real_name = old_name.unwrap().RealName();
+        assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName"));
+    });
+}
diff --git a/tests/rust/test_service.rs b/tests/rust/test_service.rs
new file mode 100644
index 0000000..b4bb2ee
--- /dev/null
+++ b/tests/rust/test_service.rs
@@ -0,0 +1,331 @@
+/*
+ * Copyright (C) 2020, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//! Test Rust service for the AIDL compiler.
+
+use aidl_test_interface::aidl::android::aidl::tests::ITestService::{
+    self, BnTestService, BpTestService,
+};
+use aidl_test_interface::aidl::android::aidl::tests::{
+    BackendType::BackendType,
+    ByteEnum::ByteEnum, ConstantExpressionEnum::ConstantExpressionEnum, INamedCallback, INewName,
+    IOldName, IntEnum::IntEnum, LongEnum::LongEnum, StructuredParcelable, Union,
+};
+use aidl_test_interface::binder::{self, Interface, ParcelFileDescriptor, SpIBinder};
+use aidl_test_versioned_interface::aidl::android::aidl::versioned::tests::{
+    IFooInterface, IFooInterface::BnFooInterface, IFooInterface::BpFooInterface, BazUnion::BazUnion,
+};
+use std::collections::HashMap;
+use std::sync::Mutex;
+
+fn dup_fd(fd: &ParcelFileDescriptor) -> ParcelFileDescriptor {
+    ParcelFileDescriptor::new(fd.as_ref().try_clone().unwrap())
+}
+
+struct NamedCallback(String);
+
+impl Interface for NamedCallback {}
+
+impl INamedCallback::INamedCallback for NamedCallback {
+    fn GetName(&self) -> binder::Result<String> {
+        Ok(self.0.clone())
+    }
+}
+
+struct OldName;
+
+impl Interface for OldName {}
+
+impl IOldName::IOldName for OldName {
+    fn RealName(&self) -> binder::Result<String> {
+        Ok("OldName".into())
+    }
+}
+
+#[derive(Debug, Default)]
+struct NewName;
+
+impl Interface for NewName {}
+
+impl INewName::INewName for NewName {
+    fn RealName(&self) -> binder::Result<String> {
+        Ok("NewName".into())
+    }
+}
+
+#[derive(Default)]
+struct TestService {
+    service_map: Mutex<HashMap<String, Box<dyn INamedCallback::INamedCallback>>>,
+}
+
+impl Interface for TestService {}
+
+macro_rules! impl_repeat {
+    ($repeat_name:ident, $type:ty) => {
+        fn $repeat_name(&self, token: $type) -> binder::Result<$type> {
+            Ok(token)
+        }
+    };
+}
+
+macro_rules! impl_reverse {
+    ($reverse_name:ident, $type:ty) => {
+        fn $reverse_name(
+            &self,
+            input: &[$type],
+            repeated: &mut Vec<$type>,
+        ) -> binder::Result<Vec<$type>> {
+            repeated.clear();
+            repeated.extend_from_slice(input);
+            Ok(input.iter().rev().cloned().collect())
+        }
+    };
+}
+
+macro_rules! impl_repeat_reverse {
+    ($repeat_name:ident, $reverse_name:ident, $type:ty) => {
+        impl_repeat! {$repeat_name, $type}
+        impl_reverse! {$reverse_name, $type}
+    };
+}
+
+macro_rules! impl_repeat_nullable {
+    ($repeat_nullable_name:ident, $type:ty) => {
+        fn $repeat_nullable_name(
+            &self,
+            input: Option<&[$type]>,
+        ) -> binder::Result<Option<Vec<$type>>> {
+            Ok(input.map(<[$type]>::to_vec))
+        }
+    };
+}
+
+impl ITestService::ITestService for TestService {
+    impl_repeat! {RepeatByte, i8}
+    impl_reverse! {ReverseByte, u8}
+
+    fn UnimplementedMethod(&self, _: i32) -> binder::Result<i32> {
+        // Pretend this method hasn't been implemented
+        Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+    }
+
+    fn TestOneway(&self) -> binder::Result<()> {
+        Err(binder::StatusCode::UNKNOWN_ERROR.into())
+    }
+
+    impl_repeat_reverse! {RepeatBoolean, ReverseBoolean, bool}
+    impl_repeat_reverse! {RepeatChar, ReverseChar, u16}
+    impl_repeat_reverse! {RepeatInt, ReverseInt, i32}
+    impl_repeat_reverse! {RepeatLong, ReverseLong, i64}
+    impl_repeat_reverse! {RepeatFloat, ReverseFloat, f32}
+    impl_repeat_reverse! {RepeatDouble, ReverseDouble, f64}
+    impl_repeat_reverse! {RepeatByteEnum, ReverseByteEnum, ByteEnum}
+    impl_repeat_reverse! {RepeatIntEnum, ReverseIntEnum, IntEnum}
+    impl_repeat_reverse! {RepeatLongEnum, ReverseLongEnum, LongEnum}
+    impl_reverse! {ReverseString, String}
+    impl_reverse! {ReverseStringList, String}
+    impl_reverse! {ReverseUtf8CppString, String}
+
+    fn RepeatString(&self, input: &str) -> binder::Result<String> {
+        Ok(input.into())
+    }
+
+    fn RepeatUtf8CppString(&self, input: &str) -> binder::Result<String> {
+        Ok(input.into())
+    }
+
+    fn GetOtherTestService(
+        &self,
+        name: &str,
+    ) -> binder::Result<Box<dyn INamedCallback::INamedCallback>> {
+        let mut service_map = self.service_map.lock().unwrap();
+        let other_service = service_map.entry(name.into()).or_insert_with(|| {
+            let named_callback = NamedCallback(name.into());
+            Box::new(INamedCallback::BnNamedCallback::new_binder(named_callback))
+        });
+        Ok(other_service.to_owned())
+    }
+
+    fn VerifyName(
+        &self,
+        service: &dyn INamedCallback::INamedCallback,
+        name: &str,
+    ) -> binder::Result<bool> {
+        service.GetName().map(|found_name| found_name == name)
+    }
+
+    fn RepeatParcelFileDescriptor(
+        &self,
+        read: &ParcelFileDescriptor,
+    ) -> binder::Result<ParcelFileDescriptor> {
+        Ok(dup_fd(read))
+    }
+
+    fn ReverseParcelFileDescriptorArray(
+        &self,
+        input: &[ParcelFileDescriptor],
+        repeated: &mut Vec<Option<ParcelFileDescriptor>>,
+    ) -> binder::Result<Vec<ParcelFileDescriptor>> {
+        repeated.clear();
+        repeated.extend(input.iter().map(dup_fd).map(Some));
+        Ok(input.iter().rev().map(dup_fd).collect())
+    }
+
+    fn ThrowServiceException(&self, code: i32) -> binder::Result<()> {
+        Err(binder::Status::new_service_specific_error(code, None))
+    }
+
+    impl_repeat_nullable! {RepeatNullableIntArray, i32}
+    impl_repeat_nullable! {RepeatNullableByteEnumArray, ByteEnum}
+    impl_repeat_nullable! {RepeatNullableIntEnumArray, IntEnum}
+    impl_repeat_nullable! {RepeatNullableLongEnumArray, LongEnum}
+    impl_repeat_nullable! {RepeatNullableStringList, Option<String>}
+
+    fn RepeatNullableString(&self, input: Option<&str>) -> binder::Result<Option<String>> {
+        Ok(input.map(String::from))
+    }
+
+    fn RepeatNullableUtf8CppString(&self, input: Option<&str>) -> binder::Result<Option<String>> {
+        Ok(input.map(String::from))
+    }
+
+    fn RepeatNullableParcelable(
+        &self,
+        input: Option<&StructuredParcelable::StructuredParcelable>,
+    ) -> binder::Result<Option<StructuredParcelable::StructuredParcelable>> {
+        Ok(input.cloned())
+    }
+
+    fn TakesAnIBinder(&self, _: &SpIBinder) -> binder::Result<()> {
+        Ok(())
+    }
+
+    fn TakesANullableIBinder(&self, _: Option<&SpIBinder>) -> binder::Result<()> {
+        Ok(())
+    }
+
+    fn ReverseNullableUtf8CppString(
+        &self,
+        input: Option<&[Option<String>]>,
+        repeated: &mut Option<Vec<Option<String>>>,
+    ) -> binder::Result<Option<Vec<Option<String>>>> {
+        if let Some(input) = input {
+            *repeated = Some(input.to_vec());
+            Ok(Some(input.iter().rev().cloned().collect()))
+        } else {
+            // We don't touch `repeated` here, since
+            // the C++ test service doesn't either
+            Ok(None)
+        }
+    }
+
+    fn ReverseUtf8CppStringList(
+        &self,
+        input: Option<&[Option<String>]>,
+        repeated: &mut Option<Vec<Option<String>>>,
+    ) -> binder::Result<Option<Vec<Option<String>>>> {
+        self.ReverseNullableUtf8CppString(input, repeated)
+    }
+
+    fn GetCallback(
+        &self,
+        return_null: bool,
+    ) -> binder::Result<Option<Box<dyn INamedCallback::INamedCallback>>> {
+        if return_null {
+            Ok(None)
+        } else {
+            self.GetOtherTestService("ABT: always be testing").map(Some)
+        }
+    }
+
+    fn FillOutStructuredParcelable(
+        &self,
+        parcelable: &mut StructuredParcelable::StructuredParcelable,
+    ) -> binder::Result<()> {
+        parcelable.shouldBeJerry = "Jerry".into();
+        parcelable.shouldContainThreeFs = vec![parcelable.f, parcelable.f, parcelable.f];
+        parcelable.shouldBeByteBar = ByteEnum::BAR;
+        parcelable.shouldBeIntBar = IntEnum::BAR;
+        parcelable.shouldBeLongBar = LongEnum::BAR;
+        parcelable.shouldContainTwoByteFoos = vec![ByteEnum::FOO, ByteEnum::FOO];
+        parcelable.shouldContainTwoIntFoos = vec![IntEnum::FOO, IntEnum::FOO];
+        parcelable.shouldContainTwoLongFoos = vec![LongEnum::FOO, LongEnum::FOO];
+
+        parcelable.const_exprs_1 = ConstantExpressionEnum::decInt32_1;
+        parcelable.const_exprs_2 = ConstantExpressionEnum::decInt32_2;
+        parcelable.const_exprs_3 = ConstantExpressionEnum::decInt64_1;
+        parcelable.const_exprs_4 = ConstantExpressionEnum::decInt64_2;
+        parcelable.const_exprs_5 = ConstantExpressionEnum::decInt64_3;
+        parcelable.const_exprs_6 = ConstantExpressionEnum::decInt64_4;
+        parcelable.const_exprs_7 = ConstantExpressionEnum::hexInt32_1;
+        parcelable.const_exprs_8 = ConstantExpressionEnum::hexInt32_2;
+        parcelable.const_exprs_9 = ConstantExpressionEnum::hexInt32_3;
+        parcelable.const_exprs_10 = ConstantExpressionEnum::hexInt64_1;
+
+        parcelable.shouldSetBit0AndBit2 = StructuredParcelable::BIT0 | StructuredParcelable::BIT2;
+
+        parcelable.u = Some(Union::Union::Ns(vec![1, 2, 3]));
+        parcelable.shouldBeConstS1 = Some(Union::Union::S(Union::S1.to_string()));
+        Ok(())
+    }
+
+    fn GetOldNameInterface(&self) -> binder::Result<Box<dyn IOldName::IOldName>> {
+        Ok(Box::new(IOldName::BnOldName::new_binder(OldName)))
+    }
+
+    fn GetNewNameInterface(&self) -> binder::Result<Box<dyn INewName::INewName>> {
+        Ok(Box::new(INewName::BnNewName::new_binder(NewName)))
+    }
+
+    fn GetCppJavaTests(&self) -> binder::Result<Option<SpIBinder>> {
+        Ok(None)
+    }
+
+    fn getBackendType(&self) -> binder::Result<BackendType> {
+        Ok(BackendType::RUST)
+    }
+}
+
+struct FooInterface;
+
+impl Interface for FooInterface {}
+
+impl IFooInterface::IFooInterface for FooInterface {
+    fn originalApi(&self) -> binder::Result<()> {
+        Ok(())
+    }
+    fn acceptUnionAndReturnString(&self, u: &BazUnion) -> binder::Result<String> {
+        match u {
+            BazUnion::IntNum(n) => Ok(n.to_string()),
+        }
+    }
+}
+
+fn main() {
+    binder::ProcessState::set_thread_pool_max_thread_count(0);
+    binder::ProcessState::start_thread_pool();
+
+    let service_name = <BpTestService as ITestService::ITestService>::get_descriptor();
+    let service = BnTestService::new_binder(TestService::default());
+    binder::add_service(service_name, service.as_binder()).expect("Could not register service");
+
+    let versioned_service_name = <BpFooInterface as IFooInterface::IFooInterface>::get_descriptor();
+    let versioned_service = BnFooInterface::new_binder(FooInterface);
+    binder::add_service(versioned_service_name, versioned_service.as_binder())
+        .expect("Could not register service");
+
+    binder::ProcessState::join_thread_pool();
+}
diff --git a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
index 6f2054e..55317cd 100644
--- a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
index 291c472..bf17dd9 100644
--- a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfExtendableParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
index 63ceb55..14c6b77 100644
--- a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfParcelable.aidl
index 6d00aaf..92d6f2f 100644
--- a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfParcelable.aidl
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfParcelable.aidl
@@ -1,14 +1,30 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 ///////////////////////////////////////////////////////////////////////////////
 // THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
 ///////////////////////////////////////////////////////////////////////////////
 
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
 //
-// You must not make a backward incompatible changes to the AIDL files built
+// You must not make a backward incompatible change to any AIDL file built
 // with the aidl_interface module type with versions property set. The module
 // type is used to build AIDL files in a way that they can be used across
 // independently updatable components of the system. If a device is shipped
diff --git a/tests/test_data.h b/tests/test_data.h
deleted file mode 100644
index 468e519..0000000
--- a/tests/test_data.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AIDL_TESTS_TEST_DATA_H_
-#define AIDL_TESTS_TEST_DATA_H_
-
-namespace android {
-namespace aidl {
-namespace test_data {
-
-namespace example_interface {
-
-extern const char kCanonicalName[];
-extern const char kJavaOutputPath[];
-extern const char kInterfaceDefinition[];
-extern const char kInterfaceDefinitionOutlining[];
-extern const char* kImportedParcelables[];
-extern const char* kImportedInterfaces[];
-
-extern const char kExpectedJavaDepsOutput[];
-extern const char kExpectedJavaOutput[];
-extern const char kExpectedJavaOutputOutlining[];
-extern const char kExpectedJavaOutputWithTransactionNames[];
-extern const char kExpectedJavaOutputWithTrace[];
-extern const char kExpectedJavaOutputWithVersionAndHash[];
-
-extern const char kRustOutputDirectory[];
-extern const char kRustOutputPath[];
-extern const char kExpectedRustDepsOutput[];
-extern const char kExpectedRustOutput[];
-extern const char kExpectedRustOutputWithVersionAndHash[];
-
-}  // namespace example_interface
-
-namespace ping_responder {
-
-extern const char kCanonicalName[];
-extern const char kInterfaceDefinition[];
-
-extern const char kCppOutputPath[];
-extern const char kCppParcelableHeader[];
-extern const char* kImportedParcelables[];
-extern const char* kImportedInterfaces[];
-
-extern const char kGenHeaderDir[];
-extern const char kGenInterfaceHeaderPath[];
-extern const char kGenClientHeaderPath[];
-extern const char kGenServerHeaderPath[];
-
-extern const char kExpectedCppDepsOutput[];
-
-extern const char kExpectedCppOutput[];
-extern const char kExpectedIHeaderOutput[];
-extern const char kExpectedBpHeaderOutput[];
-extern const char kExpectedBnHeaderOutput[];
-
-extern const char kExpectedCppOutputWithVersionAndHash[];
-extern const char kExpectedIHeaderOutputWithVersionAndHash[];
-extern const char kExpectedBpHeaderOutputWithVersionAndHash[];
-extern const char kExpectedBnHeaderOutputWithVersionAndHash[];
-
-extern const char kRustOutputDirectory[];
-extern const char kRustOutputPath[];
-extern const char kExpectedRustDepsOutput[];
-extern const char kExpectedRustOutput[];
-extern const char kExpectedRustOutputWithVersionAndHash[];
-
-}  // namespace ping_responder
-
-namespace string_constants {
-
-extern const char kCanonicalName[];
-extern const char kInterfaceDefinition[];
-
-extern const char kJavaOutputPath[];
-extern const char kExpectedJavaOutput[];
-
-extern const char kExpectedJavaOutputWithVersionAndHash[];
-
-extern const char kCppOutputPath[];
-extern const char kGenHeaderDir[];
-extern const char kGenInterfaceHeaderPath[];
-extern const char kExpectedIHeaderOutput[];
-extern const char kExpectedCppOutput[];
-
-extern const char kExpectedIHeaderOutputWithVersionAndHash[];
-extern const char kExpectedCppOutputWithVersionAndHash[];
-
-extern const char kRustOutputDirectory[];
-extern const char kRustOutputPath[];
-extern const char kExpectedRustOutput[];
-extern const char kExpectedRustOutputWithVersionAndHash[];
-
-}  // namespace string_constants
-
-}  // namespace test_data
-}  // namespace aidl
-}  // namespace android
-
-#endif // AIDL_TESTS_TEST_DATA_H_
diff --git a/tests/test_data_example_interface.cpp b/tests/test_data_example_interface.cpp
deleted file mode 100644
index 966b23b..0000000
--- a/tests/test_data_example_interface.cpp
+++ /dev/null
@@ -1,3600 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "tests/test_data.h"
-
-namespace android {
-namespace aidl {
-namespace test_data {
-namespace example_interface {
-
-const char kCanonicalName[] = "android.test.IExampleInterface";
-
-const char kJavaOutputPath[] = "some/path/to/output.java";
-
-const char* kImportedParcelables[] = {
-  "android.foo.ExampleParcelable",
-  nullptr,
-};
-
-const char* kImportedInterfaces[] = {
-  "android.bar.IAuxInterface",
-  "android.test.IAuxInterface2",
-  nullptr,
-};
-
-const char kInterfaceDefinition[] = R"(
-package android.test;
-
-import android.foo.ExampleParcelable;
-import android.test.CompoundParcelable;
-import android.bar.IAuxInterface;
-import android.test.IAuxInterface2;
-
-@Hide
-@UnsupportedAppUsage
-interface IExampleInterface {
-    const int EXAMPLE_CONSTANT = 3;
-    boolean isEnabled();
-    int getState();
-    String getAddress();
-
-    /* Test long comment */
-    @Hide
-    @UnsupportedAppUsage
-    ExampleParcelable[] getParcelables();
-
-    // Test short comment
-    boolean setScanMode(int mode, int duration);
-
-    /* Test long comment */
-    // And short comment
-    void registerBinder(IAuxInterface foo);
-    IExampleInterface getRecursiveBinder();
-
-    int takesAnInterface(in IAuxInterface2 arg);
-    int takesAParcelable(in CompoundParcelable.Subclass1 arg,
-                         inout CompoundParcelable.Subclass2 arg2);
-}
-)";
-
-const char kInterfaceDefinitionOutlining[] = R"(
-package android.test;
-
-import android.foo.ExampleParcelable;
-import android.test.CompoundParcelable;
-import android.bar.IAuxInterface;
-import android.test.IAuxInterface2;
-
-interface IExampleInterface {
-    const int EXAMPLE_CONSTANT = 3;
-    boolean isEnabled();
-    int getState(int a, int b);
-    String getAddress();
-
-    /* Test long comment */
-    ExampleParcelable[] getParcelables();
-
-    // Test short comment
-    boolean setScanMode(int mode, int duration);
-
-    /* Test long comment */
-    // And short comment
-    void registerBinder(IAuxInterface foo);
-    IExampleInterface getRecursiveBinder();
-
-    int takesAnInterface(in IAuxInterface2 arg);
-    int takesAParcelable(in CompoundParcelable.Subclass1 arg,
-                         inout CompoundParcelable.Subclass2 arg2);
-}
-)";
-
-const char kExpectedJavaDepsOutput[] =
-    R"(some/path/to/output.java : \
-  android/test/IExampleInterface.aidl \
-  ./android/foo/ExampleParcelable.aidl \
-  ./android/test/CompoundParcelable.aidl \
-  ./android/bar/IAuxInterface.aidl \
-  ./android/test/IAuxInterface2.aidl
-
-android/test/IExampleInterface.aidl :
-./android/foo/ExampleParcelable.aidl :
-./android/test/CompoundParcelable.aidl :
-./android/bar/IAuxInterface.aidl :
-./android/test/IAuxInterface2.aidl :
-)";
-
-const char kExpectedJavaOutput[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.test;
-@android.annotation.Hide
-@android.compat.annotation.UnsupportedAppUsage(overrideSourcePosition="android/test/IExampleInterface.aidl:10:1:10:21")
-public interface IExampleInterface extends android.os.IInterface
-{
-  /** Default implementation for IExampleInterface. */
-  public static class Default implements android.test.IExampleInterface
-  {
-    @Override public boolean isEnabled() throws android.os.RemoteException
-    {
-      return false;
-    }
-    @Override public int getState() throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public java.lang.String getAddress() throws android.os.RemoteException
-    {
-      return null;
-    }
-    /* Test long comment */
-    @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-    {
-      return null;
-    }
-    // Test short comment
-
-    @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-    {
-      return false;
-    }
-    /* Test long comment */// And short comment
-
-    @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-    {
-    }
-    @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-    {
-      return null;
-    }
-    @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.test.IExampleInterface
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.test.IExampleInterface interface,
-     * generating a proxy if needed.
-     */
-    public static android.test.IExampleInterface asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.test.IExampleInterface))) {
-        return ((android.test.IExampleInterface)iin);
-      }
-      return new android.test.IExampleInterface.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_isEnabled:
-        {
-          data.enforceInterface(descriptor);
-          boolean _result = this.isEnabled();
-          reply.writeNoException();
-          reply.writeInt(((_result)?(1):(0)));
-          return true;
-        }
-        case TRANSACTION_getState:
-        {
-          data.enforceInterface(descriptor);
-          int _result = this.getState();
-          reply.writeNoException();
-          reply.writeInt(_result);
-          return true;
-        }
-        case TRANSACTION_getAddress:
-        {
-          data.enforceInterface(descriptor);
-          java.lang.String _result = this.getAddress();
-          reply.writeNoException();
-          reply.writeString(_result);
-          return true;
-        }
-        case TRANSACTION_getParcelables:
-        {
-          data.enforceInterface(descriptor);
-          android.foo.ExampleParcelable[] _result = this.getParcelables();
-          reply.writeNoException();
-          reply.writeTypedArray(_result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-          return true;
-        }
-        case TRANSACTION_setScanMode:
-        {
-          data.enforceInterface(descriptor);
-          int _arg0;
-          _arg0 = data.readInt();
-          int _arg1;
-          _arg1 = data.readInt();
-          boolean _result = this.setScanMode(_arg0, _arg1);
-          reply.writeNoException();
-          reply.writeInt(((_result)?(1):(0)));
-          return true;
-        }
-        case TRANSACTION_registerBinder:
-        {
-          data.enforceInterface(descriptor);
-          android.bar.IAuxInterface _arg0;
-          _arg0 = android.bar.IAuxInterface.Stub.asInterface(data.readStrongBinder());
-          this.registerBinder(_arg0);
-          reply.writeNoException();
-          return true;
-        }
-        case TRANSACTION_getRecursiveBinder:
-        {
-          data.enforceInterface(descriptor);
-          android.test.IExampleInterface _result = this.getRecursiveBinder();
-          reply.writeNoException();
-          reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
-          return true;
-        }
-        case TRANSACTION_takesAnInterface:
-        {
-          data.enforceInterface(descriptor);
-          android.test.IAuxInterface2 _arg0;
-          _arg0 = android.test.IAuxInterface2.Stub.asInterface(data.readStrongBinder());
-          int _result = this.takesAnInterface(_arg0);
-          reply.writeNoException();
-          reply.writeInt(_result);
-          return true;
-        }
-        case TRANSACTION_takesAParcelable:
-        {
-          data.enforceInterface(descriptor);
-          android.test.CompoundParcelable.Subclass1 _arg0;
-          if ((0!=data.readInt())) {
-            _arg0 = android.test.CompoundParcelable.Subclass1.CREATOR.createFromParcel(data);
-          }
-          else {
-            _arg0 = null;
-          }
-          android.test.CompoundParcelable.Subclass2 _arg1;
-          if ((0!=data.readInt())) {
-            _arg1 = android.test.CompoundParcelable.Subclass2.CREATOR.createFromParcel(data);
-          }
-          else {
-            _arg1 = null;
-          }
-          int _result = this.takesAParcelable(_arg0, _arg1);
-          reply.writeNoException();
-          reply.writeInt(_result);
-          if ((_arg1!=null)) {
-            reply.writeInt(1);
-            _arg1.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-          }
-          else {
-            reply.writeInt(0);
-          }
-          return true;
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.test.IExampleInterface
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override public boolean isEnabled() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().isEnabled();
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int getState() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getState();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public java.lang.String getAddress() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        java.lang.String _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getAddress();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readString();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */
-      @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.foo.ExampleParcelable[] _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getParcelables();
-            }
-          }
-          _reply.readException();
-          _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      // Test short comment
-
-      @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(mode);
-          _data.writeInt(duration);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().setScanMode(mode, duration);
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */// And short comment
-
-      @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              getDefaultImpl().registerBinder(foo);
-              return;
-            }
-          }
-          _reply.readException();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-      }
-      @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.test.IExampleInterface _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getRecursiveBinder();
-            }
-          }
-          _reply.readException();
-          _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAnInterface(arg);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          if ((arg!=null)) {
-            _data.writeInt(1);
-            arg.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          if ((arg2!=null)) {
-            _data.writeInt(1);
-            arg2.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAParcelable(arg, arg2);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-          if ((0!=_reply.readInt())) {
-            arg2.readFromParcel(_reply);
-          }
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      public static android.test.IExampleInterface sDefaultImpl;
-    }
-    static final int TRANSACTION_isEnabled = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
-    static final int TRANSACTION_getState = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
-    static final int TRANSACTION_getAddress = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
-    static final int TRANSACTION_getParcelables = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
-    static final int TRANSACTION_setScanMode = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
-    static final int TRANSACTION_registerBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
-    static final int TRANSACTION_getRecursiveBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
-    static final int TRANSACTION_takesAnInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
-    static final int TRANSACTION_takesAParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
-    public static boolean setDefaultImpl(android.test.IExampleInterface impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.test.IExampleInterface getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.test.IExampleInterface";
-  public static final int EXAMPLE_CONSTANT = 3;
-  public boolean isEnabled() throws android.os.RemoteException;
-  public int getState() throws android.os.RemoteException;
-  public java.lang.String getAddress() throws android.os.RemoteException;
-  /* Test long comment */
-  @android.annotation.Hide
-  @android.compat.annotation.UnsupportedAppUsage(overrideSourcePosition="android/test/IExampleInterface.aidl:19:1:19:25")
-  public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException;
-  // Test short comment
-
-  public boolean setScanMode(int mode, int duration) throws android.os.RemoteException;
-  /* Test long comment */// And short comment
-
-  public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException;
-  public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException;
-  public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException;
-  public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException;
-}
-)";
-
-const char kExpectedJavaOutputWithTransactionNames[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.test;
-@android.annotation.Hide
-@android.compat.annotation.UnsupportedAppUsage(overrideSourcePosition="android/test/IExampleInterface.aidl:10:1:10:21")
-public interface IExampleInterface extends android.os.IInterface
-{
-  /** Default implementation for IExampleInterface. */
-  public static class Default implements android.test.IExampleInterface
-  {
-    @Override public boolean isEnabled() throws android.os.RemoteException
-    {
-      return false;
-    }
-    @Override public int getState() throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public java.lang.String getAddress() throws android.os.RemoteException
-    {
-      return null;
-    }
-    /* Test long comment */
-    @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-    {
-      return null;
-    }
-    // Test short comment
-
-    @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-    {
-      return false;
-    }
-    /* Test long comment */// And short comment
-
-    @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-    {
-    }
-    @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-    {
-      return null;
-    }
-    @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.test.IExampleInterface
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.test.IExampleInterface interface,
-     * generating a proxy if needed.
-     */
-    public static android.test.IExampleInterface asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.test.IExampleInterface))) {
-        return ((android.test.IExampleInterface)iin);
-      }
-      return new android.test.IExampleInterface.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    /** @hide */
-    public static java.lang.String getDefaultTransactionName(int transactionCode)
-    {
-      switch (transactionCode)
-      {
-        case TRANSACTION_isEnabled:
-        {
-          return "isEnabled";
-        }
-        case TRANSACTION_getState:
-        {
-          return "getState";
-        }
-        case TRANSACTION_getAddress:
-        {
-          return "getAddress";
-        }
-        case TRANSACTION_getParcelables:
-        {
-          return "getParcelables";
-        }
-        case TRANSACTION_setScanMode:
-        {
-          return "setScanMode";
-        }
-        case TRANSACTION_registerBinder:
-        {
-          return "registerBinder";
-        }
-        case TRANSACTION_getRecursiveBinder:
-        {
-          return "getRecursiveBinder";
-        }
-        case TRANSACTION_takesAnInterface:
-        {
-          return "takesAnInterface";
-        }
-        case TRANSACTION_takesAParcelable:
-        {
-          return "takesAParcelable";
-        }
-        default:
-        {
-          return null;
-        }
-      }
-    }
-    /** @hide */
-    public java.lang.String getTransactionName(int transactionCode)
-    {
-      return this.getDefaultTransactionName(transactionCode);
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_isEnabled:
-        {
-          data.enforceInterface(descriptor);
-          boolean _result = this.isEnabled();
-          reply.writeNoException();
-          reply.writeInt(((_result)?(1):(0)));
-          return true;
-        }
-        case TRANSACTION_getState:
-        {
-          data.enforceInterface(descriptor);
-          int _result = this.getState();
-          reply.writeNoException();
-          reply.writeInt(_result);
-          return true;
-        }
-        case TRANSACTION_getAddress:
-        {
-          data.enforceInterface(descriptor);
-          java.lang.String _result = this.getAddress();
-          reply.writeNoException();
-          reply.writeString(_result);
-          return true;
-        }
-        case TRANSACTION_getParcelables:
-        {
-          data.enforceInterface(descriptor);
-          android.foo.ExampleParcelable[] _result = this.getParcelables();
-          reply.writeNoException();
-          reply.writeTypedArray(_result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-          return true;
-        }
-        case TRANSACTION_setScanMode:
-        {
-          data.enforceInterface(descriptor);
-          int _arg0;
-          _arg0 = data.readInt();
-          int _arg1;
-          _arg1 = data.readInt();
-          boolean _result = this.setScanMode(_arg0, _arg1);
-          reply.writeNoException();
-          reply.writeInt(((_result)?(1):(0)));
-          return true;
-        }
-        case TRANSACTION_registerBinder:
-        {
-          data.enforceInterface(descriptor);
-          android.bar.IAuxInterface _arg0;
-          _arg0 = android.bar.IAuxInterface.Stub.asInterface(data.readStrongBinder());
-          this.registerBinder(_arg0);
-          reply.writeNoException();
-          return true;
-        }
-        case TRANSACTION_getRecursiveBinder:
-        {
-          data.enforceInterface(descriptor);
-          android.test.IExampleInterface _result = this.getRecursiveBinder();
-          reply.writeNoException();
-          reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
-          return true;
-        }
-        case TRANSACTION_takesAnInterface:
-        {
-          data.enforceInterface(descriptor);
-          android.test.IAuxInterface2 _arg0;
-          _arg0 = android.test.IAuxInterface2.Stub.asInterface(data.readStrongBinder());
-          int _result = this.takesAnInterface(_arg0);
-          reply.writeNoException();
-          reply.writeInt(_result);
-          return true;
-        }
-        case TRANSACTION_takesAParcelable:
-        {
-          data.enforceInterface(descriptor);
-          android.test.CompoundParcelable.Subclass1 _arg0;
-          if ((0!=data.readInt())) {
-            _arg0 = android.test.CompoundParcelable.Subclass1.CREATOR.createFromParcel(data);
-          }
-          else {
-            _arg0 = null;
-          }
-          android.test.CompoundParcelable.Subclass2 _arg1;
-          if ((0!=data.readInt())) {
-            _arg1 = android.test.CompoundParcelable.Subclass2.CREATOR.createFromParcel(data);
-          }
-          else {
-            _arg1 = null;
-          }
-          int _result = this.takesAParcelable(_arg0, _arg1);
-          reply.writeNoException();
-          reply.writeInt(_result);
-          if ((_arg1!=null)) {
-            reply.writeInt(1);
-            _arg1.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-          }
-          else {
-            reply.writeInt(0);
-          }
-          return true;
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.test.IExampleInterface
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override public boolean isEnabled() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().isEnabled();
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int getState() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getState();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public java.lang.String getAddress() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        java.lang.String _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getAddress();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readString();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */
-      @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.foo.ExampleParcelable[] _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getParcelables();
-            }
-          }
-          _reply.readException();
-          _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      // Test short comment
-
-      @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(mode);
-          _data.writeInt(duration);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().setScanMode(mode, duration);
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */// And short comment
-
-      @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              getDefaultImpl().registerBinder(foo);
-              return;
-            }
-          }
-          _reply.readException();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-      }
-      @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.test.IExampleInterface _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getRecursiveBinder();
-            }
-          }
-          _reply.readException();
-          _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAnInterface(arg);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          if ((arg!=null)) {
-            _data.writeInt(1);
-            arg.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          if ((arg2!=null)) {
-            _data.writeInt(1);
-            arg2.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAParcelable(arg, arg2);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-          if ((0!=_reply.readInt())) {
-            arg2.readFromParcel(_reply);
-          }
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      public static android.test.IExampleInterface sDefaultImpl;
-    }
-    static final int TRANSACTION_isEnabled = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
-    static final int TRANSACTION_getState = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
-    static final int TRANSACTION_getAddress = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
-    static final int TRANSACTION_getParcelables = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
-    static final int TRANSACTION_setScanMode = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
-    static final int TRANSACTION_registerBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
-    static final int TRANSACTION_getRecursiveBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
-    static final int TRANSACTION_takesAnInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
-    static final int TRANSACTION_takesAParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
-    public static boolean setDefaultImpl(android.test.IExampleInterface impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.test.IExampleInterface getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.test.IExampleInterface";
-  public static final int EXAMPLE_CONSTANT = 3;
-  public boolean isEnabled() throws android.os.RemoteException;
-  public int getState() throws android.os.RemoteException;
-  public java.lang.String getAddress() throws android.os.RemoteException;
-  /* Test long comment */
-  @android.annotation.Hide
-  @android.compat.annotation.UnsupportedAppUsage(overrideSourcePosition="android/test/IExampleInterface.aidl:19:1:19:25")
-  public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException;
-  // Test short comment
-
-  public boolean setScanMode(int mode, int duration) throws android.os.RemoteException;
-  /* Test long comment */// And short comment
-
-  public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException;
-  public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException;
-  public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException;
-  public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException;
-}
-)";
-
-const char kExpectedJavaOutputWithTrace[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.test;
-@android.annotation.Hide
-@android.compat.annotation.UnsupportedAppUsage(overrideSourcePosition="android/test/IExampleInterface.aidl:10:1:10:21")
-public interface IExampleInterface extends android.os.IInterface
-{
-  /** Default implementation for IExampleInterface. */
-  public static class Default implements android.test.IExampleInterface
-  {
-    @Override public boolean isEnabled() throws android.os.RemoteException
-    {
-      return false;
-    }
-    @Override public int getState() throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public java.lang.String getAddress() throws android.os.RemoteException
-    {
-      return null;
-    }
-    /* Test long comment */
-    @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-    {
-      return null;
-    }
-    // Test short comment
-
-    @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-    {
-      return false;
-    }
-    /* Test long comment */// And short comment
-
-    @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-    {
-    }
-    @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-    {
-      return null;
-    }
-    @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.test.IExampleInterface
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.test.IExampleInterface interface,
-     * generating a proxy if needed.
-     */
-    public static android.test.IExampleInterface asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.test.IExampleInterface))) {
-        return ((android.test.IExampleInterface)iin);
-      }
-      return new android.test.IExampleInterface.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_isEnabled:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::isEnabled::server");
-            data.enforceInterface(descriptor);
-            boolean _result = this.isEnabled();
-            reply.writeNoException();
-            reply.writeInt(((_result)?(1):(0)));
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_getState:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getState::server");
-            data.enforceInterface(descriptor);
-            int _result = this.getState();
-            reply.writeNoException();
-            reply.writeInt(_result);
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_getAddress:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getAddress::server");
-            data.enforceInterface(descriptor);
-            java.lang.String _result = this.getAddress();
-            reply.writeNoException();
-            reply.writeString(_result);
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_getParcelables:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getParcelables::server");
-            data.enforceInterface(descriptor);
-            android.foo.ExampleParcelable[] _result = this.getParcelables();
-            reply.writeNoException();
-            reply.writeTypedArray(_result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_setScanMode:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::setScanMode::server");
-            data.enforceInterface(descriptor);
-            int _arg0;
-            _arg0 = data.readInt();
-            int _arg1;
-            _arg1 = data.readInt();
-            boolean _result = this.setScanMode(_arg0, _arg1);
-            reply.writeNoException();
-            reply.writeInt(((_result)?(1):(0)));
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_registerBinder:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::registerBinder::server");
-            data.enforceInterface(descriptor);
-            android.bar.IAuxInterface _arg0;
-            _arg0 = android.bar.IAuxInterface.Stub.asInterface(data.readStrongBinder());
-            this.registerBinder(_arg0);
-            reply.writeNoException();
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_getRecursiveBinder:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getRecursiveBinder::server");
-            data.enforceInterface(descriptor);
-            android.test.IExampleInterface _result = this.getRecursiveBinder();
-            reply.writeNoException();
-            reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_takesAnInterface:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::takesAnInterface::server");
-            data.enforceInterface(descriptor);
-            android.test.IAuxInterface2 _arg0;
-            _arg0 = android.test.IAuxInterface2.Stub.asInterface(data.readStrongBinder());
-            int _result = this.takesAnInterface(_arg0);
-            reply.writeNoException();
-            reply.writeInt(_result);
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        case TRANSACTION_takesAParcelable:
-        {
-          try {
-            android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::takesAParcelable::server");
-            data.enforceInterface(descriptor);
-            android.test.CompoundParcelable.Subclass1 _arg0;
-            if ((0!=data.readInt())) {
-              _arg0 = android.test.CompoundParcelable.Subclass1.CREATOR.createFromParcel(data);
-            }
-            else {
-              _arg0 = null;
-            }
-            android.test.CompoundParcelable.Subclass2 _arg1;
-            if ((0!=data.readInt())) {
-              _arg1 = android.test.CompoundParcelable.Subclass2.CREATOR.createFromParcel(data);
-            }
-            else {
-              _arg1 = null;
-            }
-            int _result = this.takesAParcelable(_arg0, _arg1);
-            reply.writeNoException();
-            reply.writeInt(_result);
-            if ((_arg1!=null)) {
-              reply.writeInt(1);
-              _arg1.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-            }
-            else {
-              reply.writeInt(0);
-            }
-            return true;
-          }
-          finally {
-            android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-          }
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.test.IExampleInterface
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override public boolean isEnabled() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::isEnabled::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().isEnabled();
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      @Override public int getState() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getState::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getState();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      @Override public java.lang.String getAddress() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        java.lang.String _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getAddress::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getAddress();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readString();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      /* Test long comment */
-      @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.foo.ExampleParcelable[] _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getParcelables::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getParcelables();
-            }
-          }
-          _reply.readException();
-          _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      // Test short comment
-
-      @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::setScanMode::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(mode);
-          _data.writeInt(duration);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().setScanMode(mode, duration);
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      /* Test long comment */// And short comment
-
-      @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::registerBinder::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              getDefaultImpl().registerBinder(foo);
-              return;
-            }
-          }
-          _reply.readException();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-      }
-      @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.test.IExampleInterface _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::getRecursiveBinder::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getRecursiveBinder();
-            }
-          }
-          _reply.readException();
-          _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::takesAnInterface::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAnInterface(arg);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "AIDL::java::IExampleInterface::takesAParcelable::client");
-          _data.writeInterfaceToken(DESCRIPTOR);
-          if ((arg!=null)) {
-            _data.writeInt(1);
-            arg.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          if ((arg2!=null)) {
-            _data.writeInt(1);
-            arg2.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAParcelable(arg, arg2);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-          if ((0!=_reply.readInt())) {
-            arg2.readFromParcel(_reply);
-          }
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-          android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
-        }
-        return _result;
-      }
-      public static android.test.IExampleInterface sDefaultImpl;
-    }
-    static final int TRANSACTION_isEnabled = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
-    static final int TRANSACTION_getState = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
-    static final int TRANSACTION_getAddress = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
-    static final int TRANSACTION_getParcelables = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
-    static final int TRANSACTION_setScanMode = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
-    static final int TRANSACTION_registerBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
-    static final int TRANSACTION_getRecursiveBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
-    static final int TRANSACTION_takesAnInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
-    static final int TRANSACTION_takesAParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
-    public static boolean setDefaultImpl(android.test.IExampleInterface impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.test.IExampleInterface getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.test.IExampleInterface";
-  public static final int EXAMPLE_CONSTANT = 3;
-  public boolean isEnabled() throws android.os.RemoteException;
-  public int getState() throws android.os.RemoteException;
-  public java.lang.String getAddress() throws android.os.RemoteException;
-  /* Test long comment */
-  @android.annotation.Hide
-  @android.compat.annotation.UnsupportedAppUsage(overrideSourcePosition="android/test/IExampleInterface.aidl:19:1:19:25")
-  public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException;
-  // Test short comment
-
-  public boolean setScanMode(int mode, int duration) throws android.os.RemoteException;
-  /* Test long comment */// And short comment
-
-  public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException;
-  public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException;
-  public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException;
-  public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException;
-}
-)";
-
-const char kExpectedJavaOutputOutlining[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.test;
-public interface IExampleInterface extends android.os.IInterface
-{
-  /** Default implementation for IExampleInterface. */
-  public static class Default implements android.test.IExampleInterface
-  {
-    @Override public boolean isEnabled() throws android.os.RemoteException
-    {
-      return false;
-    }
-    @Override public int getState(int a, int b) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public java.lang.String getAddress() throws android.os.RemoteException
-    {
-      return null;
-    }
-    /* Test long comment */
-    @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-    {
-      return null;
-    }
-    // Test short comment
-
-    @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-    {
-      return false;
-    }
-    /* Test long comment */// And short comment
-
-    @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-    {
-    }
-    @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-    {
-      return null;
-    }
-    @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.test.IExampleInterface
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.test.IExampleInterface interface,
-     * generating a proxy if needed.
-     */
-    public static android.test.IExampleInterface asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.test.IExampleInterface))) {
-        return ((android.test.IExampleInterface)iin);
-      }
-      return new android.test.IExampleInterface.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_isEnabled:
-        {
-          data.enforceInterface(descriptor);
-          boolean _result = this.isEnabled();
-          reply.writeNoException();
-          reply.writeInt(((_result)?(1):(0)));
-          return true;
-        }
-        case TRANSACTION_getState:
-        {
-          return this.onTransact$getState$(data, reply);
-        }
-        case TRANSACTION_getAddress:
-        {
-          data.enforceInterface(descriptor);
-          java.lang.String _result = this.getAddress();
-          reply.writeNoException();
-          reply.writeString(_result);
-          return true;
-        }
-        case TRANSACTION_getParcelables:
-        {
-          data.enforceInterface(descriptor);
-          android.foo.ExampleParcelable[] _result = this.getParcelables();
-          reply.writeNoException();
-          reply.writeTypedArray(_result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-          return true;
-        }
-        case TRANSACTION_setScanMode:
-        {
-          return this.onTransact$setScanMode$(data, reply);
-        }
-        case TRANSACTION_registerBinder:
-        {
-          return this.onTransact$registerBinder$(data, reply);
-        }
-        case TRANSACTION_getRecursiveBinder:
-        {
-          return this.onTransact$getRecursiveBinder$(data, reply);
-        }
-        case TRANSACTION_takesAnInterface:
-        {
-          return this.onTransact$takesAnInterface$(data, reply);
-        }
-        case TRANSACTION_takesAParcelable:
-        {
-          return this.onTransact$takesAParcelable$(data, reply);
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.test.IExampleInterface
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override public boolean isEnabled() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().isEnabled();
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int getState(int a, int b) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(a);
-          _data.writeInt(b);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getState(a, b);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public java.lang.String getAddress() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        java.lang.String _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getAddress();
-            }
-          }
-          _reply.readException();
-          _result = _reply.readString();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */
-      @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.foo.ExampleParcelable[] _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getParcelables();
-            }
-          }
-          _reply.readException();
-          _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      // Test short comment
-
-      @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(mode);
-          _data.writeInt(duration);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().setScanMode(mode, duration);
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */// And short comment
-
-      @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              getDefaultImpl().registerBinder(foo);
-              return;
-            }
-          }
-          _reply.readException();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-      }
-      @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.test.IExampleInterface _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getRecursiveBinder();
-            }
-          }
-          _reply.readException();
-          _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAnInterface(arg);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          if ((arg!=null)) {
-            _data.writeInt(1);
-            arg.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          if ((arg2!=null)) {
-            _data.writeInt(1);
-            arg2.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAParcelable(arg, arg2);
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-          if ((0!=_reply.readInt())) {
-            arg2.readFromParcel(_reply);
-          }
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      public static android.test.IExampleInterface sDefaultImpl;
-    }
-    static final int TRANSACTION_isEnabled = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
-    static final int TRANSACTION_getState = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
-    private boolean onTransact$getState$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      int _arg0;
-      _arg0 = data.readInt();
-      int _arg1;
-      _arg1 = data.readInt();
-      int _result = this.getState(_arg0, _arg1);
-      reply.writeNoException();
-      reply.writeInt(_result);
-      return true;
-    }
-    static final int TRANSACTION_getAddress = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
-    static final int TRANSACTION_getParcelables = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
-    static final int TRANSACTION_setScanMode = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
-    private boolean onTransact$setScanMode$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      int _arg0;
-      _arg0 = data.readInt();
-      int _arg1;
-      _arg1 = data.readInt();
-      boolean _result = this.setScanMode(_arg0, _arg1);
-      reply.writeNoException();
-      reply.writeInt(((_result)?(1):(0)));
-      return true;
-    }
-    static final int TRANSACTION_registerBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
-    private boolean onTransact$registerBinder$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.bar.IAuxInterface _arg0;
-      _arg0 = android.bar.IAuxInterface.Stub.asInterface(data.readStrongBinder());
-      this.registerBinder(_arg0);
-      reply.writeNoException();
-      return true;
-    }
-    static final int TRANSACTION_getRecursiveBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
-    private boolean onTransact$getRecursiveBinder$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.test.IExampleInterface _result = this.getRecursiveBinder();
-      reply.writeNoException();
-      reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
-      return true;
-    }
-    static final int TRANSACTION_takesAnInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
-    private boolean onTransact$takesAnInterface$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.test.IAuxInterface2 _arg0;
-      _arg0 = android.test.IAuxInterface2.Stub.asInterface(data.readStrongBinder());
-      int _result = this.takesAnInterface(_arg0);
-      reply.writeNoException();
-      reply.writeInt(_result);
-      return true;
-    }
-    static final int TRANSACTION_takesAParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
-    private boolean onTransact$takesAParcelable$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.test.CompoundParcelable.Subclass1 _arg0;
-      if ((0!=data.readInt())) {
-        _arg0 = android.test.CompoundParcelable.Subclass1.CREATOR.createFromParcel(data);
-      }
-      else {
-        _arg0 = null;
-      }
-      android.test.CompoundParcelable.Subclass2 _arg1;
-      if ((0!=data.readInt())) {
-        _arg1 = android.test.CompoundParcelable.Subclass2.CREATOR.createFromParcel(data);
-      }
-      else {
-        _arg1 = null;
-      }
-      int _result = this.takesAParcelable(_arg0, _arg1);
-      reply.writeNoException();
-      reply.writeInt(_result);
-      if ((_arg1!=null)) {
-        reply.writeInt(1);
-        _arg1.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-      }
-      else {
-        reply.writeInt(0);
-      }
-      return true;
-    }
-    public static boolean setDefaultImpl(android.test.IExampleInterface impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.test.IExampleInterface getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.test.IExampleInterface";
-  public static final int EXAMPLE_CONSTANT = 3;
-  public boolean isEnabled() throws android.os.RemoteException;
-  public int getState(int a, int b) throws android.os.RemoteException;
-  public java.lang.String getAddress() throws android.os.RemoteException;
-  /* Test long comment */
-  public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException;
-  // Test short comment
-
-  public boolean setScanMode(int mode, int duration) throws android.os.RemoteException;
-  /* Test long comment */// And short comment
-
-  public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException;
-  public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException;
-  public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException;
-  public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException;
-}
-)";
-
-const char kExpectedJavaOutputWithVersionAndHash[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.test;
-public interface IExampleInterface extends android.os.IInterface
-{
-  /**
-   * The version of this interface that the caller is built against.
-   * This might be different from what {@link #getInterfaceVersion()
-   * getInterfaceVersion} returns as that is the version of the interface
-   * that the remote object is implementing.
-   */
-  public static final int VERSION = 10;
-  public static final String HASH = "abcdefg";
-  /** Default implementation for IExampleInterface. */
-  public static class Default implements android.test.IExampleInterface
-  {
-    @Override public boolean isEnabled() throws android.os.RemoteException
-    {
-      return false;
-    }
-    @Override public int getState(int a, int b) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public java.lang.String getAddress() throws android.os.RemoteException
-    {
-      return null;
-    }
-    /* Test long comment */
-    @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-    {
-      return null;
-    }
-    // Test short comment
-
-    @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-    {
-      return false;
-    }
-    /* Test long comment */// And short comment
-
-    @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-    {
-    }
-    @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-    {
-      return null;
-    }
-    @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-    {
-      return 0;
-    }
-    @Override
-    public int getInterfaceVersion() {
-      return 0;
-    }
-    @Override
-    public String getInterfaceHash() {
-      return "";
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.test.IExampleInterface
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.test.IExampleInterface interface,
-     * generating a proxy if needed.
-     */
-    public static android.test.IExampleInterface asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.test.IExampleInterface))) {
-        return ((android.test.IExampleInterface)iin);
-      }
-      return new android.test.IExampleInterface.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_isEnabled:
-        {
-          data.enforceInterface(descriptor);
-          boolean _result = this.isEnabled();
-          reply.writeNoException();
-          reply.writeInt(((_result)?(1):(0)));
-          return true;
-        }
-        case TRANSACTION_getState:
-        {
-          return this.onTransact$getState$(data, reply);
-        }
-        case TRANSACTION_getAddress:
-        {
-          data.enforceInterface(descriptor);
-          java.lang.String _result = this.getAddress();
-          reply.writeNoException();
-          reply.writeString(_result);
-          return true;
-        }
-        case TRANSACTION_getParcelables:
-        {
-          data.enforceInterface(descriptor);
-          android.foo.ExampleParcelable[] _result = this.getParcelables();
-          reply.writeNoException();
-          reply.writeTypedArray(_result, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-          return true;
-        }
-        case TRANSACTION_setScanMode:
-        {
-          return this.onTransact$setScanMode$(data, reply);
-        }
-        case TRANSACTION_registerBinder:
-        {
-          return this.onTransact$registerBinder$(data, reply);
-        }
-        case TRANSACTION_getRecursiveBinder:
-        {
-          return this.onTransact$getRecursiveBinder$(data, reply);
-        }
-        case TRANSACTION_takesAnInterface:
-        {
-          return this.onTransact$takesAnInterface$(data, reply);
-        }
-        case TRANSACTION_takesAParcelable:
-        {
-          return this.onTransact$takesAParcelable$(data, reply);
-        }
-        case TRANSACTION_getInterfaceVersion:
-        {
-          data.enforceInterface(descriptor);
-          reply.writeNoException();
-          reply.writeInt(getInterfaceVersion());
-          return true;
-        }
-        case TRANSACTION_getInterfaceHash:
-        {
-          data.enforceInterface(descriptor);
-          reply.writeNoException();
-          reply.writeString(getInterfaceHash());
-          return true;
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.test.IExampleInterface
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      private int mCachedVersion = -1;
-      private String mCachedHash = "-1";
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override public boolean isEnabled() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().isEnabled();
-            }
-            else {
-              throw new android.os.RemoteException("Method isEnabled is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int getState(int a, int b) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(a);
-          _data.writeInt(b);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getState(a, b);
-            }
-            else {
-              throw new android.os.RemoteException("Method getState is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public java.lang.String getAddress() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        java.lang.String _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getAddress();
-            }
-            else {
-              throw new android.os.RemoteException("Method getAddress is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = _reply.readString();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */
-      @Override public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.foo.ExampleParcelable[] _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getParcelables();
-            }
-            else {
-              throw new android.os.RemoteException("Method getParcelables is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = _reply.createTypedArray(android.foo.ExampleParcelable.CREATOR);
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      // Test short comment
-
-      @Override public boolean setScanMode(int mode, int duration) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        boolean _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeInt(mode);
-          _data.writeInt(duration);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().setScanMode(mode, duration);
-            }
-            else {
-              throw new android.os.RemoteException("Method setScanMode is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = (0!=_reply.readInt());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      /* Test long comment */// And short comment
-
-      @Override public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((foo!=null))?(foo.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_registerBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              getDefaultImpl().registerBinder(foo);
-              return;
-            }
-            else {
-              throw new android.os.RemoteException("Method registerBinder is unimplemented.");
-            }
-          }
-          _reply.readException();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-      }
-      @Override public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        android.test.IExampleInterface _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().getRecursiveBinder();
-            }
-            else {
-              throw new android.os.RemoteException("Method getRecursiveBinder is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = android.test.IExampleInterface.Stub.asInterface(_reply.readStrongBinder());
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeStrongBinder((((arg!=null))?(arg.asBinder()):(null)));
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAnInterface, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAnInterface(arg);
-            }
-            else {
-              throw new android.os.RemoteException("Method takesAnInterface is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          if ((arg!=null)) {
-            _data.writeInt(1);
-            arg.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          if ((arg2!=null)) {
-            _data.writeInt(1);
-            arg2.writeToParcel(_data, 0);
-          }
-          else {
-            _data.writeInt(0);
-          }
-          boolean _status = mRemote.transact(Stub.TRANSACTION_takesAParcelable, _data, _reply, 0);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().takesAParcelable(arg, arg2);
-            }
-            else {
-              throw new android.os.RemoteException("Method takesAParcelable is unimplemented.");
-            }
-          }
-          _reply.readException();
-          _result = _reply.readInt();
-          if ((0!=_reply.readInt())) {
-            arg2.readFromParcel(_reply);
-          }
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
-      @Override
-      public int getInterfaceVersion() throws android.os.RemoteException {
-        if (mCachedVersion == -1) {
-          android.os.Parcel data = android.os.Parcel.obtain();
-          android.os.Parcel reply = android.os.Parcel.obtain();
-          try {
-            data.writeInterfaceToken(DESCRIPTOR);
-            boolean _status = mRemote.transact(Stub.TRANSACTION_getInterfaceVersion, data, reply, 0);
-            if (!_status) {
-              if (getDefaultImpl() != null) {
-                return getDefaultImpl().getInterfaceVersion();
-              }
-            }
-            reply.readException();
-            mCachedVersion = reply.readInt();
-          } finally {
-            reply.recycle();
-            data.recycle();
-          }
-        }
-        return mCachedVersion;
-      }
-      @Override
-      public synchronized String getInterfaceHash() throws android.os.RemoteException {
-        if ("-1".equals(mCachedHash)) {
-          android.os.Parcel data = android.os.Parcel.obtain();
-          android.os.Parcel reply = android.os.Parcel.obtain();
-          try {
-            data.writeInterfaceToken(DESCRIPTOR);
-            boolean _status = mRemote.transact(Stub.TRANSACTION_getInterfaceHash, data, reply, 0);
-            if (!_status) {
-              if (getDefaultImpl() != null) {
-                return getDefaultImpl().getInterfaceHash();
-              }
-            }
-            reply.readException();
-            mCachedHash = reply.readString();
-          } finally {
-            reply.recycle();
-            data.recycle();
-          }
-        }
-        return mCachedHash;
-      }
-      public static android.test.IExampleInterface sDefaultImpl;
-    }
-    static final int TRANSACTION_isEnabled = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
-    static final int TRANSACTION_getState = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
-    private boolean onTransact$getState$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      int _arg0;
-      _arg0 = data.readInt();
-      int _arg1;
-      _arg1 = data.readInt();
-      int _result = this.getState(_arg0, _arg1);
-      reply.writeNoException();
-      reply.writeInt(_result);
-      return true;
-    }
-    static final int TRANSACTION_getAddress = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
-    static final int TRANSACTION_getParcelables = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
-    static final int TRANSACTION_setScanMode = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
-    private boolean onTransact$setScanMode$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      int _arg0;
-      _arg0 = data.readInt();
-      int _arg1;
-      _arg1 = data.readInt();
-      boolean _result = this.setScanMode(_arg0, _arg1);
-      reply.writeNoException();
-      reply.writeInt(((_result)?(1):(0)));
-      return true;
-    }
-    static final int TRANSACTION_registerBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
-    private boolean onTransact$registerBinder$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.bar.IAuxInterface _arg0;
-      _arg0 = android.bar.IAuxInterface.Stub.asInterface(data.readStrongBinder());
-      this.registerBinder(_arg0);
-      reply.writeNoException();
-      return true;
-    }
-    static final int TRANSACTION_getRecursiveBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
-    private boolean onTransact$getRecursiveBinder$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.test.IExampleInterface _result = this.getRecursiveBinder();
-      reply.writeNoException();
-      reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null)));
-      return true;
-    }
-    static final int TRANSACTION_takesAnInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
-    private boolean onTransact$takesAnInterface$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.test.IAuxInterface2 _arg0;
-      _arg0 = android.test.IAuxInterface2.Stub.asInterface(data.readStrongBinder());
-      int _result = this.takesAnInterface(_arg0);
-      reply.writeNoException();
-      reply.writeInt(_result);
-      return true;
-    }
-    static final int TRANSACTION_takesAParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
-    private boolean onTransact$takesAParcelable$(android.os.Parcel data, android.os.Parcel reply) throws android.os.RemoteException
-    {
-      data.enforceInterface(DESCRIPTOR);
-      android.test.CompoundParcelable.Subclass1 _arg0;
-      if ((0!=data.readInt())) {
-        _arg0 = android.test.CompoundParcelable.Subclass1.CREATOR.createFromParcel(data);
-      }
-      else {
-        _arg0 = null;
-      }
-      android.test.CompoundParcelable.Subclass2 _arg1;
-      if ((0!=data.readInt())) {
-        _arg1 = android.test.CompoundParcelable.Subclass2.CREATOR.createFromParcel(data);
-      }
-      else {
-        _arg1 = null;
-      }
-      int _result = this.takesAParcelable(_arg0, _arg1);
-      reply.writeNoException();
-      reply.writeInt(_result);
-      if ((_arg1!=null)) {
-        reply.writeInt(1);
-        _arg1.writeToParcel(reply, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
-      }
-      else {
-        reply.writeInt(0);
-      }
-      return true;
-    }
-    static final int TRANSACTION_getInterfaceVersion = (android.os.IBinder.FIRST_CALL_TRANSACTION + 16777214);
-    static final int TRANSACTION_getInterfaceHash = (android.os.IBinder.FIRST_CALL_TRANSACTION + 16777213);
-    public static boolean setDefaultImpl(android.test.IExampleInterface impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.test.IExampleInterface getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.test.IExampleInterface";
-  public static final int EXAMPLE_CONSTANT = 3;
-  public boolean isEnabled() throws android.os.RemoteException;
-  public int getState(int a, int b) throws android.os.RemoteException;
-  public java.lang.String getAddress() throws android.os.RemoteException;
-  /* Test long comment */
-  public android.foo.ExampleParcelable[] getParcelables() throws android.os.RemoteException;
-  // Test short comment
-
-  public boolean setScanMode(int mode, int duration) throws android.os.RemoteException;
-  /* Test long comment */// And short comment
-
-  public void registerBinder(android.bar.IAuxInterface foo) throws android.os.RemoteException;
-  public android.test.IExampleInterface getRecursiveBinder() throws android.os.RemoteException;
-  public int takesAnInterface(android.test.IAuxInterface2 arg) throws android.os.RemoteException;
-  public int takesAParcelable(android.test.CompoundParcelable.Subclass1 arg, android.test.CompoundParcelable.Subclass2 arg2) throws android.os.RemoteException;
-  public int getInterfaceVersion() throws android.os.RemoteException;
-  public String getInterfaceHash() throws android.os.RemoteException;
-}
-)";
-
-const char kRustOutputDirectory[] = "some/path/to";
-const char kRustOutputPath[] = "some/path/to/android/test/IExampleInterface.rs";
-
-const char kExpectedRustDepsOutput[] =
-    R"(some/path/to/android/test/IExampleInterface.rs : \
-  android/test/IExampleInterface.aidl \
-  ./android/foo/ExampleParcelable.aidl \
-  ./android/test/CompoundParcelable.aidl \
-  ./android/bar/IAuxInterface.aidl \
-  ./android/test/IAuxInterface2.aidl
-
-android/test/IExampleInterface.aidl :
-./android/foo/ExampleParcelable.aidl :
-./android/test/CompoundParcelable.aidl :
-./android/bar/IAuxInterface.aidl :
-./android/test/IAuxInterface2.aidl :
-)";
-
-const char kExpectedRustOutput[] =
-    R"(#![allow(non_upper_case_globals)]
-#![allow(non_snake_case)]
-#[allow(unused_imports)] use binder::IBinder;
-use binder::declare_binder_interface;
-declare_binder_interface! {
-  IExampleInterface["android.test.IExampleInterface"] {
-    native: BnExampleInterface(on_transact),
-    proxy: BpExampleInterface {
-    },
-  }
-}
-pub trait IExampleInterface: binder::Interface + Send {
-  fn get_descriptor() -> &'static str where Self: Sized { "android.test.IExampleInterface" }
-  fn isEnabled(&self) -> binder::public_api::Result<bool> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getState(&self) -> binder::public_api::Result<i32> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getAddress(&self) -> binder::public_api::Result<String> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getParcelables(&self) -> binder::public_api::Result<Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn setScanMode(&self, _arg_mode: i32, _arg_duration: i32) -> binder::public_api::Result<bool> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn registerBinder(&self, _arg_foo: &dyn crate::mangled::_7_android_3_bar_13_IAuxInterface) -> binder::public_api::Result<()> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getRecursiveBinder(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn takesAnInterface(&self, _arg_arg: &dyn crate::mangled::_7_android_4_test_14_IAuxInterface2) -> binder::public_api::Result<i32> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn takesAParcelable(&self, _arg_arg: &crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1, _arg_arg2: &mut crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2) -> binder::public_api::Result<i32> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getDefaultImpl() -> IExampleInterfaceDefault where Self: Sized {
-    DEFAULT_IMPL.lock().unwrap().clone()
-  }
-  fn setDefaultImpl(d: IExampleInterfaceDefault) -> IExampleInterfaceDefault where Self: Sized {
-    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
-  }
-}
-pub mod transactions {
-  #[allow(unused_imports)] use binder::IBinder;
-  pub const isEnabled: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
-  pub const getState: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
-  pub const getAddress: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
-  pub const getParcelables: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
-  pub const setScanMode: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 4;
-  pub const registerBinder: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 5;
-  pub const getRecursiveBinder: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 6;
-  pub const takesAnInterface: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 7;
-  pub const takesAParcelable: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 8;
-}
-pub type IExampleInterfaceDefault = Option<std::sync::Arc<dyn IExampleInterface + Sync>>;
-use lazy_static::lazy_static;
-lazy_static! {
-  static ref DEFAULT_IMPL: std::sync::Mutex<IExampleInterfaceDefault> = std::sync::Mutex::new(None);
-}
-pub const EXAMPLE_CONSTANT: i32 = 3;
-pub(crate) mod mangled { pub use super::IExampleInterface as _7_android_4_test_17_IExampleInterface; }
-impl IExampleInterface for BpExampleInterface {
-  fn isEnabled(&self) -> binder::public_api::Result<bool> {
-    let _aidl_reply = self.binder.transact(transactions::isEnabled, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.isEnabled();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: bool = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getState(&self) -> binder::public_api::Result<i32> {
-    let _aidl_reply = self.binder.transact(transactions::getState, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getState();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getAddress(&self) -> binder::public_api::Result<String> {
-    let _aidl_reply = self.binder.transact(transactions::getAddress, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getAddress();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getParcelables(&self) -> binder::public_api::Result<Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable>> {
-    let _aidl_reply = self.binder.transact(transactions::getParcelables, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getParcelables();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn setScanMode(&self, _arg_mode: i32, _arg_duration: i32) -> binder::public_api::Result<bool> {
-    let _aidl_reply = self.binder.transact(transactions::setScanMode, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_mode)?;
-      _aidl_data.write(&_arg_duration)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.setScanMode(_arg_mode, _arg_duration);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: bool = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn registerBinder(&self, _arg_foo: &dyn crate::mangled::_7_android_3_bar_13_IAuxInterface) -> binder::public_api::Result<()> {
-    let _aidl_reply = self.binder.transact(transactions::registerBinder, 0, |_aidl_data| {
-      _aidl_data.write(_arg_foo)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.registerBinder(_arg_foo);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    Ok(())
-  }
-  fn getRecursiveBinder(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface>> {
-    let _aidl_reply = self.binder.transact(transactions::getRecursiveBinder, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getRecursiveBinder();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn takesAnInterface(&self, _arg_arg: &dyn crate::mangled::_7_android_4_test_14_IAuxInterface2) -> binder::public_api::Result<i32> {
-    let _aidl_reply = self.binder.transact(transactions::takesAnInterface, 0, |_aidl_data| {
-      _aidl_data.write(_arg_arg)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.takesAnInterface(_arg_arg);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn takesAParcelable(&self, _arg_arg: &crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1, _arg_arg2: &mut crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2) -> binder::public_api::Result<i32> {
-    let _aidl_reply = self.binder.transact(transactions::takesAParcelable, 0, |_aidl_data| {
-      _aidl_data.write(_arg_arg)?;
-      _aidl_data.write(_arg_arg2)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.takesAParcelable(_arg_arg, _arg_arg2);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    *_arg_arg2 = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-}
-impl IExampleInterface for binder::Binder<BnExampleInterface> {
-  fn isEnabled(&self) -> binder::public_api::Result<bool> { self.0.isEnabled() }
-  fn getState(&self) -> binder::public_api::Result<i32> { self.0.getState() }
-  fn getAddress(&self) -> binder::public_api::Result<String> { self.0.getAddress() }
-  fn getParcelables(&self) -> binder::public_api::Result<Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable>> { self.0.getParcelables() }
-  fn setScanMode(&self, _arg_mode: i32, _arg_duration: i32) -> binder::public_api::Result<bool> { self.0.setScanMode(_arg_mode, _arg_duration) }
-  fn registerBinder(&self, _arg_foo: &dyn crate::mangled::_7_android_3_bar_13_IAuxInterface) -> binder::public_api::Result<()> { self.0.registerBinder(_arg_foo) }
-  fn getRecursiveBinder(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface>> { self.0.getRecursiveBinder() }
-  fn takesAnInterface(&self, _arg_arg: &dyn crate::mangled::_7_android_4_test_14_IAuxInterface2) -> binder::public_api::Result<i32> { self.0.takesAnInterface(_arg_arg) }
-  fn takesAParcelable(&self, _arg_arg: &crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1, _arg_arg2: &mut crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2) -> binder::public_api::Result<i32> { self.0.takesAParcelable(_arg_arg, _arg_arg2) }
-}
-fn on_transact(_aidl_service: &dyn IExampleInterface, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
-  match _aidl_code {
-    transactions::isEnabled => {
-      let _aidl_return = _aidl_service.isEnabled();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getState => {
-      let _aidl_return = _aidl_service.getState();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getAddress => {
-      let _aidl_return = _aidl_service.getAddress();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getParcelables => {
-      let _aidl_return = _aidl_service.getParcelables();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::setScanMode => {
-      let _arg_mode: i32 = _aidl_data.read()?;
-      let _arg_duration: i32 = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.setScanMode(_arg_mode, _arg_duration);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::registerBinder => {
-      let _arg_foo: Box<dyn crate::mangled::_7_android_3_bar_13_IAuxInterface> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.registerBinder(&*_arg_foo);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getRecursiveBinder => {
-      let _aidl_return = _aidl_service.getRecursiveBinder();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::takesAnInterface => {
-      let _arg_arg: Box<dyn crate::mangled::_7_android_4_test_14_IAuxInterface2> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.takesAnInterface(&*_arg_arg);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::takesAParcelable => {
-      let _arg_arg: crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1 = _aidl_data.read()?;
-      let mut _arg_arg2: crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2 = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.takesAParcelable(&_arg_arg, &mut _arg_arg2);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-          _aidl_reply.write(&_arg_arg2)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
-  }
-}
-)";
-
-const char kExpectedRustOutputWithVersionAndHash[] =
-    R"(#![allow(non_upper_case_globals)]
-#![allow(non_snake_case)]
-#[allow(unused_imports)] use binder::IBinder;
-use binder::declare_binder_interface;
-declare_binder_interface! {
-  IExampleInterface["android.test.IExampleInterface"] {
-    native: BnExampleInterface(on_transact),
-    proxy: BpExampleInterface {
-      cached_version: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(-1),
-      cached_hash: std::sync::Mutex<Option<String>> = std::sync::Mutex::new(None)
-    },
-  }
-}
-pub trait IExampleInterface: binder::Interface + Send {
-  fn get_descriptor() -> &'static str where Self: Sized { "android.test.IExampleInterface" }
-  fn isEnabled(&self) -> binder::public_api::Result<bool> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getState(&self, _arg_a: i32, _arg_b: i32) -> binder::public_api::Result<i32> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getAddress(&self) -> binder::public_api::Result<String> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getParcelables(&self) -> binder::public_api::Result<Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn setScanMode(&self, _arg_mode: i32, _arg_duration: i32) -> binder::public_api::Result<bool> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn registerBinder(&self, _arg_foo: &dyn crate::mangled::_7_android_3_bar_13_IAuxInterface) -> binder::public_api::Result<()> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getRecursiveBinder(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn takesAnInterface(&self, _arg_arg: &dyn crate::mangled::_7_android_4_test_14_IAuxInterface2) -> binder::public_api::Result<i32> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn takesAParcelable(&self, _arg_arg: &crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1, _arg_arg2: &mut crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2) -> binder::public_api::Result<i32> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> {
-    Ok(VERSION)
-  }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> {
-    Ok(HASH.into())
-  }
-  fn getDefaultImpl() -> IExampleInterfaceDefault where Self: Sized {
-    DEFAULT_IMPL.lock().unwrap().clone()
-  }
-  fn setDefaultImpl(d: IExampleInterfaceDefault) -> IExampleInterfaceDefault where Self: Sized {
-    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
-  }
-}
-pub mod transactions {
-  #[allow(unused_imports)] use binder::IBinder;
-  pub const isEnabled: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
-  pub const getState: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
-  pub const getAddress: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
-  pub const getParcelables: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
-  pub const setScanMode: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 4;
-  pub const registerBinder: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 5;
-  pub const getRecursiveBinder: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 6;
-  pub const takesAnInterface: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 7;
-  pub const takesAParcelable: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 8;
-  pub const getInterfaceVersion: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16777214;
-  pub const getInterfaceHash: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16777213;
-}
-pub type IExampleInterfaceDefault = Option<std::sync::Arc<dyn IExampleInterface + Sync>>;
-use lazy_static::lazy_static;
-lazy_static! {
-  static ref DEFAULT_IMPL: std::sync::Mutex<IExampleInterfaceDefault> = std::sync::Mutex::new(None);
-}
-pub const EXAMPLE_CONSTANT: i32 = 3;
-pub(crate) mod mangled { pub use super::IExampleInterface as _7_android_4_test_17_IExampleInterface; }
-pub const VERSION: i32 = 10;
-pub const HASH: &str = "abcdefg";
-impl IExampleInterface for BpExampleInterface {
-  fn isEnabled(&self) -> binder::public_api::Result<bool> {
-    let _aidl_reply = self.binder.transact(transactions::isEnabled, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.isEnabled();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: bool = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getState(&self, _arg_a: i32, _arg_b: i32) -> binder::public_api::Result<i32> {
-    let _aidl_reply = self.binder.transact(transactions::getState, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_a)?;
-      _aidl_data.write(&_arg_b)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getState(_arg_a, _arg_b);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getAddress(&self) -> binder::public_api::Result<String> {
-    let _aidl_reply = self.binder.transact(transactions::getAddress, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getAddress();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getParcelables(&self) -> binder::public_api::Result<Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable>> {
-    let _aidl_reply = self.binder.transact(transactions::getParcelables, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getParcelables();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn setScanMode(&self, _arg_mode: i32, _arg_duration: i32) -> binder::public_api::Result<bool> {
-    let _aidl_reply = self.binder.transact(transactions::setScanMode, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_mode)?;
-      _aidl_data.write(&_arg_duration)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.setScanMode(_arg_mode, _arg_duration);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: bool = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn registerBinder(&self, _arg_foo: &dyn crate::mangled::_7_android_3_bar_13_IAuxInterface) -> binder::public_api::Result<()> {
-    let _aidl_reply = self.binder.transact(transactions::registerBinder, 0, |_aidl_data| {
-      _aidl_data.write(_arg_foo)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.registerBinder(_arg_foo);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    Ok(())
-  }
-  fn getRecursiveBinder(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface>> {
-    let _aidl_reply = self.binder.transact(transactions::getRecursiveBinder, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getRecursiveBinder();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn takesAnInterface(&self, _arg_arg: &dyn crate::mangled::_7_android_4_test_14_IAuxInterface2) -> binder::public_api::Result<i32> {
-    let _aidl_reply = self.binder.transact(transactions::takesAnInterface, 0, |_aidl_data| {
-      _aidl_data.write(_arg_arg)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.takesAnInterface(_arg_arg);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn takesAParcelable(&self, _arg_arg: &crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1, _arg_arg2: &mut crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2) -> binder::public_api::Result<i32> {
-    let _aidl_reply = self.binder.transact(transactions::takesAParcelable, 0, |_aidl_data| {
-      _aidl_data.write(_arg_arg)?;
-      _aidl_data.write(_arg_arg2)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.takesAParcelable(_arg_arg, _arg_arg2);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    *_arg_arg2 = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> {
-    let _aidl_version = self.cached_version.load(std::sync::atomic::Ordering::Relaxed);
-    if _aidl_version != -1 { return Ok(_aidl_version); }
-    let _aidl_reply = self.binder.transact(transactions::getInterfaceVersion, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getInterfaceVersion();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    self.cached_version.store(_aidl_return, std::sync::atomic::Ordering::Relaxed);
-    Ok(_aidl_return)
-  }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> {
-    {
-      let _aidl_hash_lock = self.cached_hash.lock().unwrap();
-      if let Some(ref _aidl_hash) = *_aidl_hash_lock {
-        return Ok(_aidl_hash.clone());
-      }
-    }
-    let _aidl_reply = self.binder.transact(transactions::getInterfaceHash, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IExampleInterface>::getDefaultImpl() {
-        return _aidl_default_impl.getInterfaceHash();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    *self.cached_hash.lock().unwrap() = Some(_aidl_return.clone());
-    Ok(_aidl_return)
-  }
-}
-impl IExampleInterface for binder::Binder<BnExampleInterface> {
-  fn isEnabled(&self) -> binder::public_api::Result<bool> { self.0.isEnabled() }
-  fn getState(&self, _arg_a: i32, _arg_b: i32) -> binder::public_api::Result<i32> { self.0.getState(_arg_a, _arg_b) }
-  fn getAddress(&self) -> binder::public_api::Result<String> { self.0.getAddress() }
-  fn getParcelables(&self) -> binder::public_api::Result<Vec<crate::mangled::_7_android_3_foo_17_ExampleParcelable>> { self.0.getParcelables() }
-  fn setScanMode(&self, _arg_mode: i32, _arg_duration: i32) -> binder::public_api::Result<bool> { self.0.setScanMode(_arg_mode, _arg_duration) }
-  fn registerBinder(&self, _arg_foo: &dyn crate::mangled::_7_android_3_bar_13_IAuxInterface) -> binder::public_api::Result<()> { self.0.registerBinder(_arg_foo) }
-  fn getRecursiveBinder(&self) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_4_test_17_IExampleInterface>> { self.0.getRecursiveBinder() }
-  fn takesAnInterface(&self, _arg_arg: &dyn crate::mangled::_7_android_4_test_14_IAuxInterface2) -> binder::public_api::Result<i32> { self.0.takesAnInterface(_arg_arg) }
-  fn takesAParcelable(&self, _arg_arg: &crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1, _arg_arg2: &mut crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2) -> binder::public_api::Result<i32> { self.0.takesAParcelable(_arg_arg, _arg_arg2) }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> { self.0.getInterfaceVersion() }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> { self.0.getInterfaceHash() }
-}
-fn on_transact(_aidl_service: &dyn IExampleInterface, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
-  match _aidl_code {
-    transactions::isEnabled => {
-      let _aidl_return = _aidl_service.isEnabled();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getState => {
-      let _arg_a: i32 = _aidl_data.read()?;
-      let _arg_b: i32 = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.getState(_arg_a, _arg_b);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getAddress => {
-      let _aidl_return = _aidl_service.getAddress();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getParcelables => {
-      let _aidl_return = _aidl_service.getParcelables();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::setScanMode => {
-      let _arg_mode: i32 = _aidl_data.read()?;
-      let _arg_duration: i32 = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.setScanMode(_arg_mode, _arg_duration);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::registerBinder => {
-      let _arg_foo: Box<dyn crate::mangled::_7_android_3_bar_13_IAuxInterface> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.registerBinder(&*_arg_foo);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getRecursiveBinder => {
-      let _aidl_return = _aidl_service.getRecursiveBinder();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::takesAnInterface => {
-      let _arg_arg: Box<dyn crate::mangled::_7_android_4_test_14_IAuxInterface2> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.takesAnInterface(&*_arg_arg);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::takesAParcelable => {
-      let _arg_arg: crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass1 = _aidl_data.read()?;
-      let mut _arg_arg2: crate::mangled::_7_android_4_test_18_CompoundParcelable_9_Subclass2 = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.takesAParcelable(&_arg_arg, &mut _arg_arg2);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-          _aidl_reply.write(&_arg_arg2)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getInterfaceVersion => {
-      let _aidl_return = _aidl_service.getInterfaceVersion();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getInterfaceHash => {
-      let _aidl_return = _aidl_service.getInterfaceHash();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
-  }
-}
-)";
-
-}  // namespace example_interface
-}  // namespace test_data
-}  // namespace aidl
-}  // namespace android
diff --git a/tests/test_data_ping_responder.cpp b/tests/test_data_ping_responder.cpp
deleted file mode 100644
index 64d1990..0000000
--- a/tests/test_data_ping_responder.cpp
+++ /dev/null
@@ -1,1402 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "tests/test_data.h"
-
-namespace android {
-namespace aidl {
-namespace test_data {
-namespace ping_responder {
-
-// clang-format off
-const char kCanonicalName[] = "android.os.IPingResponder";
-const char kInterfaceDefinition[] = R"(
-package android.os;
-
-import bar.Unused;
-
-interface IPingResponder {
-  String Ping(String input);
-
-  @nullable
-  String NullablePing(@nullable String input);
-
-  @utf8InCpp
-  String Utf8Ping(@utf8InCpp String input);
-
-  @utf8InCpp @nullable
-  String NullableUtf8Ping(@utf8InCpp @nullable String input);
-}
-)";
-
-const char kCppOutputPath[] = "some/path/to/output.cpp";
-
-const char kCppParcelableHeader[] = "cpp-header-str";
-
-const char* kImportedParcelables[] = {
-  "bar.Unused",
-  nullptr,
-};
-
-const char* kImportedInterfaces[] = {
-  nullptr,
-};
-
-const char kGenHeaderDir[] = "some/path";
-const char kGenInterfaceHeaderPath[] = "some/path/android/os/IPingResponder.h";
-const char kGenClientHeaderPath[] = "some/path/android/os/BpPingResponder.h";
-const char kGenServerHeaderPath[] = "some/path/android/os/BnPingResponder.h";
-
-const char kExpectedCppDepsOutput[] =
-R"(some/path/to/output.cpp : \
-  android/os/IPingResponder.aidl \
-  ./bar/Unused.aidl
-
-android/os/IPingResponder.aidl :
-./bar/Unused.aidl :
-
-some/path/android/os/BpPingResponder.h \
-    some/path/android/os/BnPingResponder.h \
-    some/path/android/os/IPingResponder.h : \
-    android/os/IPingResponder.aidl \
-    ./bar/Unused.aidl
-)";
-
-const char kExpectedCppOutput[] =
-    R"(#include <android/os/IPingResponder.h>
-#include <android/os/BpPingResponder.h>
-
-namespace android {
-
-namespace os {
-
-DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(PingResponder, "android.os.IPingResponder")
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BpPingResponder.h>
-#include <binder/Parcel.h>
-#include <android-base/macros.h>
-
-namespace android {
-
-namespace os {
-
-BpPingResponder::BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl)
-    : BpInterface<IPingResponder>(_aidl_impl){
-}
-
-::android::binder::Status BpPingResponder::Ping(const ::android::String16& input, ::android::String16* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeString16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->Ping(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-::android::binder::Status BpPingResponder::NullablePing(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeString16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->NullablePing(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-::android::binder::Status BpPingResponder::Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->Utf8Ping(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-::android::binder::Status BpPingResponder::NullableUtf8Ping(const ::std::optional<::std::string>& input, ::std::optional<::std::string>* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->NullableUtf8Ping(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BnPingResponder.h>
-#include <binder/Parcel.h>
-#include <binder/Stability.h>
-
-namespace android {
-
-namespace os {
-
-BnPingResponder::BnPingResponder()
-{
-  ::android::internal::Stability::markCompilationUnit(this);
-}
-
-::android::status_t BnPingResponder::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  switch (_aidl_code) {
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */:
-  {
-    ::android::String16 in_input;
-    ::android::String16 _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readString16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(Ping(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */:
-  {
-    ::std::optional<::android::String16> in_input;
-    ::std::optional<::android::String16> _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readString16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(NullablePing(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */:
-  {
-    ::std::string in_input;
-    ::std::string _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(Utf8Ping(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */:
-  {
-    ::std::optional<::std::string> in_input;
-    ::std::optional<::std::string> _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(NullableUtf8Ping(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  default:
-  {
-    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
-  }
-  break;
-  }
-  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
-    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
-  }
-  return _aidl_ret_status;
-}
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedIHeaderOutput[] =
-    R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <optional>
-#include <string>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-
-namespace os {
-
-class IPingResponder : public ::android::IInterface {
-public:
-  DECLARE_META_INTERFACE(PingResponder)
-  virtual ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) = 0;
-  virtual ::android::binder::Status NullablePing(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) = 0;
-  virtual ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) = 0;
-  virtual ::android::binder::Status NullableUtf8Ping(const ::std::optional<::std::string>& input, ::std::optional<::std::string>* _aidl_return) = 0;
-};  // class IPingResponder
-
-class IPingResponderDefault : public IPingResponder {
-public:
-  ::android::IBinder* onAsBinder() override {
-    return nullptr;
-  }
-  ::android::binder::Status Ping(const ::android::String16&, ::android::String16*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  ::android::binder::Status NullablePing(const ::std::optional<::android::String16>&, ::std::optional<::android::String16>*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  ::android::binder::Status Utf8Ping(const ::std::string&, ::std::string*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  ::android::binder::Status NullableUtf8Ping(const ::std::optional<::std::string>&, ::std::optional<::std::string>*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-};  // class IPingResponderDefault
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedBpHeaderOutput[] =
-    R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <utils/Errors.h>
-#include <android/os/IPingResponder.h>
-
-namespace android {
-
-namespace os {
-
-class BpPingResponder : public ::android::BpInterface<IPingResponder> {
-public:
-  explicit BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl);
-  virtual ~BpPingResponder() = default;
-  ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) override;
-  ::android::binder::Status NullablePing(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) override;
-  ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
-  ::android::binder::Status NullableUtf8Ping(const ::std::optional<::std::string>& input, ::std::optional<::std::string>* _aidl_return) override;
-};  // class BpPingResponder
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedBnHeaderOutput[] =
-    R"(#pragma once
-
-#include <binder/IInterface.h>
-#include <android/os/IPingResponder.h>
-
-namespace android {
-
-namespace os {
-
-class BnPingResponder : public ::android::BnInterface<IPingResponder> {
-public:
-  explicit BnPingResponder();
-  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
-};  // class BnPingResponder
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedCppOutputWithVersionAndHash[] =
-    R"(#include <android/os/IPingResponder.h>
-#include <android/os/BpPingResponder.h>
-
-namespace android {
-
-namespace os {
-
-DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(PingResponder, "android.os.IPingResponder")
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BpPingResponder.h>
-#include <binder/Parcel.h>
-#include <android-base/macros.h>
-
-namespace android {
-
-namespace os {
-
-BpPingResponder::BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl)
-    : BpInterface<IPingResponder>(_aidl_impl){
-}
-
-::android::binder::Status BpPingResponder::Ping(const ::android::String16& input, ::android::String16* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeString16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->Ping(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-::android::binder::Status BpPingResponder::NullablePing(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeString16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->NullablePing(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readString16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-::android::binder::Status BpPingResponder::Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->Utf8Ping(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-::android::binder::Status BpPingResponder::NullableUtf8Ping(const ::std::optional<::std::string>& input, ::std::optional<::std::string>* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeUtf8AsUtf16(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */, _aidl_data, &_aidl_reply);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IPingResponder::getDefaultImpl())) {
-     return IPingResponder::getDefaultImpl()->NullableUtf8Ping(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readUtf8FromUtf16(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
-int32_t BpPingResponder::getInterfaceVersion() {
-  if (cached_version_ == -1) {
-    ::android::Parcel data;
-    ::android::Parcel reply;
-    data.writeInterfaceToken(getInterfaceDescriptor());
-    ::android::status_t err = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 16777214 /* getInterfaceVersion */, data, &reply);
-    if (err == ::android::OK) {
-      ::android::binder::Status _aidl_status;
-      err = _aidl_status.readFromParcel(reply);
-      if (err == ::android::OK && _aidl_status.isOk()) {
-        cached_version_ = reply.readInt32();
-      }
-    }
-  }
-  return cached_version_;
-}
-
-std::string BpPingResponder::getInterfaceHash() {
-  std::lock_guard<std::mutex> lockGuard(cached_hash_mutex_);
-  if (cached_hash_ == "-1") {
-    ::android::Parcel data;
-    ::android::Parcel reply;
-    data.writeInterfaceToken(getInterfaceDescriptor());
-    ::android::status_t err = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 16777213 /* getInterfaceHash */, data, &reply);
-    if (err == ::android::OK) {
-      ::android::binder::Status _aidl_status;
-      err = _aidl_status.readFromParcel(reply);
-      if (err == ::android::OK && _aidl_status.isOk()) {
-        reply.readUtf8FromUtf16(&cached_hash_);
-      }
-    }
-  }
-  return cached_hash_;
-}
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BnPingResponder.h>
-#include <binder/Parcel.h>
-#include <binder/Stability.h>
-
-namespace android {
-
-namespace os {
-
-BnPingResponder::BnPingResponder()
-{
-  ::android::internal::Stability::markCompilationUnit(this);
-}
-
-::android::status_t BnPingResponder::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  switch (_aidl_code) {
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* Ping */:
-  {
-    ::android::String16 in_input;
-    ::android::String16 _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readString16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(Ping(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* NullablePing */:
-  {
-    ::std::optional<::android::String16> in_input;
-    ::std::optional<::android::String16> _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readString16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(NullablePing(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeString16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* Utf8Ping */:
-  {
-    ::std::string in_input;
-    ::std::string _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(Utf8Ping(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableUtf8Ping */:
-  {
-    ::std::optional<::std::string> in_input;
-    ::std::optional<::std::string> _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readUtf8FromUtf16(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    ::android::binder::Status _aidl_status(NullableUtf8Ping(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeUtf8AsUtf16(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 16777214 /* getInterfaceVersion */:
-  {
-    _aidl_data.checkInterface(this);
-    _aidl_reply->writeNoException();
-    _aidl_reply->writeInt32(IPingResponder::VERSION);
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 16777213 /* getInterfaceHash */:
-  {
-    _aidl_data.checkInterface(this);
-    _aidl_reply->writeNoException();
-    _aidl_reply->writeUtf8AsUtf16(IPingResponder::HASH);
-  }
-  break;
-  default:
-  {
-    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
-  }
-  break;
-  }
-  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
-    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
-  }
-  return _aidl_ret_status;
-}
-
-int32_t BnPingResponder::getInterfaceVersion() {
-  return IPingResponder::VERSION;
-}
-
-std::string BnPingResponder::getInterfaceHash() {
-  return IPingResponder::HASH;
-}
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedIHeaderOutputWithVersionAndHash[] =
-    R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <cstdint>
-#include <optional>
-#include <string>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-
-namespace os {
-
-class IPingResponder : public ::android::IInterface {
-public:
-  DECLARE_META_INTERFACE(PingResponder)
-  const int32_t VERSION = 10;
-  const std::string HASH = "abcdefg";
-  virtual ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) = 0;
-  virtual ::android::binder::Status NullablePing(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) = 0;
-  virtual ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) = 0;
-  virtual ::android::binder::Status NullableUtf8Ping(const ::std::optional<::std::string>& input, ::std::optional<::std::string>* _aidl_return) = 0;
-  virtual int32_t getInterfaceVersion() = 0;
-  virtual std::string getInterfaceHash() = 0;
-};  // class IPingResponder
-
-class IPingResponderDefault : public IPingResponder {
-public:
-  ::android::IBinder* onAsBinder() override {
-    return nullptr;
-  }
-  ::android::binder::Status Ping(const ::android::String16&, ::android::String16*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  ::android::binder::Status NullablePing(const ::std::optional<::android::String16>&, ::std::optional<::android::String16>*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  ::android::binder::Status Utf8Ping(const ::std::string&, ::std::string*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  ::android::binder::Status NullableUtf8Ping(const ::std::optional<::std::string>&, ::std::optional<::std::string>*) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
-  int32_t getInterfaceVersion() override {
-    return 0;
-  }
-  std::string getInterfaceHash() override {
-    return "";
-  }
-};  // class IPingResponderDefault
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedBpHeaderOutputWithVersionAndHash[] =
-R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <utils/Errors.h>
-#include <android/os/IPingResponder.h>
-
-namespace android {
-
-namespace os {
-
-class BpPingResponder : public ::android::BpInterface<IPingResponder> {
-public:
-  explicit BpPingResponder(const ::android::sp<::android::IBinder>& _aidl_impl);
-  virtual ~BpPingResponder() = default;
-  ::android::binder::Status Ping(const ::android::String16& input, ::android::String16* _aidl_return) override;
-  ::android::binder::Status NullablePing(const ::std::optional<::android::String16>& input, ::std::optional<::android::String16>* _aidl_return) override;
-  ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
-  ::android::binder::Status NullableUtf8Ping(const ::std::optional<::std::string>& input, ::std::optional<::std::string>* _aidl_return) override;
-  int32_t getInterfaceVersion() override;
-  std::string getInterfaceHash() override;
-private:
-  int32_t cached_version_ = -1;
-  std::string cached_hash_ = "-1";
-  std::mutex cached_hash_mutex_;
-};  // class BpPingResponder
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedBnHeaderOutputWithVersionAndHash[] =
-    R"(#pragma once
-
-#include <binder/IInterface.h>
-#include <android/os/IPingResponder.h>
-
-namespace android {
-
-namespace os {
-
-class BnPingResponder : public ::android::BnInterface<IPingResponder> {
-public:
-  explicit BnPingResponder();
-  ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
-  int32_t getInterfaceVersion() final override;
-  std::string getInterfaceHash();
-};  // class BnPingResponder
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kRustOutputDirectory[] = "some/path/to";
-const char kRustOutputPath[] = "some/path/to/android/os/IPingResponder.rs";
-
-const char kExpectedRustDepsOutput[] =
-R"(some/path/to/android/os/IPingResponder.rs : \
-  android/os/IPingResponder.aidl \
-  ./bar/Unused.aidl
-
-android/os/IPingResponder.aidl :
-./bar/Unused.aidl :
-)";
-
-const char kExpectedRustOutput[] =
-    R"(#![allow(non_upper_case_globals)]
-#![allow(non_snake_case)]
-#[allow(unused_imports)] use binder::IBinder;
-use binder::declare_binder_interface;
-declare_binder_interface! {
-  IPingResponder["android.os.IPingResponder"] {
-    native: BnPingResponder(on_transact),
-    proxy: BpPingResponder {
-    },
-  }
-}
-pub trait IPingResponder: binder::Interface + Send {
-  fn get_descriptor() -> &'static str where Self: Sized { "android.os.IPingResponder" }
-  fn Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn NullablePing(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn Utf8Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn NullableUtf8Ping(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getDefaultImpl() -> IPingResponderDefault where Self: Sized {
-    DEFAULT_IMPL.lock().unwrap().clone()
-  }
-  fn setDefaultImpl(d: IPingResponderDefault) -> IPingResponderDefault where Self: Sized {
-    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
-  }
-}
-pub mod transactions {
-  #[allow(unused_imports)] use binder::IBinder;
-  pub const Ping: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
-  pub const NullablePing: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
-  pub const Utf8Ping: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
-  pub const NullableUtf8Ping: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
-}
-pub type IPingResponderDefault = Option<std::sync::Arc<dyn IPingResponder + Sync>>;
-use lazy_static::lazy_static;
-lazy_static! {
-  static ref DEFAULT_IMPL: std::sync::Mutex<IPingResponderDefault> = std::sync::Mutex::new(None);
-}
-pub(crate) mod mangled { pub use super::IPingResponder as _7_android_2_os_14_IPingResponder; }
-impl IPingResponder for BpPingResponder {
-  fn Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    let _aidl_reply = self.binder.transact(transactions::Ping, 0, |_aidl_data| {
-      _aidl_data.write(_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.Ping(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn NullablePing(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    let _aidl_reply = self.binder.transact(transactions::NullablePing, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.NullablePing(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Option<String> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn Utf8Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    let _aidl_reply = self.binder.transact(transactions::Utf8Ping, 0, |_aidl_data| {
-      _aidl_data.write(_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.Utf8Ping(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn NullableUtf8Ping(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    let _aidl_reply = self.binder.transact(transactions::NullableUtf8Ping, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.NullableUtf8Ping(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Option<String> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-}
-impl IPingResponder for binder::Binder<BnPingResponder> {
-  fn Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> { self.0.Ping(_arg_input) }
-  fn NullablePing(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> { self.0.NullablePing(_arg_input) }
-  fn Utf8Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> { self.0.Utf8Ping(_arg_input) }
-  fn NullableUtf8Ping(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> { self.0.NullableUtf8Ping(_arg_input) }
-}
-fn on_transact(_aidl_service: &dyn IPingResponder, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
-  match _aidl_code {
-    transactions::Ping => {
-      let _arg_input: String = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.Ping(&_arg_input);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::NullablePing => {
-      let _arg_input: Option<String> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.NullablePing(_arg_input.as_deref());
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::Utf8Ping => {
-      let _arg_input: String = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.Utf8Ping(&_arg_input);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::NullableUtf8Ping => {
-      let _arg_input: Option<String> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.NullableUtf8Ping(_arg_input.as_deref());
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
-  }
-}
-)";
-
-const char kExpectedRustOutputWithVersionAndHash[] =
-    R"(#![allow(non_upper_case_globals)]
-#![allow(non_snake_case)]
-#[allow(unused_imports)] use binder::IBinder;
-use binder::declare_binder_interface;
-declare_binder_interface! {
-  IPingResponder["android.os.IPingResponder"] {
-    native: BnPingResponder(on_transact),
-    proxy: BpPingResponder {
-      cached_version: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(-1),
-      cached_hash: std::sync::Mutex<Option<String>> = std::sync::Mutex::new(None)
-    },
-  }
-}
-pub trait IPingResponder: binder::Interface + Send {
-  fn get_descriptor() -> &'static str where Self: Sized { "android.os.IPingResponder" }
-  fn Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn NullablePing(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn Utf8Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn NullableUtf8Ping(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> {
-    Ok(VERSION)
-  }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> {
-    Ok(HASH.into())
-  }
-  fn getDefaultImpl() -> IPingResponderDefault where Self: Sized {
-    DEFAULT_IMPL.lock().unwrap().clone()
-  }
-  fn setDefaultImpl(d: IPingResponderDefault) -> IPingResponderDefault where Self: Sized {
-    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
-  }
-}
-pub mod transactions {
-  #[allow(unused_imports)] use binder::IBinder;
-  pub const Ping: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
-  pub const NullablePing: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
-  pub const Utf8Ping: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
-  pub const NullableUtf8Ping: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
-  pub const getInterfaceVersion: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16777214;
-  pub const getInterfaceHash: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16777213;
-}
-pub type IPingResponderDefault = Option<std::sync::Arc<dyn IPingResponder + Sync>>;
-use lazy_static::lazy_static;
-lazy_static! {
-  static ref DEFAULT_IMPL: std::sync::Mutex<IPingResponderDefault> = std::sync::Mutex::new(None);
-}
-pub(crate) mod mangled { pub use super::IPingResponder as _7_android_2_os_14_IPingResponder; }
-pub const VERSION: i32 = 10;
-pub const HASH: &str = "abcdefg";
-impl IPingResponder for BpPingResponder {
-  fn Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    let _aidl_reply = self.binder.transact(transactions::Ping, 0, |_aidl_data| {
-      _aidl_data.write(_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.Ping(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn NullablePing(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    let _aidl_reply = self.binder.transact(transactions::NullablePing, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.NullablePing(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Option<String> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn Utf8Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> {
-    let _aidl_reply = self.binder.transact(transactions::Utf8Ping, 0, |_aidl_data| {
-      _aidl_data.write(_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.Utf8Ping(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn NullableUtf8Ping(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> {
-    let _aidl_reply = self.binder.transact(transactions::NullableUtf8Ping, 0, |_aidl_data| {
-      _aidl_data.write(&_arg_input)?;
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.NullableUtf8Ping(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Option<String> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> {
-    let _aidl_version = self.cached_version.load(std::sync::atomic::Ordering::Relaxed);
-    if _aidl_version != -1 { return Ok(_aidl_version); }
-    let _aidl_reply = self.binder.transact(transactions::getInterfaceVersion, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.getInterfaceVersion();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    self.cached_version.store(_aidl_return, std::sync::atomic::Ordering::Relaxed);
-    Ok(_aidl_return)
-  }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> {
-    {
-      let _aidl_hash_lock = self.cached_hash.lock().unwrap();
-      if let Some(ref _aidl_hash) = *_aidl_hash_lock {
-        return Ok(_aidl_hash.clone());
-      }
-    }
-    let _aidl_reply = self.binder.transact(transactions::getInterfaceHash, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IPingResponder>::getDefaultImpl() {
-        return _aidl_default_impl.getInterfaceHash();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    *self.cached_hash.lock().unwrap() = Some(_aidl_return.clone());
-    Ok(_aidl_return)
-  }
-}
-impl IPingResponder for binder::Binder<BnPingResponder> {
-  fn Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> { self.0.Ping(_arg_input) }
-  fn NullablePing(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> { self.0.NullablePing(_arg_input) }
-  fn Utf8Ping(&self, _arg_input: &str) -> binder::public_api::Result<String> { self.0.Utf8Ping(_arg_input) }
-  fn NullableUtf8Ping(&self, _arg_input: Option<&str>) -> binder::public_api::Result<Option<String>> { self.0.NullableUtf8Ping(_arg_input) }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> { self.0.getInterfaceVersion() }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> { self.0.getInterfaceHash() }
-}
-fn on_transact(_aidl_service: &dyn IPingResponder, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
-  match _aidl_code {
-    transactions::Ping => {
-      let _arg_input: String = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.Ping(&_arg_input);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::NullablePing => {
-      let _arg_input: Option<String> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.NullablePing(_arg_input.as_deref());
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::Utf8Ping => {
-      let _arg_input: String = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.Utf8Ping(&_arg_input);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::NullableUtf8Ping => {
-      let _arg_input: Option<String> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.NullableUtf8Ping(_arg_input.as_deref());
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getInterfaceVersion => {
-      let _aidl_return = _aidl_service.getInterfaceVersion();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getInterfaceHash => {
-      let _aidl_return = _aidl_service.getInterfaceHash();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
-  }
-}
-)";
-
-// clang-format on
-}  // namespace ping_responder
-}  // namespace test_data
-}  // namespace aidl
-}  // namespace android
diff --git a/tests/test_data_string_constants.cpp b/tests/test_data_string_constants.cpp
deleted file mode 100644
index 06fe09f..0000000
--- a/tests/test_data_string_constants.cpp
+++ /dev/null
@@ -1,739 +0,0 @@
-/*
- * Copyright (C) 2016, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "tests/test_data.h"
-
-namespace android {
-namespace aidl {
-namespace test_data {
-namespace string_constants {
-
-const char kCanonicalName[] = "android.os.IStringConstants";
-const char kInterfaceDefinition[] = R"(
-package android.os;
-
-interface IStringConstants {
-  const String EXAMPLE_CONSTANT = "foo";
-}
-)";
-
-const char kJavaOutputPath[] = "some/path/to/output.java";
-const char kExpectedJavaOutput[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.os;
-public interface IStringConstants extends android.os.IInterface
-{
-  /** Default implementation for IStringConstants. */
-  public static class Default implements android.os.IStringConstants
-  {
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.os.IStringConstants
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.os.IStringConstants interface,
-     * generating a proxy if needed.
-     */
-    public static android.os.IStringConstants asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.os.IStringConstants))) {
-        return ((android.os.IStringConstants)iin);
-      }
-      return new android.os.IStringConstants.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.os.IStringConstants
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      public static android.os.IStringConstants sDefaultImpl;
-    }
-    public static boolean setDefaultImpl(android.os.IStringConstants impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.os.IStringConstants getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.os.IStringConstants";
-  public static final String EXAMPLE_CONSTANT = "foo";
-}
-)";
-
-const char kCppOutputPath[] = "some/path/to/output.cpp";
-const char kGenHeaderDir[] = "output";
-const char kGenInterfaceHeaderPath[] = "output/android/os/IStringConstants.h";
-const char kExpectedIHeaderOutput[] =
-    R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-
-namespace os {
-
-class IStringConstants : public ::android::IInterface {
-public:
-  DECLARE_META_INTERFACE(StringConstants)
-  static const ::android::String16& EXAMPLE_CONSTANT();
-};  // class IStringConstants
-
-class IStringConstantsDefault : public IStringConstants {
-public:
-  ::android::IBinder* onAsBinder() override {
-    return nullptr;
-  }
-};  // class IStringConstantsDefault
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedCppOutput[] =
-    R"(#include <android/os/IStringConstants.h>
-#include <android/os/BpStringConstants.h>
-
-namespace android {
-
-namespace os {
-
-DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(StringConstants, "android.os.IStringConstants")
-
-const ::android::String16& IStringConstants::EXAMPLE_CONSTANT() {
-  static const ::android::String16 value(::android::String16("foo"));
-  return value;
-}
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BpStringConstants.h>
-#include <binder/Parcel.h>
-#include <android-base/macros.h>
-
-namespace android {
-
-namespace os {
-
-BpStringConstants::BpStringConstants(const ::android::sp<::android::IBinder>& _aidl_impl)
-    : BpInterface<IStringConstants>(_aidl_impl){
-}
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BnStringConstants.h>
-#include <binder/Parcel.h>
-#include <binder/Stability.h>
-
-namespace android {
-
-namespace os {
-
-BnStringConstants::BnStringConstants()
-{
-  ::android::internal::Stability::markCompilationUnit(this);
-}
-
-::android::status_t BnStringConstants::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  switch (_aidl_code) {
-  default:
-  {
-    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
-  }
-  break;
-  }
-  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
-    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
-  }
-  return _aidl_ret_status;
-}
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedJavaOutputWithVersionAndHash[] =
-    R"(/*
- * This file is auto-generated.  DO NOT MODIFY.
- */
-package android.os;
-public interface IStringConstants extends android.os.IInterface
-{
-  /**
-   * The version of this interface that the caller is built against.
-   * This might be different from what {@link #getInterfaceVersion()
-   * getInterfaceVersion} returns as that is the version of the interface
-   * that the remote object is implementing.
-   */
-  public static final int VERSION = 10;
-  public static final String HASH = "abcdefg";
-  /** Default implementation for IStringConstants. */
-  public static class Default implements android.os.IStringConstants
-  {
-    @Override
-    public int getInterfaceVersion() {
-      return 0;
-    }
-    @Override
-    public String getInterfaceHash() {
-      return "";
-    }
-    @Override
-    public android.os.IBinder asBinder() {
-      return null;
-    }
-  }
-  /** Local-side IPC implementation stub class. */
-  public static abstract class Stub extends android.os.Binder implements android.os.IStringConstants
-  {
-    /** Construct the stub at attach it to the interface. */
-    public Stub()
-    {
-      this.attachInterface(this, DESCRIPTOR);
-    }
-    /**
-     * Cast an IBinder object into an android.os.IStringConstants interface,
-     * generating a proxy if needed.
-     */
-    public static android.os.IStringConstants asInterface(android.os.IBinder obj)
-    {
-      if ((obj==null)) {
-        return null;
-      }
-      android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
-      if (((iin!=null)&&(iin instanceof android.os.IStringConstants))) {
-        return ((android.os.IStringConstants)iin);
-      }
-      return new android.os.IStringConstants.Stub.Proxy(obj);
-    }
-    @Override public android.os.IBinder asBinder()
-    {
-      return this;
-    }
-    @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
-    {
-      java.lang.String descriptor = DESCRIPTOR;
-      switch (code)
-      {
-        case INTERFACE_TRANSACTION:
-        {
-          reply.writeString(descriptor);
-          return true;
-        }
-        case TRANSACTION_getInterfaceVersion:
-        {
-          data.enforceInterface(descriptor);
-          reply.writeNoException();
-          reply.writeInt(getInterfaceVersion());
-          return true;
-        }
-        case TRANSACTION_getInterfaceHash:
-        {
-          data.enforceInterface(descriptor);
-          reply.writeNoException();
-          reply.writeString(getInterfaceHash());
-          return true;
-        }
-        default:
-        {
-          return super.onTransact(code, data, reply, flags);
-        }
-      }
-    }
-    private static class Proxy implements android.os.IStringConstants
-    {
-      private android.os.IBinder mRemote;
-      Proxy(android.os.IBinder remote)
-      {
-        mRemote = remote;
-      }
-      private int mCachedVersion = -1;
-      private String mCachedHash = "-1";
-      @Override public android.os.IBinder asBinder()
-      {
-        return mRemote;
-      }
-      public java.lang.String getInterfaceDescriptor()
-      {
-        return DESCRIPTOR;
-      }
-      @Override
-      public int getInterfaceVersion() throws android.os.RemoteException {
-        if (mCachedVersion == -1) {
-          android.os.Parcel data = android.os.Parcel.obtain();
-          android.os.Parcel reply = android.os.Parcel.obtain();
-          try {
-            data.writeInterfaceToken(DESCRIPTOR);
-            boolean _status = mRemote.transact(Stub.TRANSACTION_getInterfaceVersion, data, reply, 0);
-            if (!_status) {
-              if (getDefaultImpl() != null) {
-                return getDefaultImpl().getInterfaceVersion();
-              }
-            }
-            reply.readException();
-            mCachedVersion = reply.readInt();
-          } finally {
-            reply.recycle();
-            data.recycle();
-          }
-        }
-        return mCachedVersion;
-      }
-      @Override
-      public synchronized String getInterfaceHash() throws android.os.RemoteException {
-        if ("-1".equals(mCachedHash)) {
-          android.os.Parcel data = android.os.Parcel.obtain();
-          android.os.Parcel reply = android.os.Parcel.obtain();
-          try {
-            data.writeInterfaceToken(DESCRIPTOR);
-            boolean _status = mRemote.transact(Stub.TRANSACTION_getInterfaceHash, data, reply, 0);
-            if (!_status) {
-              if (getDefaultImpl() != null) {
-                return getDefaultImpl().getInterfaceHash();
-              }
-            }
-            reply.readException();
-            mCachedHash = reply.readString();
-          } finally {
-            reply.recycle();
-            data.recycle();
-          }
-        }
-        return mCachedHash;
-      }
-      public static android.os.IStringConstants sDefaultImpl;
-    }
-    static final int TRANSACTION_getInterfaceVersion = (android.os.IBinder.FIRST_CALL_TRANSACTION + 16777214);
-    static final int TRANSACTION_getInterfaceHash = (android.os.IBinder.FIRST_CALL_TRANSACTION + 16777213);
-    public static boolean setDefaultImpl(android.os.IStringConstants impl) {
-      // Only one user of this interface can use this function
-      // at a time. This is a heuristic to detect if two different
-      // users in the same process use this function.
-      if (Stub.Proxy.sDefaultImpl != null) {
-        throw new IllegalStateException("setDefaultImpl() called twice");
-      }
-      if (impl != null) {
-        Stub.Proxy.sDefaultImpl = impl;
-        return true;
-      }
-      return false;
-    }
-    public static android.os.IStringConstants getDefaultImpl() {
-      return Stub.Proxy.sDefaultImpl;
-    }
-  }
-  public static final java.lang.String DESCRIPTOR = "android.os.IStringConstants";
-  public static final String EXAMPLE_CONSTANT = "foo";
-  public int getInterfaceVersion() throws android.os.RemoteException;
-  public String getInterfaceHash() throws android.os.RemoteException;
-}
-)";
-
-const char kExpectedIHeaderOutputWithVersionAndHash[] =
-    R"(#pragma once
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <cstdint>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-
-namespace os {
-
-class IStringConstants : public ::android::IInterface {
-public:
-  DECLARE_META_INTERFACE(StringConstants)
-  const int32_t VERSION = 10;
-  const std::string HASH = "abcdefg";
-  static const ::android::String16& EXAMPLE_CONSTANT();
-  virtual int32_t getInterfaceVersion() = 0;
-  virtual std::string getInterfaceHash() = 0;
-};  // class IStringConstants
-
-class IStringConstantsDefault : public IStringConstants {
-public:
-  ::android::IBinder* onAsBinder() override {
-    return nullptr;
-  }
-  int32_t getInterfaceVersion() override {
-    return 0;
-  }
-  std::string getInterfaceHash() override {
-    return "";
-  }
-};  // class IStringConstantsDefault
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kExpectedCppOutputWithVersionAndHash[] =
-    R"(#include <android/os/IStringConstants.h>
-#include <android/os/BpStringConstants.h>
-
-namespace android {
-
-namespace os {
-
-DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(StringConstants, "android.os.IStringConstants")
-
-const ::android::String16& IStringConstants::EXAMPLE_CONSTANT() {
-  static const ::android::String16 value(::android::String16("foo"));
-  return value;
-}
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BpStringConstants.h>
-#include <binder/Parcel.h>
-#include <android-base/macros.h>
-
-namespace android {
-
-namespace os {
-
-BpStringConstants::BpStringConstants(const ::android::sp<::android::IBinder>& _aidl_impl)
-    : BpInterface<IStringConstants>(_aidl_impl){
-}
-
-int32_t BpStringConstants::getInterfaceVersion() {
-  if (cached_version_ == -1) {
-    ::android::Parcel data;
-    ::android::Parcel reply;
-    data.writeInterfaceToken(getInterfaceDescriptor());
-    ::android::status_t err = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 16777214 /* getInterfaceVersion */, data, &reply);
-    if (err == ::android::OK) {
-      ::android::binder::Status _aidl_status;
-      err = _aidl_status.readFromParcel(reply);
-      if (err == ::android::OK && _aidl_status.isOk()) {
-        cached_version_ = reply.readInt32();
-      }
-    }
-  }
-  return cached_version_;
-}
-
-std::string BpStringConstants::getInterfaceHash() {
-  std::lock_guard<std::mutex> lockGuard(cached_hash_mutex_);
-  if (cached_hash_ == "-1") {
-    ::android::Parcel data;
-    ::android::Parcel reply;
-    data.writeInterfaceToken(getInterfaceDescriptor());
-    ::android::status_t err = remote()->transact(::android::IBinder::FIRST_CALL_TRANSACTION + 16777213 /* getInterfaceHash */, data, &reply);
-    if (err == ::android::OK) {
-      ::android::binder::Status _aidl_status;
-      err = _aidl_status.readFromParcel(reply);
-      if (err == ::android::OK && _aidl_status.isOk()) {
-        reply.readUtf8FromUtf16(&cached_hash_);
-      }
-    }
-  }
-  return cached_hash_;
-}
-
-}  // namespace os
-
-}  // namespace android
-#include <android/os/BnStringConstants.h>
-#include <binder/Parcel.h>
-#include <binder/Stability.h>
-
-namespace android {
-
-namespace os {
-
-BnStringConstants::BnStringConstants()
-{
-  ::android::internal::Stability::markCompilationUnit(this);
-}
-
-::android::status_t BnStringConstants::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  switch (_aidl_code) {
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 16777214 /* getInterfaceVersion */:
-  {
-    _aidl_data.checkInterface(this);
-    _aidl_reply->writeNoException();
-    _aidl_reply->writeInt32(IStringConstants::VERSION);
-  }
-  break;
-  case ::android::IBinder::FIRST_CALL_TRANSACTION + 16777213 /* getInterfaceHash */:
-  {
-    _aidl_data.checkInterface(this);
-    _aidl_reply->writeNoException();
-    _aidl_reply->writeUtf8AsUtf16(IStringConstants::HASH);
-  }
-  break;
-  default:
-  {
-    _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
-  }
-  break;
-  }
-  if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
-    _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
-  }
-  return _aidl_ret_status;
-}
-
-int32_t BnStringConstants::getInterfaceVersion() {
-  return IStringConstants::VERSION;
-}
-
-std::string BnStringConstants::getInterfaceHash() {
-  return IStringConstants::HASH;
-}
-
-}  // namespace os
-
-}  // namespace android
-)";
-
-const char kRustOutputDirectory[] = "some/path/to";
-const char kRustOutputPath[] = "some/path/to/android/os/IStringConstants.rs";
-
-const char kExpectedRustOutput[] =
-    R"(#![allow(non_upper_case_globals)]
-#![allow(non_snake_case)]
-#[allow(unused_imports)] use binder::IBinder;
-use binder::declare_binder_interface;
-declare_binder_interface! {
-  IStringConstants["android.os.IStringConstants"] {
-    native: BnStringConstants(on_transact),
-    proxy: BpStringConstants {
-    },
-  }
-}
-pub trait IStringConstants: binder::Interface + Send {
-  fn get_descriptor() -> &'static str where Self: Sized { "android.os.IStringConstants" }
-  fn getDefaultImpl() -> IStringConstantsDefault where Self: Sized {
-    DEFAULT_IMPL.lock().unwrap().clone()
-  }
-  fn setDefaultImpl(d: IStringConstantsDefault) -> IStringConstantsDefault where Self: Sized {
-    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
-  }
-}
-pub mod transactions {
-  #[allow(unused_imports)] use binder::IBinder;
-}
-pub type IStringConstantsDefault = Option<std::sync::Arc<dyn IStringConstants + Sync>>;
-use lazy_static::lazy_static;
-lazy_static! {
-  static ref DEFAULT_IMPL: std::sync::Mutex<IStringConstantsDefault> = std::sync::Mutex::new(None);
-}
-pub const EXAMPLE_CONSTANT: &str = "foo";
-pub(crate) mod mangled { pub use super::IStringConstants as _7_android_2_os_16_IStringConstants; }
-impl IStringConstants for BpStringConstants {
-}
-impl IStringConstants for binder::Binder<BnStringConstants> {
-}
-fn on_transact(_aidl_service: &dyn IStringConstants, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
-  match _aidl_code {
-    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
-  }
-}
-)";
-
-const char kExpectedRustOutputWithVersionAndHash[] =
-    R"(#![allow(non_upper_case_globals)]
-#![allow(non_snake_case)]
-#[allow(unused_imports)] use binder::IBinder;
-use binder::declare_binder_interface;
-declare_binder_interface! {
-  IStringConstants["android.os.IStringConstants"] {
-    native: BnStringConstants(on_transact),
-    proxy: BpStringConstants {
-      cached_version: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(-1),
-      cached_hash: std::sync::Mutex<Option<String>> = std::sync::Mutex::new(None)
-    },
-  }
-}
-pub trait IStringConstants: binder::Interface + Send {
-  fn get_descriptor() -> &'static str where Self: Sized { "android.os.IStringConstants" }
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> {
-    Ok(VERSION)
-  }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> {
-    Ok(HASH.into())
-  }
-  fn getDefaultImpl() -> IStringConstantsDefault where Self: Sized {
-    DEFAULT_IMPL.lock().unwrap().clone()
-  }
-  fn setDefaultImpl(d: IStringConstantsDefault) -> IStringConstantsDefault where Self: Sized {
-    std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
-  }
-}
-pub mod transactions {
-  #[allow(unused_imports)] use binder::IBinder;
-  pub const getInterfaceVersion: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16777214;
-  pub const getInterfaceHash: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 16777213;
-}
-pub type IStringConstantsDefault = Option<std::sync::Arc<dyn IStringConstants + Sync>>;
-use lazy_static::lazy_static;
-lazy_static! {
-  static ref DEFAULT_IMPL: std::sync::Mutex<IStringConstantsDefault> = std::sync::Mutex::new(None);
-}
-pub const EXAMPLE_CONSTANT: &str = "foo";
-pub(crate) mod mangled { pub use super::IStringConstants as _7_android_2_os_16_IStringConstants; }
-pub const VERSION: i32 = 10;
-pub const HASH: &str = "abcdefg";
-impl IStringConstants for BpStringConstants {
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> {
-    let _aidl_version = self.cached_version.load(std::sync::atomic::Ordering::Relaxed);
-    if _aidl_version != -1 { return Ok(_aidl_version); }
-    let _aidl_reply = self.binder.transact(transactions::getInterfaceVersion, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IStringConstants>::getDefaultImpl() {
-        return _aidl_default_impl.getInterfaceVersion();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: i32 = _aidl_reply.read()?;
-    self.cached_version.store(_aidl_return, std::sync::atomic::Ordering::Relaxed);
-    Ok(_aidl_return)
-  }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> {
-    {
-      let _aidl_hash_lock = self.cached_hash.lock().unwrap();
-      if let Some(ref _aidl_hash) = *_aidl_hash_lock {
-        return Ok(_aidl_hash.clone());
-      }
-    }
-    let _aidl_reply = self.binder.transact(transactions::getInterfaceHash, 0, |_aidl_data| {
-      Ok(())
-    });
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as IStringConstants>::getDefaultImpl() {
-        return _aidl_default_impl.getInterfaceHash();
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: String = _aidl_reply.read()?;
-    *self.cached_hash.lock().unwrap() = Some(_aidl_return.clone());
-    Ok(_aidl_return)
-  }
-}
-impl IStringConstants for binder::Binder<BnStringConstants> {
-  fn getInterfaceVersion(&self) -> binder::public_api::Result<i32> { self.0.getInterfaceVersion() }
-  fn getInterfaceHash(&self) -> binder::public_api::Result<String> { self.0.getInterfaceHash() }
-}
-fn on_transact(_aidl_service: &dyn IStringConstants, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
-  match _aidl_code {
-    transactions::getInterfaceVersion => {
-      let _aidl_return = _aidl_service.getInterfaceVersion();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    transactions::getInterfaceHash => {
-      let _aidl_return = _aidl_service.getInterfaceHash();
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
-    _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
-  }
-}
-)";
-
-}  // namespace string_constants
-}  // namespace test_data
-}  // namespace aidl
-}  // namespace android
diff --git a/tests/versioned/android/aidl/versioned/tests/BazUnion.aidl b/tests/versioned/android/aidl/versioned/tests/BazUnion.aidl
new file mode 100644
index 0000000..0fb6d02
--- /dev/null
+++ b/tests/versioned/android/aidl/versioned/tests/BazUnion.aidl
@@ -0,0 +1,8 @@
+package android.aidl.versioned.tests;
+
+union BazUnion {
+    // V1
+    int intNum;
+    // V2
+    long longNum;
+}
\ No newline at end of file
diff --git a/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl b/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
index 445bb8c..d8b88f6 100644
--- a/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
+++ b/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
@@ -1,8 +1,9 @@
 package android.aidl.versioned.tests;
-
+import android.aidl.versioned.tests.BazUnion;
 interface IFooInterface {
     // V1
-    void foo();
+    void originalApi();
+    @utf8InCpp String acceptUnionAndReturnString(in BazUnion u);
     // V2
-    void bar();
+    void newApi();
 }