Snap for 7550844 from 79d715bab4ceff0dc3924f9f029529309f45f014 to mainline-conscrypt-release
Change-Id: I022d688cf16b0d7d2aa3c8e381289b39c6fb6a0a
diff --git a/Android.bp b/Android.bp
index 879792c..077be21 100644
--- a/Android.bp
+++ b/Android.bp
@@ -14,6 +14,23 @@
// limitations under the License.
//
+package {
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+ name: "system_tools_aidl_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ ],
+ license_text: [
+ "NOTICE",
+ ],
+}
+
cc_defaults {
name: "aidl_defaults",
cflags: [
@@ -21,11 +38,17 @@
"-Werror",
"-Wextra",
],
- whole_static_libs: ["libgtest_prod"],
+ header_libs: ["libgtest_prod_headers"],
static_libs: [
"libbase",
"libcutils",
+ "libgtest",
],
+ // TODO(b/174366536): basic_stringbuf::overflow causes "ubsan: implicit-conversion"
+ // sanitize: {
+ // integer_overflow: true,
+ // misc_undefined: ["integer"],
+ // },
target: {
windows: {
enabled: true,
@@ -37,6 +60,11 @@
],
},
},
+ product_variables: {
+ platform_sdk_version: {
+ cflags: ["-DPLATFORM_SDK_VERSION=%d"],
+ },
+ },
}
// Logic shared between aidl and its unittests
@@ -44,34 +72,39 @@
name: "libaidl-common",
defaults: ["aidl_defaults"],
host_supported: true,
- cflags: [
- "-Wno-bool-operation", // found in aidl_const_expressions.cpp:69
- ],
srcs: [
- "aidl.cpp",
"aidl_checkapi.cpp",
"aidl_const_expressions.cpp",
- "aidl_language.cpp",
+ "aidl_dumpapi.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",
"io_delegate.cpp",
+ "line_reader.cpp",
+ "location.cpp",
+ "logging.cpp",
"options.cpp",
+ "parser.cpp",
],
yacc: {
gen_location_hh: true,
@@ -109,7 +142,7 @@
name: "aidl_unittests",
host_supported: true,
- test_suites: ["device-tests"],
+ test_suites: ["general-tests"],
cflags: [
"-Wall",
@@ -123,15 +156,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",
],
@@ -142,6 +172,8 @@
"libgmock",
"liblog",
],
+
+ required: ["aidl-golden-test-build-hook"],
}
cc_fuzz {
@@ -154,6 +186,7 @@
fuzz_config: {
cc: [
+ "devinmoore@google.com",
"smoreland@google.com",
"jiyong@google.com",
"jeongik@google.com",
@@ -169,6 +202,7 @@
"libaidl-common",
"libbase",
"libcutils",
+ "libgtest",
"liblog",
],
// Enable this to show additional information about what is being parsed during fuzzing.
@@ -176,17 +210,26 @@
}
//
-// Everything below here is used for integration testing of generated AIDL code.
+// Integration testing of generated AIDL code.
//
-cc_test {
- name: "aidl_test_sentinel_searcher",
- gtest: false,
- srcs: ["tests/aidl_test_sentinel_searcher.cpp"],
- cflags: [
- "-Wall",
- "-Wextra",
- "-Werror",
+
+python_test_host {
+ name: "aidl_integration_test",
+ main: "tests/aidl_integration_test.py",
+ srcs: ["tests/aidl_integration_test.py"],
+ test_config: "tests/aidl_integration_test.xml",
+ target_required: [
+ "aidl_test_client",
+ "aidl_test_service",
+ "aidl_test_java_client",
+ "aidl_test_java_service",
+ "aidl_test_rust_client",
+ "aidl_test_rust_service",
],
+ test_suites: ["general-tests"],
+ test_options: {
+ unit_test: false,
+ },
}
cc_defaults {
@@ -202,24 +245,96 @@
"liblog",
"libutils",
],
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+ test_suites: ["general-tests"],
+}
+
+// Header-only library used for atrace in platform NDK builds
+cc_library_headers {
+ name: "libandroid_aidltrace",
+ host_supported: true,
+ vendor_available: true,
+ export_include_dirs: ["trace"],
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
}
filegroup {
name: "libaidl-integration-test-files",
- srcs: ["tests/android/aidl/tests/*.aidl"],
+ srcs: [
+ "tests/android/aidl/tests/BackendType.aidl",
+ "tests/android/aidl/tests/ByteEnum.aidl",
+ "tests/android/aidl/tests/ConstantExpressionEnum.aidl",
+ "tests/android/aidl/tests/DeprecatedEnum.aidl",
+ "tests/android/aidl/tests/DeprecatedParcelable.aidl",
+ "tests/android/aidl/tests/GenericStructuredParcelable.aidl",
+ "tests/android/aidl/tests/IDeprecated.aidl",
+ "tests/android/aidl/tests/INamedCallback.aidl",
+ "tests/android/aidl/tests/INewName.aidl",
+ "tests/android/aidl/tests/IOldName.aidl",
+ "tests/android/aidl/tests/ITestService.aidl",
+ "tests/android/aidl/tests/IntEnum.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",
+}
+
+aidl_interface {
+ name: "aidl-test-versioned-interface",
+ local_include_dir: "tests/versioned",
+ flags: ["-Werror"],
+ srcs: [
+ "tests/versioned/**/*.aidl",
+ ],
+ versions: [
+ "1",
+ "2",
+ ],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
+}
+
cc_library_static {
name: "libaidl-integration-test",
defaults: ["aidl_test_defaults"],
aidl: {
+ generate_traces: true,
export_aidl_headers: true,
local_include_dirs: ["tests"],
include_dirs: ["frameworks/native/aidl/binder"],
},
srcs: [
":libaidl-integration-test-files",
+ ":libaidl-integration-cpp-java-test-files",
"tests/simple_parcelable.cpp",
],
}
@@ -228,15 +343,27 @@
name: "aidl_test_service",
gtest: false,
defaults: ["aidl_test_defaults"],
- static_libs: ["libaidl-integration-test"],
+ static_libs: [
+ "libaidl-integration-test",
+ "libcutils",
+ // service uses the old version
+ "aidl-test-versioned-interface-V1-cpp",
+ "aidl_test_loggable_interface-cpp",
+ ],
srcs: ["tests/aidl_test_service.cpp"],
}
cc_test {
name: "aidl_test_client",
- gtest: false,
defaults: ["aidl_test_defaults"],
- static_libs: ["libaidl-integration-test"],
+ static_libs: [
+ "libaidl-integration-test",
+ "libcutils",
+ "libgmock",
+ // client uses the latest version
+ "aidl-test-versioned-interface-V2-cpp",
+ "aidl_test_loggable_interface-cpp"
+ ],
srcs: [
"tests/aidl_test_client.cpp",
"tests/aidl_test_client_file_descriptors.cpp",
@@ -246,11 +373,34 @@
"tests/aidl_test_client_utf8_strings.cpp",
"tests/aidl_test_client_service_exceptions.cpp",
"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_app {
- name: "aidl_test_services",
+cc_test {
+ name: "aidl_test_client_ndk",
+ defaults: ["aidl_test_defaults"],
+ static_libs: [
+ "libcutils",
+ "libgmock",
+ // client uses the latest version
+ "aidl-test-versioned-interface-V2-ndk_platform",
+ "aidl-test-interface-ndk_platform",
+ "aidl_test_loggable_interface-ndk_platform"
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ],
+ srcs: [
+ "tests/aidl_test_client_ndk_loggable_interface.cpp",
+ "tests/aidl_test_client_ndk_versioned_interface.cpp",
+ ],
+}
+
+java_defaults {
+ name: "aidl_test_java_defaults",
platform_apis: true,
// Turn off Java optimization tools to speed up our test iterations.
optimize: {
@@ -259,44 +409,209 @@
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",
+ // 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/java_app/src/android/aidl/tests/GenericTests.java",
- "tests/java_app/src/android/aidl/tests/MapTests.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/TestLogger.java",
- "tests/java_app/src/android/aidl/tests/TestServiceClient.java",
- "tests/java_app/src/android/aidl/tests/generic/Pair.java",
+ "tests/android/aidl/tests/extension/*.aidl",
+ "tests/android/aidl/tests/unions/*.aidl",
+ "tests/java/src/android/aidl/tests/SimpleParcelable.java",
+ "tests/java/src/android/aidl/tests/generic/Pair.java",
],
aidl: {
include_dirs: [
"system/tools/aidl/tests/",
"frameworks/native/aidl/binder",
],
+ generate_traces: true,
},
+ test_suites: ["general-tests"],
}
+java_test {
+ name: "aidl_test_java_client",
+ defaults: ["aidl_test_java_defaults"],
+ static_libs: [
+ // client uses the new version
+ "aidl-test-versioned-interface-V2-java",
+ ],
+ // tests are included in defaults
+ srcs: [
+ "tests/java/src/android/aidl/tests/MapTests.java",
+ "tests/java/src/android/aidl/tests/TestServiceClient.java",
+ "tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java",
+ "tests/java/src/android/aidl/tests/AidlJavaTests.java",
+ "tests/java/src/android/aidl/tests/GenericTests.java",
+ "tests/java/src/android/aidl/tests/TestVersionedInterface.java",
+ "tests/java/src/android/aidl/tests/UnionTests.java",
+ "tests/java/src/android/aidl/tests/ExtensionTests.java",
+ "tests/java/src/android/aidl/tests/NullableTests.java",
+ "tests/java/src/android/aidl/tests/VintfTests.java",
+ ],
+}
+
+java_test {
+ name: "aidl_test_java_service",
+ defaults: ["aidl_test_java_defaults"],
+ static_libs: [
+ // service uses the old version
+ "aidl-test-versioned-interface-V1-java",
+ ],
+ srcs: [
+ "tests/java/src/android/aidl/service/**/*.java",
+ ],
+}
+
+//
+// "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
+//
+
aidl_interface {
name: "aidl_test_loggable_interface",
unstable: true,
local_include_dir: "tests",
+ flags: ["-Werror"],
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,
+ flags: ["-Werror"],
+ 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/OWNERS b/OWNERS
index b233181..fc45550 100644
--- a/OWNERS
+++ b/OWNERS
@@ -3,5 +3,4 @@
malchev@google.com
sadmac@google.com
smoreland@google.com
-agampe@google.com
vmarko@google.com
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/README.md b/README.md
new file mode 100644
index 0000000..02409cb
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+Documentation for this project is currently maintained here:
+
+https://source.android.com/devices/architecture/aidl/overview
diff --git a/TEST_MAPPING b/TEST_MAPPING
index a54f480..6b29745 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -4,6 +4,9 @@
"name": "aidl_unittests"
},
{
+ "name": "aidl_integration_test"
+ },
+ {
"name": "CtsNdkBinderTestCases"
},
{
diff --git a/aidl-format.sh b/aidl-format.sh
new file mode 100755
index 0000000..4f2a104
--- /dev/null
+++ b/aidl-format.sh
@@ -0,0 +1,188 @@
+#!/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="$([ -f "$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" || (
+ echo "You can try to fix this by running:"
+ echo "$0 -w <file>"
+ echo ""
+ )
+ 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 2c9bd2e..77c5f31 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -36,16 +36,20 @@
#include <android-base/strings.h>
+#include "aidl_checkapi.h"
+#include "aidl_dumpapi.h"
#include "aidl_language.h"
#include "aidl_typenames.h"
#include "generate_aidl_mappings.h"
#include "generate_cpp.h"
#include "generate_java.h"
#include "generate_ndk.h"
+#include "generate_rust.h"
#include "import_resolver.h"
#include "logging.h"
#include "options.h"
#include "os.h"
+#include "parser.h"
#ifndef O_BINARY
# define O_BINARY 0
@@ -53,11 +57,10 @@
using android::base::Join;
using android::base::Split;
-using std::cerr;
-using std::endl;
using std::set;
using std::string;
using std::unique_ptr;
+using std::unordered_set;
using std::vector;
namespace android {
@@ -164,7 +167,7 @@
CodeWriterPtr writer = io_delegate.GetCodeWriter(dep_file_name);
if (!writer) {
- LOG(ERROR) << "Could not open dependency file: " << dep_file_name;
+ AIDL_ERROR(dep_file_name) << "Could not open dependency file.";
return false;
}
@@ -215,31 +218,32 @@
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()) {
result += ".cpp";
+ } else if (options.TargetLanguage() == Options::Language::RUST) {
+ result += ".rs";
} else {
- LOG(FATAL) << "Should not reach here" << endl;
+ AIDL_FATAL("Unknown target language");
return "";
}
@@ -299,8 +303,8 @@
}
// TODO: Remove this in favor of using the YACC parser b/25479378
-bool ParsePreprocessedLine(const string& line, string* decl,
- vector<string>* package, string* class_name) {
+bool ParsePreprocessedLine(const string& line, string* decl, std::string* package,
+ string* class_name) {
// erase all trailing whitespace and semicolons
const size_t end = line.find_last_not_of(" ;\t");
if (end == string::npos) {
@@ -334,7 +338,7 @@
size_t dot_pos = type.rfind('.');
if (dot_pos != string::npos) {
*class_name = type.substr(dot_pos + 1);
- *package = Split(type.substr(0, dot_pos), ".");
+ *package = type.substr(0, dot_pos);
} else {
*class_name = type;
package->clear();
@@ -343,6 +347,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 {
@@ -352,7 +407,7 @@
bool success = true;
unique_ptr<LineReader> line_reader = io_delegate.GetLineReader(filename);
if (!line_reader) {
- LOG(ERROR) << "cannot open preprocessed file: " << filename;
+ AIDL_ERROR(filename) << "cannot open preprocessed file";
success = false;
return success;
}
@@ -366,7 +421,7 @@
}
string decl;
- vector<string> package;
+ std::string package;
string class_name;
if (!ParsePreprocessedLine(line, &decl, &package, &class_name)) {
success = false;
@@ -374,7 +429,7 @@
}
AidlLocation::Point point = {.line = lineno, .column = 0 /*column*/};
- AidlLocation location = AidlLocation(filename, point, point);
+ AidlLocation location = AidlLocation(filename, point, point, AidlLocation::Source::EXTERNAL);
if (decl == "parcelable") {
// ParcelFileDescriptor is treated as a built-in type, but it's also in the framework.aidl.
@@ -383,18 +438,15 @@
if (AidlTypenames::IsBuiltinTypename(class_name)) {
continue;
}
- AidlParcelable* doc = new AidlParcelable(
- location, new AidlQualifiedName(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, new AidlQualifiedName(location, class_name, ""),
- package, "" /* comments */, temp);
+ 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;
@@ -402,8 +454,8 @@
}
}
if (!success) {
- LOG(ERROR) << filename << ':' << lineno
- << " malformed preprocessed file line: '" << line << "'";
+ AIDL_ERROR(filename) << " on line " << lineno << " malformed preprocessed file line: '" << line
+ << "'";
}
return success;
@@ -411,7 +463,6 @@
AidlError load_and_validate_aidl(const std::string& input_file_name, const Options& options,
const IoDelegate& io_delegate, AidlTypenames* typenames,
- vector<AidlDefinedType*>* defined_types,
vector<string>* imported_files) {
AidlError err = AidlError::OK;
@@ -424,16 +475,16 @@
if (main_parser == nullptr) {
return AidlError::PARSE_ERROR;
}
- int num_interfaces_or_structured_parcelables = 0;
- for (AidlDefinedType* type : main_parser->GetDefinedTypes()) {
- if (type->AsInterface() != nullptr || type->AsStructuredParcelable() != nullptr) {
- num_interfaces_or_structured_parcelables++;
+ int num_top_level_decls = 0;
+ for (const auto& type : main_parser->ParsedDocument().DefinedTypes()) {
+ 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;
+ }
}
}
- if (num_interfaces_or_structured_parcelables > 1) {
- AIDL_ERROR(input_file_name) << "You must declare only one type per a file.";
- return AidlError::BAD_TYPE;
- }
// Import the preprocessed file
for (const string& s : options.PreprocessedFiles()) {
@@ -449,51 +500,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->GetImports()) {
- if (!AidlTypenames::IsBuiltinTypename(import->GetNeededClass())) {
- type_from_import_statements.emplace_back(import->GetNeededClass());
+ for (const auto& import : main_parser->ParsedDocument().Imports()) {
+ 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).second) {
- // 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(import) << "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;
}
@@ -501,7 +526,7 @@
std::unique_ptr<Parser> import_parser = Parser::Parse(import_path, io_delegate, *typenames);
if (import_parser == nullptr) {
- cerr << "error while importing " << import_path << " for " << import << endl;
+ AIDL_ERROR(import_path) << "error while importing " << import_path << " for " << import;
err = AidlError::BAD_IMPORT;
continue;
}
@@ -523,39 +548,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;
}
//////////////////////////////////////////////////////////////////////////
@@ -568,131 +598,174 @@
// serious failures.
bool contains_unstructured_parcelable = false;
- const int num_defined_types = main_parser->GetDefinedTypes().size();
- for (const auto defined_type : main_parser->GetDefinedTypes()) {
- CHECK(defined_type != nullptr);
+ const auto& types = main_parser->ParsedDocument().DefinedTypes();
+ const int num_defined_types = types.size();
+ for (const auto& defined_type : types) {
+ AIDL_FATAL_IF(defined_type == nullptr, main_parser->FileName());
- // Language specific validation
- if (!defined_type->LanguageSpecificCheckValid(options.TargetLanguage())) {
- return AidlError::BAD_TYPE;
- }
-
- AidlParcelable* unstructuredParcelable = defined_type->AsUnstructuredParcelable();
- if (unstructuredParcelable != nullptr) {
- if (!unstructuredParcelable->CheckValid(*typenames)) {
- return AidlError::BAD_TYPE;
- }
- bool isStable = unstructuredParcelable->IsStableApiParcelable(options.TargetLanguage());
- if (options.IsStructured() && !isStable) {
- AIDL_ERROR(unstructuredParcelable)
- << "Cannot declared parcelable in a --structured interface. Parcelable must be defined "
- "in AIDL directly.";
- return AidlError::NOT_STRUCTURED;
- }
- if (options.FailOnParcelable()) {
- AIDL_ERROR(unstructuredParcelable)
- << "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() &&
- (options.GetStability() != Options::Stability::VINTF || !options.IsStructured())) {
- AIDL_ERROR(defined_type)
- << "Must compile @VintfStability type w/ aidl_interface 'stability: \"vintf\"'";
- return AidlError::NOT_STRUCTURED;
- }
-
- // Ensure that a type is either an interface, structured parcelable, or
- // enum.
+ // 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();
- CHECK(!!interface + !!parcelable + !!enum_decl == 1);
+ 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;
}
- // 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)) {
+ {
+ 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;
}
}
+ if (unstructured_parcelable != nullptr) {
+ bool isStable = unstructured_parcelable->IsStableApiParcelable(options.TargetLanguage());
+ if (options.IsStructured() && !isStable) {
+ 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(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;
+ }
+
+ if (defined_type->IsVintfStability()) {
+ bool success = true;
+ if (options.GetStability() != Options::Stability::VINTF) {
+ AIDL_ERROR(defined_type)
+ << "Must compile @VintfStability type w/ aidl_interface 'stability: \"vintf\"'";
+ success = false;
+ }
+ if (!options.IsStructured()) {
+ AIDL_ERROR(defined_type)
+ << "Must compile @VintfStability type w/ aidl_interface --structured";
+ success = false;
+ }
+ if (!success) return AidlError::NOT_STRUCTURED;
+ }
+
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:
- LOG(FATAL) << "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())) {
err = AidlError::NOT_STRUCTURED;
- LOG(ERROR) << type.GetCanonicalName()
- << " is not structured, but this is a structured interface.";
+ AIDL_ERROR(type) << type.GetCanonicalName()
+ << " is not structured, but this is a structured interface.";
}
if (options.GetStability() == Options::Stability::VINTF && !type.IsVintfStability()) {
err = AidlError::NOT_STRUCTURED;
- LOG(ERROR) << type.GetCanonicalName()
- << " does not have VINTF level stability, but this interface requires it.";
+ AIDL_ERROR(type) << type.GetCanonicalName()
+ << " does not have VINTF level stability, but this interface requires it.";
+ }
+
+ // Ensure that untyped List/Map is not used in a parcelable, a union and a stable interface.
+
+ 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;
+ }
+ 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());
}
});
@@ -700,10 +773,6 @@
return err;
}
- if (defined_types != nullptr) {
- *defined_types = main_parser->GetDefinedTypes();
- }
-
if (imported_files != nullptr) {
*imported_files = import_paths;
}
@@ -723,23 +792,22 @@
for (const string& input_file : options.InputFiles()) {
AidlTypenames typenames;
- vector<AidlDefinedType*> defined_types;
vector<string> imported_files;
- AidlError aidl_err = internals::load_and_validate_aidl(
- input_file, options, io_delegate, &typenames, &defined_types, &imported_files);
+ AidlError aidl_err = internals::load_and_validate_aidl(input_file, options, io_delegate,
+ &typenames, &imported_files);
bool allowError = aidl_err == AidlError::FOUND_PARCELABLE && !options.FailOnParcelable();
if (aidl_err != AidlError::OK && !allowError) {
return 1;
}
- for (const auto defined_type : defined_types) {
- CHECK(defined_type != nullptr);
+ for (const auto& defined_type : typenames.MainDocument().DefinedTypes()) {
+ AIDL_FATAL_IF(defined_type == nullptr, input_file);
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;
}
@@ -762,12 +830,14 @@
// Legacy behavior. For parcelable declarations in Java, don't generate output file.
success = true;
} else {
- success =
- java::generate_java(output_file_name, defined_type, typenames, io_delegate, options);
+ success = java::generate_java(output_file_name, defined_type.get(), typenames,
+ io_delegate, options);
}
+ } else if (lang == Options::Language::RUST) {
+ success = rust::GenerateRust(output_file_name, defined_type.get(), typenames, io_delegate,
+ options);
} else {
- LOG(FATAL) << "Should not reach here" << endl;
- return 1;
+ AIDL_FATAL(input_file) << "Should not reach here.";
}
if (!success) {
return 1;
@@ -781,17 +851,15 @@
android::aidl::mappings::SignatureMap all_mappings;
for (const string& input_file : options.InputFiles()) {
AidlTypenames typenames;
- vector<AidlDefinedType*> defined_types;
vector<string> imported_files;
- AidlError aidl_err = internals::load_and_validate_aidl(
- input_file, options, io_delegate, &typenames, &defined_types, &imported_files);
+ AidlError aidl_err = internals::load_and_validate_aidl(input_file, options, io_delegate,
+ &typenames, &imported_files);
if (aidl_err != AidlError::OK) {
- LOG(WARNING) << "AIDL file is invalid.\n";
- continue;
+ return false;
}
- for (const auto defined_type : defined_types) {
- auto mappings = mappings::generate_mappings(defined_type, typenames);
+ for (const auto& defined_type : typenames.MainDocument().DefinedTypes()) {
+ auto mappings = mappings::generate_mappings(defined_type.get(), typenames);
all_mappings.insert(mappings.begin(), mappings.end());
}
}
@@ -812,7 +880,7 @@
std::unique_ptr<Parser> p = Parser::Parse(file, io_delegate, typenames);
if (p == nullptr) return false;
- for (const auto& defined_type : p->GetDefinedTypes()) {
+ for (const auto& defined_type : p->ParsedDocument().DefinedTypes()) {
if (!writer->Write("%s %s;\n", defined_type->GetPreprocessDeclarationName().c_str(),
defined_type->GetCanonicalName().c_str())) {
return false;
@@ -823,32 +891,39 @@
return writer->Close();
}
-static string GetApiDumpPathFor(const AidlDefinedType& defined_type, const Options& options) {
- string package_as_path = Join(Split(defined_type.GetPackage(), "."), OS_PATH_SEPARATOR);
- CHECK(!options.OutputDir().empty() && options.OutputDir().back() == '/');
- return options.OutputDir() + package_as_path + OS_PATH_SEPARATOR + defined_type.GetName() +
- ".aidl";
-}
+int aidl_entry(const Options& options, const IoDelegate& io_delegate) {
+ AidlErrorLog::clearError();
-bool dump_api(const Options& options, const IoDelegate& io_delegate) {
- for (const auto& file : options.InputFiles()) {
- AidlTypenames typenames;
- vector<AidlDefinedType*> defined_types;
- if (internals::load_and_validate_aidl(file, options, io_delegate, &typenames, &defined_types,
- nullptr) == AidlError::OK) {
- for (const auto type : defined_types) {
- unique_ptr<CodeWriter> writer =
- io_delegate.GetCodeWriter(GetApiDumpPathFor(*type, options));
- if (!type->GetPackage().empty()) {
- (*writer) << kPreamble << "package " << type->GetPackage() << ";\n";
- }
- type->Dump(writer.get());
- }
- } else {
- return false;
- }
+ int ret = 1;
+ switch (options.GetTask()) {
+ case Options::Task::COMPILE:
+ ret = android::aidl::compile_aidl(options, io_delegate);
+ break;
+ case Options::Task::PREPROCESS:
+ ret = android::aidl::preprocess_aidl(options, io_delegate) ? 0 : 1;
+ break;
+ case Options::Task::DUMP_API:
+ ret = android::aidl::dump_api(options, io_delegate) ? 0 : 1;
+ break;
+ case Options::Task::CHECK_API:
+ ret = android::aidl::check_api(options, io_delegate) ? 0 : 1;
+ break;
+ case Options::Task::DUMP_MAPPINGS:
+ ret = android::aidl::dump_mappings(options, io_delegate) ? 0 : 1;
+ break;
+ default:
+ AIDL_FATAL(AIDL_LOCATION_HERE)
+ << "Unrecognized task: " << static_cast<size_t>(options.GetTask());
}
- return true;
+
+ // compiler invariants
+ const bool shouldReportError = ret != 0;
+ const bool reportedError = AidlErrorLog::hadError();
+ AIDL_FATAL_IF(shouldReportError != reportedError, AIDL_LOCATION_HERE)
+ << "Compiler returned error " << ret << " but did" << (reportedError ? "" : " not")
+ << " emit error logs";
+
+ return ret;
}
} // namespace aidl
diff --git a/aidl.h b/aidl.h
index 298a6cc..1ff8d46 100644
--- a/aidl.h
+++ b/aidl.h
@@ -47,21 +47,24 @@
int compile_aidl(const Options& options, const IoDelegate& io_delegate);
bool preprocess_aidl(const Options& options, const IoDelegate& io_delegate);
-bool dump_api(const Options& options, const IoDelegate& io_delegate);
bool dump_mappings(const Options& options, const IoDelegate& io_delegate);
+// main entry point to AIDL
+int aidl_entry(const Options& options, const IoDelegate& io_delegate);
+
const char kPreamble[] =
R"(///////////////////////////////////////////////////////////////////////////////
// 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
@@ -77,7 +80,6 @@
AidlError load_and_validate_aidl(const std::string& input_file_name, const Options& options,
const IoDelegate& io_delegate, AidlTypenames* typenames,
- vector<AidlDefinedType*>* defined_types,
vector<string>* imported_files);
bool parse_preprocessed_file(const IoDelegate& io_delegate, const std::string& filename,
diff --git a/aidl_api/aidl-test-versioned-interface/1/.hash b/aidl_api/aidl-test-versioned-interface/1/.hash
new file mode 100644
index 0000000..34d8ec6
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/1/.hash
@@ -0,0 +1 @@
+9e7be1859820c59d9d55dd133e71a3687b5d2e5b
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/Foo.aidl b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/Foo.aidl
new file mode 100644
index 0000000..da1c01b
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/Foo.aidl
@@ -0,0 +1,20 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+parcelable Foo {
+}
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
new file mode 100644
index 0000000..cbf37e8
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/1/android/aidl/versioned/tests/IFooInterface.aidl
@@ -0,0 +1,24 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+interface IFooInterface {
+ void originalApi();
+ @utf8InCpp String acceptUnionAndReturnString(in android.aidl.versioned.tests.BazUnion u);
+ @SuppressWarnings(value={"inout-parameter"}) int ignoreParcelablesAndRepeatInt(in android.aidl.versioned.tests.Foo inFoo, inout android.aidl.versioned.tests.Foo inoutFoo, out android.aidl.versioned.tests.Foo outFoo, int value);
+ int returnsLengthOfFooArray(in android.aidl.versioned.tests.Foo[] foos);
+}
diff --git a/aidl_api/aidl-test-versioned-interface/2/.hash b/aidl_api/aidl-test-versioned-interface/2/.hash
new file mode 100644
index 0000000..5cd45f5
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/2/.hash
@@ -0,0 +1 @@
+da8c4bc94ca7feff0e0a65563a466787698b5891
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/Foo.aidl b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/Foo.aidl
new file mode 100644
index 0000000..bd8beb6
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/Foo.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;
+parcelable Foo {
+ int intDefault42 = 42;
+}
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
new file mode 100644
index 0000000..303d01d
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/2/android/aidl/versioned/tests/IFooInterface.aidl
@@ -0,0 +1,25 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+interface IFooInterface {
+ void originalApi();
+ @utf8InCpp String acceptUnionAndReturnString(in android.aidl.versioned.tests.BazUnion u);
+ @SuppressWarnings(value={"inout-parameter"}) int ignoreParcelablesAndRepeatInt(in android.aidl.versioned.tests.Foo inFoo, inout android.aidl.versioned.tests.Foo inoutFoo, out android.aidl.versioned.tests.Foo outFoo, int value);
+ int returnsLengthOfFooArray(in android.aidl.versioned.tests.Foo[] foos);
+ 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/Foo.aidl b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/Foo.aidl
new file mode 100644
index 0000000..dad05e6
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/Foo.aidl
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+parcelable Foo {
+ int intDefault42 = 42;
+}
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
new file mode 100644
index 0000000..01df310
--- /dev/null
+++ b/aidl_api/aidl-test-versioned-interface/current/android/aidl/versioned/tests/IFooInterface.aidl
@@ -0,0 +1,26 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+interface IFooInterface {
+ void originalApi();
+ @utf8InCpp String acceptUnionAndReturnString(in android.aidl.versioned.tests.BazUnion u);
+ @SuppressWarnings(value={"inout-parameter"}) int ignoreParcelablesAndRepeatInt(in android.aidl.versioned.tests.Foo inFoo, inout android.aidl.versioned.tests.Foo inoutFoo, out android.aidl.versioned.tests.Foo outFoo, int value);
+ int returnsLengthOfFooArray(in android.aidl.versioned.tests.Foo[] foos);
+ void newApi();
+}
diff --git a/aidl_checkapi.cpp b/aidl_checkapi.cpp
index b2a884c..47733c1 100644
--- a/aidl_checkapi.cpp
+++ b/aidl_checkapi.cpp
@@ -15,26 +15,62 @@
*/
#include "aidl.h"
-#include "aidl_language.h"
-#include "import_resolver.h"
-#include "logging.h"
-#include "options.h"
#include <map>
#include <string>
#include <vector>
+#include <android-base/result.h>
#include <android-base/strings.h>
+#include <gtest/gtest.h>
+
+#include "aidl_dumpapi.h"
+#include "aidl_language.h"
+#include "import_resolver.h"
+#include "logging.h"
+#include "options.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) {
+struct DumpForEqualityVisitor : DumpVisitor {
+ DumpForEqualityVisitor(CodeWriter& out) : DumpVisitor(out) {}
+
+ void DumpConstantValue(const AidlTypeSpecifier&, const AidlConstantValue& c) {
+ out << c.Literal();
+ }
+};
+
+static std::string Dump(const AidlDefinedType& type) {
+ string code;
+ CodeWriterPtr out = CodeWriter::ForString(&code);
+ DumpForEqualityVisitor visitor(*out);
+ type.DispatchVisit(visitor);
+ out->Close();
+ return code;
+}
+
+// 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
@@ -46,24 +82,38 @@
// - a new implementation might change so that it no longer returns null
// values (remove @nullable)
// - a new implementation might start accepting null values (add @nullable)
- static const set<std::string> kIgnoreAnnotations{
- "nullable",
- "JavaDerive",
+ static const set<AidlAnnotation::Type> kIgnoreAnnotations{
+ AidlAnnotation::Type::NULLABLE,
+ // @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.GetName()) == 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();
@@ -75,17 +125,48 @@
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;
- compatible &= have_compatible_annotations(older, newer);
map<string, AidlMethod*> new_methods;
for (const auto& m : newer.AsInterface()->GetMethods()) {
@@ -124,7 +205,7 @@
const auto& old_args = old_m->GetArguments();
const auto& new_args = new_m->GetArguments();
// this is guaranteed because arguments are part of AidlMethod::Signature()
- CHECK(old_args.size() == new_args.size());
+ AIDL_FATAL_IF(old_args.size() != new_args.size(), old_m);
for (size_t i = 0; i < old_args.size(); i++) {
const AidlArgument& old_a = *(old_args.at(i));
const AidlArgument& new_a = *(new_args.at(i));
@@ -138,36 +219,34 @@
}
}
- 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;
}
-static bool are_compatible_parcelables(const AidlStructuredParcelable& older,
- const AidlStructuredParcelable& newer) {
+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 EvaluatesToZero(const AidlEnumDeclaration& enum_decl, const std::string& value) {
+ if (value == "") return true;
+ // Because --check_api runs with "valid" AIDL definitions, we can safely assume that
+ // the value is formatted as <scope>.<enumerator>.
+ auto enumerator_name = value.substr(value.find_last_of('.') + 1);
+ for (const auto& enumerator : enum_decl.GetEnumerators()) {
+ if (enumerator->GetName() == enumerator_name) {
+ return enumerator->GetValue()->Literal() == "0";
+ }
+ }
+ AIDL_FATAL(enum_decl) << "Can't find " << enumerator_name << " in " << enum_decl.GetName();
+}
+
+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()) {
@@ -176,6 +255,21 @@
<< old_fields.size() << " to " << new_fields.size() << ".";
return false;
}
+ if (newer.IsFixedSize() && old_fields.size() != new_fields.size()) {
+ AIDL_ERROR(newer) << "Number of fields in " << older.GetCanonicalName() << " is changed from "
+ << old_fields.size() << " to " << new_fields.size()
+ << ". This is an incompatible change for FixedSize types.";
+ return false;
+ }
+
+ // android.net.UidRangeParcel should be frozen to prevent breakage in legacy (b/186720556)
+ if (older.GetCanonicalName() == "android.net.UidRangeParcel" &&
+ old_fields.size() != new_fields.size()) {
+ AIDL_ERROR(newer) << "Number of fields in " << older.GetCanonicalName() << " is changed from "
+ << old_fields.size() << " to " << new_fields.size()
+ << ". But it is forbidden because of legacy support.";
+ return false;
+ }
bool compatible = true;
for (size_t i = 0; i < old_fields.size(); i++) {
@@ -183,12 +277,20 @@
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);
- if (old_value != new_value) {
- AIDL_ERROR(newer) << "Changed default value: " << old_value << " to " << new_value << ".";
- compatible = false;
+ 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) {
+ continue;
}
+ // For enum type fields, we accept setting explicit default value which is "zero"
+ auto enum_decl = new_types.GetEnumDeclaration(new_field->GetType());
+ if (old_value == "" && enum_decl && EvaluatesToZero(*enum_decl, new_value)) {
+ continue;
+ }
+
+ AIDL_ERROR(new_field) << "Changed default value: " << old_value << " to " << new_value << ".";
+ compatible = false;
}
// Reordering of fields is an incompatible change.
@@ -207,6 +309,61 @@
}
}
+ for (size_t i = old_fields.size(); i < new_fields.size(); i++) {
+ const auto& new_field = new_fields.at(i);
+ 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;
}
@@ -233,10 +390,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 << ".";
@@ -246,48 +401,61 @@
return compatible;
}
+static Result<AidlTypenames> load_from_dir(const Options& options, const IoDelegate& io_delegate,
+ const std::string& dir) {
+ Result<std::vector<std::string>> dir_files = io_delegate.ListFiles(dir);
+ if (!dir_files.ok()) {
+ AIDL_ERROR(dir) << dir_files.error();
+ return Error();
+ }
+
+ AidlTypenames typenames;
+ for (const auto& file : *dir_files) {
+ if (!android::base::EndsWith(file, ".aidl")) continue;
+ if (internals::load_and_validate_aidl(file, options, io_delegate, &typenames,
+ nullptr /* imported_files */) != AidlError::OK) {
+ AIDL_ERROR(file) << "Failed to read.";
+ return Error();
+ }
+ }
+
+ return typenames;
+}
+
bool check_api(const Options& options, const IoDelegate& io_delegate) {
- CHECK(options.IsStructured());
- CHECK(options.InputFiles().size() == 2) << "--checkapi requires two inputs "
- << "but got " << options.InputFiles().size();
- AidlTypenames old_tns;
- const string old_dir = options.InputFiles().at(0);
- vector<AidlDefinedType*> old_types;
- vector<string> old_files = io_delegate.ListFiles(old_dir);
- if (old_files.size() == 0) {
- AIDL_ERROR(old_dir) << "No API file exist";
+ AIDL_FATAL_IF(!options.IsStructured(), AIDL_LOCATION_HERE);
+ AIDL_FATAL_IF(options.InputFiles().size() != 2, AIDL_LOCATION_HERE)
+ << "--checkapi requires two inputs "
+ << "but got " << options.InputFiles().size();
+ auto old_tns = load_from_dir(options, io_delegate, options.InputFiles().at(0));
+ if (!old_tns.ok()) {
return false;
}
- for (const auto& file : old_files) {
- if (!android::base::EndsWith(file, ".aidl")) continue;
-
- vector<AidlDefinedType*> types;
- if (internals::load_and_validate_aidl(file, options, io_delegate, &old_tns, &types,
- nullptr /* imported_files */) != AidlError::OK) {
- AIDL_ERROR(file) << "Failed to read.";
- return false;
- }
- old_types.insert(old_types.end(), types.begin(), types.end());
- }
-
- AidlTypenames new_tns;
- const string new_dir = options.InputFiles().at(1);
- vector<AidlDefinedType*> new_types;
- vector<string> new_files = io_delegate.ListFiles(new_dir);
- if (new_files.size() == 0) {
- AIDL_ERROR(new_dir) << "No API file exist";
+ auto new_tns = load_from_dir(options, io_delegate, options.InputFiles().at(1));
+ if (!new_tns.ok()) {
return false;
}
- for (const auto& file : new_files) {
- if (!android::base::EndsWith(file, ".aidl")) continue;
- vector<AidlDefinedType*> types;
- if (internals::load_and_validate_aidl(file, options, io_delegate, &new_tns, &types,
- nullptr /* imported_files */) != AidlError::OK) {
- AIDL_ERROR(file) << "Failed to read.";
- 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());
}
- new_types.insert(new_types.end(), types.begin(), types.end());
+ 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;
@@ -295,7 +463,6 @@
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()) {
@@ -305,6 +472,16 @@
}
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;
+ }
if (old_type->AsInterface() != nullptr) {
if (new_type->AsInterface() == nullptr) {
AIDL_ERROR(new_type) << "Type mismatch: " << old_type->GetCanonicalName()
@@ -322,8 +499,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 6194d7d..b97889d 100644
--- a/aidl_const_expressions.cpp
+++ b/aidl_const_expressions.cpp
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <algorithm>
#include <iostream>
+#include <limits>
#include <memory>
#include <android-base/parsedouble.h>
@@ -28,17 +29,132 @@
#include <android-base/strings.h>
using android::base::ConsumeSuffix;
+using android::base::EndsWith;
using android::base::Join;
+using android::base::StartsWith;
using std::string;
using std::unique_ptr;
using std::vector;
-#define SHOULD_NOT_REACH() CHECK(false) << LOG(FATAL) << ": should not reach here: "
+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);
+}
+
+template <typename T>
+class OverflowGuard {
+ public:
+ OverflowGuard(T value) : mValue(value) {}
+ bool Overflowed() const { return mOverflowed; }
+
+ T operator+() { return +mValue; }
+ T operator-() {
+ if (isMin()) {
+ mOverflowed = true;
+ return 0;
+ }
+ return -mValue;
+ }
+ T operator!() { return !mValue; }
+ T operator~() { return ~mValue; }
+
+ T operator+(T o) {
+ T out;
+ mOverflowed = __builtin_add_overflow(mValue, o, &out);
+ return out;
+ }
+ T operator-(T o) {
+ T out;
+ mOverflowed = __builtin_sub_overflow(mValue, o, &out);
+ return out;
+ }
+ T operator*(T o) {
+ T out;
+#ifdef _WIN32
+ // ___mulodi4 not on windows https://bugs.llvm.org/show_bug.cgi?id=46669
+ // we should still get an error here from ubsan, but the nice error
+ // is needed on linux for aidl_parser_fuzzer, where we are more
+ // concerned about overflows elsewhere in the compiler in addition to
+ // those in interfaces.
+ out = mValue * o;
+#else
+ mOverflowed = __builtin_mul_overflow(mValue, o, &out);
+#endif
+ return out;
+ }
+ T operator/(T o) {
+ if (o == 0 || (isMin() && o == -1)) {
+ mOverflowed = true;
+ return 0;
+ }
+ return mValue / o;
+ }
+ T operator%(T o) {
+ if (o == 0 || (isMin() && o == -1)) {
+ mOverflowed = true;
+ return 0;
+ }
+ return mValue % o;
+ }
+ T operator|(T o) { return mValue | o; }
+ T operator^(T o) { return mValue ^ o; }
+ T operator&(T o) { return mValue & o; }
+ T operator<(T o) { return mValue < o; }
+ T operator>(T o) { return mValue > o; }
+ T operator<=(T o) { return mValue <= o; }
+ T operator>=(T o) { return mValue >= o; }
+ T operator==(T o) { return mValue == o; }
+ T operator!=(T o) { return mValue != o; }
+ T operator>>(T o) {
+ if (o < 0 || o >= static_cast<T>(sizeof(T) * 8) || mValue < 0) {
+ mOverflowed = true;
+ return 0;
+ }
+ return mValue >> o;
+ }
+ T operator<<(T o) {
+ if (o < 0 || mValue < 0 || o > CLZ(mValue) || o >= static_cast<T>(sizeof(T) * 8)) {
+ mOverflowed = true;
+ return 0;
+ }
+ return mValue << o;
+ }
+ T operator||(T o) { return mValue || o; }
+ T operator&&(T o) { return mValue && o; }
+
+ private:
+ bool isMin() { return mValue == std::numeric_limits<T>::min(); }
+
+ T mValue;
+ bool mOverflowed = false;
+};
+
+template <typename T>
+bool processGuard(const OverflowGuard<T>& guard, const AidlConstantValue& context) {
+ if (guard.Overflowed()) {
+ AIDL_ERROR(context) << "Constant expression computation overflows.";
+ return false;
+ }
+ return true;
+}
+
+// TODO: factor out all these macros
+#define SHOULD_NOT_REACH() AIDL_FATAL(AIDL_LOCATION_HERE) << "Should not reach."
#define OPEQ(__y__) (string(op_) == string(__y__))
-#define COMPUTE_UNARY(__op__) \
- if (op == string(#__op__)) return __op__ val;
-#define COMPUTE_BINARY(__op__) \
- if (op == string(#__op__)) return lval __op__ rval;
+#define COMPUTE_UNARY(T, __op__) \
+ if (op == string(#__op__)) { \
+ OverflowGuard<T> guard(val); \
+ *out = __op__ guard; \
+ return processGuard(guard, context); \
+ }
+#define COMPUTE_BINARY(T, __op__) \
+ if (op == string(#__op__)) { \
+ OverflowGuard<T> guard(lval); \
+ *out = guard __op__ rval; \
+ return processGuard(guard, context); \
+ }
#define OP_IS_BIN_ARITHMETIC (OPEQ("+") || OPEQ("-") || OPEQ("*") || OPEQ("/") || OPEQ("%"))
#define OP_IS_BIN_BITFLIP (OPEQ("|") || OPEQ("^") || OPEQ("&"))
#define OP_IS_BIN_COMP \
@@ -62,53 +178,67 @@
}
template <class T>
-T handleUnary(const string& op, T val) {
- COMPUTE_UNARY(+)
- COMPUTE_UNARY(-)
- COMPUTE_UNARY(!)
- COMPUTE_UNARY(~)
- // Should not reach here.
- SHOULD_NOT_REACH() << "Could not handleUnary for " << op << " " << val;
- return static_cast<T>(0xdeadbeef);
+bool handleUnary(const AidlConstantValue& context, const string& op, T val, int64_t* out) {
+ COMPUTE_UNARY(T, +)
+ COMPUTE_UNARY(T, -)
+ COMPUTE_UNARY(T, !)
+ COMPUTE_UNARY(T, ~)
+ AIDL_FATAL(context) << "Could not handleUnary for " << op << " " << val;
+ return false;
+}
+template <>
+bool handleUnary<bool>(const AidlConstantValue& context, const string& op, bool val, int64_t* out) {
+ COMPUTE_UNARY(bool, +)
+ COMPUTE_UNARY(bool, -)
+ COMPUTE_UNARY(bool, !)
+
+ if (op == "~") {
+ AIDL_ERROR(context) << "Bitwise negation of a boolean expression is always true.";
+ return false;
+ }
+ AIDL_FATAL(context) << "Could not handleUnary for " << op << " " << val;
+ return false;
}
template <class T>
-T handleBinaryCommon(T lval, const string& op, T rval) {
- COMPUTE_BINARY(+)
- COMPUTE_BINARY(-)
- COMPUTE_BINARY(*)
- COMPUTE_BINARY(/)
- COMPUTE_BINARY(%)
- COMPUTE_BINARY(|)
- COMPUTE_BINARY(^)
- COMPUTE_BINARY(&)
+bool handleBinaryCommon(const AidlConstantValue& context, T lval, const string& op, T rval,
+ int64_t* out) {
+ COMPUTE_BINARY(T, +)
+ COMPUTE_BINARY(T, -)
+ COMPUTE_BINARY(T, *)
+ COMPUTE_BINARY(T, /)
+ COMPUTE_BINARY(T, %)
+ COMPUTE_BINARY(T, |)
+ COMPUTE_BINARY(T, ^)
+ COMPUTE_BINARY(T, &)
// comparison operators: return 0 or 1 by nature.
- COMPUTE_BINARY(==)
- COMPUTE_BINARY(!=)
- COMPUTE_BINARY(<)
- COMPUTE_BINARY(>)
- COMPUTE_BINARY(<=)
- COMPUTE_BINARY(>=)
- // Should not reach here.
- SHOULD_NOT_REACH() << "Could not handleBinaryCommon for " << lval << " " << op << " " << rval;
- return static_cast<T>(0xdeadbeef);
+ COMPUTE_BINARY(T, ==)
+ COMPUTE_BINARY(T, !=)
+ COMPUTE_BINARY(T, <)
+ COMPUTE_BINARY(T, >)
+ COMPUTE_BINARY(T, <=)
+ COMPUTE_BINARY(T, >=)
+
+ AIDL_FATAL(context) << "Could not handleBinaryCommon for " << lval << " " << op << " " << rval;
+ return false;
}
template <class T>
-T handleShift(T lval, const string& op, int64_t rval) {
+bool handleShift(const AidlConstantValue& context, T lval, const string& op, T rval, int64_t* out) {
// just cast rval to int64_t and it should fit.
- COMPUTE_BINARY(>>)
- COMPUTE_BINARY(<<)
- // Should not reach here.
- SHOULD_NOT_REACH() << "Could not handleShift for " << lval << " " << op << " " << rval;
- return static_cast<T>(0xdeadbeef);
+ COMPUTE_BINARY(T, >>)
+ COMPUTE_BINARY(T, <<)
+
+ AIDL_FATAL(context) << "Could not handleShift for " << lval << " " << op << " " << rval;
+ return false;
}
-bool handleLogical(bool lval, const string& op, bool rval) {
- COMPUTE_BINARY(||);
- COMPUTE_BINARY(&&);
- // Should not reach here.
- SHOULD_NOT_REACH() << "Could not handleLogical for " << lval << " " << op << " " << rval;
+bool handleLogical(const AidlConstantValue& context, bool lval, const string& op, bool rval,
+ int64_t* out) {
+ COMPUTE_BINARY(bool, ||);
+ COMPUTE_BINARY(bool, &&);
+
+ AIDL_FATAL(context) << "Could not handleLogical for " << lval << " " << op << " " << rval;
return false;
}
@@ -118,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) {
@@ -166,8 +310,8 @@
AidlConstantValue::Type AidlBinaryConstExpression::UsualArithmeticConversion(Type left,
Type right) {
// These are handled as special cases
- CHECK(left != Type::STRING && right != Type::STRING);
- CHECK(left != Type::FLOATING && right != Type::FLOATING);
+ AIDL_FATAL_IF(left == Type::STRING || right == Type::STRING, AIDL_LOCATION_HERE);
+ AIDL_FATAL_IF(left == Type::FLOATING || right == Type::FLOATING, AIDL_LOCATION_HERE);
// Kinds in concern: bool, (u)int[8|32|64]
if (left == right) return left; // easy case
@@ -182,13 +326,28 @@
return (Type::INT32 < in) ? in : Type::INT32;
}
-template <typename T>
-T AidlConstantValue::cast() const {
- CHECK(is_evaluated_ == true);
+AidlConstantValue* AidlConstantValue::Default(const AidlTypeSpecifier& specifier) {
+ AidlLocation location = specifier.GetLocation();
-#define CASE_CAST_T(__type__) return static_cast<T>(static_cast<__type__>(final_value_));
+ // allocation of int[0] is a bit wasteful in Java
+ if (specifier.IsArray()) {
+ return nullptr;
+ }
- SWITCH_KIND(final_type_, CASE_CAST_T, SHOULD_NOT_REACH(); return 0;);
+ const std::string name = specifier.GetName();
+ if (name == "boolean") {
+ return Boolean(location, false);
+ }
+ if (name == "byte" || name == "int" || name == "long") {
+ return Integral(location, "0");
+ }
+ if (name == "float") {
+ return Floating(location, "0.0f");
+ }
+ if (name == "double") {
+ return Floating(location, "0.0");
+ }
+ return nullptr;
}
AidlConstantValue* AidlConstantValue::Boolean(const AidlLocation& location, bool value) {
@@ -210,26 +369,19 @@
}
bool AidlConstantValue::IsHex(const string& value) {
- if (value.length() > (sizeof("0x") - 1)) {
- if (value[0] == '0' && (value[1] == 'x' || value[1] == 'X')) {
- return true;
- }
- }
- return false;
+ return StartsWith(value, "0x") || StartsWith(value, "0X");
}
bool AidlConstantValue::ParseIntegral(const string& value, int64_t* parsed_value,
Type* parsed_type) {
- bool isLong = false;
-
if (parsed_value == nullptr || parsed_type == nullptr) {
return false;
}
- if (IsHex(value)) {
- bool parseOK = false;
- uint32_t rawValue32;
+ const bool isLong = EndsWith(value, 'l') || EndsWith(value, 'L');
+ const std::string value_substr = isLong ? value.substr(0, value.size() - 1) : value;
+ if (IsHex(value)) {
// AIDL considers 'const int foo = 0xffffffff' as -1, but if we want to
// handle that when computing constant expressions, then we need to
// represent 0xffffffff as a uint32_t. However, AIDL only has signed types;
@@ -237,35 +389,34 @@
// int. One example of this is in ICameraService.aidl where a constant int
// is used for bit manipulations which ideally should be handled with an
// unsigned int.
- parseOK = android::base::ParseUint<uint32_t>(value, &rawValue32);
- if (parseOK) {
+ //
+ // Note, for historical consistency, we need to consider small hex values
+ // as an integral type. Recognizing them as INT8 could break some files,
+ // even though it would simplify this code.
+ if (uint32_t rawValue32;
+ !isLong && android::base::ParseUint<uint32_t>(value_substr, &rawValue32)) {
*parsed_value = static_cast<int32_t>(rawValue32);
*parsed_type = Type::INT32;
- } else {
- parseOK = android::base::ParseInt<int64_t>(value, parsed_value);
- if (!parseOK) {
- *parsed_type = Type::ERROR;
- return false;
- }
-
+ } else if (uint64_t rawValue64; android::base::ParseUint<uint64_t>(value_substr, &rawValue64)) {
+ *parsed_value = static_cast<int64_t>(rawValue64);
*parsed_type = Type::INT64;
+ } else {
+ *parsed_value = 0;
+ *parsed_type = Type::ERROR;
+ return false;
}
return true;
}
- if (value[value.size() - 1] == 'l' || value[value.size() - 1] == 'L') {
- isLong = true;
- *parsed_type = Type::INT64;
- }
-
- string value_substr = value.substr(0, isLong ? value.size() - 1 : value.size());
- bool parseOK = android::base::ParseInt<int64_t>(value_substr, parsed_value);
- if (!parseOK) {
+ if (!android::base::ParseInt<int64_t>(value_substr, parsed_value)) {
+ *parsed_value = 0;
*parsed_type = Type::ERROR;
return false;
}
- if (!isLong) {
+ if (isLong) {
+ *parsed_type = Type::INT64;
+ } else {
// guess literal type.
if (*parsed_value <= INT8_MAX && *parsed_value >= INT8_MIN) {
*parsed_type = Type::INT8;
@@ -279,7 +430,7 @@
}
AidlConstantValue* AidlConstantValue::Integral(const AidlLocation& location, const string& value) {
- CHECK(!value.empty());
+ AIDL_FATAL_IF(value.empty(), location);
Type parsed_type;
int64_t parsed_value = 0;
@@ -293,7 +444,12 @@
AidlConstantValue* AidlConstantValue::Array(
const AidlLocation& location, std::unique_ptr<vector<unique_ptr<AidlConstantValue>>> values) {
- return new AidlConstantValue(location, Type::ARRAY, std::move(values));
+ AIDL_FATAL_IF(values == nullptr, location);
+ 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) {
@@ -308,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()) {
@@ -337,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 "";
@@ -347,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;
@@ -412,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;
@@ -442,7 +591,7 @@
break;
}
- CHECK(err != 0);
+ AIDL_FATAL_IF(err == 0, this);
AIDL_ERROR(this) << "Invalid type specifier for " << ToString(final_type_) << ": " << type_string;
return "";
}
@@ -457,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:
@@ -475,7 +628,7 @@
return true;
}
-bool AidlConstantValue::evaluate(const AidlTypeSpecifier& type) const {
+bool AidlConstantValue::evaluate() const {
if (is_evaluated_) {
return is_valid_;
}
@@ -484,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;
@@ -567,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:
@@ -574,17 +724,89 @@
case Type::BINARY:
return "a binary expression";
case Type::ERROR:
- LOG(FATAL) << "aidl internal error: error type failed to halt program";
+ AIDL_FATAL(AIDL_LOCATION_HERE) << "aidl internal error: error type failed to halt program";
return "";
default:
- LOG(FATAL) << "aidl internal error: unknown constant type: " << static_cast<int>(type);
+ AIDL_FATAL(AIDL_LOCATION_HERE)
+ << "aidl internal error: unknown constant type: " << static_cast<int>(type);
return ""; // not reached
}
}
+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_;
- CHECK(unary_ != nullptr);
+ AIDL_FATAL_IF(unary_ == nullptr, this);
is_valid_ = unary_->CheckValid();
if (!is_valid_) {
@@ -595,7 +817,7 @@
return AidlConstantValue::CheckValid();
}
-bool AidlUnaryConstExpression::evaluate(const AidlTypeSpecifier& type) const {
+bool AidlUnaryConstExpression::evaluate() const {
if (is_evaluated_) {
return is_valid_;
}
@@ -605,14 +827,21 @@
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;
}
}
- if (!unary_->is_valid_ || !IsCompatibleType(unary_->final_type_, op_)) {
- AIDL_ERROR(type) << "Invalid constant unary expression: " + value_;
+ if (!IsCompatibleType(unary_->final_type_, op_)) {
+ AIDL_ERROR(unary_) << "'" << op_ << "'"
+ << " is not compatible with " << ToString(unary_->final_type_)
+ << ": " + value_;
+ is_valid_ = false;
+ return false;
+ }
+ if (!unary_->is_valid_) {
+ AIDL_ERROR(unary_) << "Invalid constant unary expression: " + value_;
is_valid_ = false;
return false;
}
@@ -624,9 +853,9 @@
return true;
}
-#define CASE_UNARY(__type__) \
- final_value_ = handleUnary(op_, static_cast<__type__>(unary_->final_value_)); \
- return true;
+#define CASE_UNARY(__type__) \
+ 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;)
@@ -635,8 +864,8 @@
bool AidlBinaryConstExpression::CheckValid() const {
bool success = false;
if (is_evaluated_) return is_valid_;
- CHECK(left_val_ != nullptr);
- CHECK(right_val_ != nullptr);
+ AIDL_FATAL_IF(left_val_ == nullptr, this);
+ AIDL_FATAL_IF(right_val_ == nullptr, this);
success = left_val_->CheckValid();
if (!success) {
@@ -659,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;
- CHECK(left_val_ != nullptr);
- CHECK(right_val_ != nullptr);
+ 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;
@@ -684,6 +913,9 @@
}
is_valid_ = AreCompatibleTypes(left_val_->final_type_, right_val_->final_type_);
if (!is_valid_) {
+ AIDL_ERROR(this) << "Cannot perform operation '" << op_ << "' on "
+ << ToString(right_val_->GetType()) << " and " << ToString(left_val_->GetType())
+ << ".";
return false;
}
@@ -691,8 +923,9 @@
// Handle String case first
if (left_val_->final_type_ == Type::STRING) {
+ AIDL_FATAL_IF(right_val_->final_type_ != Type::STRING, this);
if (!OPEQ("+")) {
- // invalid operation on strings
+ AIDL_ERROR(this) << "Only '+' is supported for strings, not '" << op_ << "'.";
final_type_ = Type::ERROR;
is_valid_ = false;
return false;
@@ -720,17 +953,8 @@
return true;
}
- // TODO(b/139877950) Add support for handling overflows
-
// CASE: + - * / % | ^ & < > <= >= == !=
if (isArithmeticOrBitflip || OP_IS_BIN_COMP) {
- if ((op_ == "/" || op_ == "%") && right_val_->final_value_ == 0) {
- final_type_ = Type::ERROR;
- is_valid_ = false;
- AIDL_ERROR(this) << "Cannot do division operation with zero for expression: " + value_;
- return false;
- }
-
// promoted kind for both operands.
Type promoted = UsualArithmeticConversion(IntegralPromotion(left_val_->final_type_),
IntegralPromotion(right_val_->final_type_));
@@ -739,10 +963,10 @@
? promoted // arithmetic or bitflip operators generates promoted type
: Type::BOOLEAN; // comparison operators generates bool
-#define CASE_BINARY_COMMON(__type__) \
- final_value_ = handleBinaryCommon(static_cast<__type__>(left_val_->final_value_), op_, \
- static_cast<__type__>(right_val_->final_value_)); \
- return true;
+#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;)
@@ -751,9 +975,10 @@
// CASE: << >>
string newOp = op_;
if (OP_IS_BIN_SHIFT) {
- final_type_ = IntegralPromotion(left_val_->final_type_);
- // instead of promoting rval, simply casting it to int64 should also be good.
- int64_t numBits = right_val_->cast<int64_t>();
+ // promoted kind for both operands.
+ final_type_ = UsualArithmeticConversion(IntegralPromotion(left_val_->final_type_),
+ IntegralPromotion(right_val_->final_type_));
+ auto numBits = right_val_->final_value_;
if (numBits < 0) {
// shifting with negative number of bits is undefined in C. In AIDL it
// is defined as shifting into the other direction.
@@ -761,9 +986,9 @@
numBits = -numBits;
}
-#define CASE_SHIFT(__type__) \
- final_value_ = handleShift(static_cast<__type__>(left_val_->final_value_), newOp, numBits); \
- return true;
+#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;)
@@ -773,8 +998,8 @@
if (OP_IS_BIN_LOGICAL) {
final_type_ = Type::BOOLEAN;
// easy; everything is bool.
- final_value_ = handleLogical(left_val_->final_value_, op_, right_val_->final_value_);
- return true;
+ return handleLogical(*this, left_val_->final_value_, op_, right_val_->final_value_,
+ &final_value_);
}
SHOULD_NOT_REACH();
@@ -789,8 +1014,8 @@
value_(checked_value),
final_type_(parsed_type),
final_value_(parsed_value) {
- CHECK(!value_.empty() || type_ == Type::ERROR);
- CHECK(type_ == Type::INT8 || type_ == Type::INT32 || type_ == Type::INT64);
+ AIDL_FATAL_IF(value_.empty() && type_ != Type::ERROR, location);
+ AIDL_FATAL_IF(type_ != Type::INT8 && type_ != Type::INT32 && type_ != Type::INT64, location);
}
AidlConstantValue::AidlConstantValue(const AidlLocation& location, Type type,
@@ -799,7 +1024,7 @@
type_(type),
value_(checked_value),
final_type_(type) {
- CHECK(!value_.empty() || type_ == Type::ERROR);
+ AIDL_FATAL_IF(value_.empty() && type_ != Type::ERROR, location);
switch (type_) {
case Type::INT8:
case Type::INT32:
@@ -813,14 +1038,16 @@
}
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) {
- CHECK(type_ == Type::ARRAY);
+ AIDL_FATAL_IF(type_ != Type::ARRAY, location);
}
AidlUnaryConstExpression::AidlUnaryConstExpression(const AidlLocation& location, const string& op,
diff --git a/aidl_dumpapi.cpp b/aidl_dumpapi.cpp
new file mode 100644
index 0000000..c121f9f
--- /dev/null
+++ b/aidl_dumpapi.cpp
@@ -0,0 +1,200 @@
+/*
+ * 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 "aidl_dumpapi.h"
+
+#include <android-base/strings.h>
+
+#include "aidl.h"
+#include "logging.h"
+#include "os.h"
+
+using android::base::EndsWith;
+using android::base::Join;
+using android::base::Split;
+using std::string;
+using std::unique_ptr;
+
+namespace android {
+namespace aidl {
+
+void DumpVisitor::DumpType(const AidlDefinedType& dt, const string& type) {
+ DumpComments(dt);
+ DumpAnnotations(dt);
+ out << type << " " << dt.GetName();
+ if (auto generic_type = dt.AsParameterizable(); generic_type && generic_type->IsGeneric()) {
+ out << "<" << Join(generic_type->GetTypeParameters(), ", ") << ">";
+ }
+ out << " {\n";
+ out.Indent();
+ DumpMembers(dt);
+ out.Dedent();
+ out << "}\n";
+}
+
+void DumpVisitor::DumpMembers(const AidlDefinedType& dt) {
+ for (const auto& method : dt.GetMethods()) {
+ if (!method->IsUserDefined()) continue;
+ method->DispatchVisit(*this);
+ }
+ for (const auto& field : dt.GetFields()) {
+ field->DispatchVisit(*this);
+ }
+ for (const auto& constdecl : dt.GetConstantDeclarations()) {
+ constdecl->DispatchVisit(*this);
+ }
+}
+
+// Dumps comment only if its has meaningful tags.
+void DumpVisitor::DumpComments(const AidlCommentable& c) {
+ const auto hidden = c.IsHidden();
+ const auto deprecated = FindDeprecated(c.GetComments());
+ if (hidden && !deprecated) {
+ // to pass --checkapi between the current and the tot in the mainline-prod branch
+ // emit @hide in a legacy dump style
+ out << "/* @hide */\n";
+ } else if (hidden || deprecated) {
+ out << "/**\n";
+ if (hidden) {
+ out << " * @hide\n";
+ }
+ if (deprecated) {
+ out << " * @deprecated " << deprecated->note << "\n";
+ }
+ out << " */\n";
+ }
+}
+
+void DumpVisitor::DumpAnnotations(const AidlAnnotatable& a) {
+ auto annotations = a.ToString();
+ if (!annotations.empty()) {
+ out << annotations << "\n";
+ }
+}
+
+void DumpVisitor::DumpConstantValue(const AidlTypeSpecifier& type, const AidlConstantValue& c) {
+ out << c.ValueString(type, AidlConstantValueDecorator);
+}
+
+void DumpVisitor::Visit(const AidlInterface& t) {
+ DumpType(t, "interface");
+}
+void DumpVisitor::Visit(const AidlParcelable& t) {
+ DumpType(t, "parcelable");
+}
+void DumpVisitor::Visit(const AidlStructuredParcelable& t) {
+ DumpType(t, "parcelable");
+}
+void DumpVisitor::Visit(const AidlUnionDecl& t) {
+ DumpType(t, "union");
+}
+void DumpVisitor::Visit(const AidlEnumDeclaration& t) {
+ DumpComments(t);
+ DumpAnnotations(t);
+ out << "enum " << t.GetName() << " {\n";
+ out.Indent();
+ for (const auto& e : t.GetEnumerators()) {
+ out << e->GetName() << " = ";
+ DumpConstantValue(t.GetBackingType(), *e->GetValue());
+ out << ",\n";
+ }
+ out.Dedent();
+ out << "}\n";
+}
+
+void DumpVisitor::Visit(const AidlMethod& m) {
+ DumpComments(m);
+ out << m.ToString() << ";\n";
+}
+void DumpVisitor::Visit(const AidlVariableDeclaration& v) {
+ DumpComments(v);
+ Visit(v.GetType());
+ if (v.IsDefaultUserSpecified()) {
+ out << " " << v.GetName() << " = ";
+ DumpConstantValue(v.GetType(), *v.GetDefaultValue());
+ out << ";\n";
+ } else {
+ out << " " << v.GetName() << ";\n";
+ }
+}
+void DumpVisitor::Visit(const AidlConstantDeclaration& c) {
+ DumpComments(c);
+ out << "const ";
+ Visit(c.GetType());
+ out << " " << c.GetName() << " = ";
+ DumpConstantValue(c.GetType(), c.GetValue());
+ out << ";\n";
+}
+
+void DumpVisitor::Visit(const AidlEnumerator& e) {
+ out << e.GetName() << " = ";
+
+ e.GetValue()->DispatchVisit(*this);
+ out << ",\n";
+}
+
+void DumpVisitor::Visit(const AidlTypeSpecifier& t) {
+ out << t.ToString();
+}
+
+static string GetApiDumpPathFor(const AidlDefinedType& defined_type, const Options& options) {
+ string package_as_path = Join(Split(defined_type.GetPackage(), "."), OS_PATH_SEPARATOR);
+ AIDL_FATAL_IF(options.OutputDir().empty() || options.OutputDir().back() != '/', defined_type);
+ return options.OutputDir() + package_as_path + OS_PATH_SEPARATOR + defined_type.GetName() +
+ ".aidl";
+}
+
+static void DumpComments(CodeWriter& out, const Comments& comments) {
+ bool needs_newline = false;
+ for (const auto& c : comments) {
+ out << c.body;
+ needs_newline = !EndsWith(c.body, "\n");
+ }
+ if (needs_newline) {
+ out << "\n";
+ }
+}
+
+bool dump_api(const Options& options, const IoDelegate& io_delegate) {
+ for (const auto& file : options.InputFiles()) {
+ AidlTypenames typenames;
+ if (internals::load_and_validate_aidl(file, options, io_delegate, &typenames, nullptr) ==
+ AidlError::OK) {
+ const auto& doc = typenames.MainDocument();
+
+ for (const auto& type : doc.DefinedTypes()) {
+ unique_ptr<CodeWriter> writer =
+ io_delegate.GetCodeWriter(GetApiDumpPathFor(*type, options));
+ if (!options.DumpNoLicense()) {
+ // dump doc comments (license) as well for each type
+ DumpComments(*writer, doc.GetComments());
+ }
+ (*writer) << kPreamble;
+ if (!type->GetPackage().empty()) {
+ (*writer) << "package " << type->GetPackage() << ";\n";
+ }
+ DumpVisitor visitor(*writer);
+ type->DispatchVisit(visitor);
+ }
+ } else {
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace aidl
+} // namespace android
\ No newline at end of file
diff --git a/aidl_dumpapi.h b/aidl_dumpapi.h
new file mode 100644
index 0000000..6d000dd
--- /dev/null
+++ b/aidl_dumpapi.h
@@ -0,0 +1,48 @@
+/*
+ * 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 "aidl_language.h"
+#include "code_writer.h"
+
+namespace android {
+namespace aidl {
+
+struct DumpVisitor : AidlVisitor {
+ CodeWriter& out;
+ DumpVisitor(CodeWriter& out) : out(out) {}
+
+ void DumpType(const AidlDefinedType& dt, const string& type);
+ void DumpMembers(const AidlDefinedType& dt);
+ void DumpComments(const AidlCommentable& c);
+ void DumpAnnotations(const AidlAnnotatable& a);
+ virtual void DumpConstantValue(const AidlTypeSpecifier& type, const AidlConstantValue& c);
+
+ void Visit(const AidlInterface& t) override;
+ void Visit(const AidlParcelable& t) override;
+ void Visit(const AidlStructuredParcelable& t) override;
+ void Visit(const AidlUnionDecl& t) override;
+ void Visit(const AidlEnumDeclaration& t) override;
+ void Visit(const AidlMethod& m) override;
+ void Visit(const AidlVariableDeclaration& v) override;
+ void Visit(const AidlConstantDeclaration& c) override;
+ void Visit(const AidlEnumerator& e) override;
+ void Visit(const AidlTypeSpecifier& t) override;
+};
+
+bool dump_api(const Options& options, const IoDelegate& io_delegate);
+
+} // namespace aidl
+} // namespace android
diff --git a/aidl_language.cpp b/aidl_language.cpp
index be1221d..5bff95e 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -16,6 +16,7 @@
#include "aidl_language.h"
#include "aidl_typenames.h"
+#include "parser.h"
#include <stdio.h>
#include <stdlib.h>
@@ -31,7 +32,8 @@
#include <android-base/parseint.h>
#include <android-base/strings.h>
-#include "aidl_language_y-module.h"
+#include "aidl_language_y.h"
+#include "comments.h"
#include "logging.h"
#include "aidl.h"
@@ -47,7 +49,6 @@
using android::base::Join;
using android::base::Split;
using std::cerr;
-using std::endl;
using std::pair;
using std::set;
using std::string;
@@ -68,40 +69,10 @@
};
return std::find(kJavaKeywords.begin(), kJavaKeywords.end(), str) != kJavaKeywords.end();
}
-
-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
-void yylex_init(void **);
-void yylex_destroy(void *);
-void yyset_in(FILE *f, void *);
-int yyparse(Parser*);
-YY_BUFFER_STATE yy_scan_buffer(char *, size_t, void *);
-void yy_delete_buffer(YY_BUFFER_STATE, void *);
-
-AidlToken::AidlToken(const std::string& text, const std::string& comments)
- : text_(text),
- comments_(comments) {}
-
-AidlLocation::AidlLocation(const std::string& file, Point begin, Point end)
- : file_(file), begin_(begin), end_(end) {}
-
-std::ostream& operator<<(std::ostream& os, const AidlLocation& l) {
- os << l.file_ << ":" << 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;
@@ -116,96 +87,166 @@
return ss.str();
}
-AidlError::AidlError(bool fatal) : os_(std::cerr), fatal_(fatal) {
- sHadError = true;
+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{}};
- os_ << "ERROR: ";
+const std::vector<AidlAnnotation::Schema>& AidlAnnotation::AllSchemas() {
+ static const std::vector<Schema> kSchemas{
+ {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",
+ 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",
+ 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;
}
-bool AidlError::sHadError = false;
-
-static const string kNullable("nullable");
-static const string kUtf8InCpp("utf8InCpp");
-static const string kVintfStability("VintfStability");
-static const string kUnsupportedAppUsage("UnsupportedAppUsage");
-static const string kJavaStableParcelable("JavaOnlyStableParcelable");
-static const string kHide("Hide");
-static const string kBacking("Backing");
-static const string kJavaDerive("JavaDerive");
-
-static const std::map<string, std::map<std::string, std::string>> kAnnotationParameters{
- {kNullable, {}},
- {kUtf8InCpp, {}},
- {kVintfStability, {}},
- {kUnsupportedAppUsage,
- {{"expectedSignature", "String"},
- {"implicitMember", "String"},
- {"maxTargetSdk", "int"},
- {"publicAlternatives", "String"},
- {"trackingBug", "long"}}},
- {kJavaStableParcelable, {}},
- {kHide, {}},
- {kBacking, {{"type", "String"}}},
- {kJavaDerive, {{"toString", "boolean"}}}};
+std::string AidlAnnotation::TypeToString(Type type) {
+ for (const Schema& schema : AllSchemas()) {
+ if (type == schema.type) return schema.name;
+ }
+ AIDL_FATAL(AIDL_LOCATION_HERE) << "Unrecognized type: " << static_cast<size_t>(type);
+ __builtin_unreachable();
+}
AidlAnnotation* AidlAnnotation::Parse(
const AidlLocation& location, const string& name,
- std::map<std::string, std::shared_ptr<AidlConstantValue>>* parameter_list) {
- if (kAnnotationParameters.find(name) == kAnnotationParameters.end()) {
+ 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) {
+ schema = &a_schema;
+ }
+ }
+
+ if (schema == nullptr) {
std::ostringstream stream;
stream << "'" << name << "' is not a recognized annotation. ";
stream << "It must be one of:";
- for (const auto& kv : kAnnotationParameters) {
- stream << " " << kv.first;
+ for (const Schema& s : AllSchemas()) {
+ stream << " " << s.name;
}
stream << ".";
AIDL_ERROR(location) << stream.str();
return nullptr;
}
if (parameter_list == nullptr) {
- return new AidlAnnotation(location, name);
+ return new AidlAnnotation(location, *schema, {}, comments);
}
- return new AidlAnnotation(location, name, std::move(*parameter_list));
+ return new AidlAnnotation(location, *schema, std::move(*parameter_list), comments);
}
-AidlAnnotation::AidlAnnotation(const AidlLocation& location, const string& name)
- : AidlAnnotation(location, name, {}) {}
-
AidlAnnotation::AidlAnnotation(
- const AidlLocation& location, const string& name,
- std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters)
- : AidlNode(location), name_(name), parameters_(std::move(parameters)) {}
+ const AidlLocation& location, const Schema& schema,
+ std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters,
+ const Comments& comments)
+ : AidlNode(location, comments), schema_(schema), parameters_(std::move(parameters)) {}
-bool AidlAnnotation::CheckValid() const {
- auto supported_params_iterator = kAnnotationParameters.find(GetName());
- if (supported_params_iterator == kAnnotationParameters.end()) {
- AIDL_ERROR(this) << GetName() << " annotation does not have any supported parameters.";
- return false;
+struct ConstReferenceFinder : AidlVisitor {
+ const AidlConstantReference* found;
+ void Visit(const AidlConstantReference& ref) override {
+ if (!found) found = &ref;
}
- const auto& supported_params = supported_params_iterator->second;
+ 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 = supported_params.find(param_name);
- if (parameter_mapping_it == supported_params.end()) {
- std::ostringstream stream;
- stream << "Parameter " << param_name << " not supported ";
- stream << "for annotation " << GetName() << ".";
- stream << "It must be one of:";
- for (const auto& kv : supported_params) {
- 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 "
@@ -213,127 +254,187 @@
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(
const ConstantValueDecorator& decorator) const {
std::map<std::string, std::string> raw_params;
- const auto& supported_params = kAnnotationParameters.at(GetName());
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;
- AidlTypeSpecifier type{AIDL_LOCATION_HERE, supported_params.at(param_name), false, nullptr, ""};
- if (!param->CheckValid()) {
- AIDL_ERROR(this) << "Invalid value for parameter " << param_name << " on annotation "
- << GetName() << ".";
- raw_params.clear();
- return raw_params;
- }
-
- 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, ", ") + ")";
}
}
-static bool HasAnnotation(const vector<AidlAnnotation>& annotations, const string& name) {
- for (const auto& a : annotations) {
- if (a.GetName() == name) {
- return true;
- }
+void AidlAnnotation::TraverseChildren(std::function<void(const AidlNode&)> traverse) const {
+ for (const auto& [name, value] : parameters_) {
+ (void)name;
+ traverse(*value);
}
- return false;
}
static const AidlAnnotation* GetAnnotation(const vector<AidlAnnotation>& annotations,
- const string& name) {
+ AidlAnnotation::Type type) {
for (const auto& a : annotations) {
- if (a.GetName() == name) {
+ 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 HasAnnotation(annotations_, kNullable);
+ return GetAnnotation(annotations_, AidlAnnotation::Type::NULLABLE);
}
bool AidlAnnotatable::IsUtf8InCpp() const {
- return HasAnnotation(annotations_, kUtf8InCpp);
+ return GetAnnotation(annotations_, AidlAnnotation::Type::UTF8_IN_CPP);
+}
+
+bool AidlAnnotatable::IsSensitiveData() const {
+ return GetAnnotation(annotations_, AidlAnnotation::Type::SENSITIVE_DATA);
}
bool AidlAnnotatable::IsVintfStability() const {
- return HasAnnotation(annotations_, kVintfStability);
+ return GetAnnotation(annotations_, AidlAnnotation::Type::VINTF_STABILITY);
+}
+
+bool AidlAnnotatable::IsJavaOnlyImmutable() const {
+ return GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE);
+}
+
+bool AidlAnnotatable::IsFixedSize() const {
+ return GetAnnotation(annotations_, AidlAnnotation::Type::FIXED_SIZE);
}
const AidlAnnotation* AidlAnnotatable::UnsupportedAppUsage() const {
- return GetAnnotation(annotations_, kUnsupportedAppUsage);
+ return GetAnnotation(annotations_, AidlAnnotation::Type::UNSUPPORTED_APP_USAGE);
}
-const AidlTypeSpecifier* AidlAnnotatable::BackingType(const AidlTypenames& typenames) const {
- auto annotation = GetAnnotation(annotations_, kBacking);
- 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;
- AidlTypeSpecifier* type_specifier =
- new AidlTypeSpecifier(AIDL_LOCATION_HERE,
- // Strip the quotes off the type String.
- type.substr(1, type.length() - 2), false, nullptr, "");
- type_specifier->Resolve(typenames);
- return type_specifier;
- }
+const AidlAnnotation* AidlAnnotatable::RustDerive() const {
+ return GetAnnotation(annotations_, AidlAnnotation::Type::RUST_DERIVE);
+}
+
+const AidlAnnotation* AidlAnnotatable::BackingType() const {
+ return GetAnnotation(annotations_, AidlAnnotation::Type::BACKING);
+}
+
+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 {
- return HasAnnotation(annotations_, kJavaStableParcelable) && lang == Options::Language::JAVA;
+ return lang == Options::Language::JAVA &&
+ GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_STABLE_PARCELABLE);
}
bool AidlAnnotatable::IsHide() const {
- return HasAnnotation(annotations_, kHide);
+ return GetAnnotation(annotations_, AidlAnnotation::Type::HIDE);
}
-const AidlAnnotation* AidlAnnotatable::JavaDerive() const {
- return GetAnnotation(annotations_, kJavaDerive);
+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;
}
-void AidlAnnotatable::DumpAnnotations(CodeWriter* writer) const {
- if (annotations_.empty()) return;
-
- writer->Write("%s\n", AidlAnnotatable::ToString().c_str());
+std::string AidlAnnotatable::GetDescriptor() const {
+ auto annotation = GetAnnotation(annotations_, AidlAnnotation::Type::DESCRIPTOR);
+ if (annotation != nullptr) {
+ return annotation->ParamValue<std::string>("value").value();
+ }
+ return "";
}
-bool AidlAnnotatable::CheckValidAnnotations() const {
+bool AidlAnnotatable::CheckValid(const AidlTypenames&) const {
for (const auto& annotation : GetAnnotations()) {
if (!annotation.CheckValid()) {
return false;
}
}
+ 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 repeated, but not allowed. Previous location: " << iter->second;
+ return false;
+ }
+ }
+
return true;
}
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, " ");
@@ -342,34 +443,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, ",") + ">";
}
@@ -379,8 +477,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;
@@ -389,29 +487,41 @@
}
bool AidlTypeSpecifier::Resolve(const AidlTypenames& typenames) {
- CHECK(!IsResolved());
- pair<string, bool> result = typenames.ResolveTypename(unresolved_name_);
- if (result.second) {
- fully_qualified_name_ = result.first;
+ AIDL_FATAL_IF(IsResolved(), this);
+ AidlTypenames::ResolvedTypename result = typenames.ResolveTypename(unresolved_name_);
+ if (result.is_resolved) {
+ fully_qualified_name_ = result.canonical_name;
split_name_ = Split(fully_qualified_name_, ".");
+ defined_type_ = result.defined_type;
}
- return result.second;
+ return result.is_resolved;
+}
+
+const AidlDefinedType* AidlTypeSpecifier::GetDefinedType() const {
+ return defined_type_;
}
bool AidlTypeSpecifier::CheckValid(const AidlTypenames& typenames) const {
- if (!CheckValidAnnotations()) {
+ if (!AidlAnnotatable::CheckValid(typenames)) {
return false;
}
if (IsGeneric()) {
- const string& type_name = GetName();
+ const auto& types = GetTypeParameters();
+ for (const auto& arg : types) {
+ if (!arg->CheckValid(typenames)) {
+ return false;
+ }
+ }
- auto& types = GetTypeParameters();
+ const string& type_name = GetName();
// 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 !type_ptr->IsArray() &&
+ (typenames.GetEnumDeclaration(*type_ptr) ||
+ AidlTypenames::IsPrimitiveTypename(type_ptr->GetName()));
})) {
- AIDL_ERROR(this) << "A generic type cannot has any primitive type parameters.";
+ AIDL_ERROR(this) << "A generic type cannot have any primitive type parameters.";
return false;
}
}
@@ -423,18 +533,42 @@
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];
+ if (contained_type.IsArray()) {
+ AIDL_ERROR(this)
+ << "List of arrays is not supported. List<T> supports parcelable/union, String, "
+ "IBinder, and ParcelFileDescriptor.";
+ return false;
+ }
+ 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) {
- const string& key_type = GetTypeParameters()[0]->GetName();
+ const string& key_type = GetTypeParameters()[0]->Signature();
if (key_type != "String") {
AIDL_ERROR(this) << "The type of key in map must be String, but it is "
<< "'" << key_type << "'";
@@ -475,6 +609,10 @@
AIDL_ERROR(this) << "Binder type cannot be an array";
return false;
}
+ if (GetName() == "ParcelableHolder") {
+ AIDL_ERROR(this) << "Arrays of ParcelableHolder are not supported.";
+ return false;
+ }
}
if (IsNullable()) {
@@ -487,23 +625,53 @@
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;
}
AidlVariableDeclaration::AidlVariableDeclaration(const AidlLocation& location,
AidlTypeSpecifier* type, const std::string& name)
- : AidlVariableDeclaration(location, type, name, nullptr /*default_value*/) {}
+ : AidlVariableDeclaration(location, type, name, AidlConstantValue::Default(*type)) {
+ default_user_specified_ = false;
+}
AidlVariableDeclaration::AidlVariableDeclaration(const AidlLocation& location,
AidlTypeSpecifier* type, const std::string& name,
AidlConstantValue* default_value)
- : AidlNode(location), type_(type), name_(name), default_value_(default_value) {}
+ : 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;
@@ -523,9 +691,16 @@
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_;
- if (default_value_ != nullptr) {
+ string ret = type_->ToString() + " " + name_;
+ if (default_value_ != nullptr && default_user_specified_) {
ret += " = " + ValueString(AidlConstantValueDecorator);
}
return ret;
@@ -543,6 +718,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),
@@ -555,44 +738,94 @@
direction_(AidlArgument::IN_DIR),
direction_specified_(false) {}
+static std::string to_string(AidlArgument::Direction direction) {
+ switch (direction) {
+ case AidlArgument::IN_DIR:
+ return "in";
+ case AidlArgument::OUT_DIR:
+ return "out";
+ case AidlArgument::INOUT_DIR:
+ return "inout";
+ }
+}
+
string AidlArgument::GetDirectionSpecifier() const {
string ret;
if (direction_specified_) {
- switch(direction_) {
- case AidlArgument::IN_DIR:
- ret += "in ";
- break;
- case AidlArgument::OUT_DIR:
- ret += "out ";
- break;
- case AidlArgument::INOUT_DIR:
- ret += "inout ";
- break;
- }
+ ret = to_string(direction_);
}
return ret;
}
string AidlArgument::ToString() const {
- return GetDirectionSpecifier() + AidlVariableDeclaration::ToString();
+ if (direction_specified_) {
+ return GetDirectionSpecifier() + " " + AidlVariableDeclaration::ToString();
+ } else {
+ return AidlVariableDeclaration::ToString();
+ }
}
-std::string AidlArgument::Signature() const {
- class AidlInterface;
- class AidlInterface;
- class AidlParcelable;
- class AidlStructuredParcelable;
- class AidlParcelable;
- class AidlStructuredParcelable;
- return GetDirectionSpecifier() + AidlVariableDeclaration::Signature();
+static std::string FormatDirections(const std::set<AidlArgument::Direction>& directions) {
+ std::vector<std::string> out;
+ for (const auto& d : directions) {
+ out.push_back(to_string(d));
+ }
+
+ if (out.size() <= 1) { // [] => "" or [A] => "A"
+ return Join(out, "");
+ } else if (out.size() == 2) { // [A,B] => "A or B"
+ return Join(out, " or ");
+ } else { // [A,B,C] => "A, B, or C"
+ out.back() = "or " + out.back();
+ return Join(out, ", ");
+ }
}
-AidlMember::AidlMember(const AidlLocation& location) : AidlNode(location) {}
+bool AidlArgument::CheckValid(const AidlTypenames& typenames) const {
+ if (!GetType().CheckValid(typenames)) {
+ return false;
+ }
+
+ const auto& aspect = typenames.GetArgumentAspect(GetType());
+
+ if (aspect.possible_directions.size() == 0) {
+ AIDL_ERROR(this) << aspect.name << " cannot be an argument type";
+ return false;
+ }
+
+ // when direction is not specified, "in" is assumed and should be the only possible direction
+ if (!DirectionWasSpecified() && aspect.possible_directions != std::set{AidlArgument::IN_DIR}) {
+ AIDL_ERROR(this) << "The direction of '" << GetName() << "' is not specified. " << aspect.name
+ << " can be an " << FormatDirections(aspect.possible_directions)
+ << " parameter.";
+ return false;
+ }
+
+ if (aspect.possible_directions.count(GetDirection()) == 0) {
+ AIDL_ERROR(this) << "'" << GetName() << "' can't be an " << GetDirectionSpecifier()
+ << " parameter because " << aspect.name << " can only be an "
+ << FormatDirections(aspect.possible_directions) << " parameter.";
+ return false;
+ }
+
+ return true;
+}
+
+bool AidlCommentable::IsHidden() const {
+ return android::aidl::HasHideInComments(GetComments());
+}
+
+bool AidlCommentable::IsDeprecated() const {
+ return android::aidl::FindDeprecated(GetComments()).has_value();
+}
+
+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;
@@ -600,9 +833,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;
}
@@ -620,17 +853,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)),
@@ -644,14 +876,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, ", ") + ")";
}
@@ -659,9 +887,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());
@@ -670,16 +898,38 @@
}
AidlDefinedType::AidlDefinedType(const AidlLocation& location, const std::string& name,
- const std::string& comments,
- const std::vector<std::string>& package)
- : AidlAnnotatable(location), name_(name), comments_(comments), package_(package) {}
-
-std::string AidlDefinedType::GetPackage() const {
- return Join(package_, '.');
+ const Comments& comments, const std::string& package,
+ std::vector<std::unique_ptr<AidlMember>>* members)
+ : AidlAnnotatable(location, comments),
+ name_(name),
+ package_(package),
+ split_package_(package.empty() ? std::vector<std::string>()
+ : 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::IsHidden() const {
- return HasHideComment(GetComments());
+bool AidlDefinedType::CheckValid(const AidlTypenames& typenames) const {
+ if (!AidlAnnotatable::CheckValid(typenames)) {
+ return false;
+ }
+ if (!CheckValidWithMembers(typenames)) {
+ return false;
+ }
+ return true;
}
std::string AidlDefinedType::GetCanonicalName() const {
@@ -689,19 +939,68 @@
return GetPackage() + "." + GetName();
}
-void AidlDefinedType::DumpHeader(CodeWriter* writer) const {
- if (this->IsHidden()) {
- AddHideComment(writer);
+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;
}
- DumpAnnotations(writer);
+
+ // 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;
}
-AidlParcelable::AidlParcelable(const AidlLocation& location, AidlQualifiedName* name,
- const std::vector<std::string>& package, const std::string& comments,
- const std::string& cpp_header, std::vector<std::string>* type_params)
- : AidlDefinedType(location, name->GetDotName(), comments, package),
+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 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),
- name_(name),
cpp_header_(cpp_header) {
// Strip off quotation marks if we actually have a cpp header.
if (cpp_header_.length() >= 2) {
@@ -713,7 +1012,7 @@
// Copying is not supported if it has type parameters.
// It doesn't make a problem because only ArrayBase() makes a copy,
// and it can be called only if a type is not generic.
- CHECK(!other.IsGeneric());
+ AIDL_FATAL_IF(other.IsGeneric(), AIDL_LOCATION_HERE);
}
template <typename T>
@@ -734,122 +1033,137 @@
return true;
}
-bool AidlParcelable::CheckValid(const AidlTypenames&) const {
- static const std::set<string> allowed{kJavaStableParcelable};
- if (!CheckValidAnnotations()) {
+bool AidlParcelable::CheckValid(const AidlTypenames& typenames) const {
+ if (!AidlDefinedType::CheckValid(typenames)) {
return false;
}
if (!AidlParameterizable<std::string>::CheckValid()) {
return false;
}
- for (const auto& v : GetAnnotations()) {
- if (allowed.find(v.GetName()) == allowed.end()) {
- std::ostringstream stream;
- stream << "Unstructured parcelable can contain only";
- for (const string& kv : allowed) {
- stream << " " << kv;
- }
- stream << ".";
- AIDL_ERROR(this) << stream.str();
- return false;
- }
- }
return true;
}
-void AidlParcelable::Dump(CodeWriter* writer) const {
- DumpHeader(writer);
- writer->Write("parcelable %s ;\n", GetName().c_str());
-}
-
AidlStructuredParcelable::AidlStructuredParcelable(
- const AidlLocation& location, AidlQualifiedName* name, const std::vector<std::string>& package,
- const std::string& comments, std::vector<std::unique_ptr<AidlVariableDeclaration>>* variables)
- : AidlParcelable(location, name, package, comments, "" /*cpp_header*/),
- variables_(std::move(*variables)) {}
-
-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());
- }
- writer->Dedent();
- writer->Write("}\n");
-}
+ 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) {}
bool AidlStructuredParcelable::CheckValid(const AidlTypenames& typenames) const {
- bool success = true;
- for (const auto& v : GetFields()) {
- success = success && v->CheckValid(typenames);
+ if (!AidlParcelable::CheckValid(typenames)) {
+ 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;
+ }
+ }
+
return success;
}
// TODO: we should treat every backend all the same in future.
-bool AidlTypeSpecifier::LanguageSpecificCheckValid(Options::Language lang) const {
+bool AidlTypeSpecifier::LanguageSpecificCheckValid(const AidlTypenames& typenames,
+ Options::Language lang) const {
+ if (IsGeneric()) {
+ const auto& types = GetTypeParameters();
+ for (const auto& arg : types) {
+ if (!arg->LanguageSpecificCheckValid(typenames, lang)) {
+ return false;
+ }
+ }
+ }
+
+ if ((lang == Options::Language::NDK || lang == Options::Language::RUST) && IsArray() &&
+ GetName() == "IBinder") {
+ AIDL_ERROR(this) << "The " << to_string(lang) << " backend does not support array of IBinder";
+ return false;
+ }
+ 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 " << 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 " << 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 " << to_string(lang) << " backend.";
+ return false;
+ }
+ if (this->IsGeneric()) {
+ if (this->GetName() == "List") {
+ 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;
+ }
+ if (contained_type_name == "IBinder") {
+ AIDL_ERROR(this) << "List<" << contained_type_name
+ << "> is not supported. List in NDK doesn't support IBinder.";
+ return false;
+ }
+ }
+ }
+ }
+
+ if (this->IsArray()) {
+ if (this->GetName() == "List" || this->GetName() == "Map" ||
+ this->GetName() == "CharSequence") {
+ AIDL_ERROR(this) << this->GetName() << "[] is not supported.";
+ return false;
+ }
+ }
+
if (lang != Options::Language::JAVA) {
if (this->GetName() == "List" && !this->IsGeneric()) {
AIDL_ERROR(this) << "Currently, only the Java backend supports non-generic List.";
return false;
}
- }
- if (this->GetName() == "FileDescriptor" && lang == Options::Language::NDK) {
- AIDL_ERROR(this) << "FileDescriptor isn't supported with the NDK.";
- 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) {
- auto& name = this->GetTypeParameters()[0]->GetName();
- if (!(name == "String" || name == "IBinder")) {
- AIDL_ERROR(this) << "List in cpp supports only string and IBinder for now.";
- 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 << "> isn't supported in Java";
- return false;
- }
- }
- }
- }
- }
- if (this->GetName() == "Map" || this->GetName() == "CharSequence") {
- if (lang != Options::Language::JAVA) {
+ if (this->GetName() == "Map" || this->GetName() == "CharSequence") {
AIDL_ERROR(this) << "Currently, only Java backend supports " << this->GetName() << ".";
return false;
}
}
- if (lang == Options::Language::JAVA) {
- const string name = this->GetName();
- // List[], Map[], CharSequence[] are not supported.
- if (AidlTypenames::IsBuiltinTypename(name) && this->IsArray()) {
- if (name == "List" || name == "Map" || name == "CharSequence") {
- AIDL_ERROR(this) << "List[], Map[], CharSequence[] are not supported.";
- return false;
- }
- }
- }
return true;
}
// TODO: we should treat every backend all the same in future.
-bool AidlParcelable::LanguageSpecificCheckValid(Options::Language lang) const {
- if (lang != Options::Language::JAVA) {
+bool AidlParcelable::LanguageSpecificCheckValid(const AidlTypenames& /*typenames*/,
+ Options::Language lang) const {
+ if (lang == Options::Language::CPP || lang == Options::Language::NDK) {
const AidlParcelable* unstructured_parcelable = this->AsUnstructuredParcelable();
if (unstructured_parcelable != nullptr) {
if (unstructured_parcelable->GetCppHeader().empty()) {
@@ -863,12 +1177,13 @@
}
// TODO: we should treat every backend all the same in future.
-bool AidlStructuredParcelable::LanguageSpecificCheckValid(Options::Language lang) const {
- if (!AidlParcelable::LanguageSpecificCheckValid(lang)) {
+bool AidlStructuredParcelable::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(lang)) {
+ if (!v->GetType().LanguageSpecificCheckValid(typenames, lang)) {
return false;
}
}
@@ -876,8 +1191,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) {
@@ -900,39 +1218,62 @@
AidlEnumDeclaration::AidlEnumDeclaration(const AidlLocation& location, const std::string& name,
std::vector<std::unique_ptr<AidlEnumerator>>* enumerators,
- const std::vector<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(AIDL_LOCATION_HERE, "0")));
+ enumerator->SetValue(
+ 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>(
- AIDL_LOCATION_HERE, std::move(prev_value), "+",
- std::unique_ptr<AidlConstantValue>(
- AidlConstantValue::Integral(AIDL_LOCATION_HERE, "1"))));
+ loc, std::move(prev_value), "+",
+ std::unique_ptr<AidlConstantValue>(AidlConstantValue::Integral(loc, "1"))));
}
}
previous = enumerator.get();
}
+}
+
+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&) const {
+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;
@@ -941,29 +1282,92 @@
for (const auto& enumerator : enumerators_) {
success = success && enumerator->CheckValid(GetBackingType());
}
+
return success;
}
-void AidlEnumDeclaration::Dump(CodeWriter* writer) const {
- DumpHeader(writer);
- writer->Write("enum %s {\n", GetName().c_str());
- writer->Indent();
- for (const auto& enumerator : GetEnumerators()) {
- writer->Write("%s = %s,\n", enumerator->GetName().c_str(),
- enumerator->ValueString(GetBackingType(), AidlConstantValueDecorator).c_str());
+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) {}
+
+bool AidlUnionDecl::CheckValid(const AidlTypenames& typenames) const {
+ // visit parents
+ if (!AidlParcelable::CheckValid(typenames)) {
+ return false;
}
- writer->Dedent();
- writer->Write("}\n");
+
+ // 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 AidlInterface::LanguageSpecificCheckValid(Options::Language lang) const {
+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 {
for (const auto& m : this->GetMethods()) {
- if (!m->GetType().LanguageSpecificCheckValid(lang)) {
+ if (!m->GetType().LanguageSpecificCheckValid(typenames, lang)) {
return false;
}
for (const auto& arg : m->GetArguments()) {
- if (!arg->GetType().LanguageSpecificCheckValid(lang)) {
+ if (!arg->GetType().LanguageSpecificCheckValid(typenames, lang)) {
return false;
}
}
@@ -972,52 +1376,16 @@
}
AidlInterface::AidlInterface(const AidlLocation& location, const std::string& name,
- const std::string& comments, bool oneway,
- std::vector<std::unique_ptr<AidlMember>>* members,
- const std::vector<std::string>& package)
- : AidlDefinedType(location, name, comments, package) {
- for (auto& member : *members) {
- AidlMember* local = member.release();
- AidlMethod* method = local->AsMethod();
- AidlConstantDeclaration* constant = local->AsConstantDeclaration();
-
- CHECK(method == nullptr || constant == nullptr);
-
- 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());
- }
- writer->Dedent();
- writer->Write("}\n");
}
bool AidlInterface::CheckValid(const AidlTypenames& typenames) const {
- if (!CheckValidAnnotations()) {
+ if (!AidlDefinedType::CheckValid(typenames)) {
return false;
}
// Has to be a pointer due to deleting copy constructor. No idea why.
@@ -1027,6 +1395,11 @@
return false;
}
+ // TODO(b/156872582): Support it when ParcelableHolder supports every backend.
+ if (m->GetType().GetName() == "ParcelableHolder") {
+ AIDL_ERROR(m) << "ParcelableHolder cannot be a return type";
+ return false;
+ }
if (m->IsOneway() && m->GetType().GetName() != "void") {
AIDL_ERROR(m) << "oneway method '" << m->GetName() << "' cannot return a value";
return false;
@@ -1042,7 +1415,7 @@
}
argument_names.insert(arg->GetName());
- if (!arg->GetType().CheckValid(typenames)) {
+ if (!arg->CheckValid(typenames)) {
return false;
}
@@ -1050,17 +1423,6 @@
AIDL_ERROR(m) << "oneway method '" << m->GetName() << "' cannot have out parameters";
return false;
}
- const bool can_be_out = typenames.CanBeOutParameter(arg->GetType());
- if (!arg->DirectionWasSpecified() && can_be_out) {
- AIDL_ERROR(arg) << "'" << arg->GetType().ToString()
- << "' 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.";
- return false;
- }
// check that the name doesn't match a keyword
if (IsJavaKeyword(arg->GetName().c_str())) {
@@ -1089,102 +1451,61 @@
"getTransactionName(int)"};
if (reserved_methods.find(m->Signature()) != reserved_methods.end()) {
- AIDL_ERROR(m) << " method " << m->Signature() << " is reserved for internal use." << endl;
+ AIDL_ERROR(m) << " method " << m->Signature() << " is reserved for internal use.";
return false;
}
}
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) {
- LOG(ERROR) << "Found duplicate constant name '" << constant->GetName() << "'";
+ AIDL_ERROR(constant) << "Found duplicate constant name '" << constant->GetName() << "'";
success = false;
}
constant_names.insert(constant->GetName());
success = success && constant->CheckValid(typenames);
}
-
return success;
}
-AidlQualifiedName::AidlQualifiedName(const AidlLocation& location, const std::string& term,
- const std::string& comments)
- : AidlNode(location), terms_({term}), comments_(comments) {
- if (term.find('.') != string::npos) {
- terms_ = Split(term, ".");
- for (const auto& subterm : terms_) {
- if (subterm.empty()) {
- AIDL_FATAL(this) << "Malformed qualified identifier: '" << term << "'";
+std::string AidlInterface::GetDescriptor() const {
+ std::string annotatedDescriptor = AidlAnnotatable::GetDescriptor();
+ if (annotatedDescriptor != "") {
+ return annotatedDescriptor;
+ }
+ return GetCanonicalName();
+}
+
+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;
}
}
-}
-
-void AidlQualifiedName::AddTerm(const std::string& term) {
- terms_.push_back(term);
-}
-
-AidlImport::AidlImport(const AidlLocation& location, const std::string& needed_class)
- : AidlNode(location), needed_class_(needed_class) {}
-
-std::unique_ptr<Parser> Parser::Parse(const std::string& filename,
- const android::aidl::IoDelegate& io_delegate,
- AidlTypenames& typenames) {
- // Make sure we can read the file first, before trashing previous state.
- unique_ptr<string> raw_buffer = io_delegate.GetFileContents(filename);
- if (raw_buffer == nullptr) {
- AIDL_ERROR(filename) << "Error while opening file for parsing";
- return nullptr;
+ // if not found, use unresolved_name as it is
+ if (canonical_name == "") {
+ return unresolved_name;
}
-
- // We're going to scan this buffer in place, and yacc demands we put two
- // nulls at the end.
- raw_buffer->append(2u, '\0');
-
- std::unique_ptr<Parser> parser(new Parser(filename, *raw_buffer, typenames));
-
- if (yy::parser(parser.get()).parse() != 0 || parser->HasError()) return nullptr;
-
- return parser;
-}
-
-std::vector<std::string> Parser::Package() const {
- if (!package_) {
- return {};
- }
- return package_->GetTerms();
-}
-
-void Parser::AddImport(std::unique_ptr<AidlImport>&& import) {
- for (const auto& i : imports_) {
- if (i->GetNeededClass() == import->GetNeededClass()) {
- return;
- }
- }
- imports_.emplace_back(std::move(import));
-}
-
-bool Parser::Resolve() {
- bool success = true;
- for (AidlTypeSpecifier* typespec : unresolved_typespecs_) {
- if (!typespec->Resolve(typenames_)) {
- AIDL_ERROR(typespec) << "Failed to resolve '" << typespec->GetUnresolvedName() << "'";
- success = false;
- // don't stop to show more errors if any
- }
- }
- return success;
-}
-
-Parser::Parser(const std::string& filename, std::string& raw_buffer,
- android::aidl::AidlTypenames& typenames)
- : filename_(filename), typenames_(typenames) {
- yylex_init(&scanner_);
- buffer_ = yy_scan_buffer(&raw_buffer[0], raw_buffer.length(), scanner_);
-}
-
-Parser::~Parser() {
- yy_delete_buffer(buffer_, scanner_);
- yylex_destroy(scanner_);
+ return canonical_name;
}
diff --git a/aidl_language.h b/aidl_language.h
index 920970f..e0c28a0 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -16,25 +16,26 @@
#pragma once
-#include "aidl_typenames.h"
-#include "code_writer.h"
-#include "io_delegate.h"
-#include "options.h"
-
#include <memory>
#include <regex>
#include <string>
#include <unordered_set>
#include <vector>
-#include <android-base/macros.h>
#include <android-base/strings.h>
-struct yy_buffer_state;
-typedef yy_buffer_state* YY_BUFFER_STATE;
+#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;
@@ -42,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 {
@@ -53,113 +74,83 @@
} // namespace aidl
} // namespace android
-class AidlToken {
+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:
- AidlToken(const std::string& text, const std::string& comments);
-
- const std::string& GetText() const { return text_; }
- const std::string& GetComments() const { return comments_; }
-
- private:
- std::string text_;
- std::string comments_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlToken);
+ 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&) {}
};
-class AidlLocation {
- public:
- struct Point {
- int line;
- int column;
- };
-
- AidlLocation(const std::string& file, Point begin, Point end);
-
- friend std::ostream& operator<<(std::ostream& os, const AidlLocation& l);
- friend class AidlNode;
-
- private:
- const std::string file_;
- Point begin_;
- Point end_;
-};
-
-#define AIDL_LOCATION_HERE \
- AidlLocation { \
- __FILE__, {__LINE__, 0}, { __LINE__, 0 } \
- }
-
-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;
- AidlNode(AidlNode&&) = default;
virtual ~AidlNode() = default;
- // DO NOT ADD. This is intentionally omitted. Nothing should refer to the location
- // for a functional purpose. It is only for error messages.
- // NO const AidlLocation& GetLocation() const { return location_; } NO
+ AidlNode(AidlNode&&) = delete;
+ AidlNode& operator=(AidlNode&&) = delete;
- // To be able to print AidlLocation (nothing else should use this information)
- friend class AidlError;
+ // To be able to print AidlLocation
+ friend class AidlErrorLog;
friend std::string android::aidl::mappings::dump_location(const AidlNode&);
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_;
};
-// Generic point for printing any error in the AIDL compiler.
-class AidlError {
- public:
- AidlError(bool fatal, const std::string& filename) : AidlError(fatal) { os_ << filename << ": "; }
- AidlError(bool fatal, const AidlLocation& location) : AidlError(fatal) {
- os_ << location << ": ";
- }
- AidlError(bool fatal, const AidlNode& node) : AidlError(fatal, node.location_) {}
- AidlError(bool fatal, const AidlNode* node) : AidlError(fatal, *node) {}
-
- template <typename T>
- AidlError(bool fatal, const std::unique_ptr<T>& node) : AidlError(fatal, *node) {}
- ~AidlError() {
- os_ << std::endl;
- if (fatal_) abort();
- }
-
- std::ostream& os_;
-
- static bool hadError() { return sHadError; }
-
- private:
- AidlError(bool fatal);
-
- bool fatal_;
-
- static bool sHadError;
-
- DISALLOW_COPY_AND_ASSIGN(AidlError);
-};
-
-#define AIDL_ERROR(CONTEXT) ::AidlError(false /*fatal*/, (CONTEXT)).os_
-#define AIDL_FATAL(CONTEXT) ::AidlError(true /*fatal*/, (CONTEXT)).os_
-#define AIDL_FATAL_IF(CONDITION, CONTEXT) \
- if (CONDITION) AIDL_FATAL(CONTEXT) << "Bad internal state: " << #CONDITION << ": "
-
-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>
@@ -171,21 +162,34 @@
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;
+};
// Transforms a value string into a language specific form. Raw value as produced by
// AidlConstantValue.
@@ -194,28 +198,101 @@
class AidlAnnotation : public AidlNode {
public:
+ enum class Type {
+ BACKING = 1,
+ HIDE,
+ JAVA_STABLE_PARCELABLE,
+ UNSUPPORTED_APP_USAGE,
+ VINTF_STABILITY,
+ NULLABLE,
+ UTF8_IN_CPP,
+ SENSITIVE_DATA,
+ JAVA_PASSTHROUGH,
+ 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;
+ bool CheckContext(TargetContext context) const;
+ const string& GetName() const { return schema_.name; }
+ const Type& GetType() const { return schema_.type; }
+ bool Repeatable() const { return schema_.repeatable; }
- const string& GetName() const { return name_; }
- string ToString(const ConstantValueDecorator& decorator) const;
+ // 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:
- AidlAnnotation(const AidlLocation& location, const string& name);
- AidlAnnotation(const AidlLocation& location, const string& name,
- std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters);
- const string name_;
- string comments_;
+ struct ParamType {
+ std::string name;
+ const AidlTypeSpecifier& type;
+ bool required = false;
+ };
+
+ struct Schema {
+ AidlAnnotation::Type type;
+ std::string name;
+ TargetContext target_context;
+ std::vector<ParamType> parameters;
+ bool repeatable = false;
+
+ const ParamType* ParamType(const std::string& name) const {
+ for (const auto& param : parameters) {
+ if (param.name == name) {
+ return ¶m;
+ }
+ }
+ return nullptr;
+ }
+ };
+
+ static const std::vector<Schema>& AllSchemas();
+
+ AidlAnnotation(const AidlLocation& location, const Schema& schema,
+ std::map<std::string, std::shared_ptr<AidlConstantValue>>&& parameters,
+ const Comments& comments);
+
+ const Schema& schema_;
std::map<std::string, std::shared_ptr<AidlConstantValue>> parameters_;
};
@@ -226,9 +303,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;
@@ -241,37 +318,48 @@
}
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;
- const AidlAnnotation* JavaDerive() const;
-
- void DumpAnnotations(CodeWriter* writer) const;
+ bool JavaDerive(const std::string& method) const;
+ std::string GetDescriptor() const;
const AidlAnnotation* UnsupportedAppUsage() const;
- const AidlTypeSpecifier* BackingType(const AidlTypenames& typenames) const;
+ const AidlAnnotation* RustDerive() 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_; }
- bool CheckValidAnnotations() const;
+ 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_;
};
-class AidlQualifiedName;
-
// AidlTypeSpecifier represents a reference to either a built-in type,
// a defined type, or a variant (e.g., array of generic) of a type.
class AidlTypeSpecifier final : public AidlAnnotatable,
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
@@ -286,49 +374,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);
bool CheckValid(const AidlTypenames& typenames) const;
- bool LanguageSpecificCheckValid(Options::Language lang) 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 AidlVariableDeclaration : public AidlNode {
+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 AidlMember {
public:
AidlVariableDeclaration(const AidlLocation& location, AidlTypeSpecifier* type,
const std::string& name);
@@ -336,24 +472,50 @@
const std::string& name, AidlConstantValue* default_value);
virtual ~AidlVariableDeclaration() = default;
+ // non-copyable, non-movable
+ AidlVariableDeclaration(const AidlVariableDeclaration&) = delete;
+ AidlVariableDeclaration(AidlVariableDeclaration&&) = delete;
+ 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_;
+ bool default_user_specified_;
std::unique_ptr<AidlConstantValue> default_value_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlVariableDeclaration);
};
class AidlArgument : public AidlVariableDeclaration {
@@ -365,39 +527,43 @@
AidlArgument(const AidlLocation& location, AidlTypeSpecifier* type, const std::string& name);
virtual ~AidlArgument() = default;
+ // non-copyable, non-movable
+ AidlArgument(const AidlArgument&) = delete;
+ AidlArgument(AidlArgument&&) = delete;
+ AidlArgument& operator=(const AidlArgument&) = delete;
+ AidlArgument& operator=(AidlArgument&&) = delete;
+
Direction GetDirection() const { return direction_; }
bool IsOut() const { return direction_ & OUT_DIR; }
bool IsIn() const { return direction_ & IN_DIR; }
bool DirectionWasSpecified() const { return direction_specified_; }
string GetDirectionSpecifier() const;
+ bool CheckValid(const AidlTypenames& typenames) 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_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlArgument);
};
-class AidlMethod;
-class AidlConstantDeclaration;
-class AidlEnumDeclaration;
-class AidlMember : public AidlNode {
- public:
- AidlMember(const AidlLocation& location);
- virtual ~AidlMember() = default;
-
- virtual AidlMethod* AsMethod() { return nullptr; }
- virtual AidlConstantDeclaration* AsConstantDeclaration() { return nullptr; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AidlMember);
+struct ArgumentAspect {
+ std::string name;
+ std::set<AidlArgument::Direction> possible_directions;
};
class AidlUnaryConstExpression;
class AidlBinaryConstExpression;
+class AidlConstantReference;
class AidlConstantValue : public AidlNode {
public:
@@ -411,20 +577,61 @@
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;
+ // non-copyable, non-movable
+ AidlConstantValue(const AidlConstantValue&) = delete;
+ AidlConstantValue(AidlConstantValue&&) = delete;
+ AidlConstantValue& operator=(const AidlConstantValue&) = delete;
+ AidlConstantValue& operator=(AidlConstantValue&&) = delete;
+
+ // creates default value, when one isn't specified
+ // nullptr if no default available
+ static AidlConstantValue* Default(const AidlTypeSpecifier& specifier);
+
static AidlConstantValue* Boolean(const AidlLocation& location, bool value);
static AidlConstantValue* Character(const AidlLocation& location, char value);
// example: 123, -5498, maybe any size
@@ -435,29 +642,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
@@ -470,10 +683,35 @@
mutable int64_t final_value_;
mutable string final_string_value_ = "";
- DISALLOW_COPY_AND_ASSIGN(AidlConstantValue);
-
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 {
@@ -483,8 +721,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_;
@@ -502,9 +745,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_;
@@ -522,40 +770,64 @@
const string& name, AidlConstantValue* value);
virtual ~AidlConstantDeclaration() = default;
+ // non-copyable, non-movable
+ AidlConstantDeclaration(const AidlConstantDeclaration&) = delete;
+ AidlConstantDeclaration(AidlConstantDeclaration&&) = delete;
+ AidlConstantDeclaration& operator=(const AidlConstantDeclaration&) = delete;
+ AidlConstantDeclaration& operator=(AidlConstantDeclaration&&) = delete;
+
const AidlTypeSpecifier& GetType() const { return *type_; }
AidlTypeSpecifier* GetMutableType() { return type_.get(); }
const string& GetName() const { return name_; }
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_;
const string name_;
unique_ptr<AidlConstantValue> value_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlConstantDeclaration);
};
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;
- AidlMethod* AsMethod() override { return this; }
- bool IsHidden() const;
- const string& GetComments() const { return comments_; }
+ // non-copyable, non-movable
+ AidlMethod(const AidlMethod&) = delete;
+ AidlMethod(AidlMethod&&) = delete;
+ AidlMethod& operator=(const AidlMethod&) = delete;
+ AidlMethod& operator=(AidlMethod&&) = delete;
+
+ const AidlMethod* AsMethod() const override { return this; }
const AidlTypeSpecifier& GetType() const { return *type_; }
AidlTypeSpecifier* GetMutableType() { return type_.get(); }
@@ -583,17 +855,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_;
@@ -602,66 +884,41 @@
bool has_id_;
int id_;
bool is_user_defined_ = true;
-
- DISALLOW_COPY_AND_ASSIGN(AidlMethod);
};
-class AidlDefinedType;
-class AidlInterface;
-class AidlParcelable;
-class AidlStructuredParcelable;
-
-class AidlQualifiedName : public AidlNode {
- public:
- AidlQualifiedName(const AidlLocation& location, const std::string& term,
- const std::string& comments);
- virtual ~AidlQualifiedName() = default;
-
- const std::vector<std::string>& GetTerms() const { return terms_; }
- const std::string& GetComments() const { return comments_; }
- std::string GetDotName() const { return android::base::Join(terms_, '.'); }
- std::string GetColonName() const { return android::base::Join(terms_, "::"); }
-
- void AddTerm(const std::string& term);
-
- private:
- std::vector<std::string> terms_;
- std::string comments_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlQualifiedName);
-};
-
-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::vector<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
+ AidlDefinedType(const AidlDefinedType&) = delete;
+ AidlDefinedType(AidlDefinedType&&) = delete;
+ AidlDefinedType& operator=(const AidlDefinedType&) = delete;
+ 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;
+ std::string GetPackage() const { return package_; }
/* dot joined package and name, example: "android.package.foo.IBar" */
std::string GetCanonicalName() const;
- const std::vector<std::string>& GetSplitPackage() const { return package_; }
+ const std::vector<std::string>& GetSplitPackage() const { return split_package_; }
virtual std::string GetPreprocessDeclarationName() const = 0;
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; }
- virtual bool CheckValid(const AidlTypenames&) const { return CheckValidAnnotations(); }
- virtual bool LanguageSpecificCheckValid(Options::Language lang) const = 0;
+ virtual bool CheckValid(const AidlTypenames& typenames) const;
+ virtual bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
+ Options::Language lang) const = 0;
AidlStructuredParcelable* AsStructuredParcelable() {
return const_cast<AidlStructuredParcelable*>(
const_cast<const AidlDefinedType*>(this)->AsStructuredParcelable());
@@ -673,6 +930,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());
}
@@ -684,6 +945,7 @@
const AidlParcelable* AsUnstructuredParcelable() const {
if (this->AsStructuredParcelable() != nullptr) return nullptr;
+ if (this->AsUnionDeclaration() != nullptr) return nullptr;
return this->AsParcelable();
}
AidlParcelable* AsUnstructuredParcelable() {
@@ -691,224 +953,300 @@
const_cast<const AidlDefinedType*>(this)->AsUnstructuredParcelable());
}
- virtual void Dump(CodeWriter* writer) const = 0;
- void DumpHeader(CodeWriter* writer) 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:
- std::string name_;
- std::string comments_;
- const std::vector<std::string> package_;
+ bool CheckValidWithMembers(const AidlTypenames& typenames) const;
- DISALLOW_COPY_AND_ASSIGN(AidlDefinedType);
+ std::string name_;
+ 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, AidlQualifiedName* name,
- const std::vector<std::string>& package, const std::string& comments,
- const std::string& cpp_header = "",
- std::vector<std::string>* type_params = nullptr);
+ AidlParcelable(const AidlLocation& location, const std::string& name, const std::string& package,
+ 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;
- // C++ uses "::" instead of "." to refer to a inner class.
- std::string GetCppName() const { return name_->GetColonName(); }
+ // non-copyable, non-movable
+ AidlParcelable(const AidlParcelable&) = delete;
+ AidlParcelable(AidlParcelable&&) = delete;
+ AidlParcelable& operator=(const AidlParcelable&) = delete;
+ AidlParcelable& operator=(AidlParcelable&&) = delete;
+
std::string GetCppHeader() const { return cpp_header_; }
bool CheckValid(const AidlTypenames& typenames) const override;
- bool LanguageSpecificCheckValid(Options::Language lang) const override;
+ bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
+ Options::Language lang) const override;
const AidlParcelable* AsParcelable() const override { return this; }
const AidlParameterizable<std::string>* AsParameterizable() const override { return this; }
const AidlNode& AsAidlNode() const override { return *this; }
std::string GetPreprocessDeclarationName() const override { return "parcelable"; }
- void Dump(CodeWriter* writer) const override;
+ void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
private:
- std::unique_ptr<AidlQualifiedName> name_;
std::string cpp_header_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlParcelable);
};
class AidlStructuredParcelable : public AidlParcelable {
public:
- AidlStructuredParcelable(const AidlLocation& location, AidlQualifiedName* name,
- const std::vector<std::string>& package, const std::string& comments,
- std::vector<std::unique_ptr<AidlVariableDeclaration>>* variables);
+ AidlStructuredParcelable(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 ~AidlStructuredParcelable() = default;
- const std::vector<std::unique_ptr<AidlVariableDeclaration>>& GetFields() const {
- return variables_;
- }
+ // non-copyable, non-movable
+ AidlStructuredParcelable(const AidlStructuredParcelable&) = delete;
+ AidlStructuredParcelable(AidlStructuredParcelable&&) = delete;
+ AidlStructuredParcelable& operator=(const AidlStructuredParcelable&) = delete;
+ AidlStructuredParcelable& operator=(AidlStructuredParcelable&&) = delete;
const AidlStructuredParcelable* AsStructuredParcelable() const override { return this; }
std::string GetPreprocessDeclarationName() const override { return "structured_parcelable"; }
- void Dump(CodeWriter* writer) const override;
-
bool CheckValid(const AidlTypenames& typenames) const override;
- bool LanguageSpecificCheckValid(Options::Language lang) const override;
+ bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
+ Options::Language lang) const override;
- private:
- const std::vector<std::unique_ptr<AidlVariableDeclaration>> variables_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlStructuredParcelable);
+ 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
+ AidlEnumerator(const AidlEnumerator&) = delete;
+ AidlEnumerator(AidlEnumerator&&) = delete;
+ AidlEnumerator& operator=(const AidlEnumerator&) = delete;
+ AidlEnumerator& operator=(AidlEnumerator&&) = delete;
+
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_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlEnumerator);
+ 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::vector<std::string>& package, const std::string& comments);
+ const std::string& package, const Comments& comments);
virtual ~AidlEnumDeclaration() = default;
- void SetBackingType(std::unique_ptr<const AidlTypeSpecifier> type);
+ // non-copyable, non-movable
+ AidlEnumDeclaration(const AidlEnumDeclaration&) = delete;
+ AidlEnumDeclaration(AidlEnumDeclaration&&) = delete;
+ AidlEnumDeclaration& operator=(const AidlEnumDeclaration&) = delete;
+ AidlEnumDeclaration& operator=(AidlEnumDeclaration&&) = delete;
+
+ bool Autofill(const AidlTypenames&);
const AidlTypeSpecifier& GetBackingType() const { return *backing_type_; }
const std::vector<std::unique_ptr<AidlEnumerator>>& GetEnumerators() const {
return enumerators_;
}
- bool Autofill();
bool CheckValid(const AidlTypenames& typenames) const override;
- bool LanguageSpecificCheckValid(Options::Language) const override { return true; }
+ bool LanguageSpecificCheckValid(const AidlTypenames& /*typenames*/,
+ Options::Language) const override {
+ return true;
+ }
std::string GetPreprocessDeclarationName() const override { return "enum"; }
- void Dump(CodeWriter* writer) const override;
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_;
+};
- DISALLOW_COPY_AND_ASSIGN(AidlEnumDeclaration);
+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"; }
+
+ 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::vector<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;
- 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_;
- }
+ // non-copyable, non-movable
+ AidlInterface(const AidlInterface&) = delete;
+ AidlInterface(AidlInterface&&) = delete;
+ AidlInterface& operator=(const AidlInterface&) = delete;
+ AidlInterface& operator=(AidlInterface&&) = delete;
const AidlInterface* AsInterface() const override { return this; }
std::string GetPreprocessDeclarationName() const override { return "interface"; }
- void Dump(CodeWriter* writer) const override;
-
bool CheckValid(const AidlTypenames& typenames) const override;
- bool LanguageSpecificCheckValid(Options::Language lang) const override;
+ bool LanguageSpecificCheckValid(const AidlTypenames& typenames,
+ Options::Language lang) const override;
- private:
- std::vector<std::unique_ptr<AidlMethod>> methods_;
- std::vector<std::unique_ptr<AidlConstantDeclaration>> constants_;
+ std::string GetDescriptor() const;
+ void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
+};
- DISALLOW_COPY_AND_ASSIGN(AidlInterface);
+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;
- const std::string& GetFilename() const { return filename_; }
+ // non-copyable, non-movable
+ AidlImport(const AidlImport&) = delete;
+ AidlImport(AidlImport&&) = delete;
+ AidlImport& operator=(const AidlImport&) = delete;
+ AidlImport& operator=(AidlImport&&) = delete;
+
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_;
-
- DISALLOW_COPY_AND_ASSIGN(AidlImport);
};
-class Parser {
+// AidlDocument models an AIDL file
+class AidlDocument : public AidlCommentable {
public:
- ~Parser();
+ 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;
- // Parse contents of file |filename|. Should only be called once.
- static std::unique_ptr<Parser> Parse(const std::string& filename,
- const android::aidl::IoDelegate& io_delegate,
- AidlTypenames& typenames);
+ // non-copyable, non-movable
+ AidlDocument(const AidlDocument&) = delete;
+ AidlDocument(AidlDocument&&) = delete;
+ AidlDocument& operator=(const AidlDocument&) = delete;
+ AidlDocument& operator=(AidlDocument&&) = delete;
- void AddError() { error_++; }
- bool HasError() { return error_ != 0; }
-
- const std::string& FileName() const { return filename_; }
- void* Scanner() const { return scanner_; }
-
- void AddImport(std::unique_ptr<AidlImport>&& import);
- const std::vector<std::unique_ptr<AidlImport>>& GetImports() {
- return imports_;
+ 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 SetPackage(unique_ptr<AidlQualifiedName> name) { package_ = std::move(name); }
- std::vector<std::string> Package() const;
-
- void DeferResolution(AidlTypeSpecifier* typespec) {
- unresolved_typespecs_.emplace_back(typespec);
- }
-
- const vector<AidlTypeSpecifier*>& GetUnresolvedTypespecs() const { return unresolved_typespecs_; }
-
- bool Resolve();
-
- void AddDefinedType(unique_ptr<AidlDefinedType> type) {
- // Parser does NOT own AidlDefinedType, it just has references to the types
- // that it encountered while parsing the input file.
- defined_types_.emplace_back(type.get());
-
- // AidlDefinedType IS owned by AidlTypenames
- if (!typenames_.AddDefinedType(std::move(type))) {
- AddError();
+ void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
+ for (const auto& i : Imports()) {
+ traverse(*i);
+ }
+ for (const auto& t : DefinedTypes()) {
+ traverse(*t);
}
}
-
- vector<AidlDefinedType*>& GetDefinedTypes() { return defined_types_; }
+ void DispatchVisit(AidlVisitor& v) const override { v.Visit(*this); }
private:
- explicit Parser(const std::string& filename, std::string& raw_buffer,
- android::aidl::AidlTypenames& typenames);
-
- std::string filename_;
- std::unique_ptr<AidlQualifiedName> package_;
- AidlTypenames& typenames_;
-
- void* scanner_ = nullptr;
- YY_BUFFER_STATE buffer_;
- int error_ = 0;
-
- std::vector<std::unique_ptr<AidlImport>> imports_;
- vector<AidlDefinedType*> defined_types_;
- vector<AidlTypeSpecifier*> unresolved_typespecs_;
-
- DISALLOW_COPY_AND_ASSIGN(Parser);
+ 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 4813da6..e43ef45 100644
--- a/aidl_language_l.ll
+++ b/aidl_language_l.ll
@@ -19,12 +19,12 @@
#include <stdlib.h>
#include "aidl_language.h"
-#include "aidl_language_y-module.h"
+#include "parser.h"
+#include "aidl_language_y.h"
#define YY_USER_ACTION yylloc->columns(yyleng);
%}
-%option yylineno
%option noyywrap
%option nounput
%option noinput
@@ -37,26 +37,33 @@
identifier [_a-zA-Z][_a-zA-Z0-9]*
whitespace ([ \t\r]+)
intvalue [0-9]+[lL]?
-hexvalue 0[x|X][0-9a-fA-F]+
+hexvalue 0[x|X][0-9a-fA-F]+[lL]?
floatvalue [0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?
%%
%{
/* 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-module.h b/aidl_language_y-module.h
deleted file mode 100644
index 34b1620..0000000
--- a/aidl_language_y-module.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-
-// generated code prints std::string* which is disallowed
-// by android-base/logging.h
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wuser-defined-warnings"
-#include <aidl_language_y.h>
-#pragma clang diagnostic pop
diff --git a/aidl_language_y.yy b/aidl_language_y.yy
index 67a7b11..ab3e479 100644
--- a/aidl_language_y.yy
+++ b/aidl_language_y.yy
@@ -16,7 +16,8 @@
%{
#include "aidl_language.h"
-#include "aidl_language_y-module.h"
+#include "parser.h"
+#include "aidl_language_y.h"
#include "logging.h"
#include <android-base/parseint.h>
#include <set>
@@ -28,9 +29,9 @@
int yylex(yy::parser::semantic_type *, yy::parser::location_type *, void *);
AidlLocation loc(const yy::parser::location_type& begin, const yy::parser::location_type& end) {
- CHECK(begin.begin.filename == begin.end.filename);
- CHECK(begin.end.filename == end.begin.filename);
- CHECK(end.begin.filename == end.end.filename);
+ AIDL_FATAL_IF(begin.begin.filename != begin.end.filename, AIDL_LOCATION_HERE);
+ AIDL_FATAL_IF(begin.end.filename != end.begin.filename, AIDL_LOCATION_HERE);
+ AIDL_FATAL_IF(end.begin.filename != end.end.filename, AIDL_LOCATION_HERE);
AidlLocation::Point begin_point {
.line = begin.begin.line,
.column = begin.begin.column,
@@ -39,7 +40,7 @@
.line = end.end.line,
.column = end.end.column,
};
- return AidlLocation(*begin.begin.filename, begin_point, end_point);
+ return AidlLocation(*begin.begin.filename, begin_point, end_point, AidlLocation::Source::EXTERNAL);
}
AidlLocation loc(const yy::parser::location_type& l) {
@@ -80,26 +81,27 @@
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;
- AidlQualifiedName* qname;
- 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;
}
%destructor { } <character>
%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"
@@ -107,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"
@@ -116,12 +119,10 @@
%token '(' ')' ',' '=' '[' ']' '.' '{' '}' ';'
%token UNKNOWN "unrecognized character"
-%token CPP_HEADER "cpp_header"
-%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"
@@ -148,38 +149,55 @@
%right UNARY_PLUS UNARY_MINUS '!' '~'
%type<declaration> decl
-%type<variable_list> variable_decls
-%type<variable> variable_decl
-%type<interface_members> interface_members
%type<declaration> unannotated_decl
-%type<interface> interface_decl
-%type<parcelable> parcelable_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<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
%type<annotation> annotation
%type<annotation_list>annotation_list
%type<type> type
-%type<type> unannotated_type
+%type<type> non_array_type
%type<arg_list> arg_list arg_non_empty_list
%type<arg> arg
%type<direction> direction
%type<type_args> type_args
%type<type_params> type_params
-%type<qname> qualified_name
%type<const_expr> const_expr
%type<constant_value_list> constant_value_list
%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
-%type<token> identifier error
%%
+
document
- : package imports decls {};
+ : 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
@@ -188,48 +206,67 @@
*/
identifier
: IDENTIFIER
- { $$ = $1; }
| CPP_HEADER
- { $$ = new AidlToken("cpp_header", ""); }
;
package
- : {}
- | PACKAGE qualified_name ';'
- { ps->SetPackage(unique_ptr<AidlQualifiedName>($2)); };
+ : {
+ $$ = nullptr;
+ }
+ | PACKAGE qualified_name ';' {
+ $$ = new AidlPackage(loc(@1, @3), $1->GetComments());
+ ps->SetPackage($2->GetText());
+ delete $1;
+ delete $2;
+ }
+ ;
imports
- : {}
- | import imports {};
+ : { $$ = new std::vector<std::unique_ptr<AidlImport>>(); }
+ | imports import
+ {
+ $$ = $1;
+ auto it = std::find_if($$->begin(), $$->end(), [&](const auto& i) {
+ return $2->GetNeededClass() == i->GetNeededClass();
+ });
+ if (it == $$->end()) {
+ $$->emplace_back($2);
+ } else {
+ delete $2;
+ }
+ }
import
- : IMPORT qualified_name ';'
- { ps->AddImport(std::make_unique<AidlImport>(loc(@2), $2->GetDotName()));
+ : IMPORT qualified_name ';' {
+ $$ = new AidlImport(loc(@2), $2->GetText(), $1->GetComments());
+ delete $1;
delete $2;
};
qualified_name
: identifier {
- $$ = new AidlQualifiedName(loc(@1), $1->GetText(), $1->GetComments());
- delete $1;
+ $$ = $1;
}
| qualified_name '.' identifier
{ $$ = $1;
- $$->AddTerm($3->GetText());
+ $$->Append('.');
+ $$->Append($3->GetText());
delete $3;
};
decls
- : decl {
+ : decl
+ { $$ = new std::vector<std::unique_ptr<AidlDefinedType>>();
if ($1 != nullptr) {
- ps->AddDefinedType(unique_ptr<AidlDefinedType>($1));
+ $$->emplace_back($1);
}
}
- | decls decl {
+ | decls decl
+ { $$ = $1;
if ($2 != nullptr) {
- ps->AddDefinedType(unique_ptr<AidlDefinedType>($2));
+ $$->emplace_back($2);
}
- };
+ }
decl
: annotation_list unannotated_decl
@@ -248,11 +285,9 @@
unannotated_decl
: parcelable_decl
- { $$ = $1; }
| interface_decl
- { $$ = $1; }
| enum_decl
- { $$ = $1; }
+ | union_decl
;
type_params
@@ -267,44 +302,52 @@
delete $3;
};
+ optional_type_params
+ : /* none */ { $$ = nullptr; }
+ | '<' type_params '>' {
+ $$ = $2;
+ };
parcelable_decl
- : PARCELABLE qualified_name ';' {
- $$ = new AidlParcelable(loc(@2), $2, ps->Package(), $1->GetComments());
- delete $1;
- }
- | PARCELABLE qualified_name '<' type_params '>' ';' {
- $$ = new AidlParcelable(loc(@2), $2, ps->Package(), $1->GetComments(), "", $4);
- delete $1;
- }
- | PARCELABLE qualified_name CPP_HEADER C_STR ';' {
- $$ = new AidlParcelable(loc(@2), $2, ps->Package(), $1->GetComments(), $4->GetText());
- delete $1;
- delete $4;
- }
- | PARCELABLE identifier '{' variable_decls '}' {
- AidlQualifiedName* name = new AidlQualifiedName(loc(@2), $2->GetText(), $2->GetComments());
- $$ = new AidlStructuredParcelable(loc(@2), name, ps->Package(), $1->GetComments(), $4);
+ : PARCELABLE qualified_name optional_type_params ';' {
+ $$ = new AidlParcelable(loc(@2), $2->GetText(), ps->Package(), $1->GetComments(), "", $3);
delete $1;
delete $2;
- delete $4;
}
+ | PARCELABLE qualified_name optional_type_params '{' parcelable_members '}' {
+ $$ = new AidlStructuredParcelable(loc(@2), $2->GetText(), ps->Package(), $1->GetComments(), $3, $5);
+ delete $1;
+ delete $2;
+ }
+ | 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 ';' {
ps->AddError();
$$ = nullptr;
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 ';' {
@@ -316,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;
@@ -359,8 +399,8 @@
| INTVALUE {
$$ = AidlConstantValue::Integral(loc(@1), $1->GetText());
if ($$ == nullptr) {
- std::cerr << "ERROR: Could not parse integer: "
- << $1->GetText() << " at " << @1 << ".\n";
+ AIDL_ERROR(loc(@1)) << "Could not parse integer: "
+ << $1->GetText();
ps->AddError();
$$ = AidlConstantValue::Integral(loc(@1), "0");
}
@@ -373,8 +413,8 @@
| HEXVALUE {
$$ = AidlConstantValue::Integral(loc(@1), $1->GetText());
if ($$ == nullptr) {
- std::cerr << "ERROR: Could not parse hexvalue: "
- << $1->GetText() << " at " << @1 << ".\n";
+ AIDL_ERROR(loc(@1)) << "Could not parse hexvalue: "
+ << $1->GetText();
ps->AddError();
$$ = AidlConstantValue::Integral(loc(@1), "0");
}
@@ -384,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));
}
@@ -459,7 +503,7 @@
}
| '(' error ')'
{
- std::cerr << "ERROR: invalid const expression within parenthesis at " << @1 << ".\n";
+ AIDL_ERROR(loc(@1)) << "invalid const expression within parenthesis";
ps->AddError();
// to avoid segfaults
$$ = AidlConstantValue::Integral(loc(@1), "0");
@@ -473,6 +517,9 @@
| constant_value_non_empty_list {
$$ = $1;
}
+ | constant_value_non_empty_list ',' {
+ $$ = $1;
+ }
;
constant_value_non_empty_list
@@ -487,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;
}
;
@@ -531,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;
@@ -555,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();
@@ -593,43 +655,63 @@
| type identifier {
$$ = new AidlArgument(loc(@2), $1, $2->GetText());
delete $2;
- }
- ;
+ };
-unannotated_type
- : qualified_name {
- $$ = new AidlTypeSpecifier(loc(@1), $1->GetDotName(), false, nullptr, $1->GetComments());
+non_array_type
+ : annotation_list qualified_name {
+ $$ = new AidlTypeSpecifier(loc(@2), $2->GetText(), false, nullptr, $2->GetComments());
ps->DeferResolution($$);
+ if (!$1->empty()) {
+ $$->SetComments($1->begin()->GetComments());
+ $$->Annotate(std::move(*$1));
+ }
delete $1;
+ delete $2;
}
- | qualified_name '[' ']' {
- $$ = new AidlTypeSpecifier(loc(@1), $1->GetDotName(), true, nullptr, $1->GetComments());
- ps->DeferResolution($$);
- delete $1;
+ | non_array_type '<' type_args '>' {
+ ps->SetTypeParameters($1, $3);
+ $$ = $1;
}
- | qualified_name '<' type_args '>' {
- $$ = new AidlTypeSpecifier(loc(@1), $1->GetDotName(), false, $3, $1->GetComments());
- ps->DeferResolution($$);
- delete $1;
+ | non_array_type '<' non_array_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;
+ }
+ | non_array_type '<' type_args ',' non_array_type '<' type_args RSHIFT {
+ ps->SetTypeParameters($5, $7);
+ $3->emplace_back($5);
+ ps->SetTypeParameters($1, $3);
+ $$ = $1;
};
type
- : annotation_list unannotated_type {
- $$ = $2;
- if ($1->size() > 0) {
- // copy comments from annotation to type
- $2->SetComments($1->begin()->GetComments());
+ : non_array_type
+ | type annotation_list '[' ']' {
+ if (!$2->empty()) {
+ AIDL_ERROR(loc(@2)) << "Annotations for arrays are not supported.";
+ ps->AddError();
}
- $2->Annotate(std::move(*$1));
- delete $1;
- };
+ if (!$1->SetArray()) {
+ AIDL_ERROR(loc(@1)) << "Can only have one dimensional arrays.";
+ ps->AddError();
+ }
+ $$ = $1;
+ delete $2;
+ }
+ ;
type_args
- : unannotated_type {
+ : type {
+ if (!$1->GetAnnotations().empty()) {
+ AIDL_ERROR(loc(@1)) << "Annotations for type arguments are not supported.";
+ ps->AddError();
+ }
$$ = new std::vector<std::unique_ptr<AidlTypeSpecifier>>();
$$->emplace_back($1);
}
- | type_args ',' unannotated_type {
+ | type_args ',' type {
$1->emplace_back($3);
$$ = $1;
};
@@ -677,26 +759,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 9f2963e..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"
@@ -34,7 +35,7 @@
namespace cpp {
namespace {
-std::string RawParcelMethod(const AidlTypeSpecifier& raw_type, const AidlTypenames& typenames,
+std::string RawParcelMethod(const AidlTypeSpecifier& type, const AidlTypenames& typenames,
bool readMethod) {
static map<string, string> kBuiltin = {
{"byte", "Byte"},
@@ -48,6 +49,7 @@
{"long", "Int64"},
{"ParcelFileDescriptor", "Parcelable"},
{"String", "String16"},
+ {"ParcelableHolder", "Parcelable"},
};
static map<string, string> kBuiltinVector = {
@@ -64,14 +66,11 @@
{"ParcelFileDescriptor", "ParcelableVector"},
};
- const bool nullable = raw_type.IsNullable();
- const bool isVector =
- raw_type.IsArray() || (raw_type.IsGeneric() && raw_type.GetName() == "List");
- const bool utf8 = raw_type.IsUtf8InCpp();
- const auto& type = raw_type.IsGeneric() ? *raw_type.GetTypeParameters().at(0) : raw_type;
- const string& aidl_name = type.GetName();
+ const bool nullable = type.IsNullable();
+ const bool isVector = type.IsArray() || typenames.IsList(type);
+ const bool utf8 = type.IsUtf8InCpp();
- if (auto enum_decl = typenames.GetEnumDeclaration(raw_type); enum_decl != nullptr) {
+ if (auto enum_decl = typenames.GetEnumDeclaration(type); enum_decl != nullptr) {
if (isVector) {
return "EnumVector";
} else {
@@ -80,50 +79,58 @@
}
if (isVector) {
- if (kBuiltinVector.find(aidl_name) != kBuiltinVector.end()) {
- CHECK(AidlTypenames::IsBuiltinTypename(aidl_name));
+ string element_name;
+ if (typenames.IsList(type)) {
+ AIDL_FATAL_IF(type.GetTypeParameters().size() != 1, type);
+ element_name = type.GetTypeParameters().at(0)->GetName();
+ } else {
+ element_name = type.GetName();
+ }
+ if (kBuiltinVector.find(element_name) != kBuiltinVector.end()) {
+ AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(element_name), type);
if (utf8) {
- CHECK(aidl_name == "String");
+ AIDL_FATAL_IF(element_name != "String", type);
return readMethod ? "Utf8VectorFromUtf16Vector" : "Utf8VectorAsUtf16Vector";
}
- return kBuiltinVector[aidl_name];
+ return kBuiltinVector[element_name];
}
- } else {
- if (kBuiltin.find(aidl_name) != kBuiltin.end()) {
- CHECK(AidlTypenames::IsBuiltinTypename(aidl_name));
- if (aidl_name == "IBinder" && nullable && readMethod) {
- return "NullableStrongBinder";
- }
- if (aidl_name == "ParcelFileDescriptor" && nullable && !readMethod) {
- return "NullableParcelable";
- }
- if (utf8) {
- CHECK(aidl_name == "String");
- return readMethod ? "Utf8FromUtf16" : "Utf8AsUtf16";
- }
- return kBuiltin[aidl_name];
- }
- }
- CHECK(!AidlTypenames::IsBuiltinTypename(aidl_name));
- 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.
- CHECK(definedType != nullptr) << type.GetName() << " is not found.";
-
// Parcelable
- if (isVector) {
- return "ParcelableVector";
- }
if (nullable && !readMethod) {
return "NullableParcelable";
}
@@ -136,11 +143,11 @@
std::string WrapIfNullable(const std::string type_str, const AidlTypeSpecifier& raw_type,
const AidlTypenames& typenames) {
- const auto& type = raw_type.IsGeneric() ? (*raw_type.GetTypeParameters().at(0)) : raw_type;
+ const auto& type = typenames.IsList(raw_type) ? (*raw_type.GetTypeParameters().at(0)) : raw_type;
if (raw_type.IsNullable() && !AidlTypenames::IsPrimitiveTypename(type.GetName()) &&
type.GetName() != "IBinder" && typenames.GetEnumDeclaration(type) == nullptr) {
- return "::std::unique_ptr<" + type_str + ">";
+ return "::std::optional<" + type_str + ">";
}
return type_str;
}
@@ -160,18 +167,17 @@
{"ParcelFileDescriptor", "::android::os::ParcelFileDescriptor"},
{"String", "::android::String16"},
{"void", "void"},
+ {"ParcelableHolder", "::android::os::ParcelableHolder"},
};
-
- CHECK(!raw_type.IsGeneric() ||
- (raw_type.GetName() == "List" && raw_type.GetTypeParameters().size() == 1));
- const auto& type = raw_type.IsGeneric() ? (*raw_type.GetTypeParameters().at(0)) : raw_type;
+ AIDL_FATAL_IF(typenames.IsList(raw_type) && raw_type.GetTypeParameters().size() != 1, raw_type);
+ const auto& type = typenames.IsList(raw_type) ? (*raw_type.GetTypeParameters().at(0)) : raw_type;
const string& aidl_name = type.GetName();
if (m.find(aidl_name) != m.end()) {
- CHECK(AidlTypenames::IsBuiltinTypename(aidl_name));
+ AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(aidl_name), raw_type);
if (aidl_name == "byte" && type.IsArray()) {
return "uint8_t";
} else if (raw_type.IsUtf8InCpp()) {
- CHECK(aidl_name == "String");
+ AIDL_FATAL_IF(aidl_name != "String", type);
return WrapIfNullable("::std::string", raw_type, typenames);
}
return WrapIfNullable(m[aidl_name], raw_type, typenames);
@@ -197,30 +203,39 @@
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) {
- if (type.IsArray() || type.IsGeneric()) {
+ if (type.IsArray() || typenames.IsList(type)) {
std::string cpp_name = GetCppName(type, typenames);
if (type.IsNullable()) {
- return "::std::unique_ptr<::std::vector<" + cpp_name + ">>";
+ return "::std::optional<::std::vector<" + cpp_name + ">>";
}
return "::std::vector<" + cpp_name + ">";
+ } else if (type.IsGeneric()) {
+ std::vector<std::string> type_params;
+ for (const auto& parameter : type.GetTypeParameters()) {
+ type_params.push_back(CppNameOf(*parameter, typenames));
+ }
+ return StringPrintf("%s<%s>", GetCppName(type, typenames).c_str(),
+ base::Join(type_params, ", ").c_str());
}
return GetCppName(type, typenames);
}
bool IsNonCopyableType(const AidlTypeSpecifier& type, const AidlTypenames& typenames) {
- if (type.IsArray() || type.IsGeneric()) {
+ if (type.IsArray() || typenames.IsList(type)) {
return false;
}
@@ -267,63 +282,81 @@
return variable_name;
}
-void AddHeaders(const AidlTypeSpecifier& raw_type, const AidlTypenames& typenames,
- std::set<std::string>& headers) {
- bool isVector = raw_type.IsArray() || raw_type.IsGeneric();
- bool isNullable = raw_type.IsNullable();
- bool utf8 = raw_type.IsUtf8InCpp();
-
- CHECK(!raw_type.IsGeneric() ||
- (raw_type.GetName() == "List" && raw_type.GetTypeParameters().size() == 1));
- const auto& type = raw_type.IsGeneric() ? *raw_type.GetTypeParameters().at(0) : raw_type;
- auto definedType = typenames.TryGetDefinedType(type.GetName());
+void AddHeaders(const AidlTypeSpecifier& type, const AidlTypenames& typenames,
+ std::set<std::string>* headers) {
+ AIDL_FATAL_IF(typenames.IsList(type) && type.GetTypeParameters().size() != 1, type);
+ bool isVector = type.IsArray() || typenames.IsList(type);
+ bool isNullable = type.IsNullable();
+ bool utf8 = type.IsUtf8InCpp();
if (isVector) {
- headers.insert("vector");
+ headers->insert("vector");
+ }
+ if (type.IsGeneric()) {
+ for (const auto& parameter : type.GetTypeParameters()) {
+ AddHeaders(*parameter, typenames, headers);
+ }
}
if (isNullable) {
if (type.GetName() != "IBinder") {
- headers.insert("memory");
+ headers->insert("optional");
}
}
+ if (typenames.IsList(type)) {
+ // Nothing else to do for List.
+ return;
+ }
if (type.GetName() == "String") {
- headers.insert(utf8 ? "string" : "utils/String16.h");
+ headers->insert(utf8 ? "string" : "utils/String16.h");
+ return;
}
if (type.GetName() == "IBinder") {
- headers.insert("binder/IBinder.h");
+ headers->insert("binder/IBinder.h");
+ return;
}
if (type.GetName() == "FileDescriptor") {
- headers.insert("android-base/unique_fd.h");
+ headers->insert("android-base/unique_fd.h");
+ return;
}
if (type.GetName() == "ParcelFileDescriptor") {
- headers.insert("binder/ParcelFileDescriptor.h");
+ headers->insert("binder/ParcelFileDescriptor.h");
+ return;
+ }
+ if (type.GetName() == "ParcelableHolder") {
+ headers->insert("binder/ParcelableHolder.h");
+ return;
}
static const std::set<string> need_cstdint{"byte", "int", "long"};
if (need_cstdint.find(type.GetName()) != need_cstdint.end()) {
- headers.insert("cstdint");
- }
-
- if (definedType == nullptr) {
+ headers->insert("cstdint");
return;
}
+
+ if (AidlTypenames::IsPrimitiveTypename(type.GetName())) {
+ return;
+ }
+
+ auto definedType = typenames.TryGetDefinedType(type.GetName());
+ 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();
AIDL_FATAL_IF(cpp_header.empty(), definedType->AsParcelable())
<< "Parcelable " << definedType->AsParcelable()->GetCanonicalName()
<< " has no C++ header defined.";
- headers.insert(cpp_header);
+ headers->insert(cpp_header);
}
}
-void AddHeaders(const AidlDefinedType& definedType, std::set<std::string>& headers) {
+void AddHeaders(const AidlDefinedType& definedType, std::set<std::string>* headers) {
vector<string> name = definedType.GetSplitPackage();
name.push_back(definedType.GetName());
const std::string cpp_header = Join(name, '/') + ".h";
- headers.insert(cpp_header);
+ headers->insert(cpp_header);
}
} // namespace cpp
diff --git a/aidl_to_cpp.h b/aidl_to_cpp.h
index 5816b2b..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);
@@ -60,9 +59,9 @@
const std::string& variable_name);
void AddHeaders(const AidlTypeSpecifier& type, const AidlTypenames& typenames,
- std::set<std::string>& headers);
+ std::set<std::string>* headers);
-void AddHeaders(const AidlDefinedType& parcelable, std::set<std::string>& headers);
+void AddHeaders(const AidlDefinedType& parcelable, std::set<std::string>* headers);
} // namespace cpp
} // namespace aidl
} // namespace android
diff --git a/aidl_to_cpp_common.cpp b/aidl_to_cpp_common.cpp
index d1aeb2e..f0bf1dc 100644
--- a/aidl_to_cpp_common.cpp
+++ b/aidl_to_cpp_common.cpp
@@ -15,10 +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"
@@ -28,6 +33,22 @@
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;
+};
+)";
+
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])) {
@@ -90,157 +111,26 @@
return prefix + a.GetName();
}
-struct TypeInfo {
- // name of the type in C++ output
- std::string cpp_name;
-
- // 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;
-};
-
-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
-};
-
-TypeInfo GetTypeInfo(const AidlTypeSpecifier& aidl) {
- CHECK(aidl.IsResolved()) << aidl.ToString();
- const string& aidl_name = aidl.GetName();
-
- TypeInfo info;
- if (AidlTypenames::IsBuiltinTypename(aidl_name)) {
- auto it = kTypeInfoMap.find(aidl_name);
- if (it != kTypeInfoMap.end()) {
- info = it->second;
- }
- }
- // 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;
- }
-
- const string var_object_expr = ((isPointer ? "*" : "")) + name;
- 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 << ";";
- }
- writer << "\n";
-}
-
-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 + "\", ::android::internal::ToString(" + 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();
@@ -259,95 +149,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 = ::android::internal::ToString(" << 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";
@@ -366,8 +206,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";
}
@@ -376,6 +217,280 @@
return code.str();
}
+std::string TemplateDecl(const AidlParcelable& defined_type) {
+ std::string decl = "";
+ if (defined_type.IsGeneric()) {
+ std::vector<std::string> template_params;
+ for (const auto& parameter : defined_type.GetTypeParameters()) {
+ template_params.push_back(parameter);
+ }
+ decl = base::StringPrintf("template <typename %s>\n",
+ base::Join(template_params, ", typename ").c_str());
+ }
+ 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 << "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() << ": \" << ::android::internal::ToString(" << 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 << "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 << ": \" << "
+ << "::android::internal::ToString(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 <size_t _Np, typename... _Tp>
+constexpr explicit {name}(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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 a5c7896..f9fe80b 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,8 @@
namespace aidl {
namespace cpp {
+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,6 +75,44 @@
std::string GenerateEnumValues(const AidlEnumDeclaration& enum_decl,
const std::vector<std::string>& enclosing_namespaces_of_enum_decl);
+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 f4706a2..40b01d5 100644
--- a/aidl_to_java.cpp
+++ b/aidl_to_java.cpp
@@ -33,23 +33,29 @@
using android::base::Join;
-using std::endl;
using std::function;
using std::map;
using std::string;
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;
};
const string& JavaNameOf(const AidlTypeSpecifier& aidl, const AidlTypenames& typenames,
bool instantiable = false, bool boxing = false) {
- CHECK(aidl.IsResolved()) << aidl.ToString();
+ AIDL_FATAL_IF(!aidl.IsResolved(), aidl) << aidl.ToString();
if (instantiable) {
// An instantiable type is used in only out type(not even inout type),
@@ -85,6 +91,7 @@
{"FileDescriptor", "java.io.FileDescriptor"},
{"CharSequence", "java.lang.CharSequence"},
{"ParcelFileDescriptor", "android.os.ParcelFileDescriptor"},
+ {"ParcelableHolder", "android.os.ParcelableHolder"},
};
// map from primitive types to the corresponding boxing types
@@ -98,19 +105,23 @@
if (const AidlEnumDeclaration* enum_decl = typenames.GetEnumDeclaration(aidl);
enum_decl != nullptr) {
const string& backing_type_name = enum_decl->GetBackingType().GetName();
- CHECK(m.find(backing_type_name) != m.end());
- CHECK(AidlTypenames::IsBuiltinTypename(backing_type_name));
- return m[backing_type_name];
+ AIDL_FATAL_IF(m.find(backing_type_name) == m.end(), enum_decl);
+ AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(backing_type_name), enum_decl);
+ if (boxing) {
+ return boxing_types[backing_type_name];
+ } else {
+ return m[backing_type_name];
+ }
}
const string& aidl_name = aidl.GetName();
if (boxing && AidlTypenames::IsPrimitiveTypename(aidl_name)) {
// Every primitive type must have the corresponding boxing type
- CHECK(boxing_types.find(aidl_name) != m.end());
+ AIDL_FATAL_IF(boxing_types.find(aidl_name) == m.end(), aidl);
return boxing_types[aidl_name];
}
if (m.find(aidl_name) != m.end()) {
- CHECK(AidlTypenames::IsBuiltinTypename(aidl_name));
+ AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(aidl_name), aidl);
return m[aidl_name];
} else {
// 'foo.bar.IFoo' in AIDL maps to 'foo.bar.IFoo' in Java
@@ -172,10 +183,10 @@
};
const string name = AidlBackingTypeName(aidl, typenames);
- CHECK(name != "void");
+ AIDL_FATAL_IF(name == "void", aidl);
if (!aidl.IsArray() && m.find(name) != m.end()) {
- CHECK(AidlTypenames::IsBuiltinTypename(name));
+ AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(name), aidl);
return m[name];
} else {
return "null";
@@ -260,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);
- CHECK(t != nullptr) << "Unknown type: " << contained_type << endl;
- 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";
@@ -364,6 +371,10 @@
c.writer.Dedent();
c.writer << "}\n";
}},
+ {"ParcelableHolder",
+ [](const CodeGeneratorContext& c) {
+ c.writer << c.parcel << ".writeTypedObject(" << c.var << ", 0);\n";
+ }},
};
const string type_name = AidlBackingTypeName(c.type, c.typenames);
const auto found = method_map.find(type_name);
@@ -371,7 +382,7 @@
found->second(c);
} else {
const AidlDefinedType* t = c.typenames.TryGetDefinedType(c.type.GetName());
- CHECK(t != nullptr) << "Unknown type: " << c.type.GetName() << endl;
+ AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << c.type.GetName();
if (t->AsInterface() != nullptr) {
if (!c.type.IsArray()) {
// Why don't we use writeStrongInterface which does the exact same thing?
@@ -405,7 +416,7 @@
// Ensures that a variable is initialized to refer to the classloader
// of the current object and returns the name of the variable.
static string EnsureAndGetClassloader(CodeGeneratorContext& c) {
- CHECK(c.is_classloader_created != nullptr);
+ AIDL_FATAL_IF(c.is_classloader_created == nullptr, AIDL_LOCATION_HERE);
if (!*(c.is_classloader_created)) {
c.writer << "java.lang.ClassLoader cl = "
<< "(java.lang.ClassLoader)this.getClass().getClassLoader();\n";
@@ -484,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);
- CHECK(t != nullptr) << "Unknown type: " << contained_type << endl;
- 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));
@@ -516,7 +523,7 @@
c.writer << "java.util.stream.IntStream.range(0, N).forEach(i -> {\n";
c.writer.Indent();
c.writer << "String k = " << c.parcel << ".readString();\n";
- c.writer << JavaNameOf(*(c.type.GetTypeParameters().at(1)), c.typenames) << " v;\n";
+ c.writer << JavaSignatureOf(*(c.type.GetTypeParameters().at(1)), c.typenames) << " v;\n";
CodeGeneratorContext value_context{
c.writer,
c.typenames,
@@ -592,19 +599,27 @@
c.writer.Dedent();
c.writer << "}\n";
}},
+ {"ParcelableHolder",
+ [](const CodeGeneratorContext& c) {
+ c.writer << "if ((0!=" << c.parcel << ".readInt())) {\n";
+ c.writer.Indent();
+ c.writer << c.var << ".readFromParcel(" << c.parcel << ");\n";
+ c.writer.Dedent();
+ c.writer << "}\n";
+ }},
};
const auto found = method_map.find(AidlBackingTypeName(c.type, c.typenames));
if (found != method_map.end()) {
found->second(c);
} else {
const AidlDefinedType* t = c.typenames.TryGetDefinedType(c.type.GetName());
- CHECK(t != nullptr) << "Unknown type: " << c.type.GetName() << endl;
+ AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << c.type.GetName();
if (t->AsInterface() != nullptr) {
if (!c.type.IsArray()) {
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";
@@ -666,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);
- CHECK(t != nullptr) << "Unknown type: " << contained_type << endl;
- 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));
@@ -745,8 +756,8 @@
found->second(c);
} else {
const AidlDefinedType* t = c.typenames.TryGetDefinedType(c.type.GetName());
- CHECK(t != nullptr) << "Unknown type: " << c.type.GetName() << endl;
- if (t->AsParcelable() != nullptr) {
+ AIDL_FATAL_IF(t == nullptr, c.type) << "Unknown type: " << c.type.GetName();
+ if (t->AsParcelable() != nullptr || t->AsUnionDeclaration() != nullptr) {
if (c.type.IsArray()) {
c.writer << c.parcel << ".readTypedArray(" << c.var << ", " << c.type.GetName()
<< ".CREATOR);\n";
@@ -764,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;
}
@@ -803,7 +812,8 @@
c.writer << "java.util.Objects.toString(" << c.var << ")";
return;
}
- CHECK(true) << "Unhandled typename: " << name << endl;
+
+ AIDL_FATAL(AIDL_LOCATION_HERE) << "Unhandled typename: " << name;
}
} // namespace java
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index 663a17e..9d1b794 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -18,6 +18,7 @@
#include "logging.h"
#include "os.h"
+#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <functional>
@@ -69,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;
};
@@ -87,7 +99,9 @@
};
}
-TypeInfo PrimitiveType(const std::string& cpp_name, const std::string& pretty_name) {
+TypeInfo PrimitiveType(const std::string& cpp_name, const std::string& pretty_name,
+ const std::optional<std::string>& cpp_name_for_array_opt = std::nullopt) {
+ std::string cpp_name_for_array = cpp_name_for_array_opt.value_or(cpp_name);
return TypeInfo{
.raw =
TypeInfo::Aspect{
@@ -97,14 +111,14 @@
.write_func = StandardWrite("AParcel_write" + pretty_name),
},
.array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
- .cpp_name = "std::vector<" + cpp_name + ">",
+ .cpp_name = "std::vector<" + cpp_name_for_array + ">",
.value_is_cheap = false,
.read_func = StandardRead("::ndk::AParcel_readVector"),
.write_func = StandardWrite("::ndk::AParcel_writeVector"),
}),
.nullable = nullptr,
.nullable_array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
- .cpp_name = "std::optional<std::vector<" + cpp_name + ">>",
+ .cpp_name = "std::optional<std::vector<" + cpp_name_for_array + ">>",
.value_is_cheap = false,
.read_func = StandardRead("::ndk::AParcel_readVector"),
.write_func = StandardWrite("::ndk::AParcel_writeVector"),
@@ -134,9 +148,17 @@
};
}
-TypeInfo ParcelableTypeInfo(const AidlParcelable& type) {
- const std::string clazz = NdkFullClassName(type, cpp::ClassNames::RAW);
-
+TypeInfo ParcelableTypeInfo(const AidlParcelable& type, const AidlTypeSpecifier& typeSpec,
+ const AidlTypenames& types) {
+ std::string clazz = NdkFullClassName(type, cpp::ClassNames::RAW);
+ std::string template_params = "";
+ if (typeSpec.IsGeneric()) {
+ std::vector<std::string> type_params;
+ for (const auto& parameter : typeSpec.GetTypeParameters()) {
+ type_params.push_back(NdkNameOf(types, *parameter, StorageMode::STACK));
+ }
+ clazz += base::StringPrintf("<%s>", base::Join(type_params, ", ").c_str());
+ }
return TypeInfo{
.raw =
TypeInfo::Aspect{
@@ -170,7 +192,7 @@
{"long", "Int64"},
};
auto aparcel_name_it = kAParcelTypeNameMap.find(enum_decl.GetBackingType().GetName());
- CHECK(aparcel_name_it != kAParcelTypeNameMap.end());
+ AIDL_FATAL_IF(aparcel_name_it == kAParcelTypeNameMap.end(), enum_decl);
const std::string aparcel_name = aparcel_name_it->second;
const std::string backing_type_name =
@@ -235,7 +257,7 @@
static map<std::string, TypeInfo> kNdkTypeInfoMap = {
{"void", TypeInfo{{"void", true, nullptr, nullptr}, nullptr, nullptr, nullptr}},
{"boolean", PrimitiveType("bool", "Bool")},
- {"byte", PrimitiveType("int8_t", "Byte")},
+ {"byte", PrimitiveType("int8_t", "Byte", "uint8_t")},
{"char", PrimitiveType("char16_t", "Char")},
{"int", PrimitiveType("int32_t", "Int32")},
{"long", PrimitiveType("int64_t", "Int64")},
@@ -311,10 +333,23 @@
}),
.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) {
- CHECK(aidl.IsResolved()) << aidl.ToString();
+ AIDL_FATAL_IF(!aidl.IsResolved(), aidl) << aidl.ToString();
auto& aidl_name = aidl.GetName();
TypeInfo info;
@@ -324,7 +359,7 @@
AIDL_FATAL_IF(!aidl.IsGeneric(), aidl) << "List must be generic type.";
AIDL_FATAL_IF(aidl.GetTypeParameters().size() != 1, aidl)
<< "List can accept only one type parameter.";
- auto& type_param = aidl.GetTypeParameters()[0];
+ const auto& type_param = aidl.GetTypeParameters()[0];
// TODO(b/136048684) AIDL doesn't support nested type parameter yet.
AIDL_FATAL_IF(type_param->IsGeneric(), aidl) << "AIDL doesn't support nested type parameter";
@@ -337,12 +372,9 @@
return GetTypeAspect(types, array_type);
}
- // All generic types should be handled above.
- AIDL_FATAL_IF(aidl.IsGeneric(), aidl);
-
if (AidlTypenames::IsBuiltinTypename(aidl_name)) {
auto it = kNdkTypeInfoMap.find(aidl_name);
- CHECK(it != kNdkTypeInfoMap.end());
+ AIDL_FATAL_IF(it == kNdkTypeInfoMap.end(), aidl_name);
info = it->second;
} else {
const AidlDefinedType* type = types.TryGetDefinedType(aidl_name);
@@ -351,7 +383,7 @@
if (const AidlInterface* intf = type->AsInterface(); intf != nullptr) {
info = InterfaceTypeInfo(*intf);
} else if (const AidlParcelable* parcelable = type->AsParcelable(); parcelable != nullptr) {
- info = ParcelableTypeInfo(*parcelable);
+ info = ParcelableTypeInfo(*parcelable, aidl, types);
} else if (const AidlEnumDeclaration* enum_decl = type->AsEnumDeclaration();
enum_decl != nullptr) {
info = EnumDeclarationTypeInfo(*enum_decl);
@@ -362,15 +394,18 @@
if (aidl.IsArray()) {
if (aidl.IsNullable()) {
- AIDL_FATAL_IF(info.nullable_array == nullptr, aidl) << "Unsupported type in NDK Backend.";
+ AIDL_FATAL_IF(info.nullable_array == nullptr, aidl)
+ << "Unsupported type in NDK Backend: " << aidl.ToString();
return *info.nullable_array;
}
- AIDL_FATAL_IF(info.array == nullptr, aidl) << "Unsupported type in NDK Backend.";
+ AIDL_FATAL_IF(info.array == nullptr, aidl)
+ << "Unsupported type in NDK Backend: " << aidl.ToString();
return *info.array;
}
if (aidl.IsNullable()) {
- AIDL_FATAL_IF(info.nullable == nullptr, aidl) << "Unsupported type in NDK Backend.";
+ AIDL_FATAL_IF(info.nullable == nullptr, aidl)
+ << "Unsupported type in NDK Backend: " << aidl.ToString();
return *info.nullable;
}
@@ -405,6 +440,26 @@
}
}
+size_t NdkAlignmentOf(const AidlTypenames& types, const AidlTypeSpecifier& aidl) {
+ // map from NDK type name to the corresponding alignment size
+ static map<string, int> alignment = {
+ {"bool", 1}, {"int8_t", 1}, {"char16_t", 2}, {"double", 8},
+ {"float", 4}, {"int32_t", 4}, {"int64_t", 8},
+ };
+
+ const string& name = NdkNameOf(types, aidl, StorageMode::STACK);
+ if (alignment.find(name) != alignment.end()) {
+ return alignment[name];
+ } else {
+ const auto& definedType = types.TryGetDefinedType(aidl.GetName());
+ AIDL_FATAL_IF(definedType == nullptr, aidl) << "Failed to resolve type.";
+ if (const auto& enumType = definedType->AsEnumDeclaration(); enumType != nullptr) {
+ return NdkAlignmentOf(types, enumType->GetBackingType());
+ }
+ }
+ return 0;
+}
+
void WriteToParcelFor(const CodeGeneratorContext& c) {
TypeInfo::Aspect aspect = GetTypeAspect(c.types, c.type);
aspect.write_func(c);
diff --git a/aidl_to_ndk.h b/aidl_to_ndk.h
index 1f7f490..370d07b 100644
--- a/aidl_to_ndk.h
+++ b/aidl_to_ndk.h
@@ -40,6 +40,12 @@
// array modifiers.
std::string NdkNameOf(const AidlTypenames& types, const AidlTypeSpecifier& aidl, StorageMode mode);
+// Return the alignment of known types and enum backing types.
+// If the alignment is unknown, or it is a FizedSize parcelable with its
+// own guaranteed alignment(so it does not need to be specified), 0 will be
+// returned.
+size_t NdkAlignmentOf(const AidlTypenames& types, const AidlTypeSpecifier& aidl);
+
struct CodeGeneratorContext {
CodeWriter& writer;
diff --git a/aidl_to_rust.cpp b/aidl_to_rust.cpp
new file mode 100644
index 0000000..4121ff4
--- /dev/null
+++ b/aidl_to_rust.cpp
@@ -0,0 +1,302 @@
+/*
+ * 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 "aidl_to_rust.h"
+#include "aidl_language.h"
+#include "aidl_typenames.h"
+#include "logging.h"
+
+#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
+
+#include <functional>
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+using android::base::Join;
+using android::base::Split;
+using android::base::StringPrintf;
+
+namespace android {
+namespace aidl {
+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()) {
+ // Convert `{ ... }` to `vec!{ ... }`
+ return "vec!" + raw_value;
+ }
+
+ const auto& aidl_name = type.GetName();
+ if (aidl_name == "char") {
+ return raw_value + " as u16";
+ }
+
+ if (aidl_name == "float") {
+ // raw_value already ends in `f`, so just add `32`
+ return raw_value + "32";
+ }
+
+ if (aidl_name == "double") {
+ return raw_value + "f64";
+ }
+
+ if (aidl_name == "String" && !by_ref) {
+ // The actual type might be String or &str,
+ // and .into() transparently converts into either one
+ 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;
+}
+
+std::string GetRawRustName(const AidlTypeSpecifier& type) {
+ // Each Rust type is defined in a file with the same name,
+ // e.g., IFoo is in IFoo.rs
+ auto split_name = type.GetSplitName();
+ std::string rust_name{"crate::mangled::"};
+ for (const auto& component : split_name) {
+ rust_name += StringPrintf("_%zd_%s", component.size(), component.c_str());
+ }
+ return rust_name;
+}
+
+std::string GetRustName(const AidlTypeSpecifier& type, const AidlTypenames& typenames,
+ StorageMode mode) {
+ // map from AIDL built-in type name to the corresponding Rust type name
+ static map<string, string> m = {
+ {"void", "()"},
+ {"boolean", "bool"},
+ {"byte", "i8"},
+ {"char", "u16"},
+ {"int", "i32"},
+ {"long", "i64"},
+ {"float", "f32"},
+ {"double", "f64"},
+ {"String", "String"},
+ {"IBinder", "binder::SpIBinder"},
+ {"ParcelFileDescriptor", "binder::parcel::ParcelFileDescriptor"},
+ };
+
+ // If the type is an array/List<T>, get the inner element 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()) {
+ AIDL_FATAL_IF(!AidlTypenames::IsBuiltinTypename(element_type_name), type);
+ if (element_type_name == "byte" && type.IsArray()) {
+ return "u8";
+ } else if (element_type_name == "String" && mode == StorageMode::UNSIZED_ARGUMENT) {
+ return "str";
+ } else if (element_type_name == "ParcelFileDescriptor") {
+ if (type.IsArray() && mode == StorageMode::DEFAULT_VALUE) {
+ // Out-arguments of ParcelFileDescriptors arrays need to
+ // be Vec<Option<ParcelFileDescriptor>> so resize_out_vec
+ // can initialize all elements to None (it requires Default
+ // and ParcelFileDescriptor doesn't implement that)
+ return "Option<" + m[element_type_name] + ">";
+ } else {
+ return m[element_type_name];
+ }
+ }
+ return m[element_type_name];
+ }
+ if (TypeIsInterface(element_type, typenames)) {
+ return "binder::Strong<dyn " + GetRawRustName(element_type) + ">";
+ }
+
+ return GetRawRustName(element_type);
+}
+} // namespace
+
+std::string ConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value) {
+ auto rust_value = ConstantValueDecoratorInternal(type, raw_value, false);
+ if (type.IsNullable()) {
+ return "Some(" + rust_value + ")";
+ }
+ return rust_value;
+}
+
+std::string ConstantValueDecoratorRef(const AidlTypeSpecifier& type, const std::string& raw_value) {
+ auto rust_value = ConstantValueDecoratorInternal(type, raw_value, true);
+ if (type.IsNullable()) {
+ return "Some(" + rust_value + ")";
+ }
+ return rust_value;
+}
+
+std::string RustNameOf(const AidlTypeSpecifier& type, const AidlTypenames& typenames,
+ StorageMode mode) {
+ std::string rust_name;
+ 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()
+ element_mode = StorageMode::DEFAULT_VALUE;
+ } else {
+ element_mode = StorageMode::VALUE;
+ }
+ rust_name = GetRustName(type, typenames, element_mode);
+ if (type.IsNullable() && rust_name == "String") {
+ // The mapping for nullable string arrays is
+ // optional<vector<optional<string>>> in the NDK,
+ // so we do the same
+ rust_name = "Option<" + rust_name + ">";
+ }
+ if (mode == StorageMode::UNSIZED_ARGUMENT) {
+ rust_name = "[" + rust_name + "]";
+ } else {
+ rust_name = "Vec<" + rust_name + ">";
+ }
+ } else {
+ rust_name = GetRustName(type, typenames, mode);
+ }
+
+ if (mode == StorageMode::IN_ARGUMENT || mode == StorageMode::UNSIZED_ARGUMENT) {
+ // If this is a nullable input argument, put the reference inside the option,
+ // e.g., `Option<&str>` instead of `&Option<str>`
+ rust_name = "&" + rust_name;
+ }
+
+ if (type.IsNullable() ||
+ // Some types don't implement Default, so we wrap them
+ // in Option, which defaults to None
+ (!TypeHasDefault(type, typenames) &&
+ (mode == StorageMode::DEFAULT_VALUE || mode == StorageMode::OUT_ARGUMENT ||
+ mode == StorageMode::PARCELABLE_FIELD))) {
+ rust_name = "Option<" + rust_name + ">";
+ }
+
+ if (mode == StorageMode::OUT_ARGUMENT || mode == StorageMode::INOUT_ARGUMENT) {
+ rust_name = "&mut " + rust_name;
+ }
+
+ return rust_name;
+}
+
+StorageMode ArgumentStorageMode(const AidlArgument& arg, const AidlTypenames& typenames) {
+ if (arg.IsOut()) {
+ return arg.IsIn() ? StorageMode::INOUT_ARGUMENT : StorageMode::OUT_ARGUMENT;
+ }
+
+ const auto typeName = arg.GetType().GetName();
+ const auto definedType = typenames.TryGetDefinedType(typeName);
+
+ const bool isEnum = definedType && definedType->AsEnumDeclaration() != nullptr;
+ const bool isPrimitive = AidlTypenames::IsPrimitiveTypename(typeName);
+ if (typeName == "String" || arg.GetType().IsArray() || typenames.IsList(arg.GetType())) {
+ return StorageMode::UNSIZED_ARGUMENT;
+ } else if (!(isPrimitive || isEnum)) {
+ return StorageMode::IN_ARGUMENT;
+ } else {
+ return StorageMode::VALUE;
+ }
+}
+
+ReferenceMode ArgumentReferenceMode(const AidlArgument& arg, const AidlTypenames& typenames) {
+ auto arg_mode = ArgumentStorageMode(arg, typenames);
+ switch (arg_mode) {
+ case StorageMode::IN_ARGUMENT:
+ if (arg.GetType().IsNullable()) {
+ // &Option<T> => Option<&T>
+ return ReferenceMode::AS_REF;
+ } else {
+ return ReferenceMode::REF;
+ }
+
+ case StorageMode::OUT_ARGUMENT:
+ case StorageMode::INOUT_ARGUMENT:
+ return ReferenceMode::MUT_REF;
+
+ case StorageMode::UNSIZED_ARGUMENT:
+ if (arg.GetType().IsNullable()) {
+ // &Option<String> => Option<&str>
+ // &Option<Vec<T>> => Option<&[T]>
+ return ReferenceMode::AS_DEREF;
+ } else {
+ return ReferenceMode::REF;
+ }
+
+ default:
+ return ReferenceMode::VALUE;
+ }
+}
+
+std::string TakeReference(ReferenceMode ref_mode, const std::string& name) {
+ switch (ref_mode) {
+ case ReferenceMode::REF:
+ return "&" + name;
+
+ case ReferenceMode::MUT_REF:
+ return "&mut " + name;
+
+ case ReferenceMode::AS_REF:
+ return name + ".as_ref()";
+
+ case ReferenceMode::AS_DEREF:
+ return name + ".as_deref()";
+
+ default:
+ return name;
+ }
+}
+
+bool TypeIsInterface(const AidlTypeSpecifier& type, const AidlTypenames& typenames) {
+ const auto definedType = typenames.TryGetDefinedType(type.GetName());
+ return definedType != nullptr && definedType->AsInterface() != nullptr;
+}
+
+bool TypeHasDefault(const AidlTypeSpecifier& type, const AidlTypenames& typenames) {
+ if (type.IsArray() || typenames.IsList(type)) {
+ return true;
+ }
+
+ // Already an Option<T>
+ if (type.IsNullable()) {
+ return true;
+ }
+
+ const string& aidl_name = type.GetName();
+ if (aidl_name == "IBinder") {
+ return false;
+ }
+ if (aidl_name == "ParcelFileDescriptor") {
+ return false;
+ }
+
+ // Strong<dyn IFoo> values don't implement Default
+ if (TypeIsInterface(type, typenames)) {
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace rust
+} // namespace aidl
+} // namespace android
diff --git a/aidl_to_rust.h b/aidl_to_rust.h
new file mode 100644
index 0000000..292e4df
--- /dev/null
+++ b/aidl_to_rust.h
@@ -0,0 +1,77 @@
+/*
+ * 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 "aidl_language.h"
+#include "aidl_typenames.h"
+
+namespace android {
+namespace aidl {
+namespace rust {
+
+// This header provides functions that translate AIDL things to Rust things.
+
+enum class StorageMode {
+ VALUE,
+ DEFAULT_VALUE, // Value that implements Default::default()
+ IN_ARGUMENT, // Value for primitives, & for larger types
+ UNSIZED_ARGUMENT, // Unsized input argument, e.g., str/slice
+ OUT_ARGUMENT, // Mutable reference to write-only raw type
+ INOUT_ARGUMENT, // Mutable reference to inout argument
+ PARCELABLE_FIELD, // Field in a parcelable
+};
+
+enum class ReferenceMode {
+ VALUE,
+ REF,
+ MUT_REF,
+ AS_REF,
+ AS_DEREF,
+};
+
+inline bool IsReference(ReferenceMode ref_mode) {
+ switch (ref_mode) {
+ case ReferenceMode::REF:
+ case ReferenceMode::MUT_REF:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+std::string ConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value);
+
+std::string ConstantValueDecoratorRef(const AidlTypeSpecifier& type, const std::string& raw_value);
+
+// Returns the Rust type signature of the AIDL type spec
+// This includes generic type parameters with array modifiers.
+std::string RustNameOf(const AidlTypeSpecifier& aidl, const AidlTypenames& typenames,
+ StorageMode mode);
+
+StorageMode ArgumentStorageMode(const AidlArgument& arg, const AidlTypenames& typenames);
+
+ReferenceMode ArgumentReferenceMode(const AidlArgument& arg, const AidlTypenames& typenames);
+
+std::string TakeReference(ReferenceMode ref_mode, const std::string& name);
+
+bool TypeIsInterface(const AidlTypeSpecifier& type, const AidlTypenames& typenames);
+
+bool TypeHasDefault(const AidlTypeSpecifier& type, const AidlTypenames& typenames);
+
+} // namespace rust
+} // namespace aidl
+} // namespace android
diff --git a/aidl_typenames.cpp b/aidl_typenames.cpp
index 51c26d7..8440463 100644
--- a/aidl_typenames.cpp
+++ b/aidl_typenames.cpp
@@ -41,10 +41,22 @@
namespace aidl {
// The built-in AIDL types..
-static const set<string> kBuiltinTypes = {
- "void", "boolean", "byte", "char", "int",
- "long", "float", "double", "String", "List",
- "Map", "IBinder", "FileDescriptor", "CharSequence", "ParcelFileDescriptor"};
+static const set<string> kBuiltinTypes = {"void",
+ "boolean",
+ "byte",
+ "char",
+ "int",
+ "long",
+ "float",
+ "double",
+ "String",
+ "List",
+ "Map",
+ "IBinder",
+ "FileDescriptor",
+ "CharSequence",
+ "ParcelFileDescriptor",
+ "ParcelableHolder"};
static const set<string> kPrimitiveTypes = {"void", "boolean", "byte", "char",
"int", "long", "float", "double"};
@@ -64,21 +76,30 @@
// in Java and C++. Using these names will eventually cause compilation error,
// so checking this here is not a must have, but early detection of errors
// is always better.
-static const set<string> kInvalidNames = {
+static const set<string> kCppOrJavaReservedWord = {
"break", "case", "catch", "char", "class", "continue", "default",
"do", "double", "else", "enum", "false", "float", "for",
"goto", "if", "int", "long", "new", "private", "protected",
"public", "return", "short", "static", "switch", "this", "throw",
"true", "try", "void", "volatile", "while"};
-static bool IsValidName(const string& name) {
- vector<string> pieces = Split(name, ".");
- for (const auto& piece : pieces) {
- if (kInvalidNames.find(piece) != kInvalidNames.end()) {
- return false;
+static bool HasValidNameComponents(const AidlDefinedType& defined) {
+ bool success = true;
+ vector<string> pieces = Split(defined.GetCanonicalName(), ".");
+ for (const string& piece : pieces) {
+ if (kCppOrJavaReservedWord.find(piece) != kCppOrJavaReservedWord.end()) {
+ AIDL_ERROR(defined) << defined.GetCanonicalName() << " is an invalid name because '" << piece
+ << "' is a Java or C++ identifier.";
+ success = false;
+ }
+ // not checking kJavaLikeTypeToAidl, since that wouldn't make sense here
+ if (kBuiltinTypes.find(piece) != kBuiltinTypes.end()) {
+ AIDL_ERROR(defined) << defined.GetCanonicalName() << " is an invalid name because '" << piece
+ << "' is a built-in AIDL type.";
+ success = false;
}
}
- return true;
+ return success;
}
bool AidlTypenames::IsIgnorableImport(const string& import) const {
@@ -94,24 +115,44 @@
return in_ignore_import || defined_type_not_from_preprocessed;
}
-bool AidlTypenames::AddDefinedType(unique_ptr<AidlDefinedType> type) {
- const string name = type->GetCanonicalName();
- if (defined_types_.find(name) != defined_types_.end()) {
- return false;
+bool AidlTypenames::AddDocument(std::unique_ptr<AidlDocument> doc) {
+ for (const auto& type : doc->DefinedTypes()) {
+ if (defined_types_.find(type->GetCanonicalName()) != defined_types_.end()) {
+ return false;
+ }
+ if (!HasValidNameComponents(*type)) {
+ return false;
+ }
}
- if (!IsValidName(type->GetPackage()) || !IsValidName(type->GetName())) {
- return false;
+ documents_.push_back(std::move(doc));
+ for (const auto& type : documents_.back()->DefinedTypes()) {
+ defined_types_.emplace(type->GetCanonicalName(), type.get());
}
- defined_types_.emplace(name, std::move(type));
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]);
+}
+
bool AidlTypenames::AddPreprocessedType(unique_ptr<AidlDefinedType> type) {
const string name = type->GetCanonicalName();
if (preprocessed_types_.find(name) != preprocessed_types_.end()) {
return false;
}
- if (!IsValidName(type->GetPackage()) || !IsValidName(type->GetName())) {
+ if (!HasValidNameComponents(*type)) {
return false;
}
preprocessed_types_.insert(make_pair(name, std::move(type)));
@@ -127,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;
}
@@ -136,7 +187,7 @@
// Do the exact match first.
auto found_def = defined_types_.find(type_name);
if (found_def != defined_types_.end()) {
- return DefinedImplResult(found_def->second.get(), false);
+ return DefinedImplResult(found_def->second, false);
}
auto found_prep = preprocessed_types_.find(type_name);
@@ -148,7 +199,7 @@
// types from the preprocessed file.
for (auto it = defined_types_.begin(); it != defined_types_.end(); it++) {
if (it->second->GetName() == type_name) {
- return DefinedImplResult(it->second.get(), false);
+ return DefinedImplResult(it->second, false);
}
}
@@ -161,32 +212,124 @@
return DefinedImplResult(nullptr, false);
}
-pair<string, bool> AidlTypenames::ResolveTypename(const string& type_name) const {
+std::vector<AidlDefinedType*> AidlTypenames::AllDefinedTypes() const {
+ std::vector<AidlDefinedType*> res;
+ for (const auto& d : AllDocuments()) {
+ for (const auto& t : d->DefinedTypes()) {
+ res.push_back(t.get());
+ }
+ }
+ return res;
+}
+
+AidlTypenames::ResolvedTypename AidlTypenames::ResolveTypename(const string& type_name) const {
if (IsBuiltinTypename(type_name)) {
auto found = kJavaLikeTypeToAidlType.find(type_name);
if (found != kJavaLikeTypeToAidlType.end()) {
- return make_pair(found->second, true);
+ return {found->second, true, nullptr};
}
- return make_pair(type_name, true);
+ return {type_name, true, nullptr};
}
const AidlDefinedType* defined_type = TryGetDefinedType(type_name);
if (defined_type != nullptr) {
- return make_pair(defined_type->GetCanonicalName(), true);
+ return {defined_type->GetCanonicalName(), true, defined_type};
} else {
- return make_pair(type_name, false);
+ return {type_name, false, nullptr};
}
}
-// Only T[], List, Map, ParcelFileDescriptor and Parcelable can be an out parameter.
-bool AidlTypenames::CanBeOutParameter(const AidlTypeSpecifier& type) const {
+// Only immutable Parcelable, primitive type, and String, and List, Map, array of the types can be
+// immutable.
+bool AidlTypenames::CanBeJavaOnlyImmutable(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.IsGeneric()) {
+ if (type.GetName() == "List" || type.GetName() == "Map") {
+ const auto& types = type.GetTypeParameters();
+ return std::all_of(types.begin(), types.end(),
+ [this](const auto& t) { return CanBeJavaOnlyImmutable(*t); });
+ }
+ AIDL_ERROR(type) << "For a generic type, an immutable parcelable can contain only List or Map.";
+ return false;
+ }
+ if (IsPrimitiveTypename(name) || name == "String") {
+ return true;
}
const AidlDefinedType* t = TryGetDefinedType(type.GetName());
- CHECK(t != nullptr) << "Unrecognized type: '" << type.GetName() << "'";
- return t->AsParcelable() != nullptr;
+ if (t == nullptr) {
+ AIDL_ERROR(type) << "An immutable parcelable can contain only immutable Parcelable, primitive "
+ "type, and String.";
+ return false;
+ }
+ if (t->AsEnumDeclaration()) {
+ return true;
+ }
+ return t->IsJavaOnlyImmutable();
+}
+
+// Only FixedSize Parcelable, primitive types, and enum types can be FixedSize.
+bool AidlTypenames::CanBeFixedSize(const AidlTypeSpecifier& type) const {
+ const string& name = type.GetName();
+ if (type.IsGeneric() || type.IsArray()) {
+ return false;
+ }
+ if (IsPrimitiveTypename(name)) {
+ return true;
+ }
+ if (IsBuiltinTypename(name)) {
+ return false;
+ }
+ const AidlDefinedType* t = TryGetDefinedType(type.GetName());
+ AIDL_FATAL_IF(t == nullptr, type)
+ << "Failed to look up type. Cannot determine if it can be fixed size: " << type.GetName();
+
+ if (t->AsEnumDeclaration()) {
+ return true;
+ }
+ return t->IsFixedSize();
+}
+
+bool AidlTypenames::IsList(const AidlTypeSpecifier& type) {
+ return type.GetName() == "List";
+}
+
+ArgumentAspect AidlTypenames::GetArgumentAspect(const AidlTypeSpecifier& type) const {
+ if (type.IsArray()) {
+ return {"array",
+ {AidlArgument::Direction::IN_DIR, AidlArgument::Direction::OUT_DIR,
+ AidlArgument::Direction::INOUT_DIR}};
+ }
+ const string& name = type.GetName();
+ if (IsBuiltinTypename(name)) {
+ if (name == "List" || name == "Map") {
+ return {name,
+ {AidlArgument::Direction::IN_DIR, AidlArgument::Direction::OUT_DIR,
+ AidlArgument::Direction::INOUT_DIR}};
+ } else if (name == "ParcelFileDescriptor") {
+ // "out ParcelFileDescriptor" is not allowed because ParcelFileDescriptor is not
+ // default-constructible.
+ return {name, {AidlArgument::Direction::IN_DIR, AidlArgument::Direction::INOUT_DIR}};
+ } else if (name == "ParcelableHolder") {
+ // TODO(b/156872582): Support it when ParcelableHolder supports every backend.
+ return {name, {}};
+ } else {
+ return {name, {AidlArgument::Direction::IN_DIR}};
+ }
+ }
+
+ 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.
+ if (t->AsParcelable() != nullptr) {
+ if (t->IsJavaOnlyImmutable()) {
+ return {"@JavaOnlyImmutable", {AidlArgument::Direction::IN_DIR}};
+ }
+ return {"parcelable/union",
+ {AidlArgument::Direction::IN_DIR, AidlArgument::Direction::OUT_DIR,
+ AidlArgument::Direction::INOUT_DIR}};
+ }
+
+ return {t->GetPreprocessDeclarationName(), {AidlArgument::Direction::IN_DIR}};
}
const AidlEnumDeclaration* AidlTypenames::GetEnumDeclaration(const AidlTypeSpecifier& type) const {
@@ -207,6 +350,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);
@@ -216,9 +368,20 @@
}
}
-void AidlTypenames::Reset() {
- defined_types_.clear();
- preprocessed_types_.clear();
+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
diff --git a/aidl_typenames.h b/aidl_typenames.h
index 78b996f..f86f158 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,7 +35,10 @@
class AidlDefinedType;
class AidlEnumDeclaration;
class AidlInterface;
+class AidlParcelable;
class AidlTypeSpecifier;
+class AidlDocument;
+struct ArgumentAspect;
namespace android {
namespace aidl {
@@ -52,14 +57,28 @@
class AidlTypenames final {
public:
AidlTypenames() = default;
- void Reset();
- bool AddDefinedType(unique_ptr<AidlDefinedType> type);
+ 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;
- pair<string, bool> ResolveTypename(const string& type_name) const;
- bool CanBeOutParameter(const AidlTypeSpecifier& type) 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;
+ ArgumentAspect GetArgumentAspect(const AidlTypeSpecifier& type) const;
+ bool CanBeJavaOnlyImmutable(const AidlTypeSpecifier& type) const;
+ bool CanBeFixedSize(const AidlTypeSpecifier& type) const;
+ static bool IsList(const AidlTypeSpecifier& type);
+
bool IsIgnorableImport(const string& import) const;
// Returns the AidlEnumDeclaration of the given type, or nullptr if the type
// is not an AidlEnumDeclaration;
@@ -67,8 +86,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 {
@@ -78,8 +102,9 @@
const bool from_preprocessed;
};
DefinedImplResult TryGetDefinedTypeImpl(const string& type_name) const;
- map<string, unique_ptr<AidlDefinedType>> defined_types_;
+ map<string, AidlDefinedType*> defined_types_;
map<string, unique_ptr<AidlDefinedType>> preprocessed_types_;
+ std::vector<std::unique_ptr<AidlDocument>> documents_;
};
} // namespace aidl
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index fea3419..7ea8c17 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -14,30 +14,39 @@
* 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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "aidl.h"
#include "aidl_checkapi.h"
+#include "aidl_dumpapi.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"
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;
@@ -71,110 +80,17 @@
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;
-
- 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();
- if (_aidl_parcelable_size < 0) return;
- try {
- 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 {
- _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
- }
- }
- @Override public int describeContents()
- {
- return 0;
- }
-}
-)";
-
} // namespace
-class AidlTest : public ::testing::Test {
+class AidlTest : public ::testing::TestWithParam<Options::Language> {
protected:
- void SetUp() override {
- CaptureStderr();
- }
-
- void TearDown() override {
- auto actual_stderr = GetCapturedStderr();
- std::cerr << actual_stderr << std::endl;
-
- if (expected_stderr_.size() > 0) {
- EXPECT_EQ(android::base::Join(expected_stderr_, ""), actual_stderr);
- }
- }
-
- void AddExpectedStderr(string expected) { expected_stderr_.push_back(expected); }
-
AidlDefinedType* Parse(const string& path, const string& contents, AidlTypenames& typenames_,
Options::Language lang, AidlError* error = nullptr,
const vector<string> additional_arguments = {}) {
io_delegate_.SetFileContents(path, contents);
vector<string> args;
- if (lang == Options::Language::CPP) {
- args.emplace_back("aidl-cpp");
- } else {
- args.emplace_back("aidl");
- }
+ args.emplace_back("aidl");
+ args.emplace_back("--lang=" + to_string(lang));
for (const string& s : additional_arguments) {
args.emplace_back(s);
}
@@ -186,11 +102,10 @@
}
args.emplace_back(path);
Options options = Options::From(args);
- vector<AidlDefinedType*> defined_types;
vector<string> imported_files;
ImportResolver import_resolver{io_delegate_, path, import_paths_, {}};
AidlError actual_error = ::android::aidl::internals::load_and_validate_aidl(
- path, options, io_delegate_, &typenames_, &defined_types, &imported_files);
+ path, options, io_delegate_, &typenames_, &imported_files);
if (error != nullptr) {
*error = actual_error;
@@ -200,165 +115,311 @@
return nullptr;
}
+ const auto& defined_types = typenames_.MainDocument().DefinedTypes();
EXPECT_EQ(1ul, defined_types.size());
- return defined_types.front();
+ return defined_types.front().get();
}
+ Options::Language GetLanguage() { return GetParam(); }
+
FakeIoDelegate io_delegate_;
vector<string> preprocessed_files_;
set<string> import_paths_;
- vector<string> expected_stderr_;
AidlTypenames typenames_;
};
-TEST_F(AidlTest, AcceptMissingPackage) {
- EXPECT_NE(nullptr, Parse("IFoo.aidl", "interface IFoo { }", typenames_, Options::Language::JAVA));
- typenames_.Reset();
- EXPECT_NE(nullptr, Parse("IFoo.aidl", "interface IFoo { }", typenames_, Options::Language::CPP));
+// Instantiate the AidlTest parameterized suite, calling all of the TEST_P
+// tests with each of the supported languages as a parameter.
+INSTANTIATE_TEST_SUITE_P(AidlTestSuite, AidlTest,
+ testing::Values(Options::Language::CPP, Options::Language::JAVA,
+ Options::Language::NDK, Options::Language::RUST),
+ [](const testing::TestParamInfo<Options::Language>& info) {
+ return to_string(info.param);
+ });
+
+TEST_P(AidlTest, AcceptMissingPackage) {
+ EXPECT_NE(nullptr, Parse("IFoo.aidl", "interface IFoo { }", typenames_, GetLanguage()));
}
-TEST_F(AidlTest, EndsInSingleLineComment) {
- EXPECT_NE(nullptr,
- Parse("IFoo.aidl", "interface IFoo { } // foo", typenames_, Options::Language::JAVA));
- typenames_.Reset();
- EXPECT_NE(nullptr,
- Parse("IFoo.aidl", "interface IFoo { } // foo", typenames_, Options::Language::CPP));
+TEST_P(AidlTest, EndsInSingleLineComment) {
+ EXPECT_NE(nullptr, Parse("IFoo.aidl", "interface IFoo { } // foo", typenames_, GetLanguage()));
}
-TEST_F(AidlTest, RejectsArraysOfBinders) {
+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",
"package bar; interface IBar {}");
- string path = "foo/IFoo.aidl";
- string contents = "package foo;\n"
- "import bar.IBar;\n"
- "interface IFoo { void f(in IBar[] input); }";
- EXPECT_EQ(nullptr, Parse(path, contents, typenames_, Options::Language::JAVA));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse(path, contents, typenames_, Options::Language::CPP));
+ const string path = "foo/IFoo.aidl";
+ const string contents =
+ "package foo;\n"
+ "import bar.IBar;\n"
+ "interface IFoo { void f(in IBar[] input); }";
+ const string expected_stderr = "ERROR: foo/IFoo.aidl:3.27-32: Binder type cannot be an array\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse(path, contents, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, SupportOnlyOutParameters) {
- string interface_list = "package a; interface IBar { void f(out List bar); }";
- string interface_ibinder = "package a; interface IBaz { void f(out IBinder bar); }";
- // List without type isn't supported in cpp.
- EXPECT_EQ(nullptr, Parse("a/IBar.aidl", interface_list, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_NE(nullptr, Parse("a/IBar.aidl", interface_list, typenames_, Options::Language::JAVA));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IBaz.aidl", interface_ibinder, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IBaz.aidl", interface_ibinder, typenames_, Options::Language::JAVA));
+TEST_P(AidlTest, SupportOnlyOutParameters) {
+ const string interface_list = "package a; interface IBar { void f(out List<String> bar); }";
+ EXPECT_NE(nullptr, Parse("a/IBar.aidl", interface_list, typenames_, GetLanguage()));
}
-TEST_F(AidlTest, RejectsOnewayOutParameters) {
- string oneway_interface =
- "package a; oneway interface IFoo { void f(out int bar); }";
- string oneway_method =
- "package a; interface IBar { oneway void f(out int bar); }";
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_interface, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_interface, typenames_, Options::Language::JAVA));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IBar.aidl", oneway_method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IBar.aidl", oneway_method, typenames_, Options::Language::JAVA));
+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: '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());
}
-TEST_F(AidlTest, RejectsOnewayNonVoidReturn) {
- string oneway_method = "package a; interface IFoo { oneway int f(); }";
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::JAVA));
+TEST_P(AidlTest, RejectsOutParametersInOnewayInterface) {
+ const string oneway_interface = "package a; oneway interface IBar { void f(out int[] bar); }";
+ const string expected_stderr =
+ "ERROR: a/IBar.aidl:1.40-42: oneway method 'f' cannot have out parameters\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IBar.aidl", oneway_interface, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, RejectsNullablePrimitive) {
- string oneway_method = "package a; interface IFoo { @nullable int f(); }";
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::JAVA));
+TEST_P(AidlTest, RejectsOutParametersInOnewayMethod) {
+ const string oneway_method = "package a; interface IBar { oneway void f(out int[] bar); }";
+ const string expected_stderr =
+ "ERROR: a/IBar.aidl:1.40-42: oneway method 'f' cannot have out parameters\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IBar.aidl", oneway_method, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, RejectsDuplicatedArgumentNames) {
- string method = "package a; interface IFoo { void f(int a, int a); }";
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, Options::Language::JAVA));
+TEST_P(AidlTest, RejectsOnewayNonVoidReturn) {
+ const string oneway_method = "package a; interface IFoo { oneway int f(); }";
+ const string expected_stderr =
+ "ERROR: a/IFoo.aidl:1.39-41: oneway method 'f' cannot return a value\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, RejectsDuplicatedAnnotationParams) {
- string method = "package a; interface IFoo { @UnsupportedAppUsage(foo=1, foo=2)void f(); }";
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, Options::Language::JAVA));
+TEST_P(AidlTest, RejectsNullablePrimitive) {
+ const string oneway_method = "package a; interface IFoo { @nullable int f(); }";
+ const string expected_stderr =
+ "ERROR: a/IFoo.aidl:1.38-42: Primitive type cannot get nullable annotation\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, ParsesNullableAnnotation) {
- for (auto is_nullable: {true, false}) {
- auto parse_result = Parse("a/IFoo.aidl",
- StringPrintf("package a; interface IFoo {%s String f(); }",
- (is_nullable) ? "@nullable" : ""),
- typenames_, Options::Language::CPP);
- ASSERT_NE(nullptr, parse_result);
- const AidlInterface* interface = parse_result->AsInterface();
- ASSERT_NE(nullptr, interface);
- ASSERT_FALSE(interface->GetMethods().empty());
- EXPECT_EQ(interface->GetMethods()[0]->GetType().IsNullable(), is_nullable);
- typenames_.Reset();
- }
+TEST_P(AidlTest, AcceptNullableList) {
+ const string oneway_method = "package a; interface IFoo { @nullable List<String> f(); }";
+ const string expected_stderr = "";
+ CaptureStderr();
+ EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, ParsesUtf8Annotations) {
- for (auto is_utf8: {true, false}) {
- auto parse_result = Parse(
- "a/IFoo.aidl",
- StringPrintf("package a; interface IFoo {%s String f(); }", (is_utf8) ? "@utf8InCpp" : ""),
- typenames_, Options::Language::CPP);
- ASSERT_NE(nullptr, parse_result);
- const AidlInterface* interface = parse_result->AsInterface();
- ASSERT_NE(nullptr, interface);
- ASSERT_FALSE(interface->GetMethods().empty());
- EXPECT_EQ(interface->GetMethods()[0]->GetType().IsUtf8InCpp(), is_utf8);
- typenames_.Reset();
- }
+TEST_P(AidlTest, RejectsDuplicatedArgumentNames) {
+ const string method = "package a; interface IFoo { void f(int a, int a); }";
+ const string expected_stderr =
+ "ERROR: a/IFoo.aidl:1.33-35: method 'f' has duplicate argument name 'a'\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, VintfRequiresStructuredAndStability) {
+TEST_P(AidlTest, RejectsDuplicatedFieldNames) {
+ const string method = "package a; parcelable Foo { int a; String a; }";
+ 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, AcceptsEmptyParcelable) {
+ CaptureStderr();
+ EXPECT_NE(nullptr, Parse("Foo.aidl", "parcelable Foo {}", typenames_, GetLanguage()));
+ EXPECT_EQ("", 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";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_P(AidlTest, RejectUnsupportedInterfaceAnnotations) {
AidlError error;
- auto parse_result = Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
- Options::Language::CPP, &error);
- ASSERT_EQ(AidlError::NOT_STRUCTURED, error);
- ASSERT_EQ(nullptr, parse_result);
+ const string method = "package a; @nullable interface IFoo { int f(); }";
+ CaptureStderr();
+ 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_F(AidlTest, VintfRequiresStructured) {
+TEST_P(AidlTest, RejectUnsupportedTypeAnnotations) {
AidlError error;
- auto parse_result = Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
- Options::Language::CPP, &error, {"--stability", "vintf"});
- ASSERT_EQ(AidlError::NOT_STRUCTURED, error);
- ASSERT_EQ(nullptr, parse_result);
+ const string method = "package a; interface IFoo { @JavaOnlyStableParcelable int f(); }";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", method, typenames_, GetLanguage(), &error));
+ EXPECT_THAT(GetCapturedStderr(), HasSubstr("@JavaOnlyStableParcelable is not available."));
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
}
-TEST_F(AidlTest, VintfRequiresSpecifiedStability) {
+TEST_P(AidlTest, RejectUnsupportedParcelableAnnotations) {
AidlError error;
- auto parse_result = Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
- Options::Language::CPP, &error, {"--structured"});
- ASSERT_EQ(AidlError::NOT_STRUCTURED, error);
- ASSERT_EQ(nullptr, parse_result);
+ const string method = "package a; @nullable parcelable IFoo cpp_header \"IFoo.h\";";
+ CaptureStderr();
+ 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_F(AidlTest, ParsesStabilityAnnotations) {
+TEST_P(AidlTest, RejectUnsupportedParcelableDefineAnnotations) {
AidlError error;
+ const string method = "package a; @nullable parcelable IFoo { String a; String b; }";
+ CaptureStderr();
+ 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, ParsesNonNullableAnnotation) {
auto parse_result =
- Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_, Options::Language::CPP,
- &error, {"--structured", "--stability", "vintf"});
+ Parse("a/IFoo.aidl", "package a; interface IFoo { String f(); }", typenames_, GetLanguage());
+ ASSERT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
+ ASSERT_NE(nullptr, interface);
+ ASSERT_FALSE(interface->GetMethods().empty());
+ EXPECT_FALSE(interface->GetMethods()[0]->GetType().IsNullable());
+}
+
+TEST_P(AidlTest, ParsesNullableAnnotation) {
+ auto parse_result = Parse("a/IFoo.aidl", "package a; interface IFoo { @nullable String f(); }",
+ typenames_, GetLanguage());
+ ASSERT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
+ ASSERT_NE(nullptr, interface);
+ ASSERT_FALSE(interface->GetMethods().empty());
+ EXPECT_TRUE(interface->GetMethods()[0]->GetType().IsNullable());
+}
+
+TEST_P(AidlTest, ParsesNonUtf8Annotations) {
+ auto parse_result =
+ Parse("a/IFoo.aidl", "package a; interface IFoo { String f(); }", typenames_, GetLanguage());
+ ASSERT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
+ ASSERT_NE(nullptr, interface);
+ ASSERT_FALSE(interface->GetMethods().empty());
+ EXPECT_FALSE(interface->GetMethods()[0]->GetType().IsUtf8InCpp());
+}
+
+TEST_P(AidlTest, ParsesUtf8Annotations) {
+ auto parse_result = Parse("a/IFoo.aidl", "package a; interface IFoo { @utf8InCpp String f(); }",
+ typenames_, GetLanguage());
+ ASSERT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
+ ASSERT_NE(nullptr, interface);
+ ASSERT_FALSE(interface->GetMethods().empty());
+ EXPECT_TRUE(interface->GetMethods()[0]->GetType().IsUtf8InCpp());
+}
+
+TEST_P(AidlTest, VintfRequiresStructuredAndStability) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: IFoo.aidl:1.16-26: Must compile @VintfStability type w/ aidl_interface 'stability: "
+ "\"vintf\"'\n"
+ "ERROR: IFoo.aidl:1.16-26: Must compile @VintfStability type w/ aidl_interface "
+ "--structured\n";
+ CaptureStderr();
+ ASSERT_EQ(nullptr, Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
+ GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ ASSERT_EQ(AidlError::NOT_STRUCTURED, error);
+}
+
+TEST_P(AidlTest, VintfRequiresStructured) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: IFoo.aidl:1.16-26: Must compile @VintfStability type w/ aidl_interface "
+ "--structured\n";
+ CaptureStderr();
+ ASSERT_EQ(nullptr, Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
+ GetLanguage(), &error, {"--stability", "vintf"}));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ ASSERT_EQ(AidlError::NOT_STRUCTURED, error);
+}
+
+TEST_P(AidlTest, VintfRequiresSpecifiedStability) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: IFoo.aidl:1.16-26: Must compile @VintfStability type w/ aidl_interface 'stability: "
+ "\"vintf\"'\n";
+ CaptureStderr();
+ ASSERT_EQ(nullptr, Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
+ GetLanguage(), &error, {"--structured"}));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ ASSERT_EQ(AidlError::NOT_STRUCTURED, error);
+}
+
+TEST_P(AidlTest, ParsesStabilityAnnotations) {
+ AidlError error;
+ auto parse_result = Parse("IFoo.aidl", "@VintfStability interface IFoo {}", typenames_,
+ GetLanguage(), &error, {"--structured", "--stability", "vintf"});
ASSERT_EQ(AidlError::OK, error);
ASSERT_NE(nullptr, parse_result);
const AidlInterface* interface = parse_result->AsInterface();
ASSERT_NE(nullptr, interface);
ASSERT_TRUE(interface->IsVintfStability());
- typenames_.Reset();
}
TEST_F(AidlTest, ParsesJavaOnlyStableParcelable) {
@@ -366,114 +427,291 @@
Options cpp_options = Options::From("aidl --lang=cpp -o out -h out/include a/Foo.aidl");
Options cpp_structured_options =
Options::From("aidl --lang=cpp --structured -o out -h out/include a/Foo.aidl");
+ Options rust_options = Options::From("aidl --lang=rust -o out --structured a/Foo.aidl");
io_delegate_.SetFileContents(
"a/Foo.aidl",
StringPrintf("package a; @JavaOnlyStableParcelable parcelable Foo cpp_header \"Foo.h\" ;"));
EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
EXPECT_EQ(0, ::android::aidl::compile_aidl(cpp_options, io_delegate_));
- AddExpectedStderr(
+ const string expected_stderr =
"ERROR: a/Foo.aidl:1.48-52: Cannot declared parcelable in a --structured interface. "
- "Parcelable must be defined in AIDL directly.\n");
+ "Parcelable must be defined in AIDL directly.\n";
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(cpp_structured_options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+
+ CaptureStderr();
+ EXPECT_NE(0, ::android::aidl::compile_aidl(rust_options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, AcceptsOneway) {
- string oneway_method = "package a; interface IFoo { oneway void f(int a); }";
- string oneway_interface =
- "package a; oneway interface IBar { void f(int a); }";
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::JAVA));
- typenames_.Reset();
- EXPECT_NE(nullptr, Parse("a/IBar.aidl", oneway_interface, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_NE(nullptr, Parse("a/IBar.aidl", oneway_interface, typenames_, Options::Language::JAVA));
-}
-
-TEST_F(AidlTest, AcceptsAnnotatedOnewayMethod) {
- string oneway_method = "package a; interface IFoo { @UnsupportedAppUsage oneway void f(int a); }";
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::CPP));
- typenames_.Reset();
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, Options::Language::JAVA));
-}
-
-TEST_F(AidlTest, ParsesJavaDeriveAnnotation) {
- io_delegate_.SetFileContents("a/IFoo.aidl", R"(package a;
- @JavaDerive(toString=true) 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, WritesComments) {
- string foo_interface =
- "package a; /* foo */ interface IFoo {"
- " /* i */ int i();"
- " /* j */ @nullable String j();"
- " /* k */ @UnsupportedAppUsage oneway void k(int a); }";
+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());
- auto parse_result = Parse("a/IFoo.aidl", foo_interface, typenames_, Options::Language::JAVA);
+ 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/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/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; @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_));
+ 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."));
+ }
+}
+
+TEST_P(AidlTest, ParseDescriptorAnnotation) {
+ AidlError error;
+ auto parse_result = Parse("IFoo.aidl", R"(@Descriptor(value="IBar") interface IFoo{})",
+ typenames_, GetLanguage(), &error, {"--structured"});
+ ASSERT_EQ(AidlError::OK, error);
+ ASSERT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
+ ASSERT_NE(nullptr, interface);
+ ASSERT_EQ("IBar", interface->GetDescriptor());
+}
+
+TEST_P(AidlTest, AcceptsOnewayMethod) {
+ const string oneway_method = "package a; interface IFoo { oneway void f(int a); }";
+ EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage()));
+}
+
+TEST_P(AidlTest, AcceptsOnewayInterface) {
+ const string oneway_interface = "package a; oneway interface IBar { void f(int a); }";
+ EXPECT_NE(nullptr, Parse("a/IBar.aidl", oneway_interface, typenames_, GetLanguage()));
+}
+
+TEST_P(AidlTest, AcceptsAnnotatedOnewayMethod) {
+ const string oneway_method =
+ "package a; interface IFoo { @UnsupportedAppUsage oneway void f(int a); }";
+ EXPECT_NE(nullptr, Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage()));
+}
+
+TEST_P(AidlTest, AnnotationsInMultiplePlaces) {
+ const string oneway_method =
+ "package a; interface IFoo { @UnsupportedAppUsage oneway @Hide void f(int a); }";
+ const AidlDefinedType* defined = Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage());
+ ASSERT_NE(nullptr, defined);
+ const AidlInterface* iface = defined->AsInterface();
+ ASSERT_NE(nullptr, iface);
+
+ const auto& methods = iface->GetMethods();
+ ASSERT_EQ(1u, methods.size());
+ const auto& method = methods[0];
+ const AidlTypeSpecifier& ret_type = method->GetType();
+
+ // TODO(b/151102494): these annotations should be on the method
+ ASSERT_NE(nullptr, ret_type.UnsupportedAppUsage());
+ ASSERT_TRUE(ret_type.IsHide());
+}
+
+TEST_P(AidlTest, WritesComments) {
+ string foo_interface =
+ 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) {
string simple_content = "parcelable a.Foo;\ninterface b.IBar;";
io_delegate_.SetFileContents("path", simple_content);
- EXPECT_FALSE(typenames_.ResolveTypename("a.Foo").second);
+ EXPECT_FALSE(typenames_.ResolveTypename("a.Foo").is_resolved);
EXPECT_TRUE(parse_preprocessed_file(io_delegate_, "path", &typenames_));
- EXPECT_TRUE(typenames_.ResolveTypename("a.Foo").second);
- EXPECT_TRUE(typenames_.ResolveTypename("b.IBar").second);
+ EXPECT_TRUE(typenames_.ResolveTypename("a.Foo").is_resolved);
+ EXPECT_TRUE(typenames_.ResolveTypename("b.IBar").is_resolved);
}
TEST_F(AidlTest, ParsesPreprocessedFileWithWhitespace) {
string simple_content = "parcelable a.Foo;\n interface b.IBar ;\t";
io_delegate_.SetFileContents("path", simple_content);
- EXPECT_FALSE(typenames_.ResolveTypename("a.Foo").second);
+ EXPECT_FALSE(typenames_.ResolveTypename("a.Foo").is_resolved);
EXPECT_TRUE(parse_preprocessed_file(io_delegate_, "path", &typenames_));
- EXPECT_TRUE(typenames_.ResolveTypename("a.Foo").second);
- EXPECT_TRUE(typenames_.ResolveTypename("b.IBar").second);
+ EXPECT_TRUE(typenames_.ResolveTypename("a.Foo").is_resolved);
+ EXPECT_TRUE(typenames_.ResolveTypename("b.IBar").is_resolved);
}
-TEST_F(AidlTest, PreferImportToPreprocessed) {
+TEST_P(AidlTest, PreferImportToPreprocessed) {
io_delegate_.SetFileContents("preprocessed", "interface another.IBar;");
io_delegate_.SetFileContents("one/IBar.aidl", "package one; "
"interface IBar {}");
preprocessed_files_.push_back("preprocessed");
import_paths_.emplace("");
auto parse_result = Parse("p/IFoo.aidl", "package p; import one.IBar; interface IFoo {}",
- typenames_, Options::Language::JAVA);
+ typenames_, GetLanguage());
EXPECT_NE(nullptr, parse_result);
// We expect to know about both kinds of IBar
- EXPECT_TRUE(typenames_.ResolveTypename("one.IBar").second);
- EXPECT_TRUE(typenames_.ResolveTypename("another.IBar").second);
+ 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());
}
// Special case of PreferImportToPreprocessed. Imported type should be preferred
// even when the preprocessed file already has the same type.
-TEST_F(AidlTest, B147918827) {
+TEST_P(AidlTest, B147918827) {
io_delegate_.SetFileContents("preprocessed", "interface another.IBar;\ninterface one.IBar;");
io_delegate_.SetFileContents("one/IBar.aidl",
"package one; "
@@ -481,14 +719,14 @@
preprocessed_files_.push_back("preprocessed");
import_paths_.emplace("");
auto parse_result = Parse("p/IFoo.aidl", "package p; import one.IBar; interface IFoo {}",
- typenames_, Options::Language::JAVA);
+ typenames_, GetLanguage());
EXPECT_NE(nullptr, parse_result);
// We expect to know about both kinds of IBar
- EXPECT_TRUE(typenames_.ResolveTypename("one.IBar").second);
- EXPECT_TRUE(typenames_.ResolveTypename("another.IBar").second);
+ 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());
}
@@ -513,47 +751,173 @@
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));
+ EXPECT_THAT(output, HasSubstr(test_case.annotation));
+ }
+ };
+
+ // 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"])"}},
+ });
+
+ // 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()\"]"}},
+ });
+
+ // 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_F(AidlTest, RequireOuterClass) {
+TEST_P(AidlTest, RequireOuterClass) {
+ const string expected_stderr = "ERROR: p/IFoo.aidl:1.54-60: Failed to resolve 'Inner'\n";
io_delegate_.SetFileContents("p/Outer.aidl",
"package p; parcelable Outer.Inner;");
import_paths_.emplace("");
- auto parse_result =
- Parse("p/IFoo.aidl", "package p; import p.Outer; interface IFoo { void f(in Inner c); }",
- typenames_, Options::Language::JAVA);
- EXPECT_EQ(nullptr, parse_result);
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
+ "package p; import p.Outer; interface IFoo { void f(in Inner c); }",
+ typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, ParseCompoundParcelableFromPreprocess) {
+TEST_P(AidlTest, ParseCompoundParcelableFromPreprocess) {
io_delegate_.SetFileContents("preprocessed",
"parcelable p.Outer.Inner;");
preprocessed_files_.push_back("preprocessed");
auto parse_result = Parse("p/IFoo.aidl", "package p; interface IFoo { void f(in Inner c); }",
- typenames_, Options::Language::JAVA);
+ typenames_, GetLanguage());
// TODO(wiley): This should actually return nullptr because we require
// the outer class name. However, for legacy reasons,
// this behavior must be maintained. b/17415692
@@ -561,39 +925,63 @@
}
TEST_F(AidlTest, FailOnParcelable) {
+ const string expected_foo_stderr =
+ "ERROR: p/IFoo.aidl:1.22-27: Refusing to generate code with unstructured parcelables. "
+ "Declared parcelables should be in their own file and/or cannot be used with --structured "
+ "interfaces.\n";
io_delegate_.SetFileContents("p/IFoo.aidl", "package p; parcelable IFoo;");
// By default, we shouldn't fail on parcelable.
Options options1 = Options::From("aidl p/IFoo.aidl");
+ CaptureStderr();
EXPECT_EQ(0, ::android::aidl::compile_aidl(options1, io_delegate_));
+ EXPECT_EQ("", GetCapturedStderr());
// -b considers this an error
Options options2 = Options::From("aidl -b p/IFoo.aidl");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options2, io_delegate_));
+ EXPECT_EQ(expected_foo_stderr, GetCapturedStderr());
+ const string expected_bar_stderr =
+ "ERROR: p/IBar.aidl:1.22-26: Refusing to generate code with unstructured parcelables. "
+ "Declared parcelables should be in their own file and/or cannot be used with --structured "
+ "interfaces.\n";
io_delegate_.SetFileContents("p/IBar.aidl", "package p; parcelable Foo; interface IBar{}");
// With '-b' option, a parcelable and an interface should fail.
Options options3 = Options::From("aidl p/IBar.aidl");
+ CaptureStderr();
EXPECT_EQ(0, ::android::aidl::compile_aidl(options3, io_delegate_));
+ EXPECT_EQ("", GetCapturedStderr());
Options options4 = Options::From("aidl -b p/IBar.aidl");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options4, io_delegate_));
+ EXPECT_EQ(expected_bar_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, StructuredFailOnUnstructuredParcelable) {
+TEST_P(AidlTest, StructuredFailOnUnstructuredParcelable) {
+ const string expected_stderr =
+ "ERROR: ./o/WhoKnowsWhat.aidl:1.22-35: o.WhoKnowsWhat is not structured, but this is a "
+ "structured interface.\n";
io_delegate_.SetFileContents("o/WhoKnowsWhat.aidl", "package o; parcelable WhoKnowsWhat;");
import_paths_.emplace("");
- AidlError reported_error;
- auto parse_result =
+ AidlError error;
+ CaptureStderr();
+ EXPECT_EQ(
+ nullptr,
Parse("p/IFoo.aidl",
"package p; import o.WhoKnowsWhat; interface IFoo { void f(in WhoKnowsWhat thisIs); }",
- typenames_, Options::Language::JAVA, &reported_error, {"--structured"});
- EXPECT_EQ(nullptr, parse_result);
- EXPECT_EQ(AidlError::NOT_STRUCTURED, reported_error);
+ typenames_, GetLanguage(), &error, {"--structured"}));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::NOT_STRUCTURED, error);
}
-TEST_F(AidlTest, FailOnDuplicateConstantNames) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnDuplicateConstantNames) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:4.34-45: Found duplicate constant name 'DUPLICATED'\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {
@@ -601,13 +989,65 @@
const int DUPLICATED = 1;
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::BAD_TYPE, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
}
-TEST_F(AidlTest, FailOnManyDefinedTypes) {
- AidlError reported_error;
- AddExpectedStderr("ERROR: p/IFoo.aidl: You must declare only one type per a file.\n");
+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 =
+ "ERROR: p/IFoo.aidl:3.33-38: You must declare only one type per file.\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {}
@@ -615,42 +1055,86 @@
parcelable StructuredParcelable {}
interface IBaz {}
)",
- typenames_, Options::Language::CPP, &reported_error));
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
// Parse success is important for clear error handling even if the cases aren't
// actually supported in code generation.
- EXPECT_EQ(AidlError::BAD_TYPE, reported_error);
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
}
-TEST_F(AidlTest, FailOnNoDefinedTypes) {
- AidlError reported_error;
- EXPECT_EQ(nullptr, Parse("p/IFoo.aidl", R"(package p;)", typenames_, Options::Language::CPP,
- &reported_error));
- EXPECT_EQ(AidlError::PARSE_ERROR, reported_error);
+TEST_P(AidlTest, FailOnNoDefinedTypes) {
+ AidlError error;
+ const string expected_stderr = "ERROR: p/IFoo.aidl:1.11-11: syntax error, unexpected $end\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("p/IFoo.aidl", R"(package p;)", typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
}
-TEST_F(AidlTest, FailOnMalformedConstHexValue) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnEmptyListWithComma) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/Foo.aidl:1.45-47: syntax error, unexpected ',', expecting '}'\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("p/Foo.aidl", R"(package p; parcelable Foo { uint64_t[] a = { , }; })",
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
+}
+
+TEST_P(AidlTest, FailOnMalformedConstHexValue) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:3.50-71: Could not parse hexvalue: 0xffffffffffffffffff\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {
const int BAD_HEX_VALUE = 0xffffffffffffffffff;
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::PARSE_ERROR, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
}
-TEST_F(AidlTest, ParsePositiveConstHexValue) {
- AidlError reported_error;
- auto cpp_parse_result = Parse("p/IFoo.aidl",
- R"(package p;
+TEST_P(AidlTest, FailOnMalformedQualifiedNameAsIdentifier) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:1.25-26: syntax error, unexpected ';', expecting identifier or "
+ "cpp_header (which can also be used as an identifier)\n";
+ CaptureStderr();
+ // Notice the trailing dot(.) in the name, which isn't a correct name
+ EXPECT_EQ(nullptr, Parse("p/IFoo.aidl", R"(package p; parcelable A.; )", typenames_,
+ GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
+}
+
+TEST_P(AidlTest, FailOnMalformedQualifiedNameAsPackage) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:1.11-12: syntax error, unexpected ';', expecting identifier or "
+ "cpp_header (which can also be used as an identifier)\n";
+ CaptureStderr();
+ // Notice the trailing dot(.) in the package name
+ EXPECT_EQ(nullptr, Parse("p/IFoo.aidl", R"(package p.; parcelable A; )", typenames_,
+ GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
+}
+
+TEST_P(AidlTest, ParsePositiveConstHexValue) {
+ AidlError error;
+ auto parse_result = Parse("p/IFoo.aidl",
+ R"(package p;
interface IFoo {
const int POSITIVE_HEX_VALUE = 0xf5;
}
)",
- typenames_, Options::Language::CPP, &reported_error);
- EXPECT_NE(nullptr, cpp_parse_result);
- const AidlInterface* interface = cpp_parse_result->AsInterface();
+ typenames_, GetLanguage(), &error);
+ EXPECT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
ASSERT_NE(nullptr, interface);
const auto& cpp_constants = interface->GetConstantDeclarations();
EXPECT_EQ((size_t)1, cpp_constants.size());
@@ -659,17 +1143,17 @@
EXPECT_EQ("245", cpp_constants[0]->ValueString(cpp::ConstantValueDecorator));
}
-TEST_F(AidlTest, ParseNegativeConstHexValue) {
- AidlError reported_error;
- auto cpp_parse_result = Parse("p/IFoo.aidl",
- R"(package p;
+TEST_P(AidlTest, ParseNegativeConstHexValue) {
+ AidlError error;
+ auto parse_result = Parse("p/IFoo.aidl",
+ R"(package p;
interface IFoo {
const int NEGATIVE_HEX_VALUE = 0xffffffff;
}
)",
- typenames_, Options::Language::CPP, &reported_error);
- ASSERT_NE(nullptr, cpp_parse_result);
- const AidlInterface* interface = cpp_parse_result->AsInterface();
+ typenames_, GetLanguage(), &error);
+ ASSERT_NE(nullptr, parse_result);
+ const AidlInterface* interface = parse_result->AsInterface();
ASSERT_NE(nullptr, interface);
const auto& cpp_constants = interface->GetConstantDeclarations();
EXPECT_EQ((size_t)1, cpp_constants.size());
@@ -678,7 +1162,7 @@
EXPECT_EQ("-1", cpp_constants[0]->ValueString(cpp::ConstantValueDecorator));
}
-TEST_F(AidlTest, UnderstandsNestedParcelables) {
+TEST_P(AidlTest, UnderstandsNestedParcelables) {
io_delegate_.SetFileContents(
"p/Outer.aidl",
"package p; parcelable Outer.Inner cpp_header \"baz/header\";");
@@ -687,48 +1171,35 @@
const string input = "package p; import p.Outer; interface IFoo"
" { Outer.Inner get(); }";
- auto cpp_parse_result = Parse(input_path, input, typenames_, Options::Language::CPP);
- EXPECT_NE(nullptr, cpp_parse_result);
+ auto parse_result = Parse(input_path, input, typenames_, GetLanguage());
+ EXPECT_NE(nullptr, parse_result);
- auto pair = typenames_.ResolveTypename("p.Outer.Inner");
- EXPECT_TRUE(pair.second);
+ 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_));
}
-TEST_F(AidlTest, UnderstandsNativeParcelables) {
+TEST_P(AidlTest, UnderstandsNativeParcelables) {
io_delegate_.SetFileContents(
"p/Bar.aidl",
"package p; parcelable Bar cpp_header \"baz/header\";");
import_paths_.emplace("");
const string input_path = "p/IFoo.aidl";
const string input = "package p; import p.Bar; interface IFoo { }";
- {
- // C++ understands C++ specific stuff
- auto cpp_parse_result = Parse(input_path, input, typenames_, Options::Language::CPP);
- EXPECT_NE(nullptr, cpp_parse_result);
- auto pair = typenames_.ResolveTypename("p.Bar");
- EXPECT_TRUE(pair.second);
- AidlTypeSpecifier native_type(AIDL_LOCATION_HERE, "p.Bar", false, nullptr, "");
- native_type.Resolve(typenames_);
- EXPECT_EQ("::p::Bar", cpp::CppNameOf(native_type, typenames_));
- set<string> headers;
- cpp::AddHeaders(native_type, typenames_, headers);
- EXPECT_EQ(1u, headers.size());
- EXPECT_EQ(1u, headers.count("baz/header"));
- }
- typenames_.Reset();
- {
- // Java ignores C++ specific stuff
- auto java_parse_result = Parse(input_path, input, typenames_, Options::Language::JAVA);
- EXPECT_NE(nullptr, java_parse_result);
- auto pair = typenames_.ResolveTypename("p.Bar");
- EXPECT_TRUE(pair.second);
- AidlTypeSpecifier native_type(AIDL_LOCATION_HERE, "p.Bar", false, nullptr, "");
- native_type.Resolve(typenames_);
- EXPECT_EQ("p.Bar", java::InstantiableJavaSignatureOf(native_type, typenames_));
- }
+ 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, {});
+ native_type.Resolve(typenames_);
+
+ EXPECT_EQ("p.Bar", java::InstantiableJavaSignatureOf(native_type, typenames_));
+ // C++ understands C++ specific stuff
+ EXPECT_EQ("::p::Bar", cpp::CppNameOf(native_type, typenames_));
+ set<string> headers;
+ cpp::AddHeaders(native_type, typenames_, &headers);
+ EXPECT_EQ(1u, headers.size());
+ EXPECT_EQ(1u, headers.count("baz/header"));
}
TEST_F(AidlTest, WritesCorrectDependencyFile) {
@@ -813,38 +1284,155 @@
EXPECT_FALSE(io_delegate_.GetWrittenContents(options.OutputFile(), &output_file_contents));
}
-/* not working until type_namespace.h is fixed
-TEST_F(AidlTest, AcceptsNestedContainerType) {
- string nested_in_iface = "package a; interface IFoo {\n"
- " List<int, List<String, bool>> foo(); }";
- string nested_in_parcelable = "package a; parcelable IData {\n"
- " List<int, List<String, bool>> foo;}";
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", nested_in_iface, typenames_, Options::Language::JAVA));
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", nested_in_iface, typenames_, Options::Language::CPP));
- EXPECT_NE(nullptr, Parse("a/IFoo.aidl", nested_in_parcelable, typenames_,
-Options::Language::JAVA)); EXPECT_NE(nullptr, Parse("a/IFoo.aidl", nested_in_parcelable, typenames_,
-Options::Language::CPP));
+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 =
+ "package a; parcelable Foo {\n"
+ " List[] lists; }";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/Foo.aidl", list_array_parcelable, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-*/
-// TODO(b/136048684)
-TEST_F(AidlTest, PrimitiveList) {
- string primitive_interface =
+TEST_P(AidlTest, RejectsPrimitiveListInStableAidl) {
+ AidlError error;
+ string expected_stderr =
+ "ERROR: a/IFoo.aidl:2.7-11: "
+ "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";
+ if (GetLanguage() != Options::Language::JAVA) {
+ expected_stderr =
+ "ERROR: a/IFoo.aidl:2.1-7: "
+ "Currently, only the Java backend supports non-generic List.\n";
+ }
+
+ const string primitive_interface =
"package a; interface IFoo {\n"
- " List<int> foo(); }";
+ " List foo(); }";
+ CaptureStderr();
+ AidlTypenames tn1;
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", primitive_interface, tn1, GetLanguage(), &error,
+ {"--structured"}));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+
string primitive_parcelable =
- "package a; parcelable IData {\n"
- " List<int> foo;}";
+ "package a; parcelable IFoo {\n"
+ " List foo;}";
+ CaptureStderr();
+ AidlTypenames tn2;
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", primitive_parcelable, tn2, GetLanguage(), &error,
+ {"--structured"}));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_P(AidlTest, ExtensionTest) {
+ CaptureStderr();
+ string extendable_parcelable =
+ "package a; parcelable Data {\n"
+ " ParcelableHolder extension;\n"
+ " ParcelableHolder extension2;\n"
+ "}";
+ 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 Rust backend does not support ParcelableHolder "
+ "yet.\n",
+ GetCapturedStderr());
+ } else {
+ EXPECT_NE(nullptr, Parse("a/Data.aidl", extendable_parcelable, typenames_, GetLanguage()));
+ EXPECT_EQ("", GetCapturedStderr());
+ }
+}
+TEST_P(AidlTest, ParcelableHolderAsReturnType) {
+ CaptureStderr();
+ string parcelableholder_return_interface =
+ "package a; interface IFoo {\n"
+ " ParcelableHolder foo();\n"
+ "}";
EXPECT_EQ(nullptr,
- Parse("a/IFoo.aidl", primitive_interface, typenames_, Options::Language::JAVA));
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", primitive_interface, typenames_, Options::Language::CPP));
- EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", primitive_interface, typenames_, Options::Language::NDK));
+ Parse("a/IFoo.aidl", parcelableholder_return_interface, typenames_, GetLanguage()));
+
+ if (GetLanguage() == Options::Language::RUST) {
+ EXPECT_EQ(
+ "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;
+ }
+ EXPECT_EQ("ERROR: a/IFoo.aidl:2.19-23: ParcelableHolder cannot be a return type\n",
+ GetCapturedStderr());
+}
+
+TEST_P(AidlTest, ParcelableHolderAsArgumentType) {
+ CaptureStderr();
+ string extendable_parcelable_arg_interface =
+ "package a; interface IFoo {\n"
+ " void foo(in ParcelableHolder ph);\n"
+ "}";
EXPECT_EQ(nullptr,
- Parse("a/IFoo.aidl", primitive_parcelable, typenames_, Options::Language::JAVA));
- EXPECT_EQ(nullptr,
- Parse("a/IFoo.aidl", primitive_parcelable, typenames_, Options::Language::CPP));
- EXPECT_EQ(nullptr,
- Parse("a/IFoo.aidl", primitive_parcelable, typenames_, Options::Language::NDK));
+ Parse("a/IFoo.aidl", extendable_parcelable_arg_interface, typenames_, GetLanguage()));
+
+ if (GetLanguage() == Options::Language::RUST) {
+ EXPECT_EQ(
+ "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;
+ }
+ EXPECT_EQ("ERROR: a/IFoo.aidl:2.31-34: ParcelableHolder cannot be an argument type\n",
+ 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) {
@@ -852,15 +1440,20 @@
"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",
@@ -872,11 +1465,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", "");
@@ -887,35 +1478,36 @@
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;
+ 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) {
@@ -944,6 +1536,9 @@
}
TEST_F(AidlTest, ApiDumpWithManualIdsOnlyOnSomeMethods) {
+ const string expected_stderr =
+ "ERROR: foo/bar/IFoo.aidl:4.8-12: You must either assign id's to all methods or to none of "
+ "them.\n";
io_delegate_.SetFileContents(
"foo/bar/IFoo.aidl",
"package foo.bar;\n"
@@ -955,34 +1550,129 @@
vector<string> args = {"aidl", "--dumpapi", "-o dump", "foo/bar/IFoo.aidl"};
Options options = Options::From(args);
+ CaptureStderr();
EXPECT_FALSE(dump_api(options, io_delegate_));
+ 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, ApiDumpWithGenerics) {
+ io_delegate_.SetFileContents("foo/bar/Foo.aidl",
+ "package foo.bar;\n"
+ "parcelable Foo<T, U> {\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<T, U> {\n"
+ "}\n"),
+ actual);
}
TEST_F(AidlTest, CheckNumGenericTypeSecifier) {
+ const string expected_list_stderr =
+ "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");
io_delegate_.SetFileContents(options.InputFiles().front(),
"package p; interface IFoo {"
"void foo(List<String, String> a);}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_list_stderr, GetCapturedStderr());
io_delegate_.SetFileContents(options.InputFiles().front(),
"package p; interface IFoo {"
"void foo(Map<String> a);}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
-
- Options options2 = Options::From("aidl p/Data.aidl Data.java");
- io_delegate_.SetFileContents(options2.InputFiles().front(),
- "package p; parcelable Data {"
- "List<String, String> foo;}");
- EXPECT_NE(0, ::android::aidl::compile_aidl(options2, io_delegate_));
-
- io_delegate_.SetFileContents(options2.InputFiles().front(),
- "package p; parcelable Data {"
- "Map<String> foo;}");
- EXPECT_NE(0, ::android::aidl::compile_aidl(options2, io_delegate_));
+ EXPECT_EQ(expected_map_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, CheckTypeParameterInMapType) {
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:1.28-31: The type of key in map must be String, but it is 'p.Bar'\n";
Options options = Options::From("aidl -I p p/IFoo.aidl");
io_delegate_.SetFileContents("p/Bar.aidl", "package p; parcelable Bar { String s; }");
@@ -994,7 +1684,9 @@
io_delegate_.SetFileContents("p/IFoo.aidl",
"package p; interface IFoo {"
"Map<Bar, Bar> foo();}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
io_delegate_.SetFileContents("p/IFoo.aidl",
"package p; interface IFoo {"
@@ -1008,26 +1700,37 @@
}
TEST_F(AidlTest, WrongGenericType) {
+ const string expected_stderr = "ERROR: p/IFoo.aidl:1.28-34: String is not a generic type.\n";
Options options = Options::From("aidl p/IFoo.aidl IFoo.java");
io_delegate_.SetFileContents(options.InputFiles().front(),
"package p; interface IFoo {"
"String<String> foo(); }");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, UserDefinedUnstructuredGenericParcelableType) {
Options optionsForParcelable = Options::From("aidl -I p p/Bar.aidl");
io_delegate_.SetFileContents("p/Bar.aidl", "package p; parcelable Bar<T, T>;");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(optionsForParcelable, io_delegate_));
+ EXPECT_EQ("ERROR: p/Bar.aidl:1.22-26: Every type parameter should be unique.\n",
+ GetCapturedStderr());
Options options = Options::From("aidl -I p p/IFoo.aidl");
io_delegate_.SetFileContents("p/Bar.aidl", "package p; parcelable Bar;");
io_delegate_.SetFileContents("p/IFoo.aidl",
"package p; interface IFoo {"
"Bar<String, String> foo();}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ("ERROR: p/IFoo.aidl:1.28-31: p.Bar is not a generic type.\n", GetCapturedStderr());
io_delegate_.SetFileContents("p/Bar.aidl", "package p; parcelable Bar<T>;");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ("ERROR: p/IFoo.aidl:1.28-31: p.Bar must have 1 type parameters, but got 2\n",
+ GetCapturedStderr());
io_delegate_.SetFileContents("p/Bar.aidl", "package p; parcelable Bar<T, V>;");
EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
io_delegate_.SetFileContents("p/IFoo.aidl",
@@ -1048,8 +1751,11 @@
TEST_F(AidlTest, FailOnMultipleTypesInSingleFile) {
std::vector<std::string> rawOptions{"aidl --lang=java -o out foo/bar/Foo.aidl",
- "aidl --lang=cpp -o out -h out/include foo/bar/Foo.aidl"};
- for (auto& rawOption : rawOptions) {
+ "aidl --lang=cpp -o out -h out/include foo/bar/Foo.aidl",
+ "aidl --lang=rust -o out foo/bar/Foo.aidl"};
+ for (const auto& rawOption : rawOptions) {
+ string expected_stderr =
+ "ERROR: foo/bar/Foo.aidl:3.1-10: You must declare only one type per file.\n";
Options options = Options::From(rawOption);
io_delegate_.SetFileContents(options.InputFiles().front(),
"package foo.bar;\n"
@@ -1057,25 +1763,37 @@
"interface IFoo2 { int foo(); }\n"
"parcelable Data1 { int a; int b;}\n"
"parcelable Data2 { int a; int b;}\n");
-
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
io_delegate_.SetFileContents(options.InputFiles().front(),
"package foo.bar;\n"
"interface IFoo1 { int foo(); }\n"
"interface IFoo2 { int foo(); }\n");
-
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ expected_stderr = "ERROR: foo/bar/Foo.aidl:3.11-17: You must declare only one type per file.\n";
io_delegate_.SetFileContents(options.InputFiles().front(),
"package foo.bar;\n"
"parcelable Data1 { int a; int b;}\n"
"parcelable Data2 { int a; int b;}\n");
-
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
}
+TEST_P(AidlTest, FailParseOnEmptyFile) {
+ const string contents = "";
+ const string expected_stderr = "ERROR: a/IFoo.aidl:1.1-1: syntax error, unexpected $end\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", contents, typenames_, GetLanguage()));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
TEST_F(AidlTest, MultipleInputFiles) {
Options options = Options::From(
"aidl --lang=java -o out -I . foo/bar/IFoo.aidl foo/bar/Data.aidl");
@@ -1129,26 +1847,68 @@
}
}
-TEST_F(AidlTest, ConflictWithMetaTransactions) {
+TEST_F(AidlTest, MultipleInputFilesRust) {
+ Options options =
+ Options::From("aidl --lang=rust -o out -I . foo/bar/IFoo.aidl foo/bar/Data.aidl");
+
+ io_delegate_.SetFileContents(options.InputFiles().at(0),
+ "package foo.bar;\n"
+ "import foo.bar.Data;\n"
+ "interface IFoo { Data getData(); }\n");
+
+ io_delegate_.SetFileContents(options.InputFiles().at(1),
+ "package foo.bar;\n"
+ "import foo.bar.IFoo;\n"
+ "parcelable Data { IFoo foo; }\n");
+
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+
+ string content;
+ for (const auto file : {"out/foo/bar/IFoo.rs", "out/foo/bar/Data.rs"}) {
+ content.clear();
+ EXPECT_TRUE(io_delegate_.GetWrittenContents(file, &content));
+ EXPECT_FALSE(content.empty());
+ }
+}
+
+TEST_F(AidlTest, ConflictWithMetaTransactionGetVersion) {
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:1.31-51: method getInterfaceVersion() is reserved for internal use.\n";
Options options = Options::From("aidl --lang=java -o place/for/output p/IFoo.aidl");
// int getInterfaceVersion() is one of the meta transactions
io_delegate_.SetFileContents(options.InputFiles().front(),
"package p; interface IFoo {"
"int getInterfaceVersion(); }");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
- // boolean getInterfaceVersion() is not, but should be prevented
- // because return type is not part of a method signature
+TEST_F(AidlTest, ConflictWithSimilarMetaTransaction) {
+ // boolean getInterfaceVersion() is not a meta transaction, but should be
+ // prevented because return type is not part of a method signature
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:1.35-55: method getInterfaceVersion() is reserved for internal use.\n";
+ Options options = Options::From("aidl --lang=java -o place/for/output p/IFoo.aidl");
io_delegate_.SetFileContents(options.InputFiles().front(),
"package p; interface IFoo {"
"boolean getInterfaceVersion(); }");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+TEST_F(AidlTest, ConflictWithMetaTransactionGetName) {
// this is another reserved name
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:1.34-53: method getTransactionName(int) is reserved for internal use.\n";
+ Options options = Options::From("aidl --lang=java -o place/for/output p/IFoo.aidl");
io_delegate_.SetFileContents(options.InputFiles().front(),
"package p; interface IFoo {"
"String getTransactionName(int code); }");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
// this is not a meta interface method as it differs type arguments
io_delegate_.SetFileContents(options.InputFiles().front(),
@@ -1157,6 +1917,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",
@@ -1175,6 +1948,31 @@
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_));
+}
+
+TEST_F(AidlTest, CheckApiEqual_EnumFieldsWithDefaultValues) {
+ Options options = Options::From("aidl --checkapi=equal 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);
+ CaptureStderr();
+ EXPECT_TRUE(::android::aidl::check_api(options, io_delegate_));
+ EXPECT_EQ("", GetCapturedStderr());
+}
+
class AidlTestCompatibleChanges : public AidlTest {
protected:
Options options_ = Options::From("aidl --checkapi old new");
@@ -1210,6 +2008,7 @@
"interface IFoo {"
" void foo(int a);"
" void bar();"
+ " void baz(in List<IFoo> arg);"
"}");
EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
}
@@ -1224,7 +2023,21 @@
"package p;"
"parcelable Data {"
" int foo;"
- " int bar;"
+ " int bar = 0;"
+ " @nullable List<Data> list;"
+ "}");
+ EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
+TEST_F(AidlTestCompatibleChanges, NewField2) {
+ io_delegate_.SetFileContents("old/p/Data.aidl",
+ "package p;"
+ "parcelable Data {"
+ "}");
+ io_delegate_.SetFileContents("new/p/Data.aidl",
+ "package p;"
+ "parcelable Data {"
+ " int foo = 0;"
"}");
EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
}
@@ -1260,6 +2073,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;"
@@ -1328,23 +2156,100 @@
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_));
+}
+
+TEST_F(AidlTestCompatibleChanges, CompatibleExplicitDefaults) {
+ io_delegate_.SetFileContents("old/p/Data.aidl",
+ "package p;\n"
+ "parcelable Data {\n"
+ " p.Enum e;\n"
+ "}");
+ io_delegate_.SetFileContents("old/p/Enum.aidl",
+ "package p;\n"
+ "enum Enum {\n"
+ " FOO = 0,\n"
+ " BAR = 1,\n"
+ "}");
+ io_delegate_.SetFileContents("new/p/Data.aidl",
+ "package p;\n"
+ "parcelable Data {\n"
+ " p.Enum e = p.Enum.FOO;\n"
+ "}");
+ io_delegate_.SetFileContents("new/p/Enum.aidl",
+ "package p;\n"
+ "enum Enum {\n"
+ " FOO = 0,\n"
+ " BAR = 1,\n"
+ "}");
+ EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
class AidlTestIncompatibleChanges : public AidlTest {
protected:
Options options_ = Options::From("aidl --checkapi old new");
};
TEST_F(AidlTestIncompatibleChanges, RemovedType) {
+ const string expected_stderr = "ERROR: old/p/IFoo.aidl:1.11-20: Removed type: p.IFoo\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
" void foo(in String[] str);"
" void bar(@utf8InCpp String str);"
"}");
- io_delegate_.SetFileContents("new/p/IFoo.aidl", "");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, RemovedMethod) {
+ const string expected_stderr =
+ "ERROR: old/p/IFoo.aidl:1.61-65: Removed or changed method: p.IFoo.bar(String)\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1356,10 +2261,60 @@
"interface IFoo {"
" void foo(in String[] str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, UntypedListInInterface) {
+ const string expected_stderr =
+ "ERROR: new/p/IFoo.aidl:1.61-65: "
+ "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: new/p/IFoo.aidl: Failed to read.\n";
+ io_delegate_.SetFileContents("old/p/IFoo.aidl",
+ "package p;"
+ "interface IFoo {"
+ " void foo(in String[] str);"
+ "}");
+ io_delegate_.SetFileContents("new/p/IFoo.aidl",
+ "package p;"
+ "interface IFoo {"
+ " void foo(in String[] str);"
+ " void bar(in List arg);"
+ "}");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestCompatibleChanges, UntypedListInParcelable) {
+ const string expected_stderr =
+ "ERROR: new/p/Data.aidl:1.54-59: "
+ "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: new/p/Data.aidl: Failed to read.\n";
+ io_delegate_.SetFileContents("old/p/Data.aidl",
+ "package p;"
+ "parcelable Data {"
+ " int foo;"
+ "}");
+ io_delegate_.SetFileContents("new/p/Data.aidl",
+ "package p;"
+ "parcelable Data {"
+ " int foo;"
+ " @nullable List list;"
+ "}");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, RemovedField) {
+ const string expected_stderr =
+ "ERROR: new/p/Data.aidl:1.21-26: Number of fields in p.Data is reduced from 2 to 1.\n";
io_delegate_.SetFileContents("old/p/Data.aidl",
"package p;"
"parcelable Data {"
@@ -1371,10 +2326,64 @@
"parcelable Data {"
" int foo;"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ 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";
io_delegate_.SetFileContents("old/p/Enum.aidl",
"package p;"
"enum Enum {"
@@ -1386,10 +2395,33 @@
"enum Enum {"
" BAR = 2,"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ 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";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1402,10 +2434,13 @@
" void foo(in String[] str);"
" void bar2(@utf8InCpp String str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, RenamedType) {
+ const string expected_stderr = "ERROR: old/p/IFoo.aidl:1.11-20: Removed type: p.IFoo\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1418,10 +2453,14 @@
" void foo(in String[] str);"
" void bar(@utf8InCpp String str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, ChangedEnumerator) {
+ const string expected_stderr =
+ "ERROR: new/p/Enum.aidl:1.15-20: Changed enumerator value: p.Enum::FOO from 1 to 3.\n";
io_delegate_.SetFileContents("old/p/Enum.aidl",
"package p;"
"enum Enum {"
@@ -1434,10 +2473,17 @@
" FOO = 3,"
" BAR = 2,"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, ReorderedMethod) {
+ const string expected_stderr =
+ "ERROR: new/p/IFoo.aidl:1.67-71: Transaction ID changed: p.IFoo.foo(String[]) is changed "
+ "from 0 to 1.\n"
+ "ERROR: new/p/IFoo.aidl:1.33-37: Transaction ID changed: p.IFoo.bar(String) is changed from "
+ "1 to 0.\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1450,10 +2496,15 @@
" void bar(@utf8InCpp String str);"
" void foo(in String[] str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, ReorderedField) {
+ const string expected_stderr =
+ "ERROR: new/p/Data.aidl:1.33-37: Reordered bar from 1 to 0.\n"
+ "ERROR: new/p/Data.aidl:1.43-47: Reordered foo from 0 to 1.\n";
io_delegate_.SetFileContents("old/p/Data.aidl",
"package p;"
"parcelable Data {"
@@ -1466,10 +2517,13 @@
" int bar;"
" int foo;"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, ChangedDirectionSpecifier) {
+ const string expected_stderr = "ERROR: new/p/IFoo.aidl:1.33-37: Direction changed: in to out.\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1482,10 +2536,14 @@
" void foo(out String[] str);"
" void bar(@utf8InCpp String str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, AddedAnnotation) {
+ const string expected_stderr =
+ "ERROR: new/p/IFoo.aidl:1.51-58: Changed annotations: (empty) to @utf8InCpp\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1498,10 +2556,14 @@
" void foo(in @utf8InCpp String[] str);"
" void bar(@utf8InCpp String str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, RemovedAnnotation) {
+ const string expected_stderr =
+ "ERROR: new/p/IFoo.aidl:1.66-72: Changed annotations: @utf8InCpp to (empty)\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl",
"package p;"
"interface IFoo {"
@@ -1514,46 +2576,233 @@
" void foo(in String[] str);"
" void bar(String str);"
"}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ 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.32-36: Changed annotations: (empty) to @FixedSize\n";
+ io_delegate_.SetFileContents("old/p/Foo.aidl",
+ "package p;"
+ "parcelable Foo {"
+ " int A;"
+ "}");
+ io_delegate_.SetFileContents("new/p/Foo.aidl",
+ "package p;"
+ "@FixedSize parcelable Foo {"
+ " int A;"
+ "}");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, RemovedParcelableAnnotation) {
+ const string expected_stderr =
+ "ERROR: new/p/Foo.aidl:1.21-25: Changed annotations: @FixedSize to (empty)\n";
+ io_delegate_.SetFileContents("old/p/Foo.aidl",
+ "package p;"
+ "@FixedSize parcelable Foo {"
+ " int A;"
+ "}");
+ io_delegate_.SetFileContents("new/p/Foo.aidl",
+ "package p;"
+ "parcelable Foo {"
+ " int A;"
+ "}");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, RemovedPackage) {
+ const string expected_stderr = "ERROR: old/q/IFoo.aidl:1.11-21: Removed type: q.IFoo\n";
io_delegate_.SetFileContents("old/p/IFoo.aidl", "package p; interface IFoo{}");
io_delegate_.SetFileContents("old/q/IFoo.aidl", "package q; interface IFoo{}");
io_delegate_.SetFileContents("new/p/IFoo.aidl", "package p; interface IFoo{}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, ChangedDefaultValue) {
+ const string expected_stderr = "ERROR: new/p/D.aidl:1.30-32: Changed default value: 1 to 2.\n";
io_delegate_.SetFileContents("old/p/D.aidl", "package p; parcelable D { int a = 1; }");
io_delegate_.SetFileContents("new/p/D.aidl", "package p; parcelable D { int a = 2; }");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, RemovedConstValue) {
+ const string expected_stderr =
+ "ERROR: old/p/I.aidl:1.51-53: Removed constant declaration: p.I.B\n";
io_delegate_.SetFileContents("old/p/I.aidl",
"package p; interface I {"
"const int A = 1; const int B = 2;}");
io_delegate_.SetFileContents("new/p/I.aidl", "package p; interface I { const int A = 1; }");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTestIncompatibleChanges, ChangedConstValue) {
+ const string expected_stderr =
+ "ERROR: new/p/I.aidl:1.11-21: Changed constant value: p.I.A from 1 to 2.\n";
io_delegate_.SetFileContents("old/p/I.aidl", "package p; interface I { const int A = 1; }");
io_delegate_.SetFileContents("new/p/I.aidl", "package p; interface I { const int A = 2; }");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, FixedSizeAddedField) {
+ const string expected_stderr =
+ "ERROR: new/p/Foo.aidl:1.33-37: Number of fields in p.Foo is changed from 1 to 2. "
+ "This is an incompatible change for FixedSize types.\n";
+ io_delegate_.SetFileContents("old/p/Foo.aidl",
+ "package p; @FixedSize parcelable Foo { int A = 1; }");
+ io_delegate_.SetFileContents("new/p/Foo.aidl",
+ "package p; @FixedSize parcelable Foo { int A = 1; int B = 2; }");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, UidRangeParcelAddedField) {
+ const string expected_stderr =
+ "ERROR: new/android/net/UidRangeParcel.aidl:1.32-47: Number of fields in "
+ "android.net.UidRangeParcel is changed from 1 to 2. "
+ "But it is forbidden because of legacy support.\n";
+ io_delegate_.SetFileContents("old/android/net/UidRangeParcel.aidl",
+ "package android.net; parcelable UidRangeParcel { int A = 1; }");
+ io_delegate_.SetFileContents(
+ "new/android/net/UidRangeParcel.aidl",
+ "package android.net; parcelable UidRangeParcel { int A = 1; int B = 2; }");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTestIncompatibleChanges, FixedSizeRemovedField) {
+ const string expected_stderr =
+ "ERROR: new/p/Foo.aidl:1.33-37: Number of fields in p.Foo is reduced from 2 to 1.\n";
+ io_delegate_.SetFileContents("old/p/Foo.aidl",
+ "package p; @FixedSize parcelable Foo { int A = 1; int B = 1; }");
+ io_delegate_.SetFileContents("new/p/Foo.aidl",
+ "package p; @FixedSize parcelable Foo { int A = 1; }");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_P(AidlTest, RejectNonFixedSizeFromFixedSize) {
+ const string expected_stderr =
+ "ERROR: Foo.aidl:1.36-38: The @FixedSize parcelable 'Foo' has a non-fixed size field named "
+ "a.\n"
+ "ERROR: Foo.aidl:1.44-46: The @FixedSize parcelable 'Foo' has a non-fixed size field named "
+ "b.\n"
+ "ERROR: Foo.aidl:1.55-57: The @FixedSize parcelable 'Foo' has a non-fixed size field named "
+ "c.\n"
+ "ERROR: Foo.aidl:1.80-82: The @FixedSize parcelable 'Foo' has a non-fixed size field named "
+ "d.\n"
+ "ERROR: Foo.aidl:1.92-94: The @FixedSize parcelable 'Foo' has a non-fixed size field named "
+ "e.\n"
+ "ERROR: Foo.aidl:1.109-111: The @FixedSize parcelable 'Foo' has a non-fixed size field named "
+ "f.\n";
+
+ io_delegate_.SetFileContents("Foo.aidl",
+ "@FixedSize parcelable Foo { "
+ " int[] a;"
+ " Bar b;"
+ " String c;"
+ " ParcelFileDescriptor d;"
+ " IBinder e;"
+ " List<String> f;"
+ " int isFixedSize;"
+ "}");
+ io_delegate_.SetFileContents("Bar.aidl", "parcelable Bar { int a; }");
+ Options options = Options::From("aidl Foo.aidl -I . --lang=" + to_string(GetLanguage()));
+
+ CaptureStderr();
+ EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_P(AidlTest, AcceptFixedSizeFromFixedSize) {
+ const string expected_stderr = "";
+
+ 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=" + to_string(GetLanguage()));
+
+ CaptureStderr();
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, RejectAmbiguousImports) {
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl: Duplicate files found for q.IBar from:\n"
+ "dir1/q/IBar.aidl\n"
+ "dir2/q/IBar.aidl\n"
+ "ERROR: p/IFoo.aidl: Couldn't find import for class q.IBar\n";
Options options = Options::From("aidl --lang=java -o out -I dir1 -I dir2 p/IFoo.aidl");
io_delegate_.SetFileContents("p/IFoo.aidl", "package p; import q.IBar; interface IFoo{}");
io_delegate_.SetFileContents("dir1/q/IBar.aidl", "package q; interface IBar{}");
io_delegate_.SetFileContents("dir2/q/IBar.aidl", "package q; interface IBar{}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, HandleManualIdAssignments) {
+ const string expected_stderr =
+ "ERROR: new/p/IFoo.aidl:1.32-36: Transaction ID changed: p.IFoo.foo() is changed from 10 to "
+ "11.\n";
Options options = Options::From("aidl --checkapi old new");
io_delegate_.SetFileContents("old/p/IFoo.aidl", "package p; interface IFoo{ void foo() = 10;}");
io_delegate_.SetFileContents("new/p/IFoo.aidl", "package p; interface IFoo{ void foo() = 10;}");
@@ -1561,25 +2810,30 @@
EXPECT_TRUE(::android::aidl::check_api(options, io_delegate_));
io_delegate_.SetFileContents("new/p/IFoo.aidl", "package p; interface IFoo{ void foo() = 11;}");
+ CaptureStderr();
EXPECT_FALSE(::android::aidl::check_api(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
-TEST_F(AidlTest, ParcelFileDescriptorIsBuiltinType) {
- Options javaOptions = Options::From("aidl --lang=java -o out p/IFoo.aidl");
- Options cppOptions = Options::From("aidl --lang=cpp -h out -o out p/IFoo.aidl");
+TEST_P(AidlTest, ParcelFileDescriptorIsBuiltinType) {
+ Options options =
+ Options::From("aidl --lang=" + to_string(GetLanguage()) + " -h out -o out p/IFoo.aidl");
// use without import
io_delegate_.SetFileContents("p/IFoo.aidl",
"package p; interface IFoo{ void foo(in ParcelFileDescriptor fd);}");
- EXPECT_EQ(0, ::android::aidl::compile_aidl(javaOptions, io_delegate_));
- EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_));
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
- // use without impot but with full name
+ // capture output files
+ map<string, string> outputs = io_delegate_.OutputFiles();
+
+ // use without import but with full name
io_delegate_.SetFileContents(
"p/IFoo.aidl",
"package p; interface IFoo{ void foo(in android.os.ParcelFileDescriptor fd);}");
- EXPECT_EQ(0, ::android::aidl::compile_aidl(javaOptions, io_delegate_));
- EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_));
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ // output files should be the same
+ EXPECT_EQ(outputs, io_delegate_.OutputFiles());
// use with import (as before)
io_delegate_.SetFileContents("p/IFoo.aidl",
@@ -1588,8 +2842,34 @@
"interface IFoo{"
" void foo(in ParcelFileDescriptor fd);"
"}");
- EXPECT_EQ(0, ::android::aidl::compile_aidl(javaOptions, io_delegate_));
- EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_));
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ // output files should be the same
+ EXPECT_EQ(outputs, io_delegate_.OutputFiles());
+}
+
+TEST_P(AidlTest, RejectsOutputParcelFileDescriptor) {
+ Options options = Options::From("aidl p/IFoo.aidl -I . --lang=" + to_string(GetLanguage()));
+ CaptureStderr();
+ io_delegate_.SetFileContents("p/IFoo.aidl",
+ "package p;"
+ "interface IFoo{"
+ " void foo(out ParcelFileDescriptor fd);"
+ "}");
+ EXPECT_EQ(1, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_THAT(GetCapturedStderr(), HasSubstr("can't be an out parameter"));
+}
+
+TEST_P(AidlTest, RejectsArgumentDirectionNotSpecified) {
+ Options options = Options::From("aidl p/IFoo.aidl -I . --lang=" + to_string(GetLanguage()));
+ CaptureStderr();
+ io_delegate_.SetFileContents("p/IFoo.aidl",
+ "package p;"
+ "interface IFoo{"
+ " void foo(ParcelFileDescriptor fd);"
+ "}");
+ EXPECT_EQ(1, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_THAT(GetCapturedStderr(),
+ HasSubstr("ParcelFileDescriptor can be an in or inout parameter."));
}
TEST_F(AidlTest, ManualIds) {
@@ -1613,34 +2893,47 @@
}
TEST_F(AidlTest, FailOnDuplicatedIds) {
+ const string expected_stderr =
+ "ERROR: IFoo.aidl:3.7-11: Found duplicate method id (3) for method bar\n";
Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl");
io_delegate_.SetFileContents("IFoo.aidl",
"interface IFoo {\n"
" void foo() = 3;\n"
" void bar() = 3;\n"
"}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, FailOnOutOfRangeIds) {
// 16777115 is kLastMetaMethodId + 1
+ const string expected_stderr =
+ "ERROR: IFoo.aidl:3.7-11: Found out of bounds id (16777115) for method bar. "
+ "Value for id must be between 0 and 16777114 inclusive.\n";
Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl");
io_delegate_.SetFileContents("IFoo.aidl",
"interface IFoo {\n"
" void foo() = 3;\n"
" void bar() = 16777115;\n"
"}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, FailOnPartiallyAssignedIds) {
+ const string expected_stderr =
+ "ERROR: IFoo.aidl:3.7-11: You must either assign id's to all methods or to none of them.\n";
Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl");
io_delegate_.SetFileContents("IFoo.aidl",
"interface IFoo {\n"
" void foo() = 3;\n"
" void bar();\n"
"}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
TEST_F(AidlTest, AllowDuplicatedImportPaths) {
@@ -1651,11 +2944,115 @@
}
TEST_F(AidlTest, FailOnAmbiguousImports) {
+ const string expected_stderr =
+ "ERROR: IFoo.aidl: Duplicate files found for IBar from:\n"
+ "dir/IBar.aidl\n"
+ "dir2/IBar.aidl\n"
+ "ERROR: IFoo.aidl: Couldn't find import for class IBar\n";
+
Options options = Options::From("aidl --lang=java -I dir -I dir2 IFoo.aidl");
io_delegate_.SetFileContents("dir/IBar.aidl", "interface IBar{}");
io_delegate_.SetFileContents("dir2/IBar.aidl", "interface IBar{}");
io_delegate_.SetFileContents("IFoo.aidl", "import IBar; interface IFoo{}");
+ CaptureStderr();
EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+TEST_F(AidlTest, UnusedImportDoesNotContributeInclude) {
+ io_delegate_.SetFileContents("a/b/IFoo.aidl",
+ "package a.b;\n"
+ "import a.b.IBar;\n"
+ "import a.b.IQux;\n"
+ "interface IFoo { IQux foo(); }\n");
+ io_delegate_.SetFileContents("a/b/IBar.aidl", "package a.b; interface IBar { void foo(); }");
+ io_delegate_.SetFileContents("a/b/IQux.aidl", "package a.b; interface IQux { void foo(); }");
+
+ Options options = Options::From("aidl --lang=ndk a/b/IFoo.aidl -I . -o out -h out/include");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+
+ string output;
+ EXPECT_TRUE(io_delegate_.GetWrittenContents("out/include/aidl/a/b/IFoo.h", &output));
+ // IBar was imported but wasn't used. include is not expected.
+ EXPECT_THAT(output, Not(testing::HasSubstr("#include <aidl/a/b/IBar.h>")));
+ // IBar was imported and used. include is expected.
+ EXPECT_THAT(output, (testing::HasSubstr("#include <aidl/a/b/IQux.h>")));
+}
+
+TEST_F(AidlTest, ParseJavaPassthroughAnnotation) {
+ 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, 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 -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));
+ // 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 -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 -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 -I . --lang=rust -o out a/IFoo.aidl a/MyEnum.aidl");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(rust_options, io_delegate_));
+}
+
+TEST_F(AidlTest, ParseRustDerive) {
+ io_delegate_.SetFileContents("a/Foo.aidl", R"(package a;
+ @RustDerive(Clone=true, Copy=false)
+ parcelable Foo {
+ int a;
+ })");
+
+ Options rust_options = Options::From("aidl --lang=rust -o out a/Foo.aidl");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(rust_options, io_delegate_));
+
+ string rust_out;
+ EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.rs", &rust_out));
+ EXPECT_THAT(rust_out, testing::HasSubstr("#[derive(Debug, Clone)]"));
+
+ // Other backends shouldn't be bothered
+ 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/Foo.aidl");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(ndk_options, io_delegate_));
+
+ Options java_options = Options::From("aidl --lang=java -o out a/Foo.aidl");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(java_options, io_delegate_));
}
class AidlOutputPathTest : public AidlTest {
@@ -1692,56 +3089,76 @@
Test(Options::From("aidl sub/dir/foo/bar/IFoo.aidl"), "sub/dir/foo/bar/IFoo.java");
}
-TEST_F(AidlTest, FailOnOutOfBoundsInt32MaxConstInt) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnOutOfBoundsInt32MaxConstInt) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:3.58-69: Invalid type specifier for an int64 literal: int\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {
const int int32_max_oob = 2147483650;
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::BAD_TYPE, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
}
-TEST_F(AidlTest, FailOnOutOfBoundsInt32MinConstInt) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnOutOfBoundsInt32MinConstInt) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:3.58-60: Invalid type specifier for an int64 literal: int\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {
const int int32_min_oob = -2147483650;
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::BAD_TYPE, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
}
-TEST_F(AidlTest, FailOnOutOfBoundsInt64MaxConstInt) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnOutOfBoundsInt64MaxConstInt) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:3.59-86: Could not parse integer: 21474836509999999999999999\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {
const long int64_max_oob = 21474836509999999999999999;
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::PARSE_ERROR, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
}
-TEST_F(AidlTest, FailOnOutOfBoundsInt64MinConstInt) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnOutOfBoundsInt64MinConstInt) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:3.61-87: Could not parse integer: 21474836509999999999999999\n";
+ CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
R"(package p;
interface IFoo {
const long int64_min_oob = -21474836509999999999999999;
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::PARSE_ERROR, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::PARSE_ERROR, error);
}
-TEST_F(AidlTest, FailOnOutOfBoundsAutofilledEnum) {
- AidlError reported_error;
+TEST_P(AidlTest, FailOnOutOfBoundsAutofilledEnum) {
+ AidlError error;
+ const string expected_stderr =
+ "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",
R"(package p;
@Backing(type="byte")
@@ -1750,8 +3167,871 @@
BAR,
}
)",
- typenames_, Options::Language::CPP, &reported_error));
- EXPECT_EQ(AidlError::BAD_TYPE, reported_error);
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
+}
+
+TEST_P(AidlTest, UnsupportedBackingAnnotationParam) {
+ 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";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("p/TestEnum.aidl",
+ R"(package p;
+ @Backing(foo="byte")
+ enum TestEnum {
+ FOO = 1,
+ BAR,
+ }
+ )",
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
+}
+
+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; }");
+ io_delegate_.SetFileContents("Bar.aidl", "@JavaOnlyImmutable parcelable Bar { String a; }");
+ io_delegate_.SetFileContents("Baz.aidl",
+ "@JavaOnlyImmutable @JavaOnlyStableParcelable parcelable Baz;");
+ Options options = Options::From("aidl --lang=java -I . Foo.aidl");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+}
+
+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_F(AidlTest, JavaOnlyImmutableParcelableWithEnumFields) {
+ io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable parcelable Foo { Bar bar; }");
+ io_delegate_.SetFileContents("Bar.aidl", "enum Bar { FOO }");
+ CaptureStderr();
+ Options options = Options::From("aidl --lang=java Foo.aidl -I .");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ("", GetCapturedStderr());
+}
+
+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 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_F(AidlTest, ImmutableParcelableCannotBeOut) {
+ io_delegate_.SetFileContents("Foo.aidl", "@JavaOnlyImmutable parcelable Foo { int a; }");
+ 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_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.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=" + 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");
+ CaptureStderr();
+ EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr("syntax error, unexpected '<'"));
+}
+
+TEST_F(AidlTest, NullableArraysAreNotSupported) {
+ io_delegate_.SetFileContents("a/Bar.aidl",
+ "package a; parcelable Bar { String @nullable [] a; }");
+
+ Options options = Options::From("aidl a/Bar.aidl -I . -o out --lang=java");
+ CaptureStderr();
+ EXPECT_EQ(1, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr("Annotations for arrays are not supported."));
+}
+
+TEST_F(AidlTest, ListOfNullablesAreNotSupported) {
+ io_delegate_.SetFileContents("a/Bar.aidl",
+ "package a; parcelable Bar { List<@nullable String> a; }");
+
+ Options options = Options::From("aidl a/Bar.aidl -I . -o out --lang=java");
+ CaptureStderr();
+ EXPECT_EQ(1, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_THAT(GetCapturedStderr(),
+ testing::HasSubstr("Annotations for type arguments are not supported."));
+}
+
+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=" + to_string(GetLanguage()));
+ const string expected_stderr =
+ "ERROR: Foo.aidl:1.11-15: Every type parameter should be unique.\n";
+ CaptureStderr();
+ EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
+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=" + 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;
+ auto writer = CodeWriter::ForString(&code);
+ DumpVisitor visitor(*writer);
+ visitor.Visit(*enum_type);
+ writer->Close();
+ 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, RejectsIncorrectOutputFilePathOnLegacyCppInput) {
+ const std::string input_file = "base/p/q/IFoo.aidl";
+ const std::string header_dir = "out/";
+ const std::string output_file = "out/base/p/q/IFoo.cpp";
+ const std::string package = "p.q"; // not base.p.q
+ io_delegate_.SetFileContents(input_file, "package " + package + "; interface IFoo {}");
+
+ auto options = Options::From({"aidl-cpp", input_file, header_dir, output_file});
+ CaptureStderr();
+ EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+ EXPECT_THAT(
+ GetCapturedStderr(),
+ testing::StartsWith(
+ "ERROR: base/p/q/IFoo.aidl:1.13-23: Output file is expected to be at out/p/q/IFoo.cpp, "
+ "but is out/base/p/q/IFoo.cpp."));
+}
+
+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"}, {"primitiveArray", "int[]"},
+ {"String", "String"}, {"StringArray", "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_primitiveArray", "List of arrays is not supported."},
+ {"java_primitiveArray", "List of arrays is not supported."},
+ {"ndk_primitiveArray", "List of arrays is not supported."},
+ {"rust_primitiveArray", "List of arrays is not supported."},
+ {"cpp_String", ""},
+ {"java_String", ""},
+ {"ndk_String", ""},
+ {"rust_String", ""},
+ {"cpp_StringArray", "List of arrays is not supported."},
+ {"java_StringArray", "List of arrays is not supported."},
+ {"ndk_StringArray", "List of arrays is not supported."},
+ {"rust_StringArray", "List of arrays is not supported."},
+ {"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_primitiveArray", "Can only have one dimensional arrays."},
+ {"java_primitiveArray", "Can only have one dimensional arrays."},
+ {"ndk_primitiveArray", "Can only have one dimensional arrays."},
+ {"rust_primitiveArray", "Can only have one dimensional arrays."},
+ {"cpp_String", ""},
+ {"java_String", ""},
+ {"ndk_String", ""},
+ {"rust_String", ""},
+ {"cpp_StringArray", "Can only have one dimensional arrays."},
+ {"java_StringArray", "Can only have one dimensional arrays."},
+ {"ndk_StringArray", "Can only have one dimensional arrays."},
+ {"rust_StringArray", "Can only have one dimensional arrays."},
+ {"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
diff --git a/ast_cpp.cpp b/ast_cpp.cpp
index 98566fb..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"
@@ -41,36 +43,44 @@
to->Write("%s", expression_.c_str());
}
-ClassDecl::ClassDecl(const std::string& name, const std::string& parent)
- : name_(name),
- parent_(parent) {}
+ClassDecl::ClassDecl(const std::string& name, const std::string& parent,
+ 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)) {}
void ClassDecl::Write(CodeWriter* to) const {
- to->Write("class %s ", name_.c_str());
+ if (!template_params_.empty())
+ to->Write("template <typename %s>\n", base::Join(template_params_, ", typename ").c_str());
- if (parent_.length() > 0)
- to->Write(": public %s ", parent_.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());
to->Write("{\n");
- if (!public_members_.empty())
- to->Write("public:\n");
+ if (!public_members_.empty()) to->Write("public:\n");
to->Indent();
for (const auto& dec : public_members_)
dec->Write(to);
to->Dedent();
- if (!private_members_.empty())
- to->Write("private:\n");
+ if (!private_members_.empty()) to->Write("private:\n");
to->Indent();
for (const auto& dec : private_members_)
@@ -88,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 {
@@ -107,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)
@@ -186,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),
@@ -222,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");
@@ -285,17 +303,20 @@
body_.Write(to);
}
-MethodImpl::MethodImpl(const string& return_type,
- const string& class_name,
- const string& method_name,
- ArgList&& arg_list,
- bool is_const_method)
+MethodImpl::MethodImpl(const string& return_type, const string& class_name,
+ const string& method_name, const std::vector<std::string>& template_params,
+ ArgList&& arg_list, bool is_const_method)
: return_type_(return_type),
method_name_(method_name),
arguments_(std::move(arg_list)),
- is_const_method_(is_const_method) {
+ is_const_method_(is_const_method),
+ template_params_(template_params) {
if (!class_name.empty()) {
- method_name_ = class_name + "::" + method_name;
+ if (!template_params.empty()) {
+ method_name_ = class_name + "<" + base::Join(template_params, ",") + ">::" + method_name;
+ } else {
+ method_name_ = class_name + "::" + method_name;
+ }
}
}
@@ -304,6 +325,8 @@
}
void MethodImpl::Write(CodeWriter* to) const {
+ if (!template_params_.empty())
+ to->Write("template <typename %s>\n", base::Join(template_params_, ", typename ").c_str());
to->Write("%s %s", return_type_.c_str(), method_name_.c_str());
arguments_.Write(to);
to->Write("%s ", (is_const_method_) ? " const" : "");
@@ -316,7 +339,7 @@
StatementBlock* SwitchStatement::AddCase(const string& value_expression) {
auto it = std::find(case_values_.begin(), case_values_.end(), value_expression);
if (it != case_values_.end()) {
- LOG(ERROR) << "internal error: duplicate switch case labels";
+ AIDL_ERROR(value_expression) << "Duplicate switch case labels";
return nullptr;
}
StatementBlock* ret = new StatementBlock();
@@ -457,18 +480,14 @@
}
}
-CppHeader::CppHeader(const std::string& include_guard, const std::vector<std::string>& include_list,
+CppHeader::CppHeader(const std::vector<std::string>& include_list,
std::vector<std::unique_ptr<Declaration>> declarations)
- : Document(include_list, std::move(declarations)), include_guard_(include_guard) {}
+ : Document(include_list, std::move(declarations)) {}
void CppHeader::Write(CodeWriter* to) const {
- to->Write("#ifndef %s\n", include_guard_.c_str());
- to->Write("#define %s\n\n", include_guard_.c_str());
+ to->Write("#pragma once\n\n");
Document::Write(to);
- to->Write("\n");
-
- to->Write("#endif // %s\n", include_guard_.c_str());
}
CppSource::CppSource(const std::vector<std::string>& include_list,
diff --git a/ast_cpp.h b/ast_cpp.h
index 635519d..ca5105c 100644
--- a/ast_cpp.h
+++ b/ast_cpp.h
@@ -20,8 +20,6 @@
#include <string>
#include <vector>
-#include <android-base/macros.h>
-
namespace android {
namespace aidl {
class CodeWriter;
@@ -36,6 +34,13 @@
public:
AstNode() = default;
virtual ~AstNode() = default;
+
+ // All ast nodes are non-copyable and non-movable
+ AstNode(const AstNode&) = delete;
+ AstNode(AstNode&&) = delete;
+ AstNode& operator=(const AstNode&) = delete;
+ AstNode& operator=(AstNode&&) = delete;
+
virtual void Write(CodeWriter* to) const = 0;
std::string ToString();
}; // class AstNode
@@ -44,9 +49,6 @@
public:
Declaration() = default;
virtual ~Declaration() = default;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Declaration);
}; // class Declaration
class LiteralDecl : public Declaration {
@@ -57,18 +59,17 @@
private:
const std::string expression_;
-
- DISALLOW_COPY_AND_ASSIGN(LiteralDecl);
}; // class LiteralDecl
class ClassDecl : public Declaration {
public:
- ClassDecl(const std::string& name,
- const std::string& parent);
- ClassDecl(const std::string& name,
- const std::string& parent,
+ ClassDecl(const std::string& name, const std::string& parent,
+ 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,35 +80,37 @@
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_;
-
- DISALLOW_COPY_AND_ASSIGN(ClassDecl);
}; // class ClassDecl
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_;
-
- DISALLOW_COPY_AND_ASSIGN(Enum);
}; // class Enum
class ArgList : public AstNode {
@@ -123,8 +126,6 @@
private:
std::vector<std::unique_ptr<AstNode>> arguments_;
-
- DISALLOW_COPY_AND_ASSIGN(ArgList);
}; // class ArgList
class ConstructorDecl : public Declaration {
@@ -149,8 +150,6 @@
const std::string name_;
const ArgList arguments_;
const uint32_t modifiers_;
-
- DISALLOW_COPY_AND_ASSIGN(ConstructorDecl);
}; // class ConstructorDecl
class MacroDecl : public Declaration {
@@ -163,8 +162,6 @@
private:
const std::string name_;
const ArgList arguments_;
-
- DISALLOW_COPY_AND_ASSIGN(MacroDecl);
}; // class MacroDecl
class MethodDecl : public Declaration {
@@ -178,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;
@@ -192,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;
@@ -199,8 +194,6 @@
bool is_pure_virtual_ = false;
bool is_static_ = true;
bool is_final_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(MethodDecl);
}; // class MethodDecl
class StatementBlock : public Declaration {
@@ -217,8 +210,6 @@
private:
std::vector<std::unique_ptr<AstNode>> statements_;
-
- DISALLOW_COPY_AND_ASSIGN(StatementBlock);
}; // class StatementBlock
class ConstructorImpl : public Declaration {
@@ -238,19 +229,15 @@
ArgList arguments_;
std::vector<std::string> initializer_list_;
StatementBlock body_;
-
- DISALLOW_COPY_AND_ASSIGN(ConstructorImpl);
}; // class ConstructorImpl
class MethodImpl : public Declaration {
public:
// Passing an empty class name causes the method to be declared as a normal
// function (ie. no ClassName:: qualifier).
- MethodImpl(const std::string& return_type,
- const std::string& class_name,
- const std::string& method_name,
- ArgList&& arg_list,
- bool is_const_method = false);
+ MethodImpl(const std::string& return_type, const std::string& class_name,
+ const std::string& method_name, const std::vector<std::string>& template_params,
+ ArgList&& arg_list, bool is_const_method = false);
virtual ~MethodImpl() = default;
// MethodImpl retains ownership of the statement block.
@@ -264,8 +251,7 @@
const ArgList arguments_;
StatementBlock statements_;
bool is_const_method_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(MethodImpl);
+ std::vector<std::string> template_params_;
}; // class MethodImpl
class SwitchStatement : public AstNode {
@@ -285,8 +271,6 @@
const std::string switch_expression_;
std::vector<std::string> case_values_;
std::vector<std::unique_ptr<StatementBlock>> case_logic_;
-
- DISALLOW_COPY_AND_ASSIGN(SwitchStatement);
}; // class SwitchStatement
class Assignment : public AstNode {
@@ -299,8 +283,6 @@
private:
const std::string lhs_;
std::unique_ptr<AstNode> rhs_;
-
- DISALLOW_COPY_AND_ASSIGN(Assignment);
}; // class Assignment
class MethodCall : public AstNode {
@@ -314,8 +296,6 @@
private:
const std::string method_name_;
const ArgList arguments_;
-
- DISALLOW_COPY_AND_ASSIGN(MethodCall);
}; // class MethodCall
class IfStatement : public AstNode {
@@ -332,8 +312,6 @@
bool invert_expression_ = false;
StatementBlock on_true_;
StatementBlock on_false_;
-
- DISALLOW_COPY_AND_ASSIGN(IfStatement);
}; // class IfStatement
class Statement : public AstNode {
@@ -346,8 +324,6 @@
private:
std::unique_ptr<AstNode> expression_;
-
- DISALLOW_COPY_AND_ASSIGN(Statement);
}; // class Statement
class Comparison : public AstNode {
@@ -360,8 +336,6 @@
std::unique_ptr<AstNode> left_;
std::unique_ptr<AstNode> right_;
const std::string operator_;
-
- DISALLOW_COPY_AND_ASSIGN(Comparison);
}; // class Comparison
class LiteralExpression : public AstNode {
@@ -372,8 +346,6 @@
private:
const std::string expression_;
-
- DISALLOW_COPY_AND_ASSIGN(LiteralExpression);
}; // class LiteralExpression
class CppNamespace : public Declaration {
@@ -390,8 +362,6 @@
private:
std::vector<std::unique_ptr<Declaration>> declarations_;
std::string name_;
-
- DISALLOW_COPY_AND_ASSIGN(CppNamespace);
}; // class CppNamespace
class Document : public AstNode {
@@ -404,29 +374,19 @@
private:
std::vector<std::string> include_list_;
std::vector<std::unique_ptr<Declaration>> declarations_;
-
- DISALLOW_COPY_AND_ASSIGN(Document);
}; // class Document
class CppHeader final : public Document {
public:
- CppHeader(const std::string& include_guard, const std::vector<std::string>& include_list,
+ CppHeader(const std::vector<std::string>& include_list,
std::vector<std::unique_ptr<Declaration>> declarations);
void Write(CodeWriter* to) const override;
-
- private:
- const std::string include_guard_;
-
- DISALLOW_COPY_AND_ASSIGN(CppHeader);
}; // class CppHeader
class CppSource final : public Document {
public:
CppSource(const std::vector<std::string>& include_list,
std::vector<std::unique_ptr<Declaration>> declarations);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CppSource);
}; // class CppSource
} // namespace cpp
diff --git a/ast_cpp_unittest.cpp b/ast_cpp_unittest.cpp
index c8f1937..0efdbcd 100644
--- a/ast_cpp_unittest.cpp
+++ b/ast_cpp_unittest.cpp
@@ -30,9 +30,9 @@
namespace cpp {
namespace {
+// clang-format off
const char kExpectedHeaderOutput[] =
-R"(#ifndef HEADER_INCLUDE_GUARD_H_
-#define HEADER_INCLUDE_GUARD_H_
+ R"(#pragma once
#include <string>
#include <memory>
@@ -55,10 +55,30 @@
} // namespace test
} // namespace android
-
-#endif // HEADER_INCLUDE_GUARD_H_
)";
+const char kExpectedGenericHeaderOutput[] =
+ R"(#pragma once
+
+#include <string>
+#include <memory>
+
+namespace android {
+
+namespace test {
+
+template <typename A, typename B>
+class TestParcelable : public ::android::Parcelable {
+public:
+ int a;
+}; // class TestParcelable
+
+} // namespace test
+
+} // namespace android
+)";
+// clang-format on
+
const char kExpectedSwitchOutput[] =
R"(switch (var) {
case 2:
@@ -76,7 +96,14 @@
)";
const char kExpectedMethodImplOutput[] =
-R"(return_type ClassName::MethodName(arg 1, arg 2, arg 3) const {
+ R"(return_type ClassName::MethodName(int32_t a, int32_t b, int32_t* c) const {
+ foo;
+ bar;
+}
+)";
+const char kExpectedGenericMethodImplOutput[] =
+ R"(template <typename T>
+return_type ClassName<T>::MethodName(int32_t a, int32_t b, int32_t* c) const {
foo;
bar;
}
@@ -113,11 +140,10 @@
vector<unique_ptr<Declaration>> test_sub_methods;
test_sub_methods.push_back(std::move(sub2));
- unique_ptr<Declaration> test{new ClassDecl { "TestClass", "",
- std::move(test_methods), {} }};
+ unique_ptr<Declaration> test{new ClassDecl{"TestClass", "", {}, std::move(test_methods), {}}};
- unique_ptr<Declaration> test_sub{new ClassDecl { "TestSubClass",
- "TestClass", std::move(test_sub_methods), {} }};
+ unique_ptr<Declaration> test_sub{
+ new ClassDecl{"TestSubClass", "TestClass", {}, std::move(test_sub_methods), {}}};
vector<unique_ptr<Declaration>> classes;
classes.push_back(std::move(test));
@@ -135,10 +161,34 @@
vector<unique_ptr<Declaration>> test_ns_globals;
test_ns_globals.push_back(std::move(android_ns));
- CppHeader cpp_header{"HEADER_INCLUDE_GUARD_H_", {"string", "memory"}, std::move(test_ns_globals)};
+ CppHeader cpp_header{{"string", "memory"}, std::move(test_ns_globals)};
CompareGeneratedCode(cpp_header, kExpectedHeaderOutput);
}
+TEST_F(AstCppTests, GeneratesGenericHeader) {
+ const std::vector<std::string> type_params = {"A", "B"};
+ std::vector<std::unique_ptr<Declaration>> publics;
+ publics.emplace_back(new LiteralDecl("int a;\n"));
+ unique_ptr<Declaration> test{new ClassDecl{
+ "TestParcelable", "::android::Parcelable", type_params, std::move(publics), {}}};
+
+ vector<unique_ptr<Declaration>> classes;
+ classes.push_back(std::move(test));
+
+ unique_ptr<CppNamespace> test_ns{new CppNamespace{"test", std::move(classes)}};
+
+ vector<unique_ptr<Declaration>> test_ns_vec;
+ test_ns_vec.push_back(std::move(test_ns));
+
+ unique_ptr<CppNamespace> android_ns{new CppNamespace{"android", std::move(test_ns_vec)}};
+
+ vector<unique_ptr<Declaration>> test_ns_globals;
+ test_ns_globals.push_back(std::move(android_ns));
+
+ CppHeader cpp_header{{"string", "memory"}, std::move(test_ns_globals)};
+ CompareGeneratedCode(cpp_header, kExpectedGenericHeaderOutput);
+}
+
TEST_F(AstCppTests, GeneratesUnscopedEnum) {
Enum e("Foo", "", false);
e.AddValue("BAR", "42");
@@ -249,8 +299,11 @@
}
TEST_F(AstCppTests, GeneratesMethodImpl) {
- MethodImpl m{"return_type", "ClassName", "MethodName",
- ArgList{{"arg 1", "arg 2", "arg 3"}},
+ MethodImpl m{"return_type",
+ "ClassName",
+ "MethodName",
+ {},
+ ArgList{{"int32_t a", "int32_t b", "int32_t* c"}},
true};
auto b = m.GetStatementBlock();
b->AddLiteral("foo");
@@ -258,6 +311,19 @@
CompareGeneratedCode(m, kExpectedMethodImplOutput);
}
+TEST_F(AstCppTests, GeneratesGenericMethodImpl) {
+ MethodImpl m{"return_type",
+ "ClassName",
+ "MethodName",
+ {"T"},
+ ArgList{{"int32_t a", "int32_t b", "int32_t* c"}},
+ true};
+ auto b = m.GetStatementBlock();
+ b->AddLiteral("foo");
+ b->AddLiteral("bar");
+ CompareGeneratedCode(m, kExpectedGenericMethodImplOutput);
+}
+
TEST_F(AstCppTests, ToString) {
std::string literal = "void foo() {}";
LiteralDecl decl(literal);
diff --git a/ast_java.cpp b/ast_java.cpp
index f997494..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());
}
@@ -108,6 +111,9 @@
Variable::Variable(const string& t, const string& n) : type(t), name(n) {}
void Variable::WriteDeclaration(CodeWriter* to) const {
+ for (const auto& a : this->annotations) {
+ to->Write("%s ", a.c_str());
+ }
to->Write("%s %s", this->type.c_str(), this->name.c_str());
}
@@ -326,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());
@@ -378,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/ast_java.h b/ast_java.h
index d037d97..d4e8944 100644
--- a/ast_java.h
+++ b/ast_java.h
@@ -77,7 +77,6 @@
void Write(CodeWriter* to) const override;
};
-// TODO: also escape the contents. not needed for now
struct StringLiteralExpression : public Expression {
std::string value;
@@ -87,6 +86,7 @@
};
struct Variable : public Expression {
+ std::vector<std::string> annotations;
const std::string type;
std::string name;
diff --git a/build/Android.bp b/build/Android.bp
index d537196..53cf9db 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -12,21 +12,39 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "system_tools_aidl_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
bootstrap_go_package {
name: "aidl-soong-rules",
pkgPath: "android/soong/aidl",
deps: [
"blueprint",
"soong",
+ "soong-apex",
"soong-android",
"soong-cc",
"soong-genrule",
"soong-phony",
"soong-java",
+ "soong-rust",
],
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",
@@ -40,22 +58,23 @@
}
// 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 {
name: "aidl-java-module-defaults",
}
+rust_defaults {
+ name: "aidl-rust-module-defaults",
+}
+
// Tests
filegroup {
@@ -67,22 +86,13 @@
],
}
-// Copy of test-piece-1 as test only. Creating a separate library because 'vendor_available' is
-// contagious.
-aidl_interface {
- name: "test-variants",
- unstable: true,
- local_include_dir: "tests_1",
- vendor_available: true,
- host_supported: true,
- srcs: [
- ":aidl-test-filegroup",
- ],
-}
-
aidl_interface {
name: "test-piece-1",
local_include_dir: "tests_1",
+ vendor_available: true,
+ double_loadable: true,
+ host_supported: true,
+ flags: ["-Werror"],
srcs: [
"tests_1/some_package/IFoo.aidl",
"tests_1/some_package/Thing.aidl",
@@ -98,6 +108,7 @@
aidl_interface {
name: "test-piece-2",
local_include_dir: "tests_1",
+ flags: ["-Werror"],
srcs: [
"tests_1/INoPackage.aidl",
"tests_1/some_package/IBar.aidl",
@@ -105,43 +116,128 @@
imports: [
"test-piece-1",
],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ },
+ gen_trace: true,
versions: ["1"],
}
aidl_interface {
name: "test-piece-3",
local_include_dir: "tests_1",
+ flags: ["-Werror"],
srcs: [
"tests_1/other_package/IBaz.aidl",
],
imports: [
"test-piece-2",
],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ },
+ gen_trace: true,
versions: ["1"],
}
aidl_interface {
name: "test-piece-4",
local_include_dir: "tests_2",
+ flags: ["-Werror"],
srcs: [
"tests_2/another_package/IFaz.aidl",
],
imports: [
"test-piece-1",
],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ },
+ gen_trace: true,
versions: ["1"],
+ dumpapi: {
+ no_license: true,
+ },
}
aidl_interface {
name: "test-root-package",
+ flags: ["-Werror"],
srcs: [
"test_package/IBaz.aidl",
],
imports: [
"test-piece-2",
],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ },
+ gen_trace: true,
versions: [
"1",
"2",
],
}
+
+aidl_interface {
+ name: "test-piece-5",
+ unstable: true,
+ local_include_dir: "tests_3",
+ flags: ["-Werror"],
+ srcs: [
+ "tests_3/EmptyParcelable.aidl",
+ "tests_3/IEmptyInterface.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",
+ flags: ["-Werror"],
+ 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",
+ flags: ["-Werror"],
+ srcs: [ "tests_transitive_parcel/b/*.aidl" ],
+ imports: [ "tests_transitive_parcel.c" ],
+ unstable: true,
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
+}
+
+aidl_interface {
+ name: "tests_transitive_parcel.c",
+ flags: ["-Werror"],
+ srcs: [ "tests_transitive_parcel/c/*.aidl" ],
+ unstable: true,
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
+}
diff --git a/build/Android.mk b/build/Android.mk
deleted file mode 100644
index e50f702..0000000
--- a/build/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2019 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.
-#
-
-.PHONY: aidl-freeze-api
-aidl-freeze-api: $(addsuffix -freeze-api, $(SOONG_ALL_AIDL_INTERFACES))
diff --git a/build/aidl_api.go b/build/aidl_api.go
new file mode 100644
index 0000000..2798374
--- /dev/null
+++ b/build/aidl_api.go
@@ -0,0 +1,485 @@
+// 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
+ ImportsWithoutVersion []string
+ Versions []string
+ Dumpapi DumpApiProperties
+}
+
+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, m.properties.AidlRoot)
+
+ 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)
+ }
+ if proptools.Bool(m.properties.Dumpapi.No_license) {
+ optionalFlags = append(optionalFlags, "--no_license")
+ }
+
+ 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, latestVersionDump *apiDump) android.WritablePath {
+ creatingNewVersion := version != currentVersion
+ moduleDir := android.PathForModuleSrc(ctx).String()
+ targetDir := filepath.Join(moduleDir, m.apiDir(), version)
+ rb := android.NewRuleBuilder(pctx, ctx)
+
+ if creatingNewVersion {
+ // We are asked to create a new version. But before doing that, check if the given
+ // dump is the same as the latest version. If so, don't create a new version,
+ // otherwise we will be unnecessarily creating many versions. `newVersionNeededFile`
+ // is created when the equality check fails.
+ newVersionNeededFile := android.PathForModuleOut(ctx, "updateapi_"+version+".needed")
+ rb.Command().Text("rm -f " + newVersionNeededFile.String())
+
+ if latestVersionDump != nil {
+ equalityCheckCommand := rb.Command()
+ equalityCheckCommand.BuiltTool("aidl").
+ FlagWithArg("--checkapi=", "equal")
+ if m.properties.Stability != nil {
+ equalityCheckCommand.FlagWithArg("--stability ", *m.properties.Stability)
+ }
+ equalityCheckCommand.
+ Text(latestVersionDump.dir.String()).Implicits(latestVersionDump.files).
+ Text(dump.dir.String()).Implicits(dump.files).
+ Text("&> /dev/null")
+ equalityCheckCommand.
+ Text("|| touch").
+ Text(newVersionNeededFile.String())
+ } else {
+ // If there is no latest version (i.e. we are creating the initial version)
+ // create the new version unconditionally
+ rb.Command().Text("touch").Text(newVersionNeededFile.String())
+ }
+
+ // Copy the given dump to the target directory only when the equality check failed
+ // (i.e. `newVersionNeededFile` exists).
+ rb.Command().
+ Text("if [ -f " + newVersionNeededFile.String() + " ]; then").
+ Text("cp -rf " + dump.dir.String() + "/. " + targetDir).Implicits(dump.files).
+ Text("; fi")
+
+ // Also modify Android.bp file to add the new version to the 'versions' property.
+ rb.Command().
+ Text("if [ -f " + newVersionNeededFile.String() + " ]; then").
+ BuiltTool("bpmodify").
+ Text("-w -m " + m.properties.BaseName).
+ Text("-parameter versions -a " + version).
+ Text(android.PathForModuleSrc(ctx, "Android.bp").String()).
+ Text("; fi")
+
+ } else {
+ // We are updating the current version. Don't copy .hash to the current dump
+ rb.Command().Text("mkdir -p " + targetDir)
+ rb.Command().Text("rm -rf " + targetDir + "/*")
+ rb.Command().Text("cp -rf " + dump.dir.String() + "/* " + targetDir).Implicits(dump.files)
+ }
+
+ timestampFile := android.PathForModuleOut(ctx, "updateapi_"+version+".timestamp")
+ 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
+}
+
+type depTag struct {
+ blueprint.BaseDependencyTag
+ name string
+}
+
+var (
+ apiDep = depTag{name: "api"}
+ interfaceDep = depTag{name: "interface"}
+
+ importApiDep = depTag{name: "imported-api"}
+ importInterfaceDep = depTag{name: "imported-interface"}
+)
+
+// calculates import flags(-I) from deps.
+// When the target is ToT, use ToT of imported interfaces. If not, we use "current" snapshot of
+// imported interfaces.
+func getImportsFromDeps(ctx android.ModuleContext, targetIsToT bool) (importPaths []string, implicits android.Paths) {
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ switch ctx.OtherModuleDependencyTag(dep) {
+ case importInterfaceDep:
+ iface := dep.(*aidlInterface)
+ if proptools.Bool(iface.properties.Unstable) || targetIsToT {
+ importPaths = append(importPaths, iface.properties.Full_import_paths...)
+ } else {
+ // use "current" snapshot from stable "imported" modules
+ currentDir := filepath.Join(ctx.OtherModuleDir(dep), aidlApiDir, iface.BaseModuleName(), currentVersion)
+ importPaths = append(importPaths, currentDir)
+ // TODO(b/189288369) this should be transitive
+ importPaths = append(importPaths, iface.properties.Include_dirs...)
+ }
+ case interfaceDep:
+ iface := dep.(*aidlInterface)
+ importPaths = append(importPaths, iface.properties.Include_dirs...)
+ case importApiDep, apiDep:
+ api := dep.(*aidlApi)
+ // add imported module's checkapiTimestamps as implicits to make sure that imported apiDump is up-to-date
+ implicits = append(implicits, api.checkApiTimestamps.Paths()...)
+ implicits = append(implicits, api.checkHashTimestamps.Paths()...)
+ }
+ })
+ return
+}
+
+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)
+ }
+ }
+ var latestVersionDump *apiDump
+ if len(dumps) >= 1 {
+ latestVersionDump = &dumps[len(dumps)-1]
+ }
+ 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, nil)
+
+ // 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, latestVersionDump)
+}
+
+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.ImportsWithoutVersion, 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,
+ ImportsWithoutVersion: concat(i.properties.ImportsWithoutVersion, []string{i.ModuleBase.Name()}),
+ Versions: i.properties.Versions,
+ Dumpapi: i.properties.Dumpapi,
+ })
+ return apiModule
+}
+
+func init() {
+ android.RegisterSingletonType("aidl-freeze-api", freezeApiSingletonFactory)
+}
+
+func freezeApiSingletonFactory() android.Singleton {
+ return &freezeApiSingleton{}
+}
+
+type freezeApiSingleton struct{}
+
+func (f *freezeApiSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+ var files android.Paths
+ ctx.VisitAllModules(func(module android.Module) {
+ if !module.Enabled() {
+ return
+ }
+ if m, ok := module.(*aidlApi); ok {
+ files = append(files, m.freezeApiTimestamp)
+ }
+ })
+ ctx.Phony("aidl-freeze-api", files...)
+}
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..d8a5be9 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
@@ -16,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package some_package;
+@SuppressWarnings(value={"inout-parameter"})
interface IFoo {
void CanYouDealWithThisThing(inout some_package.Thing parcel);
void CanYouDealWithThisSubThing(inout some_package.sub_package.SubThing parcel);
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..179f166 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
@@ -16,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package some_package.sub_package;
+@SuppressWarnings(value={"inout-parameter"})
interface IFoo {
void CanYouDealWithThisThing(inout some_package.Thing parcel);
void CanYouDealWithThisSubThing(inout some_package.sub_package.SubThing parcel);
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..2eed6a7 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
@@ -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
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..51e0abe 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
@@ -16,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package test_package;
+@SuppressWarnings(value={"mixed-oneway", "inout-parameter", "out-array"})
interface IBaz {
oneway void CanYouDealWithThisBar(in some_package.IBar bar);
void MethodAddedInVersion2();
diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go
new file mode 100644
index 0000000..f944617
--- /dev/null
+++ b/build/aidl_gen_rule.go
@@ -0,0 +1,294 @@
+// 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
+ IsToT bool
+ ImportsWithoutVersion []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, g.properties.AidlRoot)
+
+ if ctx.Failed() {
+ return
+ }
+
+ genDirTimestamp := android.PathForModuleGen(ctx, "timestamp") // $out/gen/timestamp
+ g.implicitInputs = append(g.implicitInputs, genDirTimestamp)
+
+ importPaths, implicits := getImportsFromDeps(ctx, g.properties.IsToT)
+ imports = append(imports, importPaths...)
+
+ g.importFlags = strings.Join(wrap("-I", imports, ""), " ")
+
+ 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,
+ Implicits: implicits,
+ Inputs: srcs,
+ Output: genDirTimestamp,
+ Args: map[string]string{
+ "outDir": g.genOutDir.String(),
+ },
+ })
+
+ // This is to trigger genrule alone
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Phony,
+ Output: android.PathForModuleOut(ctx, "timestamp"), // $out/timestamp
+ Inputs: g.genOutputs.Paths(),
+ })
+}
+
+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) {
+ // original interface
+ ctx.AddDependency(ctx.Module(), interfaceDep, g.properties.BaseName+aidlInterfaceSuffix)
+
+ if !proptools.Bool(g.properties.Unstable) {
+ // for checkapi timestamps
+ ctx.AddDependency(ctx.Module(), apiDep, g.properties.BaseName+aidlApiSuffix)
+ }
+
+ // imported interfaces
+ ctx.AddDependency(ctx.Module(), importInterfaceDep, wrap("", g.properties.ImportsWithoutVersion, aidlInterfaceSuffix)...)
+
+ 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 240a0c6..251d0d6 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -17,19 +17,18 @@
import (
"android/soong/android"
"android/soong/cc"
- "android/soong/genrule"
"android/soong/java"
"android/soong/phony"
+ "android/soong/rust"
"fmt"
- "io"
"path/filepath"
+ "regexp"
+ "sort"
"strconv"
"strings"
"sync"
- "github.com/google/blueprint"
- "github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
)
@@ -42,112 +41,46 @@
langJava = "java"
langNdk = "ndk"
langNdkPlatform = "ndk_platform"
+ langRust = "rust"
currentVersion = "current"
)
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")
-
- 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")
-
- 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() {
+ pctx.Import("android/soong/android")
pctx.HostBinToolVariable("aidlCmd", "aidl")
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(registerPreDepsMutators)
+ android.PreArchBp2BuildMutators(registerPreDepsMutators)
android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("checkUnstableModule", checkUnstableModuleMutator).Parallel()
+ ctx.BottomUp("recordVersions", recordVersions).Parallel()
+ ctx.BottomUp("checkDuplicatedVersions", checkDuplicatedVersions).Parallel()
})
}
+func registerPreDepsMutators(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("checkImports", checkImports).Parallel()
+ ctx.TopDown("createAidlInterface", createAidlInterfaceMutator).Parallel()
+}
+
+func createAidlInterfaceMutator(mctx android.TopDownMutatorContext) {
+ if g, ok := mctx.Module().(*aidlImplementationGenerator); ok {
+ g.GenerateImplementation(mctx)
+ }
+}
+
func checkUnstableModuleMutator(mctx android.BottomUpMutatorContext) {
+ // If it is an aidl interface, we don't need to check its dependencies.
+ if isAidlModule(mctx.ModuleName(), mctx.Config()) {
+ return
+ }
mctx.VisitDirectDepsIf(func(m android.Module) bool {
return android.InList(m.Name(), *unstableModules(mctx.Config()))
}, func(m android.Module) {
@@ -160,41 +93,162 @@
return
}
- mctx.ModuleErrorf(m.Name() + " is disallowed in release version because it is unstable.")
+ mctx.ModuleErrorf(m.Name() + " is disallowed in release version because it is unstable, and its \"owner\" property is missing.")
})
}
-// 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
+func isAidlModule(moduleName string, config android.Config) bool {
+ for _, i := range *aidlInterfaces(config) {
+ if android.InList(moduleName, i.internalModuleNames) {
+ return true
+ }
}
- return ret
+ return false
}
-// concat(a...) = sum((i for i in a), [])
-func concat(sstrs ...[]string) []string {
- var ret []string
- for _, v := range sstrs {
- ret = append(ret, v...)
+func recordVersions(mctx android.BottomUpMutatorContext) {
+ switch mctx.Module().(type) {
+ case *java.Library:
+ case *cc.Module:
+ case *rust.Module:
+ case *aidlGenRule:
+ default:
+ return
}
- return ret
+
+ isAidlModule := isAidlModule(mctx.ModuleName(), mctx.Config())
+
+ // First, gather all the AIDL interfaces modules that are directly or indirectly
+ // depended on by this module
+ myAidlDeps := make(map[DepInfo]bool)
+ mctx.VisitDirectDeps(func(dep android.Module) {
+ switch dep.(type) {
+ 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)
+ 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, isSource}] = true
+ break
+ }
+ }
+ // If dep is in aidlDeps, that means dep has direct or indirect dependencies to AIDL interfaces
+ // That becomes this module's aidlDeps as well
+ aidlDepsMutex.RLock()
+ if depsOfDep, ok := aidlDeps(mctx.Config())[dep]; ok {
+ for _, d := range depsOfDep {
+ myAidlDeps[d] = true
+ }
+ }
+ aidlDepsMutex.RUnlock()
+ })
+
+ if len(myAidlDeps) == 0 {
+ // This should be usual case.
+ return
+ }
+
+ // Then, record the aidl deps of this module to the global map so that it can be used by
+ // next runs of this mutator for the modules that depend on this module.
+ var list []DepInfo
+ for d := range myAidlDeps {
+ list = append(list, d)
+ }
+ aidlDepsMutex.Lock()
+ aidlDeps(mctx.Config())[mctx.Module()] = list
+ aidlDepsMutex.Unlock()
}
-func getPaths(ctx android.ModuleContext, rawSrcs []string) (paths android.Paths, imports []string) {
- srcs := android.PathsForModuleSrc(ctx, rawSrcs)
+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 -> 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]
+ if versions == nil {
+ versions = make(map[string][]string)
+ 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
+ })
+ }
+ }
+ }
+}
+
+func getPaths(ctx android.ModuleContext, rawSrcs []string, root string) (srcs android.Paths, imports []string) {
+ // TODO(b/189288369): move this to android.PathsForModuleSrcSubDir(ctx, srcs, subdir)
+ for _, src := range rawSrcs {
+ if m, _ := android.SrcIsModuleWithTag(src); m != "" {
+ srcs = append(srcs, android.PathsForModuleSrc(ctx, []string{src})...)
+ } else {
+ srcs = append(srcs, android.PathsWithModuleSrcSubDir(ctx, android.PathsForModuleSrc(ctx, []string{src}), root)...)
+ }
+ }
if len(srcs) == 0 {
ctx.PropertyErrorf("srcs", "No sources provided.")
}
+ // gather base directories from input .aidl files
for _, src := range srcs {
if src.Ext() != ".aidl" {
// Silently ignore non-aidl files as some filegroups have both java and aidl files together
continue
}
baseDir := strings.TrimSuffix(src.String(), src.Rel())
+ baseDir = strings.TrimSuffix(baseDir, "/")
if baseDir != "" && !android.InList(baseDir, imports) {
imports = append(imports, baseDir)
}
@@ -211,563 +265,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]
- BaseName string
- GenLog bool
- Version string
- GenTrace bool
- Unstable *bool
-}
-
-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 {
- 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 {
- 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().DefaultAppTargetSdkInt() != android.FutureApiLevel
- 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 + "/ ").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
@@ -778,6 +275,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 {
@@ -791,13 +293,37 @@
cc.VndkProperties
}
+type DumpApiProperties struct {
+ // Dumps without license header (assuming it is the first comment in .aidl file). Default: false
+ No_license *bool
+}
+
type aidlInterfaceProperties struct {
// 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
+
// Whether the library can be used on host
Host_supported *bool
@@ -815,8 +341,12 @@
// List of aidl_interface modules that this uses. If one of your AIDL interfaces uses an
// interface or parcelable from another aidl_interface, you should put its name here.
+ // It could be an aidl_interface solely or with version(such as -V1)
Imports []string
+ // List of aidl_interface modules that this uses. It trims version suffix in 'Imports' field.
+ ImportsWithoutVersion []string `blueprint:"mutated"`
+
// Used by gen dependency to fill out aidl include path
Full_import_paths []string `blueprint:"mutated"`
@@ -834,6 +364,7 @@
Backend struct {
// Backend of the compiler generating code for Java clients.
+ // When enabled, this creates a target called "<name>-java".
Java struct {
CommonBackendProperties
// Set to the version of the sdk to compile against
@@ -845,19 +376,41 @@
}
// Backend of the compiler generating code for C++ clients using
// libbinder (unstable C++ interface)
+ // When enabled, this creates a target called "<name>-cpp".
Cpp struct {
CommonNativeBackendProperties
}
// Backend of the compiler generating code for C++ clients using
// libbinder_ndk (stable C interface to system's libbinder)
+ // When enabled, this creates a target called "<name>-ndk"
+ // (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".
+ Rust struct {
+ CommonBackendProperties
}
}
// 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
+
+ // --dumpapi options
+ Dumpapi DumpApiProperties
}
type aidlInterface struct {
@@ -866,6 +419,9 @@
properties aidlInterfaceProperties
computedTypes []string
+
+ // list of module names that are created for this interface
+ internalModuleNames []string
}
func (i *aidlInterface) shouldGenerateJavaBackend() bool {
@@ -883,6 +439,18 @@
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
+}
+
func (i *aidlInterface) gatherInterface(mctx android.LoadHookContext) {
aidlInterfaces := aidlInterfaces(mctx.Config())
aidlInterfaceMutex.Lock()
@@ -897,31 +465,56 @@
*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 _, anImportWithVersion := range i.properties.Imports {
+ anImport, version := parseModuleWithVersion(anImportWithVersion)
+ 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 version != "" {
+ candidateVersions := concat(other.properties.Versions, []string{other.nextVersion()})
+ if !android.InList(version, candidateVersions) {
+ mctx.PropertyErrorf("imports", "%q depends on %q version %q(%q), which doesn't exist. The version must be one of %q", i.ModuleBase.Name(), anImport, version, anImportWithVersion, candidateVersions)
+ }
+ }
+ 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)
+ }
}
}
}
+func (i *aidlInterface) checkGenTrace(mctx android.LoadHookContext) {
+ if !proptools.Bool(i.properties.Gen_trace) {
+ return
+ }
+ if i.shouldGenerateJavaBackend() && !proptools.Bool(i.properties.Backend.Java.Platform_apis) {
+ mctx.PropertyErrorf("gen_trace", "must be false when Java backend is enabled and platform_apis is false")
+ }
+}
+
func (i *aidlInterface) checkStability(mctx android.LoadHookContext) {
if i.properties.Stability == nil {
return
@@ -939,27 +532,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 {
@@ -968,79 +600,39 @@
}
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
}
-func (i *aidlInterface) isCurrentVersion(ctx android.LoadHookContext, version string) bool {
- return version == i.currentVersion(ctx)
+func hasVersionSuffix(moduleName string) bool {
+ hasVersionSuffix, _ := regexp.MatchString("-V\\d+$", moduleName)
+ return hasVersionSuffix
}
-// 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
-func (i *aidlInterface) versionedName(ctx android.LoadHookContext, version string) string {
- name := i.ModuleBase.Name()
- if version == "" {
- return name
+func parseModuleWithVersion(moduleName string) (string, string) {
+ if hasVersionSuffix(moduleName) {
+ versionIdx := strings.LastIndex(moduleName, "-V")
+ if versionIdx == -1 {
+ panic("-V must exist in this context")
+ }
+ return moduleName[:versionIdx], moduleName[versionIdx+len("-V"):]
}
- if i.isCurrentVersion(ctx, version) {
- return name + "-unstable"
- }
- return name + "-V" + version
+ return moduleName, ""
}
-// 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-V1
-func (i *aidlInterface) cppOutputName(version string) string {
- name := i.ModuleBase.Name()
- // Even if the module doesn't have version, it returns with version(-V1)
- if !i.hasVersion() {
- // 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 i.isCurrentVersion(mctx, version) {
- 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 trimVersionSuffixInList(moduleNames []string) []string {
+ return wrapFunc("", moduleNames, "", func(moduleName string) string {
+ moduleNameWithoutVersion, _ := parseModuleWithVersion(moduleName)
+ return moduleNameWithoutVersion
+ })
}
func aidlInterfaceHook(mctx android.LoadHookContext, i *aidlInterface) {
+ if hasVersionSuffix(i.ModuleBase.Name()) {
+ mctx.PropertyErrorf("name", "aidl_interface should not have '-V<number> suffix")
+ }
+ i.properties.ImportsWithoutVersion = trimVersionSuffixInList(i.properties.Imports)
if !isRelativePath(i.properties.Local_include_dir) {
mctx.PropertyErrorf("local_include_dir", "must be relative path: "+i.properties.Local_include_dir)
}
@@ -1053,296 +645,124 @@
i.gatherInterface(mctx)
i.checkStability(mctx)
i.checkVersions(mctx)
+ i.checkVndkUseVersion(mctx)
+ i.checkGenTrace(mctx)
if mctx.Failed() {
return
}
var libs []string
+ sdkIsFinal := !mctx.Config().DefaultAppTargetSdk(mctx).IsPreview()
- currentVersion := i.currentVersion(mctx)
+ unstable := proptools.Bool(i.properties.Unstable)
- versionsForCpp := make([]string, len(i.properties.Versions))
-
- sdkIsFinal := mctx.Config().DefaultAppTargetSdkInt() != android.FutureApiLevel
-
- 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 needToCheckUnstableVersion {
- addUnstableModule(mctx, unstableLib)
- }
- libs = append(libs, unstableLib)
- for _, version := range versionsForCpp {
- addCppLibrary(mctx, i, version, langCpp)
- }
- }
-
- if i.shouldGenerateNdkBackend() {
- if !proptools.Bool(i.properties.Vendor_available) {
- unstableLib := addCppLibrary(mctx, i, currentVersion, langNdk)
- if needToCheckUnstableVersion {
- addUnstableModule(mctx, unstableLib)
- }
- libs = append(libs, unstableLib)
- for _, version := range versionsForCpp {
- addCppLibrary(mctx, i, version, langNdk)
- }
- }
- // TODO(b/121157555): combine with '-ndk' variant
- unstableLib := addCppLibrary(mctx, i, currentVersion, langNdkPlatform)
- if needToCheckUnstableVersion {
- addUnstableModule(mctx, unstableLib)
- }
- libs = append(libs, unstableLib)
- for _, version := range versionsForCpp {
- 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 needToCheckUnstableVersion {
- addUnstableModule(mctx, unstableLib)
- }
- libs = append(libs, unstableLib)
- for _, version := range versionsForJava {
- addJavaLibrary(mctx, i, version)
- }
- }
-
- if proptools.Bool(i.properties.Unstable) {
+ if unstable {
if i.hasVersion() {
mctx.PropertyErrorf("versions", "cannot have versions for an unstable interface")
+ return
}
+ if i.properties.Stability != nil {
+ mctx.ModuleErrorf("unstable:true and stability:%q cannot happen at the same time", i.properties.Stability)
+ return
+ }
+ }
+
+ // Two different types of 'unstable' here
+ // - 'unstable: true' meaning the module is never stable
+ // - current unfrozen ToT version
+ //
+ // OEM branches may remove 'i.Owner()' here to apply the check to all interfaces, in
+ // addition to core platform interfaces. Otherwise, we rely on vts_treble_vintf_vendor_test.
+ requireFrozenVersion := !unstable && sdkIsFinal && i.Owner() == ""
+
+ // surface error early, main check is via checkUnstableModuleMutator
+ if requireFrozenVersion && !i.hasVersion() {
+ mctx.PropertyErrorf("versions", "must be set (need to be frozen) when \"unstable\" is false, PLATFORM_VERSION_CODENAME is REL, and \"owner\" property is missing.")
+ }
+
+ 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
+ }
+ libs = append(libs, addLibrary(mctx, i, nextVersion, lang))
+ if requireFrozenVersion {
+ addUnstableModule(mctx, libs[len(libs)-1])
+ }
+ for _, version := range versions {
+ libs = append(libs, addLibrary(mctx, i, version, lang))
+ }
+ }
+
+ if unstable {
apiDirRoot := filepath.Join(aidlApiDir, i.ModuleBase.Name())
aidlDumps, _ := mctx.GlobWithDeps(filepath.Join(mctx.ModuleDir(), apiDirRoot, "**/*.aidl"), nil)
if len(aidlDumps) != 0 {
mctx.PropertyErrorf("unstable", "The interface is configured as unstable, "+
"but API dumps exist under %q. Unstable interface cannot have dumps.", apiDirRoot)
}
- if i.properties.Stability != nil {
- mctx.ModuleErrorf("unstable:true and stability:%q cannot happen at the same time", i.properties.Stability)
- }
} else {
- sdkIsFinal := mctx.Config().DefaultAppTargetSdkInt() != android.FutureApiLevel
- if sdkIsFinal && !i.hasVersion() && i.Owner() == "" {
- mctx.PropertyErrorf("versions", "must be set (need to be frozen) when \"unstable\" is false and PLATFORM_VERSION_CODENAME is REL.")
- }
addApiModule(mctx, i)
}
+ if proptools.Bool(i.properties.VndkProperties.Vndk.Enabled) {
+ if "vintf" != proptools.String(i.properties.Stability) {
+ mctx.PropertyErrorf("stability", "must be \"vintf\" if the module is for VNDK.")
+ }
+ }
+
// Reserve this module name for future use
mctx.CreateModule(phony.PhonyFactory, &phonyProperties{
- Name: proptools.StringPtr(i.ModuleBase.Name()),
- Required: libs,
+ Name: proptools.StringPtr(i.ModuleBase.Name()),
})
+
+ i.internalModuleNames = libs
}
-func addCppLibrary(mctx android.LoadHookContext, i *aidlInterface, version string, lang string) string {
- cppSourceGen := i.versionedName(mctx, version) + "-" + lang + "-source"
- cppModuleGen := i.versionedName(mctx, version) + "-" + lang
- cppOutputGen := i.cppOutputName(version) + "-" + lang
- if i.hasVersion() && version == "" {
- version = i.latestVersion()
+func (i *aidlInterface) commonBackendProperties(lang string) CommonBackendProperties {
+ switch lang {
+ case langCpp:
+ return i.properties.Backend.Cpp.CommonBackendProperties
+ case langJava:
+ return i.properties.Backend.Java.CommonBackendProperties
+ case langNdk, langNdkPlatform:
+ return i.properties.Backend.Ndk.CommonBackendProperties
+ case langRust:
+ return i.properties.Backend.Rust.CommonBackendProperties
+ default:
+ panic(fmt.Errorf("unsupported language backend %q\n", 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 ""
- }
+}
- // For an interface with no versions, this is the ToT interface.
- // For an interface w/ versions, this is that latest version.
- isLatest := !i.hasVersion() || version == i.latestVersion()
-
- var overrideVndkProperties cc.VndkProperties
- if !isLatest {
- // 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,
- })
-
- importExportDependencies := wrap("", i.properties.Imports, "-"+lang)
- var libJSONCppDependency []string
- var staticLibDependency []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 {
- importExportDependencies = append(importExportDependencies, "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"}
- }
- 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"}
- }
- hostSupported = i.properties.Host_supported
- addCflags = append(addCflags, "-DBINDER_STABILITY_SUPPORT")
- minSdkVersion = i.properties.Backend.Ndk.Min_sdk_version
+// 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 {
- panic("Unrecognized language: " + lang)
+ if proptools.Bool(a.commonBackendProperties(lang).Srcs_available) {
+ // 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
+ }
}
-
- 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)
+ 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",
}
-
- mctx.CreateModule(cc.LibraryFactory, &ccProperties{
- Name: proptools.StringPtr(cppModuleGen),
- Vendor_available: vendorAvailable,
- Host_supported: hostSupported,
- Defaults: []string{"aidl-cpp-module-defaults"},
- 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: importExportDependencies,
- 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,
- }, &i.properties.VndkProperties, &commonProperties.VndkProperties, &overrideVndkProperties)
-
- return cppModuleGen
-}
-
-func addJavaLibrary(mctx android.LoadHookContext, i *aidlInterface, version string) string {
- javaSourceGen := i.versionedName(mctx, version) + "-java-source"
- javaModuleGen := i.versionedName(mctx, version) + "-java"
- if i.hasVersion() && version == "" {
- version = i.latestVersion()
- }
- 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,
- Unstable: i.properties.Unstable,
- })
-
- 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, "-java"),
- Srcs: []string{":" + javaSourceGen},
- Apex_available: i.properties.Backend.Java.Apex_available,
- Min_sdk_version: i.properties.Backend.Java.Min_sdk_version,
- })
-
- return javaModuleGen
-}
-
-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 {
@@ -1358,16 +778,16 @@
}
}
func (i *aidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) {
- i.checkImports(ctx)
-
ctx.AddReverseDependency(ctx.Module(), nil, aidlMetadataSingletonName)
}
var (
aidlInterfacesKey = android.NewOnceKey("aidlInterfaces")
unstableModulesKey = android.NewOnceKey("unstableModules")
+ aidlDepsKey = android.NewOnceKey("aidlDeps")
aidlInterfaceMutex sync.Mutex
unstableModuleMutex sync.Mutex
+ aidlDepsMutex sync.RWMutex
)
func aidlInterfaces(config android.Config) *[]*aidlInterface {
@@ -1382,6 +802,26 @@
}).(*[]string)
}
+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 {
+ return config.Once(aidlDepsKey, func() interface{} {
+ return make(map[android.Module][]DepInfo)
+ }).(map[android.Module][]DepInfo)
+}
+
func aidlInterfaceFactory() android.Module {
i := &aidlInterface{}
i.AddProperties(&i.properties)
@@ -1398,165 +838,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..79b6625
--- /dev/null
+++ b/build/aidl_interface_backends.go
@@ -0,0 +1,453 @@
+// 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,
+ IsToT: version == i.nextVersion(),
+ ImportsWithoutVersion: i.properties.ImportsWithoutVersion,
+ 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.flagsForAidlGenRule(version),
+ })
+
+ 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,
+ IsToT: version == i.nextVersion(),
+ ImportsWithoutVersion: i.properties.ImportsWithoutVersion,
+ 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.flagsForAidlGenRule(version),
+ })
+
+ 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,
+ ImportsWithoutVersion: i.properties.ImportsWithoutVersion,
+ IsToT: version == i.nextVersion(),
+ Stability: i.properties.Stability,
+ Lang: langRust,
+ BaseName: i.ModuleBase.Name(),
+ Version: i.versionForAidlGenRule(version),
+ Unstable: i.properties.Unstable,
+ Visibility: srcsVisibility(mctx, langRust),
+ Flags: i.flagsForAidlGenRule(version),
+ })
+
+ 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,
+ Apex_available: i.properties.Backend.Rust.Apex_available,
+ 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()
+ if version == "" {
+ return name
+ }
+ return name + "-V" + version
+}
+
+func (i *aidlInterface) srcsForVersion(mctx android.LoadHookContext, version string) (srcs []string, aidlRoot string) {
+ 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 ""
+ }
+ return version
+}
+
+func (i *aidlInterface) flagsForAidlGenRule(version string) (flags []string) {
+ flags = append(flags, i.properties.Flags...)
+ // For ToT, turn on "-Weverything" (enable all warnings)
+ if version == i.nextVersion() {
+ flags = append(flags, "-Weverything")
+ }
+ return
+}
+
+func (i *aidlInterface) isModuleForVndk(version string) bool {
+ 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
+// In the case that import specifies the version which it wants to use, use that version.
+func (i *aidlInterface) getImportWithVersion(version string, anImport string, config android.Config) string {
+ if hasVersionSuffix(anImport) {
+ return anImport
+ }
+ 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())
+}
+
+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..84fd834
--- /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.WritablePath
+}
+
+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")
+
+ 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..596285e
--- /dev/null
+++ b/build/aidl_mapping.go
@@ -0,0 +1,90 @@
+// 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"
+
+ "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)
+}
+
+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())
+ },
+ }
+}
diff --git a/build/aidl_rust_glue.py b/build/aidl_rust_glue.py
new file mode 100755
index 0000000..ef31c3b
--- /dev/null
+++ b/build/aidl_rust_glue.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python3
+
+#
+# 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.
+#
+
+import argparse
+import collections
+import os
+import pathlib
+import sys
+
+class RustModule:
+ def __init__(self):
+ self.files = []
+ self.nested = collections.defaultdict(RustModule)
+
+ def emit(self, output_file, indent=""):
+ for (input_name, input_path) in self.files:
+ output_file.write(indent)
+ output_file.write("pub mod %s {\n" % input_name)
+ # Copy the contents of the input file into the output
+ with open(input_path, "r") as input_file:
+ for l in input_file:
+ output_file.write(indent)
+ output_file.write(" ")
+ output_file.write(l)
+
+ output_file.write(indent)
+ output_file.write("}\n")
+
+ for name, mod in self.nested.items():
+ output_file.write(indent)
+ output_file.write("pub mod %s {\n" % name)
+ mod.emit(output_file, indent + " ")
+ output_file.write(indent)
+ output_file.write("}\n")
+
+ def emit_mangled(self, output_file, indent="", prefix=""):
+ for (input_name, _) in self.files:
+ output_file.write(indent)
+ output_file.write("pub use %s::%s::mangled::*;\n" % (prefix, input_name))
+ for name, mod in self.nested.items():
+ new_prefix = prefix + "::" + name
+ mod.emit_mangled(output_file, indent, prefix=new_prefix)
+
+def main(output, root, inputs, imports):
+ root_module = RustModule()
+ for inp in inputs:
+ in_rel = os.path.relpath(inp, root)
+ in_path = pathlib.PurePath(in_rel)
+
+ node = root_module
+ for part in in_path.parts[:-1]:
+ node = node.nested[part]
+
+ if os.path.isfile(inp):
+ in_name, in_ext = os.path.splitext(in_path.parts[-1])
+ node.files.append((in_name, inp))
+
+ 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")
+ lib_rs_file.write("pub use binder::public_api as binder;\n")
+
+ lib_rs_file.write("pub mod aidl {\n")
+ root_module.emit(lib_rs_file, indent=" ")
+ lib_rs_file.write("}\n")
+
+ lib_rs_file.write("pub mod mangled {\n")
+ root_module.emit_mangled(lib_rs_file, indent=" ", prefix="super::aidl")
+ for imp in imports:
+ lib_rs_file.write(" pub(crate) use %s::mangled::*;\n" % imp)
+ lib_rs_file.write("}\n")
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description='Generate the top-level lib.rs.')
+ 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', action='append', dest='imports',
+ default=[], help='Crates to import')
+
+ args = parser.parse_args()
+ if args is None:
+ sys.exit(1)
+
+ sys.exit(main(args.output, args.root, args.inputs, args.imports))
diff --git a/build/aidl_rust_source_provider.go b/build/aidl_rust_source_provider.go
new file mode 100644
index 0000000..eab45f1
--- /dev/null
+++ b/build/aidl_rust_source_provider.go
@@ -0,0 +1,128 @@
+// 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 trimVersionSuffixInList(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(ctx android.AndroidMkExtraEntriesContext, 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 c18098e..325cbda 100644
--- a/build/aidl_test.go
+++ b/build/aidl_test.go
@@ -15,7 +15,7 @@
package aidl
import (
- "io/ioutil"
+ "fmt"
"os"
"path/filepath"
"strings"
@@ -25,64 +25,59 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/apex"
"android/soong/cc"
+ "android/soong/genrule"
"android/soong/java"
+ "android/soong/rust"
)
-var buildDir string
-
-func setUp() {
- var err error
- buildDir, err = ioutil.TempDir("", "soong_aidl_test")
- if err != nil {
- panic(err)
- }
-}
-
-func tearDown() {
- os.RemoveAll(buildDir)
-}
-
func TestMain(m *testing.M) {
- run := func() int {
- setUp()
- defer tearDown()
-
- return m.Run()
- }
-
- os.Exit(run())
+ os.Exit(m.Run())
}
-type testCustomizer func(fs map[string][]byte, config android.Config)
-
-func withFiles(files map[string][]byte) testCustomizer {
- return func(fs map[string][]byte, config android.Config) {
- for k, v := range files {
- fs[k] = v
- }
- }
+func withFiles(files map[string][]byte) android.FixturePreparer {
+ return android.FixtureMergeMockFs(files)
}
-func setReleaseEnv() testCustomizer {
- return func(_ map[string][]byte, config android.Config) {
- config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL")
- config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true)
- }
+func intPtr(v int) *int {
+ return &v
}
-func _testAidl(t *testing.T, bp string, customizers ...testCustomizer) (*android.TestContext, android.Config) {
+func setReleaseEnv() android.FixturePreparer {
+ return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ // Q is finalized as 29. No codename that is actively being developed.
+ variables.Platform_sdk_version = intPtr(29)
+ variables.Platform_sdk_codename = proptools.StringPtr("REL")
+ variables.Platform_sdk_final = proptools.BoolPtr(true)
+ variables.Platform_version_active_codenames = []string{}
+ })
+}
+
+func _testAidl(t *testing.T, bp string, customizers ...android.FixturePreparer) android.FixturePreparer {
t.Helper()
- bp = bp + java.GatherRequiredDepsForTest()
- bp = bp + cc.GatherRequiredDepsForTest(android.Android)
+ preparers := []android.FixturePreparer{}
+
+ preparers = append(preparers,
+ cc.PrepareForTestWithCcDefaultModules,
+ java.PrepareForTestWithJavaDefaultModules,
+ genrule.PrepareForTestWithGenRuleBuildComponents,
+ )
+
bp = bp + `
+ package {
+ default_visibility: ["//visibility:public"],
+ }
java_defaults {
name: "aidl-java-module-defaults",
}
cc_defaults {
name: "aidl-cpp-module-defaults",
}
+ rust_defaults {
+ name: "aidl-rust-module-defaults",
+ }
cc_library {
name: "libbinder",
}
@@ -94,94 +89,110 @@
}
cc_library {
name: "libbinder_ndk",
+ stubs: {
+ versions: ["29"],
+ }
}
ndk_library {
name: "libbinder_ndk",
symbol_file: "libbinder_ndk.map.txt",
first_version: "29",
}
- aidl_interfaces_metadata {
- name: "aidl_metadata_json",
+ cc_library {
+ name: "liblog",
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ }
+ rust_library {
+ name: "libstd",
+ crate_name: "std",
+ srcs: [""],
+ no_stdlibs: true,
+ sysroot: true,
+ }
+ rust_library {
+ name: "libtest",
+ crate_name: "test",
+ srcs: [""],
+ no_stdlibs: true,
+ sysroot: true,
+ }
+ rust_library {
+ name: "liblazy_static",
+ crate_name: "lazy_static",
+ srcs: [""],
+ }
+ rust_library {
+ name: "libbinder_rs",
+ crate_name: "binder",
+ srcs: [""],
}
`
- fs := map[string][]byte{}
- cc.GatherRequiredFilesForTest(fs)
+ preparers = append(preparers, android.FixtureWithRootAndroidBp(bp))
+ preparers = append(preparers, android.FixtureAddTextFile("system/tools/aidl/build/Android.bp", `
+ aidl_interfaces_metadata {
+ name: "aidl_metadata_json",
+ visibility: ["//system/tools/aidl:__subpackages__"],
+ }
+ `))
- for _, c := range customizers {
- // The fs now needs to be populated before creating the config, call customizers twice
- // for now, once to get any fs changes, and later after the config was created to
- // set product variables or targets.
- tempConfig := android.TestArchConfig(buildDir, nil, bp, fs)
- c(fs, tempConfig)
- }
+ preparers = append(preparers, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ // To keep tests stable, fix Platform_sdk_codename and Platform_sdk_final
+ // Use setReleaseEnv() to test release version
+ variables.Platform_sdk_version = intPtr(28)
+ variables.Platform_sdk_codename = proptools.StringPtr("Q")
+ variables.Platform_version_active_codenames = []string{"Q"}
+ variables.Platform_sdk_final = proptools.BoolPtr(false)
+ }))
- config := android.TestArchConfig(buildDir, nil, bp, fs)
+ preparers = append(preparers, customizers...)
- // To keep tests stable, fix Platform_sdk_codename and Platform_sdk_final
- // Use setReleaseEnv() to test release version
- config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q")
- config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false)
+ preparers = append(preparers,
+ apex.PrepareForTestWithApexBuildComponents,
+ rust.PrepareForTestWithRustBuildComponents,
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("aidl_interface", aidlInterfaceFactory)
+ ctx.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
+ ctx.RegisterModuleType("rust_defaults", func() android.Module {
+ return rust.DefaultsFactory()
+ })
- for _, c := range customizers {
- // The fs now needs to be populated before creating the config, call customizers twice
- // for now, earlier to get any fs changes, and now after the config was created to
- // set product variables or targets.
- tempFS := map[string][]byte{}
- c(tempFS, config)
- }
+ ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("checkImports", checkImports)
+ ctx.TopDown("createAidlInterface", createAidlInterfaceMutator)
+ })
- ctx := android.NewTestArchContext()
- cc.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("java_library_static", java.LibraryStaticFactory)
- ctx.RegisterModuleType("java_library", java.LibraryFactory)
- ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory)
- ctx.RegisterModuleType("ndk_library", cc.NdkLibraryFactory)
+ ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("checkUnstableModule", checkUnstableModuleMutator).Parallel()
+ ctx.BottomUp("recordVersions", recordVersions).Parallel()
+ ctx.BottomUp("checkDuplicatedVersions", checkDuplicatedVersions).Parallel()
+ })
+ }),
+ )
- ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
- ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
- ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("checkUnstableModule", checkUnstableModuleMutator).Parallel()
- })
- ctx.Register(config)
-
- return ctx, config
+ return android.GroupFixturePreparers(preparers...)
}
-func testAidl(t *testing.T, bp string, customizers ...testCustomizer) (*android.TestContext, android.Config) {
+func testAidl(t *testing.T, bp string, customizers ...android.FixturePreparer) (*android.TestContext, android.Config) {
t.Helper()
- ctx, config := _testAidl(t, bp, customizers...)
- _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
- android.FailIfErrored(t, errs)
- _, errs = ctx.PrepareBuildActions(config)
- android.FailIfErrored(t, errs)
- return ctx, config
+ preparer := _testAidl(t, bp, customizers...)
+ result := preparer.RunTest(t)
+ return result.TestContext, result.Config
}
-func testAidlError(t *testing.T, pattern, bp string, customizers ...testCustomizer) {
+func testAidlError(t *testing.T, pattern, bp string, customizers ...android.FixturePreparer) {
t.Helper()
- ctx, config := _testAidl(t, bp, customizers...)
- _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
- if len(errs) > 0 {
- android.FailIfNoMatchingErrors(t, pattern, errs)
- return
- }
- _, errs = ctx.PrepareBuildActions(config)
- if len(errs) > 0 {
- android.FailIfNoMatchingErrors(t, pattern, errs)
- return
- }
- t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
+ preparer := _testAidl(t, bp, customizers...)
+ preparer.
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)).
+ RunTest(t)
}
// 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)
@@ -199,6 +210,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 := `
@@ -208,12 +236,17 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}`
- expectedError := `module "foo_interface": versions: must be set \(need to be frozen\) when "unstable" is false and PLATFORM_VERSION_CODENAME is REL`
+ expectedError := `module "foo_interface": versions: must be set \(need to be frozen\) when "unstable" is false, PLATFORM_VERSION_CODENAME is REL, and "owner" property is missing.`
testAidlError(t, expectedError, vintfWithoutVersionBp, setReleaseEnv())
ctx, _ := testAidl(t, vintfWithoutVersionBp)
- assertModulesExists(t, ctx, "foo-java", "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.
@@ -230,10 +263,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,
}))
@@ -255,7 +288,7 @@
}
java_library {
name: "bar",
- libs: ["foo-java"],
+ libs: ["foo-V1-java"],
}`
testAidl(t, stableVersionUsageInJavaBp, setReleaseEnv(), withFiles(map[string][]byte{
@@ -279,10 +312,10 @@
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 and PLATFORM_VERSION_CODENAME is REL.`
+ 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.`
testAidlError(t, expectedError, nonVersionedModuleUsageInJavaBp, setReleaseEnv())
testAidl(t, nonVersionedModuleUsageInJavaBp)
@@ -304,6 +337,56 @@
testAidl(t, nonVersionedUnstableModuleUsageInJavaBp)
}
+func TestImportInRelease(t *testing.T) {
+ importInRelease := `
+ aidl_interface {
+ name: "foo",
+ srcs: [
+ "IFoo.aidl",
+ ],
+ imports: ["bar"],
+ versions: ["1"],
+ }
+
+ aidl_interface {
+ name: "bar",
+ srcs: [
+ "IBar.aidl",
+ ],
+ versions: ["1"],
+ }
+ `
+
+ testAidl(t, importInRelease, setReleaseEnv(), withFiles(map[string][]byte{
+ "aidl_api/foo/1/foo.1.aidl": nil,
+ "aidl_api/foo/1/.hash": nil,
+ "aidl_api/bar/1/bar.1.aidl": nil,
+ "aidl_api/bar/1/.hash": nil,
+ }))
+}
+
+func TestUnstableVersionedModuleUsageInRelease(t *testing.T) {
+ nonVersionedModuleUsageInJavaBp := `
+ aidl_interface {
+ name: "foo",
+ srcs: [
+ "IFoo.aidl",
+ ],
+ versions: ["1"],
+ }
+
+ java_library {
+ name: "bar",
+ libs: ["foo-V2-java"],
+ }`
+
+ expectedError := `Android.bp:10:2: module \"bar\" variant \"android_common\": foo-V2-java is disallowed in release version because it is unstable, and its \"owner\" property is missing.`
+ testAidlError(t, expectedError, nonVersionedModuleUsageInJavaBp, setReleaseEnv())
+ testAidl(t, nonVersionedModuleUsageInJavaBp, withFiles(map[string][]byte{
+ "aidl_api/foo/1/foo.1.aidl": nil,
+ }))
+}
+
func TestUnstableModules(t *testing.T) {
testAidlError(t, `module "foo_interface": stability: must be empty when "unstable" is true`, `
aidl_interface {
@@ -313,6 +396,11 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
@@ -326,6 +414,11 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
@@ -336,10 +429,15 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
- assertModulesExists(t, ctx, "foo-java", "foo-cpp", "foo-ndk", "foo-ndk_platform")
+ assertModulesExists(t, ctx, "foo-java", "foo-rust", "foo-cpp", "foo-ndk", "foo-ndk_platform")
}
func TestCreatesModulesWithNoVersions(t *testing.T) {
@@ -349,10 +447,15 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
- assertModulesExists(t, ctx, "foo-java", "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) {
@@ -366,6 +469,11 @@
versions: [
"1",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
@@ -378,25 +486,91 @@
versions: [
"1",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`, withFiles(map[string][]byte{
"aidl_api/foo/1/foo.1.aidl": nil,
}))
- // For alias for the latest frozen version (=1)
- assertModulesExists(t, ctx, "foo-java", "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-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 (
- androidVariant = "android_common"
- nativeVariant = "android_arm_armv7-a-neon_shared"
+ androidVariant = "android_common"
+ nativeVariant = "android_arm_armv7-a-neon_shared"
+ nativeRustVariant = "android_arm_armv7-a-neon_dylib"
)
func TestNativeOutputIsAlwaysVersioned(t *testing.T) {
@@ -423,11 +597,18 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
+ // 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-java", androidVariant, "foo-java.jar")
- assertOutput("foo-cpp", nativeVariant, "foo-V1-cpp.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, `
@@ -439,6 +620,11 @@
versions: [
"1", "2",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`, withFiles(map[string][]byte{
"aidl_api/foo/1/foo.1.aidl": nil,
@@ -446,52 +632,23 @@
}))
// alias for the latest frozen version (=2)
- assertOutput("foo-java", androidVariant, "foo-java.jar")
- assertOutput("foo-cpp", nativeVariant, "foo-V2-cpp.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")
assertOutput("foo-V1-cpp", nativeVariant, "foo-V1-cpp.so")
+ 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-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 {
@@ -557,22 +714,565 @@
srcs: [
"IFoo.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
imports: [
- "bar",
+ "bar.1",
]
}
aidl_interface {
- name: "bar",
+ name: "bar.1",
srcs: [
"IBar.aidl",
],
+ backend: {
+ rust: {
+ enabled: true,
+ },
+ },
}
`)
- 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-cpp", nativeVariant, "bar-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-V1-rust", nativeRustVariant).Rule("rustc")
+ libFlags = rustcRule.Args["libFlags"]
+ libBar = filepath.Join("out", "soong", ".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)
+ }
+}
+
+func TestDuplicatedVersions(t *testing.T) {
+ // foo depends on myiface-V2-ndk via direct dep and also on
+ // myiface-V1-ndk via indirect dep. This should be prohibited.
+ testAidlError(t, `depends on multiple versions of the same aidl_interface: myiface-V1-ndk, myiface-V2-ndk`, `
+ aidl_interface {
+ name: "myiface",
+ srcs: ["IFoo.aidl"],
+ versions: ["1", "2"],
+ }
+
+ cc_library {
+ name: "foo",
+ shared_libs: ["myiface-V2-ndk", "bar"],
+ }
+
+ cc_library {
+ name: "bar",
+ shared_libs: ["myiface-V1-ndk"],
+ }
+
+ `, withFiles(map[string][]byte{
+ "aidl_api/myiface/1/myiface.1.aidl": nil,
+ "aidl_api/myiface/1/.hash": nil,
+ "aidl_api/myiface/2/myiface.2.aidl": nil,
+ "aidl_api/myiface/2/.hash": nil,
+ }))
+ testAidlError(t, `depends on multiple versions of the same aidl_interface: myiface-V1-ndk, myiface-V2-ndk`, `
+ aidl_interface {
+ name: "myiface",
+ srcs: ["IFoo.aidl"],
+ versions: ["1"],
+ }
+
+ aidl_interface {
+ name: "myiface2",
+ srcs: ["IBar.aidl"],
+ imports: ["myiface"]
+ }
+
+ cc_library {
+ name: "foobar",
+ 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{
+ "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"],
+ }
+
+ aidl_interface {
+ name: "myiface2",
+ srcs: ["IBar.aidl"],
+ imports: ["myiface"]
+ }
+
+ cc_library {
+ name: "foobar",
+ shared_libs: ["myiface-V2-ndk", "myiface2-V1-ndk"],
+ }
+
+ `, withFiles(map[string][]byte{
+ "aidl_api/myiface/1/myiface.1.aidl": nil,
+ "aidl_api/myiface/1/.hash": nil,
+ }))
+}
+
+func TestUnstableVndkModule(t *testing.T) {
+ testAidlError(t, `module "myiface_interface": stability: must be "vintf" if the module is for VNDK.`, `
+ aidl_interface {
+ name: "myiface",
+ srcs: ["IFoo.aidl"],
+ vendor_available: true,
+ product_available: true,
+ unstable: true,
+ vndk: {
+ enabled: true,
+ },
+ }
+ `)
+ testAidlError(t, `module "myiface_interface": stability: must be "vintf" if the module is for VNDK.`, `
+ aidl_interface {
+ name: "myiface",
+ vendor_available: true,
+ product_available: true,
+ srcs: ["IFoo.aidl"],
+ vndk: {
+ enabled: true,
+ },
+ }
+ `)
+ testAidl(t, `
+ aidl_interface {
+ name: "myiface",
+ vendor_available: true,
+ product_available: true,
+ srcs: ["IFoo.aidl"],
+ stability: "vintf",
+ vndk: {
+ enabled: true,
+ },
+ }
+ `)
+}
+
+func TestCcModuleWithApexNameMacro(t *testing.T) {
+ ctx, _ := testAidl(t, `
+ aidl_interface {
+ name: "myiface",
+ srcs: ["IFoo.aidl"],
+ backend: {
+ ndk: {
+ apex_available: ["myapex"],
+ },
+ },
+ }
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["myiface-V1-ndk_platform"],
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `, withFiles(map[string][]byte{
+ "system/sepolicy/apex/myapex-file_contexts": nil,
+ }))
+
+ 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 TestAidlImportFlagsForIncludeDirs(t *testing.T) {
+ customizer := withFiles(map[string][]byte{
+ "foo/Android.bp": []byte(`
+ aidl_interface {
+ name: "foo-iface",
+ local_include_dir: "src",
+ include_dirs: [
+ "path1",
+ "path2/sub",
+ ],
+ srcs: [
+ "src/foo/Foo.aidl",
+ ],
+ imports: [
+ "bar-iface",
+ ],
+ versions: ["1", "2"],
+ }
+ aidl_interface {
+ name: "bar-iface",
+ local_include_dir: "src",
+ srcs: [
+ "src/bar/Bar.aidl",
+ ],
+ }
+ `),
+ "foo/src/foo/Foo.aidl": nil,
+ "foo/src/bar/Bar.aidl": nil,
+ "foo/aidl_api/foo-iface/current/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/1/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/1/.hash": nil,
+ "foo/aidl_api/foo-iface/2/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/2/.hash": nil,
+ })
+ ctx, _ := testAidl(t, ``, customizer)
+
+ // compile for older version
+ {
+ rule := ctx.ModuleForTests("foo-iface-V1-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "should import foo/1(target) and bar/current(imported)", []string{
+ "-Ifoo/aidl_api/foo-iface/1",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/aidl_api/bar-iface/current",
+ }, imports)
+ }
+ // compile for tot version
+ {
+ rule := ctx.ModuleForTests("foo-iface-V3-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "aidlCompile should import ToT", []string{
+ "-Ifoo/src",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/src",
+ }, imports)
+ }
+}
+
+func TestSupportsGenruleAndFilegroup(t *testing.T) {
+ customizer := withFiles(map[string][]byte{
+ "foo/Android.bp": []byte(`
+ aidl_interface {
+ name: "foo-iface",
+ local_include_dir: "src",
+ include_dirs: [
+ "path1",
+ "path2/sub",
+ ],
+ srcs: [
+ "src/foo/Foo.aidl",
+ ":filegroup1",
+ ":gen1",
+ ],
+ imports: [
+ "bar-iface",
+ ],
+ versions: ["1"],
+ }
+ filegroup {
+ name: "filegroup1",
+ path: "filegroup/sub",
+ srcs: [
+ "filegroup/sub/pkg/Bar.aidl",
+ ],
+ }
+ genrule {
+ name: "gen1",
+ cmd: "generate baz/Baz.aidl",
+ out: [
+ "baz/Baz.aidl",
+ ]
+ }
+ aidl_interface {
+ name: "bar-iface",
+ local_include_dir: "src",
+ srcs: [
+ "src/bar/Bar.aidl",
+ ],
+ }
+ `),
+ "foo/aidl_api/foo-iface/1/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/1/.hash": nil,
+ "foo/filegroup/sub/pkg/Bar.aidl": nil,
+ "foo/src/foo/Foo.aidl": nil,
+ })
+ ctx, _ := testAidl(t, ``, customizer)
+
+ // aidlCompile for snapshots (v1)
+ {
+ rule := ctx.ModuleForTests("foo-iface-V1-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "aidlCompile should import filegroup/genrule as well", []string{
+ "-Ifoo/aidl_api/foo-iface/1",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/aidl_api/bar-iface/current",
+ }, imports)
+ }
+ // aidlCompile for ToT (v2)
+ {
+ rule := ctx.ModuleForTests("foo-iface-V2-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "aidlCompile should import filegroup/genrule as well", []string{
+ "-Ifoo/src",
+ "-Ifoo/filegroup/sub",
+ "-Iout/soong/.intermediates/foo/gen1/gen",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/src",
+ }, imports)
+ }
+
+ // dumpapi
+ {
+ rule := ctx.ModuleForTests("foo-iface-api", "").Rule("aidlDumpApiRule")
+ android.AssertPathsRelativeToTopEquals(t, "dumpapi should dump srcs/filegroups/genrules", []string{
+ "foo/src/foo/Foo.aidl",
+ "foo/filegroup/sub/pkg/Bar.aidl",
+ "out/soong/.intermediates/foo/gen1/gen/baz/Baz.aidl",
+ }, rule.Inputs)
+
+ dumpDir := "out/soong/.intermediates/foo/foo-iface-api/dump"
+ android.AssertPathsRelativeToTopEquals(t, "dumpapi should dump with rel paths", []string{
+ dumpDir + "/foo/Foo.aidl",
+ dumpDir + "/pkg/Bar.aidl",
+ dumpDir + "/baz/Baz.aidl",
+ dumpDir + "/.hash",
+ }, rule.Outputs.Paths())
+
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "dumpapi should import filegroup/genrule as well", []string{
+ // these are from foo-iface.srcs
+ "-Ifoo/src",
+ "-Ifoo/filegroup/sub",
+ "-Iout/soong/.intermediates/foo/gen1/gen",
+
+ // this is from bar-iface.srcs
+ "-Ifoo/src",
+
+ // this is from foo-iface.Local_include_dir
+ "-Ifoo/src",
+
+ // these are from foo-iface.include_dirs
+ "-Ipath1",
+ "-Ipath2/sub",
+ }, imports)
+ }
+}
+
+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")
+ })
+ }
+ }
+}
+
+func TestAidlModuleNameContainsVersion(t *testing.T) {
+ testAidlError(t, "aidl_interface should not have '-V<number> suffix", `
+ aidl_interface {
+ name: "myiface-V2",
+ srcs: ["a/Foo.aidl", "b/Bar.aidl"],
+ }
+ `)
+ // Ugly, but okay
+ testAidl(t, `
+ aidl_interface {
+ name: "myiface-V2aa",
+ srcs: ["a/Foo.aidl", "b/Bar.aidl"],
+ }
+ `)
+}
+
+func TestExplicitAidlModuleImport(t *testing.T) {
+ for _, importVersion := range []string{"V1", "V2"} {
+
+ ctx, _ := testAidl(t, `
+ aidl_interface {
+ name: "foo",
+ srcs: ["Foo.aidl"],
+ versions: [
+ "1",
+ ],
+ imports: ["bar-`+importVersion+`"]
+ }
+
+ aidl_interface {
+ name: "bar",
+ srcs: ["Bar.aidl"],
+ versions: [
+ "1",
+ ],
+ }
+ `, withFiles(map[string][]byte{
+ "aidl_api/foo/1/Foo.aidl": nil,
+ "aidl_api/foo/1/.hash": nil,
+ "aidl_api/bar/1/Bar.aidl": nil,
+ "aidl_api/bar/1/.hash": nil,
+ }))
+ for _, foo := range []string{"foo-V1-cpp", "foo-V2-cpp"} {
+ ldRule := ctx.ModuleForTests(foo, nativeVariant).Rule("ld")
+ libFlags := ldRule.Args["libFlags"]
+ libBar := filepath.Join("bar-"+importVersion+"-cpp", nativeVariant, "bar-"+importVersion+"-cpp.so")
+ if !strings.Contains(libFlags, libBar) {
+ t.Errorf("%q is not found in %q", libBar, libFlags)
+ }
+
+ }
+ }
+
+ testAidlError(t, "module \"foo_interface\": imports: \"foo\" depends on \"bar\" version \"3\"", `
+ aidl_interface {
+ name: "foo",
+ srcs: ["Foo.aidl"],
+ versions: [
+ "1",
+ ],
+ imports: ["bar-V3"]
+ }
+
+ aidl_interface {
+ name: "bar",
+ srcs: ["Bar.aidl"],
+ versions: [
+ "1",
+ ],
+ }
+ `, withFiles(map[string][]byte{
+ "aidl_api/foo/1/Foo.aidl": nil,
+ "aidl_api/foo/1/.hash": nil,
+ "aidl_api/bar/1/Bar.aidl": nil,
+ "aidl_api/bar/1/.hash": nil,
+ }))
}
diff --git a/build/aidl_utils.go b/build/aidl_utils.go
new file mode 100644
index 0000000..b19793c
--- /dev/null
+++ b/build/aidl_utils.go
@@ -0,0 +1,74 @@
+// 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
+}
+
+// wrapFunc(p, a, s, f) = [p + f(v) + s for v in a]
+func wrapFunc(prefix string, strs []string, suffix string, f func(string) string) []string {
+ ret := make([]string, len(strs))
+ for i, v := range strs {
+ ret[i] = prefix + f(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
new file mode 100644
index 0000000..03342a3
--- /dev/null
+++ b/build/apex/Android.bp
@@ -0,0 +1,33 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "system_tools_aidl_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
+apex_test {
+ name: "com.android.aidltest",
+ manifest: "apex_manifest.json",
+ file_contexts: ":apex.test-file_contexts",
+ key: "com.android.aidltest.key",
+ certificate: ":com.android.aidltest.certificate",
+ installable: false,
+ updatable: false,
+
+ native_shared_libs: [
+ "test-piece-1-V3-ndk_platform",
+ ],
+}
+
+apex_key {
+ name: "com.android.aidltest.key",
+ public_key: "com.android.aidltest.pubkey",
+ private_key: "com.android.aidltest.pem",
+}
+
+android_app_certificate {
+ name: "com.android.aidltest.certificate",
+ certificate: "com.android.aidltest",
+}
diff --git a/build/apex/apex_manifest.json b/build/apex/apex_manifest.json
new file mode 100644
index 0000000..5b81403
--- /dev/null
+++ b/build/apex/apex_manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.android.aidltest",
+ "version": 1
+}
diff --git a/build/apex/com.android.aidltest.pem b/build/apex/com.android.aidltest.pem
new file mode 100644
index 0000000..1982a2d
--- /dev/null
+++ b/build/apex/com.android.aidltest.pem
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKQIBAAKCAgEA5b93QQ6WB+Ms0/IztCz9ZqvEx0oL/9ZsBrzkiQcd3Yp9HVcF
+Jevu4KeX86Bu2t8nZnr6CxJPy6gw92itfHSbOXmd+fs8tch1D6bqtU3xxq3Wg8SB
+CKWD7wZoDd7rkLqCjV6IDebUK0DtP1WmtTMm2mIGKTCnqOgfcnkSe1YwQ22suKKs
+orOIrrs2wjyIZnh0iIvPpsfaI4YQ6Oo0+VTqb2kMpkSlB1ynd8fUTxMRJCYXywyO
+u8HT7DVMj9/XYF0nN7YFFf/Qcd0UOXGg0vCbmnijJawkvcb4fLqQtJ/oVajBhC+t
+cnF1mUgoh4qqBFMVcaKikiLI/9nuOr2jalnM4tpdzPWbPCBFtrp+1Bjm44+2KdwZ
+Klzzzj5gL8IOpTDGbA706nGah/YsWIewyLNub6OxZ9Sue4Sgjjl2mZMto6o1cmnw
+wzNf5B6jqAa8X8zLXjKuf9HVP+vu6wVFmfFxCVEPFTuij8fOB3YC+qIKu+ut7Z25
+MPhPQaK2xTyPFM+PxgI8oIB8Vc4U0Q3B/FsRSivQ5D3bU6t44z36VNiE0LQgWcVT
+sC6byvc3bFQelZxVZV9iOasK9tOIPTQZyvFVlEDC2UGlFIkh8o1yvDiVWqUmP6fa
+qc05ye+4WQU+QjGMzxiSmApJvyWxwQonUA31wh7hN4SYw95GQTzwh0wEIw8CAwEA
+AQKCAgAD3sXTgrtkRp9qspnMXzWllR8rfEPXe3U2Z9gxtrz6DmstI1oi2WacwjX9
+FKbJaRjw0QGFTjmp5Jtuj4Tco9o5jaLrox/SsB3ItbcedsGr5yHF9nl1+9PNIv59
+vVOajInGd+Ey2sCYOe/FMVwtkT8GTsBr0TYB0mc1NnTpPvpxKFfQhG0EEKIsz1qM
+yxhBIaZU5oYI+TTjhE6knc1mpdeNKOfdpSpihV0M14DsFBYl1b5w3TVKVGmNgRhZ
+FBw8s1UFyzsqs7R/NoowrYlYBFWatI2LBOtZhxCIiVwGrurrBny8DVGOq/qfKmgE
+YIGcsQmbcHHspElehf1NYARwtjKNV5N8IlSFMuGoMqBgxky267uBk2MsmGpSNbwy
+LNORpDz+FbGicxntqIE+F77TH8XSi2wJR9gSiWv3vfQF3WDsuiTqjnkcnaa0j/Nh
+X8bkNW8d846OopbxWSsLQHk/0tgUHmvx9VVwVwgvtdEHDFORdUI2b6FkpwwqNYB0
+F+Q7eYc4k+ZUUCj1MCwfgSoIwiHpeSjyYslFqsaTfk6cMTdgFCMrljLyMDlz1O3m
+RmCrsrkrRAdl0wMlrHhLq4ZSmwUPh8QzD0lZdLgO1ca3/k6q+l1d8UpkM4k6Pdqc
+PbU8di/GOnb37ovS6q36tVoRVmhm/wxOI0Nk6xBeS0F5HvBXAQKCAQEA+rOg9fki
+DsDNKMzI87aU8/JVbA50oYm4kxYheDQCcl6xwq6pfAshRI4Muym5GNQvvAV5kIEu
+sP4u9UGMvDFVnJn4zf8Ont53DNWLA5CA7dR1CSUUC78xzy6x2vwQN31laa3zgDmn
+2Nr3+uwvBkK96xuWPQoYKouykQ0psyio9rhAy+V9PIEnJkpKn5YIrOGsjTKTZAln
+L/uzeHgEdgGDWp0jqMMeMu8+VJSb9LND2ClquLhRnRzcEH880Crp/3V2+J7xtBz6
+7Q+jV7KkH+pPpIvOlQ0w7KK2D9nFo7Mdq/DE1A8+8UYyy28DtgQ2W5jh5vwn4K1U
+ebkpKSfxOUJqVwKCAQEA6pp4kC1XbK7dcgaWlRNFOr0IouHm/JfaSzH173qG9l/E
+zjHQjoQYN3A+lZcXWXScXrmuS0iS+RUd5Lm65EB0TEx40r7m9DL/7pJxnRSvfbrD
+cNbTZFQ25e9uJYiKodvDya706e0n0wBWb8mb/X5NlCBTPXopZbC3fn6SLm0PnNq9
+/vEPNcYABD2dUf0hF05Q2WtoGeY5dPCaO77zq+N3M6hgdfLMnDiYJBbwxbFUsH4R
+j8kDUlevQaamdgWSuHIS4xn5S5Tp019l+RmnoGYbdWSSxqrOsPRYuaSVKYx+oHQP
+UEsj4H2k0McOLe2bcQgk+8RSheIeIIrskfuDbVEKCQKCAQEA3OnozpdIUaPHpUo/
+UbL0Mrq6V0utrqMDSGlZ+Ogrt8iF772lj67nE9fwlATCHITtw0s3wgRztndlvayT
+bUoz3Jk5S5yTr57tXRvXMb7mPazXrMVFksxaAe1twEAZsiwHb0ZfqgAkTc02c6Ao
+F+Y8IK7ghs0cWnFbWsI0mrEborzeLE3/O4+7hdw1Qccdweni+VE13BMFIJ01mtR3
+ad0PeIu73nyBYfS8AiAqBUjqYdKtPjT9hermaIsWdYE7TWae/Zph9osK+larYx4B
+zjXVFHQ2B9Xl5L/EmtcVd5jgbqDtcMg2eLmZDPa4WG4B0Fk5xycvpKZYKCLniGKw
+B/rkZQKCAQAD06M1zteHOU75ZiwcoGTXsW+roH2xDxULdvQpBNmguS0vo9ZgDL2M
+YfNTY1SJLALE9MhoB/YFxBdpvLHUuUxsVi7+WQjRYOeVz6O0yTqXlW1MsORf1ZPT
+qlUknZaNT1VhO85Y5npo0a+XQTWfK+k+CkzxSsXUF87WbGAcC8FecJ76wpnZ6bHk
+X9DqHnPkum1NLphTG9NCGg6Z/OJiomI2YH+6TMyTm8S3ifxBbUQRYO0OaFv6gt2j
+94DtmeerxIiUVb8gQXyS6xJxvr5iOmgmQQ632N9oOYQc+xdHxzfljB8X0zHxnnsK
+wMR1cVPAwz4/MRObhXWyWDHFq9GX/eNpAoIBAQCxWqsYbTC4JzoBBaZSoMBpyVYB
+R9lfyKaMLlh4szG0YcP7naPI5KAidSjkU4son7vz7LsXDHBKzgK4gMtbUIFOqFFv
+ZUaaSkSBkbEcJgs7eP24QMD3I3kNprkPFIZnyMT9VKIRVLhToA2TddSS+HcIiLUV
+NpG7eD8LZW9B/CfUOEq7bnc+mw0KD48b94Bj/PGF7IOvBjyQhOs92OUnw3H+3lio
+X1gezko6qobMIBvbu4giGaJHj7bTil0l0bWR8dwfMRphYf9lpXpkiLOK/VjWT/Fn
+5nJ++VczKi7UfACemZo9uhY2o/oEuXxQ6NHI/WexZSN/ovo+RXcoBk/TZjJT
+-----END RSA PRIVATE KEY-----
diff --git a/build/apex/com.android.aidltest.pk8 b/build/apex/com.android.aidltest.pk8
new file mode 100644
index 0000000..aa7a092
--- /dev/null
+++ b/build/apex/com.android.aidltest.pk8
Binary files differ
diff --git a/build/apex/com.android.aidltest.pubkey b/build/apex/com.android.aidltest.pubkey
new file mode 100644
index 0000000..6196ca6
--- /dev/null
+++ b/build/apex/com.android.aidltest.pubkey
Binary files differ
diff --git a/build/apex/com.android.aidltest.x509.pem b/build/apex/com.android.aidltest.x509.pem
new file mode 100644
index 0000000..66972ff
--- /dev/null
+++ b/build/apex/com.android.aidltest.x509.pem
@@ -0,0 +1,35 @@
+-----BEGIN CERTIFICATE-----
+MIIGJzCCBA+gAwIBAgIUGIiwEuQwMTOwnLSG/4GGkY1o/jEwDQYJKoZIhvcNAQEL
+BQAwgaExCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQH
+DA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRy
+b2lkMR0wGwYDVQQDDBRjb20uYW5kcm9pZC5haWRsdGVzdDEiMCAGCSqGSIb3DQEJ
+ARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAgFw0yMDA4MTgwNTQ2MThaGA80NzU4MDcx
+NTA1NDYxOFowgaExCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYw
+FAYDVQQHDA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQL
+DAdBbmRyb2lkMR0wGwYDVQQDDBRjb20uYW5kcm9pZC5haWRsdGVzdDEiMCAGCSqG
+SIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCAiIwDQYJKoZIhvcNAQEBBQAD
+ggIPADCCAgoCggIBAMHqtY+vlXFVIiRNYlnrJ3dhfBPfNxvwK5n25BeAyZMlOmLr
+L8Nr5PJVsiGXts6forTUsnLSVzrNUjdFBWrOWXSJQ/QbNn0luryxcUyfDBzP85vl
+M6PZmwie3/bzQzGUY+LZwNqTMCKy1xv8KiWkmz4SN/yb4ACkhBTD/9jP/WhTLjrp
+vO7/RxigA8GyNri/CRTY5tu1E1xC+K9HVfTHjnQg69SUzIVQJpDYBwIQDXkc7uNu
+OVeoTFzzWqTHpM6fvIVvBuKBWL6uTajdnsJ6e75WIV21bwuvRBNlDKucC7Z3h8q6
+hDgm7q1YgLDBjzpfYOa+PhACEmn5FSorCZ6Ujm2osWIqaaTsrj7M+iuwOaANRVTu
+gReUtHyw9lhqotBrhEMkPMdRjKnqMQlh81+3D3H6/cZzdEsVXFerLewZI8iJYohp
+z0777SDo8FEEBrmdm/7VknNJRykKhfSpFfYZZE6AiTL1x8lH+5YBHCbadkd/reiQ
+EjfWlwfePPLV7oIki3yqRWjYT1MTt3KlASGZ9HZI2odezIcojZvgHdHX8MGytfWD
+kXziJVrXMUXgUfljQwpsjEhE1R13E5jdpVspw624BPLOwoEzY70tE0sEd6WlSVE1
+FV3AiVIS3vlXEgbK+6hmG+lg/qv0ZIcwD2bjKnvEOtL077HHWWpjy6zuVFEvAgMB
+AAGjUzBRMB0GA1UdDgQWBBSpYialgC5HyXVb1G3rqKnxa0SozjAfBgNVHSMEGDAW
+gBSpYialgC5HyXVb1G3rqKnxa0SozjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3
+DQEBCwUAA4ICAQAPAIWQdUp0pmRcTqtHN0k4CGvBJrUrJj92Ui2vDEiphH3ctxOZ
+kcW1lje1LlHGd9b070nSQhuwyJHos++xHPP3J2FcKgVS5XTLP27asIqZnS5bmESV
+yjLIiXWk3ifgyd5ntfR4pov6MUmfYJ6etRHz+16UH7IfsDU4boaZ5pd0jNL9yAHM
+S0hqEWMVSUnT6fHlEXB7WyXR92fGkmGdVMmFwtpNnmIkthvfndueaJEDWHRbwr1Y
+f0lbvZ0p7dVi9ZhR1k6aRmM6fvAWYB7A0bZe/kvUtFJjNThP4C6fLrvalBsBavw4
+zaGJAUv0cDD1dlaN4XXRs0pLFIemxtiy4FNb+lXinCu1M/LeY04SZrV24jMXX0Jl
+z0g99OByejGn2OqycTguhgdO8KKVOsHm29p9l9aDUUjtEZGd6MD+z/AA+yP/TvKm
+Lu1fwScSqSllZLY/qNMFZUTaL4upY2W3Xk2FxMG/9h8IHw6Dcn9A74Psf6tsdRWg
+D3pFceg8k9nJTh2MCChhVBP2icGsrJXtQRHtGuqOU9lsz6HD1r4DQgnPoHmP511k
+p8uKlMk0IxBf5T1hB1ebvZYS9VTNC5J9/Cjp20LXR5wZa3qT5u4G0NMJN1JX0MR1
+dQWBpJjzXI932kYJA6d3djUn8kXAobTBgySs90i+MjKe08l8/xZo/4FwXA==
+-----END CERTIFICATE-----
diff --git a/build/apex/key.pem b/build/apex/key.pem
new file mode 100644
index 0000000..ad5f02c
--- /dev/null
+++ b/build/apex/key.pem
@@ -0,0 +1,52 @@
+-----BEGIN PRIVATE KEY-----
+MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQDB6rWPr5VxVSIk
+TWJZ6yd3YXwT3zcb8CuZ9uQXgMmTJTpi6y/Da+TyVbIhl7bOn6K01LJy0lc6zVI3
+RQVqzll0iUP0GzZ9Jbq8sXFMnwwcz/Ob5TOj2ZsInt/280MxlGPi2cDakzAistcb
+/ColpJs+Ejf8m+AApIQUw//Yz/1oUy466bzu/0cYoAPBsja4vwkU2ObbtRNcQviv
+R1X0x450IOvUlMyFUCaQ2AcCEA15HO7jbjlXqExc81qkx6TOn7yFbwbigVi+rk2o
+3Z7Cenu+ViFdtW8Lr0QTZQyrnAu2d4fKuoQ4Ju6tWICwwY86X2Dmvj4QAhJp+RUq
+KwmelI5tqLFiKmmk7K4+zPorsDmgDUVU7oEXlLR8sPZYaqLQa4RDJDzHUYyp6jEJ
+YfNftw9x+v3Gc3RLFVxXqy3sGSPIiWKIac9O++0g6PBRBAa5nZv+1ZJzSUcpCoX0
+qRX2GWROgIky9cfJR/uWARwm2nZHf63okBI31pcH3jzy1e6CJIt8qkVo2E9TE7dy
+pQEhmfR2SNqHXsyHKI2b4B3R1/DBsrX1g5F84iVa1zFF4FH5Y0MKbIxIRNUddxOY
+3aVbKcOtuATyzsKBM2O9LRNLBHelpUlRNRVdwIlSEt75VxIGyvuoZhvpYP6r9GSH
+MA9m4yp7xDrS9O+xx1lqY8us7lRRLwIDAQABAoICAEenzEl5D1bep4wUkEg7zcye
+WDQbooiPWf09rxFERLg75HRTBcZHo0UtB3LEVgfKE1yQ0BP/x73xyvSja5oJACNA
+6bxVJfBetb8uLniquNYYvaMYsdlU+qXX11iwkV7Lv5E+97WM+BeKUFSF/KkGR1tL
+bibJDqAOKsRlnK/oQ3J+cjHQ10DVUdc2ocy8Zt4jsV5jvALpyWqpUK2sRYX7C5e7
+5okaJu0ILggN26EWf3QGjfu6ajQK+5TJU/BZ2XuEqSwBV+Dw/PMRA59nrVed3QX7
+W7794TfHHvevulvbgLR/PM1b2KnLMR0a/ArUq3FddzgsilBuA5HnObvoRVi0+l/D
+Sc0eoOS3+8dRklsv1+pR2rJX6vNkspex4D60/nV/vSLhaH5Qnkxs1lrApBtlnhVv
+4uRFotW8LXkFTBno4aTxHXMK0bJeQQsHyHHglcdEFpa3CZAfl/bvfiZEvJBfbIKD
+69MHii/OQBl2nslXoK9Cdcrv4Blg2Ht1V9v7opqvj+7tH86qyk+TpGwjJv0RHj+x
+nLZvix3zh77JhaPCp7+uhi7oo8ZT9y7o0gTHVWEWFi8V+tN/Trn1fLar8AFMxuD5
+4BFSgPlyzXo1hzsQLrbW6WHrbQo75LY6PQOeNI7lk9mp7PkzZ4Hwe3AU3STBEZKz
+uKf/7OnsznOcy+s+J30pAoIBAQD6y0CDUmZs+6aYxJ0D/AAIr2JUvRPlwowRZ7Ye
+Oil22DQ+cCTa5j6luAZrQ3x8Qmzy3RSetdxekygehyueWJwxtfsnUgUyIFlb1icJ
+Ou0rBFMZv/pfuGgO9QlJ67rWnd7ceolcT7i3OUvJMDMMCP5dqgQcyFqRnTMroX1c
+Y3IM0R7tzJMPX6mwgnZXNn2KVKtD4ZI2+F8t2GnK6XHv274NhTl8JCdsb3yuUhzH
+zX6axMAVIXNd0keMQ6eLdGV6LT6dCNYRrrmbjd8NzsxbIW8IsGZFlRoB6i845/sa
+C37Jntt2/G7p3cVA8tyOQ7ZZVZQ2nlL1sM8F8RACPfPaqmlVAoIBAQDF8TSk90NP
+Wc4HONuo8QPCMEXaHo1tqH+aUzqX9WamVWk4yfv1BVuD3q2UvKLNRMzQpa1gAZjk
+e4STOa1eCNCpeA3aqbdunrUrfoz02SQSoTKM+o5hbBiiH4wK+oXkkR29+VdU2Yww
+kCTKCFjBf4hV+2u1/eBuR1MDcOVwQW6N3Sk37ImwGtygRrHIPuY8Ir00WQmpKP6W
+MMdi0tUNXxp51vs8Q8TGrfZC/l7gs1OEaaSrb+60epprwFPWMiFubPHyQ7f9dm32
+lbjhUPvJfF04pTazV2aAyAYZPaQmNhQ1TQlW8ggtZfVc9/Hw/eq4K/3VevixCqqK
+mmcYcDf4qwBzAoIBADEhtm7Dqss49adCBVytdrg826+sJwTA+z3Bqpz7WfotWvbM
+c3vq1WUTyzYiT3XscXmWtB5vlE921so8QuBPjbHza9OFLv1l9vuV1anqQGJIA5us
+z3kHIGOlv38azkyTOwDIhLZv68kBUYaFicqWzHY/A3U8Dvot6MNobK230bUPFtcR
+V9IQNKcet95YD3oVIkQ3IbThLYxGtFsLJsYNr4roiZ13W73TjYJ9FaRS7rWVS+gX
+2IkN0/R3oJAiamroCDctbvqh1zzRK1yCIejMgPsby71f+2tanIuybq/ohpsrIuWJ
+iJUKXEVgDrNUMpoHuPSGScxWKgiI9FDsICS7c80CggEALUJmwCWNbXJiSoJ0r19U
+da1l+2aq/dzeOGI5bo99BiFXatW8V5z+/NsIo46yRu8pSbfoOaCD3hJkEOnKO0sW
+svkxacMOnyuIz0YjYsTXm67iCRwtPBdkVoWSFtyLiuSngU2m607G4D/FObDI4o2P
+leFkEnvXOj/yukGxJIbBiYx9JT1fijXKJpejhN7k8/EZhAOr0tL9y0eh/3Wno2QQ
+gLVoQrJYJvmV6mGRPh2ixg8FyPFSClBSSLr0MHDL9hzRAYz8X+cZY51+ZX6H490c
+z5vvMviUBnQ1+MWAaABLhJh1vzyeJAtBHB3RY0Ibzjq40nxIqup+biy5z/uwwJoR
+AwKCAQBWMGM6CNec1ZzVBjELuvOhcnL+gN6UpmiKbQR+gDqx+Ne2nGXnNvhHwmHz
+4itN/KwE3v65d89LVmWc1VBEbCc22GYAgtoNm81NTeMIiDZsckg4GWFriG7NI7vl
+ssl7NDBHfk5f3jSiv/dguEK8FQgUaYL+T0fhH714Jzdru5MAVZ3XSTqtU3KX+PHh
+6rEh2RxkP2iZZnpM1VfW/icdUalzgt6o+CNREhcg3oxo4MKJqccYw8CKiCOT5J97
+c+x69cDAOSStC9bGkRi4IDOG71asodXvfvpO/NznF43bQIslm4AO63V9A8G+oaDc
+rXj28Z+zT528vAQI3nb+Oq3EvUNN
+-----END PRIVATE KEY-----
diff --git a/build/message_check_equality.txt b/build/message_check_equality.txt
index 3fee410..bb9f5c9 100644
--- a/build/message_check_equality.txt
+++ b/build/message_check_equality.txt
@@ -4,3 +4,4 @@
Above AIDL file(s) has changed. Run `m %s-update-api` to reflect the changes
to the current version so that it is reviewed by
android-aidl-api-council@google.com
+And then you need to change dependency on %s-* to %s-unstable-* to use new APIs.
\ No newline at end of file
diff --git a/build/properties.go b/build/properties.go
index 60d6a3f..69914ed 100644
--- a/build/properties.go
+++ b/build/properties.go
@@ -17,28 +17,38 @@
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
+ Header_libs []string
Sdk_version *string
Stl *string
Cpp_std *string
@@ -46,6 +56,11 @@
Stem *string
Apex_available []string
Min_sdk_version *string
+ UseApexNameMacro bool
+ Target ccTargetProperties
+ Tidy *bool
+ Tidy_flags []string
+ Tidy_checks_as_errors []string
}
type javaProperties struct {
@@ -61,6 +76,19 @@
Min_sdk_version *string
}
+type rustProperties struct {
+ Name *string
+ Crate_name string
+ Owner *string
+ Defaults []string
+ Host_supported *bool
+ Srcs []string
+ Rustlibs []string
+ Stem *string
+ Target rustTargetProperties
+ Apex_available []string
+}
+
type phonyProperties struct {
Name *string
Required []string
diff --git a/build/test_package/IBaz.aidl b/build/test_package/IBaz.aidl
index 357dc50..599ef90 100644
--- a/build/test_package/IBaz.aidl
+++ b/build/test_package/IBaz.aidl
@@ -18,6 +18,7 @@
import some_package.IBar;
+@SuppressWarnings(value={"mixed-oneway", "inout-parameter", "out-array"})
interface IBaz {
oneway void CanYouDealWithThisBar(in IBar bar);
void MethodAddedInVersion2();
diff --git a/build/tests_1/some_package/IFoo.aidl b/build/tests_1/some_package/IFoo.aidl
index 7940435..4aa63b8 100644
--- a/build/tests_1/some_package/IFoo.aidl
+++ b/build/tests_1/some_package/IFoo.aidl
@@ -19,6 +19,7 @@
import some_package.Thing;
import some_package.sub_package.SubThing;
+@SuppressWarnings(value={"inout-parameter"})
interface IFoo {
void CanYouDealWithThisThing(inout Thing parcel);
void CanYouDealWithThisSubThing(inout SubThing parcel);
diff --git a/build/tests_1/some_package/sub_package/IFoo.aidl b/build/tests_1/some_package/sub_package/IFoo.aidl
index 0fb85f4..26a71f4 100644
--- a/build/tests_1/some_package/sub_package/IFoo.aidl
+++ b/build/tests_1/some_package/sub_package/IFoo.aidl
@@ -19,6 +19,7 @@
import some_package.Thing;
import some_package.sub_package.SubThing;
+@SuppressWarnings(value={"inout-parameter"})
interface IFoo {
void CanYouDealWithThisThing(inout Thing parcel);
void CanYouDealWithThisSubThing(inout SubThing parcel);
diff --git a/build/tests_3/EmptyParcelable.aidl b/build/tests_3/EmptyParcelable.aidl
new file mode 100644
index 0000000..1809305
--- /dev/null
+++ b/build/tests_3/EmptyParcelable.aidl
@@ -0,0 +1 @@
+parcelable EmptyParcelable {}
diff --git a/build/tests_3/IEmptyInterface.aidl b/build/tests_3/IEmptyInterface.aidl
new file mode 100644
index 0000000..6d95630
--- /dev/null
+++ b/build/tests_3/IEmptyInterface.aidl
@@ -0,0 +1 @@
+interface IEmptyInterface {}
diff --git a/build/tests_transitive_parcel/a/IA.aidl b/build/tests_transitive_parcel/a/IA.aidl
new file mode 100644
index 0000000..ff097f0
--- /dev/null
+++ b/build/tests_transitive_parcel/a/IA.aidl
@@ -0,0 +1,23 @@
+/*
+ * 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 tests_transitive_parcel.a;
+
+import tests_transitive_parcel.b.B;
+
+interface IA {
+ B getB();
+}
diff --git a/build/tests_transitive_parcel/b/B.aidl b/build/tests_transitive_parcel/b/B.aidl
new file mode 100644
index 0000000..3468d30
--- /dev/null
+++ b/build/tests_transitive_parcel/b/B.aidl
@@ -0,0 +1,24 @@
+/*
+ * 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 tests_transitive_parcel.b;
+
+import tests_transitive_parcel.c.C;
+
+parcelable B {
+ int i;
+ C c;
+}
diff --git a/build/tests_transitive_parcel/c/C.aidl b/build/tests_transitive_parcel/c/C.aidl
new file mode 100644
index 0000000..697a9f1
--- /dev/null
+++ b/build/tests_transitive_parcel/c/C.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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 tests_transitive_parcel.c;
+
+parcelable C {
+ int i;
+}
diff --git a/code_writer.cpp b/code_writer.cpp
index 096c895..773a598 100644
--- a/code_writer.cpp
+++ b/code_writer.cpp
@@ -15,13 +15,15 @@
*/
#include "code_writer.h"
+#include "logging.h"
+
#include <stdarg.h>
#include <fstream>
#include <iostream>
#include <sstream>
+#include <unordered_map>
#include <vector>
-#include <android-base/logging.h>
#include <android-base/stringprintf.h>
namespace android {
@@ -74,7 +76,7 @@
indent_level_++;
}
void CodeWriter::Dedent() {
- CHECK(indent_level_ > 0);
+ AIDL_FATAL_IF(indent_level_ <= 0, "Mismatched dedent");
indent_level_--;
}
@@ -131,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 08516bf..7501385 100644
--- a/code_writer.h
+++ b/code_writer.h
@@ -16,13 +16,13 @@
#pragma once
+#include <stdio.h>
+
+#include <functional>
#include <memory>
#include <ostream>
#include <string>
-
-#include <stdio.h>
-
-#include <android-base/macros.h>
+#include <utility>
namespace android {
namespace aidl {
@@ -39,14 +39,6 @@
// The buffer gets updated only after Close() is called or the CodeWriter
// is deleted -- much like a real file.
static CodeWriterPtr ForString(std::string* buf);
- // Run a Code Generater (which accepts CodeWriter& as a first parameter)
- // and return a result as a string.
- template <typename... Args>
- static std::string RunWith(void (*gen)(CodeWriter&, Args...), Args&&... args) {
- std::string code;
- (*gen)(*ForString(&code), std::forward<Args>(args)...);
- return code;
- }
// Write a formatted string to this writer in the usual printf sense.
// Returns false on error.
virtual bool Write(const char* format, ...) __attribute__((format(printf, 2, 3)));
@@ -67,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..694e96a
--- /dev/null
+++ b/diagnostics.cpp
@@ -0,0 +1,266 @@
+/*
+ * 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 "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 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 case: " << 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 case: " << 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()) 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 {
+ bool has_oneway = false;
+ bool has_twoway = false;
+ for (const auto& m : i.GetMethods()) {
+ if (!m->IsUserDefined()) continue;
+ if (m->IsOneway()) {
+ has_oneway = true;
+ } else {
+ has_twoway = true;
+ }
+ }
+ if (has_oneway && has_twoway) {
+ diag.Report(i.GetLocation(), DiagnosticID::mixed_oneway)
+ << "The interface '" << i.GetName()
+ << "' has both one-way and two-way methods. This makes it hard to reason about threading "
+ "of client code.";
+ }
+ }
+};
+
+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.";
+ }
+ }
+};
+
+struct DiagnoseOutNullable : DiagnosticsVisitor {
+ DiagnoseOutNullable(DiagnosticsContext& diag) : DiagnosticsVisitor(diag) {}
+ void Visit(const AidlArgument& a) override {
+ if (a.GetType().IsArray()) return;
+ if (a.IsOut() && a.GetType().IsNullable()) {
+ diag.Report(a.GetLocation(), DiagnosticID::out_nullable)
+ << "'" << a.GetName() << "' is an " << a.GetDirectionSpecifier()
+ << " parameter and also nullable. Some backends don't support setting null value to out "
+ "parameters. Please use it as return value or drop @nullable to avoid potential "
+ "errors.";
+ }
+ }
+};
+
+bool Diagnose(const AidlDocument& doc, const DiagnosticMapping& mapping) {
+ DiagnosticsContext diag(mapping);
+
+ DiagnoseInterfaceName{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);
+ DiagnoseOutNullable{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..59ea7c8
--- /dev/null
+++ b/diagnostics.inc
@@ -0,0 +1,10 @@
+// DIAG(enum, name, enable-by-default)
+DIAG(const_name, "const-name", 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(out_nullable, "out-nullable", false)
+DIAG(unknown_warning, "unknown-warning", false)
diff --git a/diagnostics_unittest.cpp b/diagnostics_unittest.cpp
new file mode 100644
index 0000000..0ea3141
--- /dev/null
+++ b/diagnostics_unittest.cpp
@@ -0,0 +1,180 @@
+/*
+ * 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 " + optional_args + " -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::string optional_args;
+ 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_explicit_default) {
+ expect_diagnostics = {DiagnosticID::enum_explicit_default};
+ ParseFiles({{"Foo.aidl", "parcelable Foo { E e; }"}, {"E.aidl", "enum E { A }"}});
+}
+
+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, OnewayInterfaceIsOkayWithSyntheticMethods) {
+ optional_args = "--version 2"; // will add getInterfaceVersion() synthetic method
+ expect_diagnostics = {};
+ ParseFiles({
+ {"IFoo.aidl", "oneway interface IFoo { void foo(); }"},
+ });
+}
+
+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"
+ "}"}});
+}
+
+TEST_F(DiagnosticsTest, out_nullable) {
+ expect_diagnostics = {DiagnosticID::out_nullable};
+ ParseFiles({{"IFoo.aidl",
+ "interface IFoo {\n"
+ " void foo(out @nullable Bar bar);\n"
+ "}"},
+ {"Bar.aidl", "parcelable Bar {}"}});
+}
+
+TEST_F(DiagnosticsTest, inout_nullable) {
+ expect_diagnostics = {DiagnosticID::out_nullable};
+ ParseFiles({{"IFoo.aidl",
+ "interface IFoo {\n"
+ " void foo(inout @nullable Bar bar);\n"
+ "}"},
+ {"Bar.aidl", "parcelable Bar {}"}});
+}
+
+TEST_F(DiagnosticsTest, out_nullable_OkayForArrays) {
+ expect_diagnostics = {DiagnosticID::out_array}; // not triggering out_nullable
+ ParseFiles({{"IFoo.aidl",
+ "interface IFoo {\n"
+ " void foo(inout @nullable Bar[] bar1, out @nullable Bar[] bar2);\n"
+ "}"},
+ {"Bar.aidl", "parcelable Bar {}"}});
+}
diff --git a/docs/aidl-cpp.md b/docs/aidl-cpp.md
deleted file mode 100644
index aa97aa9..0000000
--- a/docs/aidl-cpp.md
+++ /dev/null
@@ -1,270 +0,0 @@
-# Generating C++ Binder Interfaces with `aidl-cpp`
-
-## Background
-
-“aidl” refers to several related but distinct concepts:
-
- - the AIDL interface [definition language](http://developer.android.com/guide/components/aidl.html)
- - .aidl files (which contain AIDL)
- - the aidl generator which transforms AIDL into client/server IPC interfaces
-
-The _aidl generator_ is a command line tool that generates client and server
-stubs for Binder interfaces from a specification in a file with the .aidl
-extension. For Java interfaces, the executable is called `aidl` while for C++
-the binary is called `aidl-cpp`. In this document, we’ll use AIDL to describe
-the language of .aidl files and _aidl generator_ to refer to the code generation
-tool that takes an .aidl file, parses the AIDL, and outputs code.
-
-Previously, the _aidl generator_ only generated Java interface/stub/proxy
-objects. C++ Binder interfaces were handcrafted with various degrees of
-compatibility with the Java equivalents. The Brillo project added support for
-generating C++ with the _aidl generator_. This generated C++ is cross-language
-compatible (e.g. Java clients are tested to interoperate with native services).
-
-## Overview
-
-This document describes how C++ generation works with attention to:
-
- - build interface
- - cross-language type mapping
- - implementing a generated interface
- - C++ parcelables
- - cross-language error reporting
- - cross-language null reference handling
-
-## Detailed Design
-
-### Build Interface
-
-Write AIDL in .aidl files and add them to `LOCAL_SRC_FILES` in your Android.mk.
-If your build target is a binary (e.g. you include `$(BUILD_SHARED_LIBRARY)`),
-then the generated code will be C++, not Java.
-
-AIDL definitions should be hosted from the same repository as the
-implementation. Any system that needs the definition will also need the
-implementation (for both parcelables and interface). If there are multiple
-implementations (i.e. one in Java and one in C++), keep the definition with the
-native implementation. Android
-[now has systems](https://developers.google.com/brillo/?hl=en) that run the
-native components of the system without the Java.
-
-If you use an import statement in your AIDL, even from the same package, you
-need to add a path to `LOCAL_AIDL_INCLUDES`. This path should be relative to
-the root of the Android tree. For instance, a file IFoo.aidl defining
-com.example.IFoo might sit in a folder hierarchy
-something/something-else/com/example/IFoo.aidl. Then we would write:
-
-```
-LOCAL_AIDL_INCLUDES := something/something-else
-```
-
-Generated C++ ends up in nested namespaces corresponding to the interface’s
-package. The generated header also corresponds to the interface package. So
-com.example.IFoo becomes ::com::example::IFoo in header “com/example/IFoo.h”.
-
-Similar to how Java works, the suffix of the path to a .aidl file must match
-the package. So if IFoo.aidl declares itself to be in package com.example, the
-folder structure (as given to `LOCAL_SRC_FILES`) must look like:
-`some/prefix/com/example/IFoo.aidl`.
-
-To generate code from .aidl files from another build target (e.g. another
-binary or java), just add a relative path to the .aidl files to
-`LOCAL_SRC_FILES`. Remember that importing AIDL works the same, even for code
-in other directory hierarchies: add the include root path relative to the
-checkout root to `LOCAL_AIDL_INCLUDES`.
-
-### Type Mapping
-
-The following table summarizes the equivalent C++ types for common Java types
-and whether those types may be used as in/out/inout parameters in AIDL
-interfaces.
-
-| Java Type | C++ Type | inout | Notes |
-|-----------------------|---------------------|-------|-------------------------------------------------------|
-| boolean | bool | in | "These 8 types are all considered primitives. |
-| byte | int8\_t | in | |
-| char | char16\_t | in | |
-| int | int32\_t | in | |
-| long | int64\_t | in | |
-| float | float | in | |
-| double | double | in | |
-| String | String16 | in | Supports null references. |
-| @utf8InCpp String | std::string | in | @utf8InCpp causes UTF16 to UTF8 conversion in C++. |
-| android.os.Parcelable | android::Parcelable | inout | |
-| T extends IBinder | sp<T> | in | |
-| Arrays (T[]) | vector<T> | inout | May contain only primitives, Strings and parcelables. |
-| List<String> | vector<String16> | inout | |
-| PersistableBundle | PersistableBundle | inout | binder/PersistableBundle.h |
-| List<IBinder> | vector<sp<IBinder>> | inout | |
-| FileDescriptor | unique_fd | inout | android-base/unique_fd.h from libbase |
-
-Note that annotations may be placed at the interface level, as well as on a
-type by type basis. Interface level annotations will be applied
-opportunistically and be overridden by per type annotations. For instance, an
-interface marked @nullable will still not allow null int parameters.
-
-### Implementing a generated interface
-
-Given an interface declaration like:
-
-```
-package foo;
-
-import bar.IAnotherInterface;
-
-interface IFoo {
- IAnotherInterface DoSomething(int count, out List<String> output);
-}
-```
-
-`aidl-cpp` will generate a C++ interface:
-
-```
-namespace foo {
-
-// Some headers have been omitted for clarity.
-#include <android/String16.h>
-#include <cstdint>
-#include <vector>
-#include <bar/IAnotherInterface.h>
-
-// Some class members have been omitted for clarity.
-class IFoo : public android::IInterface {
- public:
- virtual android::binder::Status DoSomething(
- int32_t count,
- std::vector<android::String16>* output,
- android::sp<bar::IAnotherInterface>* returned_value) = 0;
-};
-```
-
-Note that `aidl-cpp` will import headers for types used in the interface. For
-imported types (e.g. parcelables and interfaces), it will import a header
-corresponding to the package/class name of the import. For instance,
-`import bar.IAnotherInterface` causes aidl-cpp to generate
-`#include <bar/IAnotherInterface.h>`.
-
-When writing a service that implements this interface, write:
-
-```
-#include "foo/BnFoo.h"
-
-namespace unrelated_namespace {
-
-class MyFoo : public foo::BnFoo {
- public:
- android::binder::Status DoSomething(
- int32_t count,
- std::vector<android::String16>* output,
- android::sp<bar::IAnotherInterface>* returned_value) override {
- for (int32_t i = 0; i < count; ++i) {
- output->push_back(String16("..."));
- }
- *returned_value = new InstanceOfAnotherInterface;
- return Status::ok();
- }
-}; // class MyFoo
-
-} // namespace unrelated_namespace
-```
-
-Note that the output values, `output` and `returned_value` are passed by
-pointer, and that this pointer is always valid.
-
-#### Dependencies
-
-The generated C++ code will use symbols from libbinder as well as libutils.
-AIDL files using the FileDescriptor type will also explicitly require
-libnativehelper, although this is likely a transitive dependency of the other
-two, and should be included automatically within the Android build tree
-regardless.
-
-### C++ Parcelables
-
-In Java, a parcelable should extend android.os.Parcelable and provide a static
-final CREATOR field that acts as a factory for new instances/arrays of
-instances of the parcelable. In addition, in order to be used as an out
-parameter, a parcelable class must define a readFromParcel method.
-
-In C++, parcelables must implement android::Parcelable from binder/Parcelable.h
-in libbinder. Parcelables must define a constructor that takes no arguments.
-In order to be used in arrays, a parcelable must implement a copy or move
-constructor (called implicitly in vector).
-
-The C++ generator needs to know what header defines the C++ parcelable. It
-learns this from the `cpp_header` directive shown below. The generator takes
-this string and uses it as the literal include statement in generated code.
-The idea here is that you generate your code once, link it into a library along
-with parcelable implementations, and export appropriate header paths. This
-header include must make sense in the context of the Android.mk that compiles
-this generated code.
-
-```
-// ExampleParcelable.aidl
-package com.example.android;
-
-// Native types must be aliased at their declaration in the appropriate .aidl
-// file. This allows multiple interfaces to use a parcelable and its C++
-// equivalent without duplicating the mapping between the C++ and Java types.
-// Generator will assume bar/foo.h declares class
-// com::example::android::ExampleParcelable
-parcelable ExampleParcelable cpp_header "bar/foo.h";
-```
-
-### Null Reference Handling
-
-The aidl generator for both C++ and Java languages has been expanded to
-understand nullable annotations.
-
-Given an interface definition like:
-
-```
-interface IExample {
- void ReadStrings(String neverNull, in @nullable String maybeNull);
-};
-```
-
-the generated C++ header code looks like:
-
-```
-class IExample {
- android::binder::Status ReadStrings(
- const android::String16& in_neverNull,
- const std::unique_ptr<android::String16>& in_maybeNull);
-};
-```
-
-Note that by default, the generated C++ passes a const reference to the value
-of a parameter and rejects null references with a NullPointerException sent
-back the caller. Parameters marked with @nullable are passed by pointer,
-allowing native services to explicitly control whether they allow method
-overloading via null parameters. Java stubs and proxies currently do nothing
-with the @nullable annotation.
-
-Consider an AIDL type `in @nullable List<String> bar`. This type
-indicates that the remote caller may pass in a list of strings, and that both
-the list and any string in the list may be null. This type will map to a C++
-type `unique_ptr<vector<unique_ptr<String16>>>* bar`. In this case:
-
- - `bar` is never null
- - `*bar` might be null
- - `(*bar)->empty()` could be true
- - `(**bar)[0]` could be null (and so on)
-
-### Exception Reporting
-
-C++ methods generated by the aidl generator return `android::binder::Status`
-objects, rather than `android::status_t`. This Status object allows generated
-C++ code to send and receive exceptions (an exception type and a String16 error
-message) since we do not use real exceptions in C++. More background on Status
-objects can be found here.
-
-For legacy support and migration ease, the Status object includes a mechanism
-to report a `android::status_t`. However, that return code is interpreted by a
-different code path and does not include a helpful String message.
-
-For situations where your native service needs to throw an error code specific
-to the service, use `Status::fromServiceSpecificError()`. This kind of
-exception comes with a helpful message and an integer error code. Make your
-error codes consistent across services by using interface constants (see
-below).
diff --git a/generate_cpp.cpp b/generate_cpp.cpp
index cc25657..fcc27b6 100644
--- a/generate_cpp.cpp
+++ b/generate_cpp.cpp
@@ -17,6 +17,7 @@
#include "generate_cpp.h"
#include "aidl.h"
+#include <algorithm>
#include <cctype>
#include <cstring>
#include <memory>
@@ -24,7 +25,9 @@
#include <set>
#include <string>
+#include <android-base/format.h>
#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
#include "aidl_language.h"
#include "aidl_to_cpp.h"
@@ -52,6 +55,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 +63,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,14 +170,15 @@
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&,
const Options& options, bool for_interface) {
- CHECK(!method.IsUserDefined());
+ AIDL_FATAL_IF(method.IsUserDefined(), method);
if (method.GetName() == kGetInterfaceVersion && options.Version()) {
std::ostringstream code;
if (for_interface) {
@@ -221,45 +227,26 @@
return NestInNamespaces(std::move(decls), package);
}
-bool DeclareLocalVariable(const AidlArgument& a, StatementBlock* b,
- const AidlTypenames& typenamespaces) {
- string type = CppNameOf(a.GetType(), typenamespaces);
-
- b->AddLiteral(type + " " + BuildVarName(a));
- return true;
-}
-
-string BuildHeaderGuard(const AidlDefinedType& defined_type, ClassNames header_type) {
- string class_name = ClassName(defined_type, header_type);
- for (size_t i = 1; i < class_name.size(); ++i) {
- if (isupper(class_name[i])) {
- class_name.insert(i, "_");
- ++i;
- }
- }
- string ret = StringPrintf("AIDL_GENERATED_%s_%s_H_", defined_type.GetPackage().c_str(),
- class_name.c_str());
- for (char& c : ret) {
- if (c == '.') {
- c = '_';
- }
- c = toupper(c);
- }
- return ret;
-}
-
unique_ptr<Declaration> DefineClientTransaction(const AidlTypenames& typenames,
const AidlInterface& interface,
const AidlMethod& method, const Options& options) {
const string i_name = ClassName(interface, ClassNames::INTERFACE);
const string bp_name = ClassName(interface, ClassNames::CLIENT);
unique_ptr<MethodImpl> ret{
- new MethodImpl{kBinderStatusLiteral, bp_name, method.GetName(),
+ new MethodImpl{kBinderStatusLiteral,
+ bp_name,
+ method.GetName(),
+ {},
ArgList{BuildArgList(typenames, method, true /* for method decl */)}}};
StatementBlock* b = ret->GetStatementBlock();
// 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));
+ }
+ b->AddLiteral(StringPrintf("%s.markForBinder(remoteStrong())", kDataVarName));
+
// Even if we're oneway, the transact method still takes a parcel.
b->AddLiteral(StringPrintf("%s %s", kAndroidParcelLiteral, kReplyVarName));
@@ -271,9 +258,9 @@
b->AddLiteral(StringPrintf("%s %s", kBinderStatusLiteral, kStatusVarName));
if (options.GenTraces()) {
- b->AddLiteral(StringPrintf("::android::ScopedTrace %s(ATRACE_TAG_AIDL, \"%s::%s::cppClient\")",
- kTraceVarName, interface.GetName().c_str(),
- method.GetName().c_str()));
+ b->AddLiteral(
+ StringPrintf("::android::ScopedTrace %s(ATRACE_TAG_AIDL, \"AIDL::cpp::%s::%s::cppClient\")",
+ kTraceVarName, interface.GetName().c_str(), method.GetName().c_str()));
}
if (options.GenLog()) {
@@ -314,14 +301,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,
@@ -418,7 +407,7 @@
const AidlInterface& interface,
const AidlMethod& method,
const Options& options) {
- CHECK(!method.IsUserDefined());
+ AIDL_FATAL_IF(method.IsUserDefined(), method);
if (method.GetName() == kGetInterfaceVersion && options.Version() > 0) {
const string iface = ClassName(interface, ClassNames::INTERFACE);
const string proxy = ClassName(interface, ClassNames::CLIENT);
@@ -432,7 +421,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"
@@ -456,7 +445,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"
@@ -479,31 +468,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)));
}
@@ -526,14 +514,79 @@
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
// in serialization.
for (const unique_ptr<AidlArgument>& a : method.GetArguments()) {
- if (!DeclareLocalVariable(*a, b, typenames)) {
- return false;
- }
+ b->AddLiteral(StringPrintf("%s %s", CppNameOf(a->GetType(), typenames).c_str(),
+ BuildVarName(*a).c_str()));
}
// Declare a variable to hold the return value.
@@ -552,6 +605,12 @@
new Assignment(kAndroidStatusVarName, "::android::BAD_TYPE"));
interface_check->OnTrue()->AddLiteral("break");
+ if (options.GenTraces()) {
+ b->AddLiteral(
+ StringPrintf("::android::ScopedTrace %s(ATRACE_TAG_AIDL, \"AIDL::cpp::%s::%s::cppServer\")",
+ kTraceVarName, interface.GetName().c_str(), method.GetName().c_str()));
+ }
+
// Deserialize each "in" parameter to the transaction.
for (const auto& a: method.GetArguments()) {
// Deserialization looks roughly like:
@@ -576,13 +635,6 @@
}
}
- if (options.GenTraces()) {
- b->AddStatement(new Statement(new MethodCall("atrace_begin",
- ArgList{{"ATRACE_TAG_AIDL",
- StringPrintf("\"%s::%s::cppServer\"",
- interface.GetName().c_str(),
- method.GetName().c_str())}})));
- }
const string bn_name = ClassName(interface, ClassNames::SERVER);
if (options.GenLog()) {
b->AddLiteral(GenLogBeforeExecute(bn_name, method, true /* isServer */, false /* isNdk */),
@@ -596,11 +648,6 @@
StringPrintf("%s %s", kBinderStatusLiteral, kStatusVarName),
ArgList(std::move(status_args)))));
- if (options.GenTraces()) {
- b->AddStatement(new Statement(new MethodCall("atrace_end",
- "ATRACE_TAG_AIDL")));
- }
-
if (options.GenLog()) {
b->AddLiteral(GenLogAfterExecute(bn_name, interface, method, kStatusVarName, kReturnVarName,
true /* isServer */, false /* isNdk */),
@@ -648,7 +695,7 @@
bool HandleServerMetaTransaction(const AidlTypenames&, const AidlInterface& interface,
const AidlMethod& method, const Options& options,
StatementBlock* b) {
- CHECK(!method.IsUserDefined());
+ AIDL_FATAL_IF(method.IsUserDefined(), method);
if (method.GetName() == kGetInterfaceVersion && options.Version() > 0) {
std::ostringstream code;
@@ -684,11 +731,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)");
@@ -697,14 +742,15 @@
"::android::internal::Stability::markCompilationUnit(this)");
}
- unique_ptr<MethodImpl> on_transact{new MethodImpl{
- kAndroidStatusLiteral, bn_name, "onTransact",
- ArgList{{StringPrintf("uint32_t %s", kCodeVarName),
- StringPrintf("const %s& %s", kAndroidParcelLiteral,
- kDataVarName),
- StringPrintf("%s* %s", kAndroidParcelLiteral, kReplyVarName),
- StringPrintf("uint32_t %s", kFlagsVarName)}}
- }};
+ unique_ptr<MethodImpl> on_transact{
+ new MethodImpl{kAndroidStatusLiteral,
+ bn_name,
+ "onTransact",
+ {},
+ ArgList{{StringPrintf("uint32_t %s", kCodeVarName),
+ StringPrintf("const %s& %s", kAndroidParcelLiteral, kDataVarName),
+ StringPrintf("%s* %s", kAndroidParcelLiteral, kReplyVarName),
+ StringPrintf("uint32_t %s", kFlagsVarName)}}}};
// Declare the status_t variable
on_transact->GetStatementBlock()->AddLiteral(
@@ -717,7 +763,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;
@@ -756,7 +802,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;
@@ -775,10 +833,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)));
}
@@ -794,32 +851,16 @@
HeaderFile(interface, ClassNames::CLIENT, false),
};
- string fq_name = ClassName(interface, ClassNames::INTERFACE);
- if (!interface.GetPackage().empty()) {
- fq_name = interface.GetPackage() + "." + fq_name;
- }
-
vector<unique_ptr<Declaration>> decls;
- unique_ptr<MacroDecl> meta_if{new MacroDecl{
- "DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE",
- ArgList{vector<string>{ClassName(interface, ClassNames::BASE), '"' + fq_name + '"'}}}};
+ unique_ptr<MacroDecl> meta_if{
+ new MacroDecl{"DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE",
+ ArgList{vector<string>{ClassName(interface, ClassNames::BASE),
+ '"' + 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,
@@ -846,6 +887,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));
@@ -858,14 +901,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"});
- }
+ includes.emplace_back("android/binder_to_string.h");
- vector<unique_ptr<Declaration>> privates;
+ publics.emplace_back(new LiteralDecl{kTransactionLogStruct});
+ publics.emplace_back(
+ new LiteralDecl{"static std::function<void(const TransactionLog&)> logFunc;\n"});
+ }
if (options.Version() > 0) {
privates.emplace_back(new LiteralDecl("int32_t cached_version_ = -1;\n"));
@@ -875,16 +917,18 @@
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>{
- new CppHeader{BuildHeaderGuard(interface, ClassNames::CLIENT), includes,
- NestInNamespaces(std::move(bp_class), interface.GetSplitPackage())}};
+ new CppHeader{includes, NestInNamespaces(std::move(bp_class), interface.GetSplitPackage())}};
}
unique_ptr<Document> BuildServerHeader(const AidlTypenames& /* typenames */,
@@ -907,12 +951,21 @@
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));
if (options.Version() > 0) {
std::ostringstream code;
- code << "int32_t " << kGetInterfaceVersion << "() final override;\n";
+ code << "int32_t " << kGetInterfaceVersion << "() final;\n";
publics.emplace_back(new LiteralDecl(code.str()));
}
if (!options.Hash().empty()) {
@@ -922,22 +975,25 @@
}
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");
+ includes.emplace_back("android/binder_to_string.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"});
}
- 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{BuildHeaderGuard(interface, ClassNames::SERVER), includes,
- NestInNamespaces(std::move(bn_class), interface.GetSplitPackage())}};
+ new CppHeader{includes, NestInNamespaces(std::move(bn_class), interface.GetSplitPackage())}};
}
unique_ptr<Document> BuildInterfaceHeader(const AidlTypenames& typenames,
@@ -946,14 +1002,15 @@
for (const auto& method : interface.GetMethods()) {
for (const auto& argument : method->GetArguments()) {
- AddHeaders(argument->GetType(), typenames, includes);
+ AddHeaders(argument->GetType(), typenames, &includes);
}
- AddHeaders(method->GetType(), typenames, includes);
+ AddHeaders(method->GetType(), typenames, &includes);
}
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)}}}});
@@ -971,41 +1028,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: {
- int_constant_enum->AddValue(constant->GetName(),
- constant->ValueString(ConstantValueDecorator));
- break;
- }
- default: {
- LOG(FATAL) << "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);
@@ -1039,7 +1062,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()));
@@ -1064,115 +1089,71 @@
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{BuildHeaderGuard(interface, ClassNames::INTERFACE),
- vector<string>(includes.begin(), includes.end()),
+ 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&) {
- unique_ptr<ClassDecl> parcel_class{new ClassDecl{parcel.GetName(), "::android::Parcelable"}};
-
- 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 << "(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)
- << ")";
- }
- out << ";\n";
-
- parcel_class->AddPublic(std::unique_ptr<LiteralDecl>(new LiteralDecl(out.str())));
- }
-
- 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));
-
- return unique_ptr<Document>{new CppHeader{
- BuildHeaderGuard(parcel, ClassNames::RAW), 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&) {
- unique_ptr<MethodImpl> read{new MethodImpl{kAndroidStatusLiteral, parcel.GetName(),
- "readFromParcel",
- 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));
read_block->AddLiteral(
- "size_t _aidl_start_pos = _aidl_parcel->dataPosition();\n"
+ "[[maybe_unused]] size_t _aidl_start_pos = _aidl_parcel->dataPosition();\n"
"int32_t _aidl_parcelable_raw_size = _aidl_parcel->readInt32();\n"
"if (_aidl_parcelable_raw_size < 0) return ::android::BAD_VALUE;\n"
- "size_t _aidl_parcelable_size = static_cast<size_t>(_aidl_parcelable_raw_size);\n");
+ "[[maybe_unused]] size_t _aidl_parcelable_size = "
+ "static_cast<size_t>(_aidl_parcelable_raw_size);\n"
+ "if (_aidl_start_pos > SIZE_MAX - _aidl_parcelable_size) return ::android::BAD_VALUE;\n",
+ /*add_semicolon=*/false);
+
+ auto checkAvailableData = StringPrintf(
+ "if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {\n"
+ " _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);\n"
+ " return %s;\n"
+ "}\n",
+ kAndroidStatusVarName);
for (const auto& variable : parcel.GetFields()) {
+ read_block->AddLiteral(checkAvailableData, /*add_semicolon=*/false);
string method = ParcelReadMethodOf(variable->GetType(), typenames);
-
read_block->AddStatement(new Assignment(
kAndroidStatusVarName, new MethodCall(StringPrintf("_aidl_parcel->%s", method.c_str()),
ParcelReadCastOf(variable->GetType(), typenames,
"&" + variable->GetName()))));
read_block->AddStatement(ReturnOnStatusNotOk());
- read_block->AddLiteral(StringPrintf(
- "if (_aidl_parcel->dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) {\n"
- " _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);\n"
- " return %s;\n"
- "}",
- kAndroidStatusVarName));
}
+ read_block->AddLiteral("_aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size)");
read_block->AddLiteral(StringPrintf("return %s", kAndroidStatusVarName));
+}
- unique_ptr<MethodImpl> write{
- new MethodImpl{kAndroidStatusLiteral, parcel.GetName(), "writeToParcel",
- 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));
write_block->AddLiteral(
"auto _aidl_start_pos = _aidl_parcel->dataPosition();\n"
- "_aidl_parcel->writeInt32(0);");
+ "_aidl_parcel->writeInt32(0);\n",
+ /*add_semicolon=*/false);
for (const auto& variable : parcel.GetFields()) {
string method = ParcelWriteMethodOf(variable->GetType(), typenames);
@@ -1187,15 +1168,167 @@
"auto _aidl_end_pos = _aidl_parcel->dataPosition();\n"
"_aidl_parcel->setDataPosition(_aidl_start_pos);\n"
"_aidl_parcel->writeInt32(_aidl_end_pos - _aidl_start_pos);\n"
- "_aidl_parcel->setDataPosition(_aidl_end_pos);");
+ "_aidl_parcel->setDataPosition(_aidl_end_pos);\n",
+ /*add_semicolon=*/false);
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_FINAL));
+ parcel_class->AddPublic(std::move(read));
+ unique_ptr<MethodDecl> write(new MethodDecl(kAndroidStatusLiteral, "writeToParcel",
+ ArgList("::android::Parcel* _aidl_parcel"),
+ 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("android/binder_to_string.h");
+ 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));
set<string> includes = {};
- AddHeaders(parcel, includes);
+ AddHeaders(parcel, &includes);
return unique_ptr<Document>{
new CppSource{vector<string>(includes.begin(), includes.end()),
@@ -1205,7 +1338,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";
+ code << "[[nodiscard]]";
+ GenerateDeprecated(code, enum_decl);
+ code << " static inline std::string toString(" << enum_decl.GetName() << " val)";
+ code << " {\n";
code << " switch(val) {\n";
std::set<std::string> unique_cases;
for (const auto& enumerator : enum_decl.GetEnumerators()) {
@@ -1230,8 +1366,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(),
@@ -1243,7 +1380,7 @@
"binder/Enums.h",
"string",
};
- AddHeaders(enum_decl.GetBackingType(), typenames, includes);
+ AddHeaders(enum_decl.GetBackingType(), typenames, &includes);
std::vector<std::unique_ptr<Declaration>> decls1;
decls1.push_back(std::move(generated_enum));
@@ -1253,8 +1390,7 @@
decls2.push_back(std::make_unique<LiteralDecl>(GenerateEnumValues(enum_decl, {""})));
return unique_ptr<Document>{
- new CppHeader{BuildHeaderGuard(enum_decl, ClassNames::RAW),
- vector<string>(includes.begin(), includes.end()),
+ new CppHeader{vector<string>(includes.begin(), includes.end()),
Append(NestInNamespaces(std::move(decls1), enum_decl.GetSplitPackage()),
NestInNamespaces(std::move(decls2), {"android", "internal"}))}};
}
@@ -1275,10 +1411,10 @@
header = BuildServerHeader(typenames, interface, options);
break;
default:
- LOG(FATAL) << "aidl internal error";
+ AIDL_FATAL(interface) << "aidl internal error";
}
if (!header) {
- LOG(ERROR) << "aidl internal error: Failed to generate header.";
+ AIDL_ERROR(interface) << "aidl internal error: Failed to generate header.";
return false;
}
@@ -1328,9 +1464,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);
@@ -1341,21 +1478,31 @@
const string header_path = options.OutputHeaderDir() + HeaderFile(parcelable, ClassNames::RAW);
unique_ptr<CodeWriter> header_writer(io_delegate.GetCodeWriter(header_path));
header->Write(header_writer.get());
- CHECK(header_writer->Close());
+ if (parcelable.IsGeneric()) {
+ // Need to write all of the source in the header file, not cpp file.
+ source->Write(header_writer.get());
+ }
+ AIDL_FATAL_IF(!header_writer->Close(), header_path);
// TODO(b/111362593): no unecessary files just to have consistent output with interfaces
const string bp_header = options.OutputHeaderDir() + HeaderFile(parcelable, ClassNames::CLIENT);
unique_ptr<CodeWriter> bp_writer(io_delegate.GetCodeWriter(bp_header));
bp_writer->Write("#error TODO(b/111362593) parcelables do not have bp classes");
- CHECK(bp_writer->Close());
+ AIDL_FATAL_IF(!bp_writer->Close(), bp_header);
const string bn_header = options.OutputHeaderDir() + HeaderFile(parcelable, ClassNames::SERVER);
unique_ptr<CodeWriter> bn_writer(io_delegate.GetCodeWriter(bn_header));
bn_writer->Write("#error TODO(b/111362593) parcelables do not have bn classes");
- CHECK(bn_writer->Close());
+ AIDL_FATAL_IF(!bn_writer->Close(), bn_header);
unique_ptr<CodeWriter> source_writer = io_delegate.GetCodeWriter(output_file);
- source->Write(source_writer.get());
- CHECK(source_writer->Close());
+ if (parcelable.IsGeneric()) {
+ // Since the type is generic, the source is written in the header file
+ auto empty_source = unique_ptr<Document>{new CppSource{{}, {}}};
+ empty_source->Write(source_writer.get());
+ } else {
+ source->Write(source_writer.get());
+ }
+ AIDL_FATAL_IF(!source_writer->Close(), output_file);
return true;
}
@@ -1365,21 +1512,21 @@
CodeWriterPtr source_writer = io_delegate.GetCodeWriter(filename);
*source_writer
<< "// This file is intentionally left blank as placeholder for parcel declaration.\n";
- CHECK(source_writer->Close());
+ AIDL_FATAL_IF(!source_writer->Close(), filename);
// TODO(b/111362593): no unecessary files just to have consistent output with interfaces
const string header_path = options.OutputHeaderDir() + HeaderFile(parcelable, ClassNames::RAW);
unique_ptr<CodeWriter> header_writer(io_delegate.GetCodeWriter(header_path));
header_writer->Write("#error TODO(b/111362593) parcelables do not have headers");
- CHECK(header_writer->Close());
+ AIDL_FATAL_IF(!header_writer->Close(), header_path);
const string bp_header = options.OutputHeaderDir() + HeaderFile(parcelable, ClassNames::CLIENT);
unique_ptr<CodeWriter> bp_writer(io_delegate.GetCodeWriter(bp_header));
bp_writer->Write("#error TODO(b/111362593) parcelables do not have bp classes");
- CHECK(bp_writer->Close());
+ AIDL_FATAL_IF(!bp_writer->Close(), bp_header);
const string bn_header = options.OutputHeaderDir() + HeaderFile(parcelable, ClassNames::SERVER);
unique_ptr<CodeWriter> bn_writer(io_delegate.GetCodeWriter(bn_header));
bn_writer->Write("#error TODO(b/111362593) parcelables do not have bn classes");
- CHECK(bn_writer->Close());
+ AIDL_FATAL_IF(!bn_writer->Close(), bn_header);
return true;
}
@@ -1394,32 +1541,68 @@
const string header_path = options.OutputHeaderDir() + HeaderFile(enum_decl, ClassNames::RAW);
unique_ptr<CodeWriter> header_writer(io_delegate.GetCodeWriter(header_path));
header->Write(header_writer.get());
- CHECK(header_writer->Close());
+ AIDL_FATAL_IF(!header_writer->Close(), header_path);
// TODO(b/111362593): no unnecessary files just to have consistent output with interfaces
CodeWriterPtr source_writer = io_delegate.GetCodeWriter(filename);
*source_writer
<< "// This file is intentionally left blank as placeholder for enum declaration.\n";
- CHECK(source_writer->Close());
+ AIDL_FATAL_IF(!source_writer->Close(), filename);
const string bp_header = options.OutputHeaderDir() + HeaderFile(enum_decl, ClassNames::CLIENT);
unique_ptr<CodeWriter> bp_writer(io_delegate.GetCodeWriter(bp_header));
bp_writer->Write("#error TODO(b/111362593) enums do not have bp classes");
- CHECK(bp_writer->Close());
+ AIDL_FATAL_IF(!bp_writer->Close(), bp_header);
const string bn_header = options.OutputHeaderDir() + HeaderFile(enum_decl, ClassNames::SERVER);
unique_ptr<CodeWriter> bn_writer(io_delegate.GetCodeWriter(bn_header));
bn_writer->Write("#error TODO(b/111362593) enums do not have bn classes");
- CHECK(bn_writer->Close());
+ AIDL_FATAL_IF(!bn_writer->Close(), bn_header);
return true;
}
+// Ensures that output_file is <out_dir>/<packagename>/<typename>.cpp
+bool ValidateOutputFilePath(const string& output_file, const Options& options,
+ const AidlDefinedType& defined_type) {
+ const auto& out_dir =
+ !options.OutputDir().empty() ? options.OutputDir() : options.OutputHeaderDir();
+ if (output_file.empty() || !android::base::StartsWith(output_file, out_dir)) {
+ // If output_file is not set (which happens in the unit tests) or is outside of out_dir, we can
+ // help but accepting it, because the path is what the user has requested.
+ return true;
+ }
+
+ string canonical_name = defined_type.GetCanonicalName();
+ std::replace(canonical_name.begin(), canonical_name.end(), '.', OS_PATH_SEPARATOR);
+ const string expected = out_dir + canonical_name + ".cpp";
+ if (expected != output_file) {
+ AIDL_ERROR(defined_type) << "Output file is expected to be at " << expected << ", but is "
+ << output_file << ".\n If this is an Android platform "
+ << "build, consider providing the input AIDL files using a filegroup "
+ << "with `path:\"<base>\"` so that the AIDL files are located at "
+ << "<base>/<packagename>/<typename>.aidl.";
+ return false;
+ }
+ return true;
+}
+
bool GenerateCpp(const string& output_file, const Options& options, const AidlTypenames& typenames,
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);
+ if (!ValidateOutputFilePath(output_file, options, defined_type)) {
+ return false;
}
+ const AidlStructuredParcelable* parcelable = defined_type.AsStructuredParcelable();
+ if (parcelable != nullptr) {
+ 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);
@@ -1435,7 +1618,7 @@
return GenerateCppInterface(output_file, options, typenames, *interface, io_delegate);
}
- CHECK(false) << "Unrecognized type sent for cpp generation.";
+ AIDL_FATAL(defined_type) << "Unrecognized type sent for cpp generation.";
return false;
}
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 53574be..ce7c18c 100644
--- a/generate_cpp_unittest.cpp
+++ b/generate_cpp_unittest.cpp
@@ -36,1491 +36,6 @@
namespace android {
namespace aidl {
namespace cpp {
-namespace {
-
-const string kComplexTypeInterfaceAIDL =
-R"(package android.os;
-import foo.IFooType;
-interface IComplexTypeInterface {
- const int MY_CONSTANT = 3;
- int[] Send(in @nullable int[] goes_in, inout double[] goes_in_and_out, out boolean[] goes_out);
- oneway void Piff(int times);
- IFooType TakesABinder(IFooType f);
- @nullable IFooType NullableBinder();
- List<String> StringListMethod(in java.util.List<String> input, out List<String> output);
- List<IBinder> BinderListMethod(in java.util.List<IBinder> input, out List<IBinder> output);
- FileDescriptor TakesAFileDescriptor(in FileDescriptor f);
- FileDescriptor[] TakesAFileDescriptorArray(in FileDescriptor[] f);
-})";
-
-const char kExpectedComplexTypeClientHeaderOutput[] =
-R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_
-#define AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <utils/Errors.h>
-#include <android/os/IComplexTypeInterface.h>
-
-namespace android {
-
-namespace os {
-
-class BpComplexTypeInterface : public ::android::BpInterface<IComplexTypeInterface> {
-public:
- explicit BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl);
- virtual ~BpComplexTypeInterface() = default;
- ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) override;
- ::android::binder::Status Piff(int32_t times) override;
- ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) override;
- ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) override;
- ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) override;
- ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) override;
- ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) override;
- ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) override;
-}; // class BpComplexTypeInterface
-
-} // namespace os
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_BP_COMPLEX_TYPE_INTERFACE_H_
-)";
-
-const char kExpectedComplexTypeClientSourceOutput[] =
- R"(#include <android/os/BpComplexTypeInterface.h>
-#include <binder/Parcel.h>
-#include <android-base/macros.h>
-
-namespace android {
-
-namespace os {
-
-BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl)
- : BpInterface<IComplexTypeInterface>(_aidl_impl){
-}
-
-::android::binder::Status BpComplexTypeInterface::Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _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.writeInt32Vector(goes_in);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _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.readDoubleVector(goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readBoolVector(goes_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) {
- ::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.writeInt32(times);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->Piff(times);
- }
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _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.writeStrongBinder(::foo::IFooType::asBinder(f));
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _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 BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _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(::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */, _aidl_data, &_aidl_reply);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_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 BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::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;
- _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(::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */, _aidl_data, &_aidl_reply);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _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(output);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _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.writeStrongBinderVector(input);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _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.readStrongBinderVector(_aidl_return);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readStrongBinderVector(output);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _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.writeUniqueFileDescriptor(f);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _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.readUniqueFileDescriptor(_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 BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _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.writeUniqueFileDescriptorVector(f);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _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.readUniqueFileDescriptorVector(_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
-)";
-
-const char kExpectedComplexTypeClientWithTraceSourceOutput[] =
- R"(#include <android/os/BpComplexTypeInterface.h>
-#include <binder/Parcel.h>
-#include <android-base/macros.h>
-
-namespace android {
-
-namespace os {
-
-BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl)
- : BpInterface<IComplexTypeInterface>(_aidl_impl){
-}
-
-::android::binder::Status BpComplexTypeInterface::Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _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, "IComplexTypeInterface::Send::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _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.readDoubleVector(goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readBoolVector(goes_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) {
- ::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, "IComplexTypeInterface::Piff::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32(times);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->Piff(times);
- }
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _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, "IComplexTypeInterface::TakesABinder::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f));
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _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 BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _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, "IComplexTypeInterface::NullableBinder::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_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 BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::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, "IComplexTypeInterface::StringListMethod::cppClient");
- _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(::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */, _aidl_data, &_aidl_reply);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _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(output);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _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, "IComplexTypeInterface::BinderListMethod::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeStrongBinderVector(input);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _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.readStrongBinderVector(_aidl_return);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readStrongBinderVector(output);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _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, "IComplexTypeInterface::TakesAFileDescriptor::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _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.readUniqueFileDescriptor(_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 BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _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, "IComplexTypeInterface::TakesAFileDescriptorArray::cppClient");
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f);
- 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);
- if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) {
- return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _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.readUniqueFileDescriptorVector(_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
-)";
-
-const char kExpectedComplexTypeServerHeaderOutput[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_
-#define AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_
-
-#include <binder/IInterface.h>
-#include <android/os/IComplexTypeInterface.h>
-
-namespace android {
-
-namespace os {
-
-class BnComplexTypeInterface : public ::android::BnInterface<IComplexTypeInterface> {
-public:
- 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
-
-} // namespace os
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_BN_COMPLEX_TYPE_INTERFACE_H_
-)";
-
-const char kExpectedComplexTypeServerSourceOutput[] =
- R"(#include <android/os/BnComplexTypeInterface.h>
-#include <binder/Parcel.h>
-#include <binder/Stability.h>
-
-namespace android {
-
-namespace os {
-
-BnComplexTypeInterface::BnComplexTypeInterface()
-{
- ::android::internal::Stability::markCompilationUnit(this);
-}
-
-::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 */:
- {
- ::std::unique_ptr<::std::vector<int32_t>> in_goes_in;
- ::std::vector<double> in_goes_in_and_out;
- ::std::vector<bool> out_goes_out;
- ::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_goes_in);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_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->writeDoubleVector(in_goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */:
- {
- int32_t in_times;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32(&in_times);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- ::android::binder::Status _aidl_status(Piff(in_times));
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */:
- {
- ::android::sp<::foo::IFooType> in_f;
- ::android::sp<::foo::IFooType> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readStrongBinder(&in_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- ::android::binder::Status _aidl_status(TakesABinder(in_f, &_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(::foo::IFooType::asBinder(_aidl_return));
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */:
- {
- ::android::sp<::foo::IFooType> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- ::android::binder::Status _aidl_status(NullableBinder(&_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(::foo::IFooType::asBinder(_aidl_return));
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */:
- {
- ::std::vector<::android::String16> in_input;
- ::std::vector<::android::String16> out_output;
- ::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(StringListMethod(in_input, &out_output, &_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_output);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */:
- {
- ::std::vector<::android::sp<::android::IBinder>> in_input;
- ::std::vector<::android::sp<::android::IBinder>> out_output;
- ::std::vector<::android::sp<::android::IBinder>> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_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->writeStrongBinderVector(_aidl_return);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */:
- {
- ::android::base::unique_fd in_f;
- ::android::base::unique_fd _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- ::android::binder::Status _aidl_status(TakesAFileDescriptor(std::move(in_f), &_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->writeUniqueFileDescriptor(_aidl_return);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */:
- {
- ::std::vector<::android::base::unique_fd> in_f;
- ::std::vector<::android::base::unique_fd> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_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->writeUniqueFileDescriptorVector(_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 kExpectedComplexTypeServerWithTraceSourceOutput[] =
- R"(#include <android/os/BnComplexTypeInterface.h>
-#include <binder/Parcel.h>
-#include <binder/Stability.h>
-
-namespace android {
-
-namespace os {
-
-BnComplexTypeInterface::BnComplexTypeInterface()
-{
- ::android::internal::Stability::markCompilationUnit(this);
-}
-
-::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 */:
- {
- ::std::unique_ptr<::std::vector<int32_t>> in_goes_in;
- ::std::vector<double> in_goes_in_and_out;
- ::std::vector<bool> out_goes_out;
- ::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_goes_in);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::Send::cppServer");
- ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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->writeDoubleVector(in_goes_in_and_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 1 /* Piff */:
- {
- int32_t in_times;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32(&in_times);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::Piff::cppServer");
- ::android::binder::Status _aidl_status(Piff(in_times));
- atrace_end(ATRACE_TAG_AIDL);
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 2 /* TakesABinder */:
- {
- ::android::sp<::foo::IFooType> in_f;
- ::android::sp<::foo::IFooType> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readStrongBinder(&in_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesABinder::cppServer");
- ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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(::foo::IFooType::asBinder(_aidl_return));
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 3 /* NullableBinder */:
- {
- ::android::sp<::foo::IFooType> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::NullableBinder::cppServer");
- ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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(::foo::IFooType::asBinder(_aidl_return));
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 4 /* StringListMethod */:
- {
- ::std::vector<::android::String16> in_input;
- ::std::vector<::android::String16> out_output;
- ::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;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::StringListMethod::cppServer");
- ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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_output);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 5 /* BinderListMethod */:
- {
- ::std::vector<::android::sp<::android::IBinder>> in_input;
- ::std::vector<::android::sp<::android::IBinder>> out_output;
- ::std::vector<::android::sp<::android::IBinder>> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::BinderListMethod::cppServer");
- ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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->writeStrongBinderVector(_aidl_return);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 6 /* TakesAFileDescriptor */:
- {
- ::android::base::unique_fd in_f;
- ::android::base::unique_fd _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptor::cppServer");
- ::android::binder::Status _aidl_status(TakesAFileDescriptor(std::move(in_f), &_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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->writeUniqueFileDescriptor(_aidl_return);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- }
- break;
- case ::android::IBinder::FIRST_CALL_TRANSACTION + 7 /* TakesAFileDescriptorArray */:
- {
- ::std::vector<::android::base::unique_fd> in_f;
- ::std::vector<::android::base::unique_fd> _aidl_return;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- atrace_begin(ATRACE_TAG_AIDL, "IComplexTypeInterface::TakesAFileDescriptorArray::cppServer");
- ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return));
- atrace_end(ATRACE_TAG_AIDL);
- _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->writeUniqueFileDescriptorVector(_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 kExpectedComplexTypeInterfaceHeaderOutput[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_
-#define AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_
-
-#include <android-base/unique_fd.h>
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <cstdint>
-#include <foo/IFooType.h>
-#include <memory>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-#include <vector>
-
-namespace android {
-
-namespace os {
-
-class IComplexTypeInterface : public ::android::IInterface {
-public:
- DECLARE_META_INTERFACE(ComplexTypeInterface)
- enum : int32_t {
- MY_CONSTANT = 3,
- };
- virtual ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) = 0;
- virtual ::android::binder::Status Piff(int32_t times) = 0;
- virtual ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) = 0;
- virtual ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) = 0;
- virtual ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) = 0;
- virtual ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) = 0;
- virtual ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) = 0;
- virtual ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) = 0;
-}; // class IComplexTypeInterface
-
-class IComplexTypeInterfaceDefault : public IComplexTypeInterface {
-public:
- ::android::IBinder* onAsBinder() override {
- return nullptr;
- }
- ::android::binder::Status Send(const ::std::unique_ptr<::std::vector<int32_t>>&, ::std::vector<double>*, ::std::vector<bool>*, ::std::vector<int32_t>*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
- ::android::binder::Status Piff(int32_t) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
- ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>&, ::android::sp<::foo::IFooType>*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
- ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
- ::android::binder::Status StringListMethod(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 BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>&, ::std::vector<::android::sp<::android::IBinder>>*, ::std::vector<::android::sp<::android::IBinder>>*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
- ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd, ::android::base::unique_fd*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
- ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>&, ::std::vector<::android::base::unique_fd>*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
-}; // class IComplexTypeInterfaceDefault
-
-} // namespace os
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_I_COMPLEX_TYPE_INTERFACE_H_
-)";
-
-const char kExpectedComplexTypeInterfaceSourceOutput[] =
- R"(#include <android/os/IComplexTypeInterface.h>
-#include <android/os/BpComplexTypeInterface.h>
-
-namespace android {
-
-namespace os {
-
-DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(ComplexTypeInterface, "android.os.IComplexTypeInterface")
-
-} // namespace os
-
-} // namespace android
-)";
-
-const string kEnumAIDL = R"(package android.os;
-enum TestEnum {
- ZERO,
- ONE,
- THREE = 3,
- FOUR = 3 + 1,
- FIVE,
- SIX,
- SEVEN,
- EIGHT = 16 / 2,
- NINE,
- TEN,
-})";
-
-// clang-format off
-const char kExpectedEnumHeaderOutput[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_TEST_ENUM_H_
-#define AIDL_GENERATED_ANDROID_OS_TEST_ENUM_H_
-
-#include <array>
-#include <binder/Enums.h>
-#include <cstdint>
-#include <string>
-
-namespace android {
-
-namespace os {
-
-enum class TestEnum : int8_t {
- ZERO = 0,
- ONE = 1,
- THREE = 3,
- FOUR = 4,
- FIVE = 5,
- SIX = 6,
- SEVEN = 7,
- EIGHT = 8,
- NINE = 9,
- TEN = 10,
-};
-
-static inline std::string toString(TestEnum val) {
- switch(val) {
- case TestEnum::ZERO:
- return "ZERO";
- case TestEnum::ONE:
- return "ONE";
- case TestEnum::THREE:
- return "THREE";
- case TestEnum::FOUR:
- return "FOUR";
- case TestEnum::FIVE:
- return "FIVE";
- case TestEnum::SIX:
- return "SIX";
- case TestEnum::SEVEN:
- return "SEVEN";
- case TestEnum::EIGHT:
- return "EIGHT";
- case TestEnum::NINE:
- return "NINE";
- case TestEnum::TEN:
- return "TEN";
- default:
- return std::to_string(static_cast<int8_t>(val));
- }
-}
-
-} // namespace os
-
-} // namespace android
-namespace android {
-
-namespace internal {
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::os::TestEnum, 10> enum_values<::android::os::TestEnum> = {
- ::android::os::TestEnum::ZERO,
- ::android::os::TestEnum::ONE,
- ::android::os::TestEnum::THREE,
- ::android::os::TestEnum::FOUR,
- ::android::os::TestEnum::FIVE,
- ::android::os::TestEnum::SIX,
- ::android::os::TestEnum::SEVEN,
- ::android::os::TestEnum::EIGHT,
- ::android::os::TestEnum::NINE,
- ::android::os::TestEnum::TEN,
-};
-#pragma clang diagnostic pop
-
-} // namespace internal
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_TEST_ENUM_H_
-)";
-// clang-format on
-
-const string kEnumWithBackingTypeAIDL = R"(package android.os;
-@Backing(type="long")
-enum TestEnum {
- FOO = 1,
- BAR = 2,
-})";
-
-// clang-format off
-const char kExpectedEnumWithBackingTypeHeaderOutput[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_TEST_ENUM_H_
-#define AIDL_GENERATED_ANDROID_OS_TEST_ENUM_H_
-
-#include <array>
-#include <binder/Enums.h>
-#include <cstdint>
-#include <string>
-
-namespace android {
-
-namespace os {
-
-enum class TestEnum : int64_t {
- FOO = 1L,
- BAR = 2L,
-};
-
-static inline std::string toString(TestEnum val) {
- switch(val) {
- case TestEnum::FOO:
- return "FOO";
- case TestEnum::BAR:
- return "BAR";
- default:
- return std::to_string(static_cast<int64_t>(val));
- }
-}
-
-} // namespace os
-
-} // namespace android
-namespace android {
-
-namespace internal {
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::os::TestEnum, 2> enum_values<::android::os::TestEnum> = {
- ::android::os::TestEnum::FOO,
- ::android::os::TestEnum::BAR,
-};
-#pragma clang diagnostic pop
-
-} // namespace internal
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_TEST_ENUM_H_
-)";
-// clang-format on
-
-} // namespace
class ASTTest : public ::testing::Test {
protected:
@@ -1531,40 +46,38 @@
AidlInterface* ParseSingleInterface() {
io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_);
- vector<AidlDefinedType*> defined_types;
vector<string> imported_files;
ImportResolver import_resolver{io_delegate_, options_.InputFiles().at(0), {"."}, {}};
AidlError err = ::android::aidl::internals::load_and_validate_aidl(
- options_.InputFiles().front(), options_, io_delegate_, &typenames_, &defined_types,
- &imported_files);
+ options_.InputFiles().front(), options_, io_delegate_, &typenames_, &imported_files);
if (err != AidlError::OK) {
return nullptr;
}
+ const auto& defined_types = typenames_.MainDocument().DefinedTypes();
EXPECT_EQ(1ul, defined_types.size());
- EXPECT_NE(nullptr, defined_types.front()->AsInterface());
+ EXPECT_NE(nullptr, defined_types.front().get()->AsInterface());
- return defined_types.front()->AsInterface();
+ return defined_types.front().get()->AsInterface();
}
AidlEnumDeclaration* ParseSingleEnumDeclaration() {
io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_);
- vector<AidlDefinedType*> defined_types;
vector<string> imported_files;
AidlError err = ::android::aidl::internals::load_and_validate_aidl(
- options_.InputFiles().front(), options_, io_delegate_, &typenames_, &defined_types,
- &imported_files);
+ options_.InputFiles().front(), options_, io_delegate_, &typenames_, &imported_files);
if (err != AidlError::OK) {
return nullptr;
}
+ const auto& defined_types = typenames_.MainDocument().DefinedTypes();
EXPECT_EQ(1ul, defined_types.size());
- EXPECT_NE(nullptr, defined_types.front()->AsEnumDeclaration());
+ EXPECT_NE(nullptr, defined_types.front().get()->AsEnumDeclaration());
- return defined_types.front()->AsEnumDeclaration();
+ return defined_types.front().get()->AsEnumDeclaration();
}
void Compare(Document* doc, const char* expected) {
@@ -1585,81 +98,6 @@
AidlTypenames typenames_;
};
-class ComplexTypeInterfaceASTTest : public ASTTest {
- public:
- ComplexTypeInterfaceASTTest()
- : ASTTest("aidl --lang=cpp -I . -o out android/os/IComplexTypeInterface.aidl",
- kComplexTypeInterfaceAIDL) {
- io_delegate_.SetFileContents("foo/IFooType.aidl",
- "package foo; interface IFooType {}");
- }
-};
-
-TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientHeader) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildClientHeader(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeClientHeaderOutput);
-}
-
-TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientSource) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildClientSource(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeClientSourceOutput);
-}
-
-TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerHeader) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildServerHeader(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeServerHeaderOutput);
-}
-
-TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerSource) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildServerSource(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeServerSourceOutput);
-}
-
-TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceHeader) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildInterfaceHeader(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeInterfaceHeaderOutput);
-}
-
-TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceSource) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildInterfaceSource(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeInterfaceSourceOutput);
-}
-
-class ComplexTypeInterfaceASTTestWithTrace : public ASTTest {
- public:
- ComplexTypeInterfaceASTTestWithTrace()
- : ASTTest("aidl --lang=cpp -t -I . -o out android/os/IComplexTypeInterface.aidl",
- kComplexTypeInterfaceAIDL) {
- io_delegate_.SetFileContents("foo/IFooType.aidl", "package foo; interface IFooType {}");
- }
-};
-
-TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesClientSource) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildClientSource(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeClientWithTraceSourceOutput);
-}
-
-TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesServerSource) {
- AidlInterface* interface = ParseSingleInterface();
- ASSERT_NE(interface, nullptr);
- unique_ptr<Document> doc = internals::BuildServerSource(typenames_, *interface, options_);
- Compare(doc.get(), kExpectedComplexTypeServerWithTraceSourceOutput);
-}
-
namespace test_io_handling {
const char kInputPath[] = "a/IFoo.aidl";
@@ -1712,31 +150,6 @@
ASSERT_TRUE(io_delegate_.PathWasRemoved(kOutputPath));
}
-class EnumASTTest : public ASTTest {
- public:
- EnumASTTest() : ASTTest("aidl --lang=cpp -I . -o out android/os/TestEnum.aidl", kEnumAIDL) {}
-};
-
-TEST_F(EnumASTTest, GeneratesEnumHeader) {
- AidlEnumDeclaration* enum_decl = ParseSingleEnumDeclaration();
- ASSERT_NE(enum_decl, nullptr);
- unique_ptr<Document> doc = internals::BuildEnumHeader(typenames_, *enum_decl);
- Compare(doc.get(), kExpectedEnumHeaderOutput);
-}
-
-class EnumWithBackingTypeASTTest : public ASTTest {
- public:
- EnumWithBackingTypeASTTest()
- : ASTTest("aidl --lang=cpp -I . -o out android/os/TestEnum.aidl", kEnumWithBackingTypeAIDL) {}
-};
-
-TEST_F(EnumWithBackingTypeASTTest, GeneratesEnumHeader) {
- AidlEnumDeclaration* enum_decl = ParseSingleEnumDeclaration();
- ASSERT_NE(enum_decl, nullptr);
- unique_ptr<Document> doc = internals::BuildEnumHeader(typenames_, *enum_decl);
- Compare(doc.get(), kExpectedEnumWithBackingTypeHeaderOutput);
-}
-
} // namespace cpp
} // namespace aidl
} // namespace android
diff --git a/generate_java.cpp b/generate_java.cpp
index f120ac5..f3b7a93 100644
--- a/generate_java.cpp
+++ b/generate_java.cpp
@@ -19,24 +19,169 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#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 {
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";
@@ -60,26 +205,106 @@
out << "}\n";
}
-template <typename ParcelableType>
-void GenerateDerivedMethods(CodeWriter& out, const ParcelableType& parcel,
- const AidlTypenames& typenames) {
- if (auto java_derive = parcel.JavaDerive(); java_derive) {
- auto synthetic_methods = java_derive->AnnotationParams(ConstantValueDecorator);
- for (const auto& [method_name, generate] : synthetic_methods) {
- if (generate == "true") {
- if (method_name == "toString") {
- GenerateToString(out, parcel, typenames);
- }
- }
- }
+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) {
@@ -115,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) {
@@ -132,44 +365,107 @@
return generate_java_interface(filename, interface, typenames, io_delegate, options);
}
- CHECK(false) << "Unrecognized type sent for java generation.";
+ 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;
}
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(), ",") + ">";
+ }
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()) {
+ out << "final ";
}
- out << "public " << JavaSignatureOf(variable->GetType(), typenames) << " "
- << variable->GetName();
- if (variable->GetDefaultValue()) {
+ out << JavaSignatureOf(variable->GetType(), typenames) << " " << variable->GetName();
+ if (!parcel->IsJavaOnlyImmutable() && variable->GetDefaultValue()) {
out << " = " << variable->ValueString(ConstantValueDecorator);
+ } else if (variable->GetType().GetName() == "ParcelableHolder") {
+ out << std::boolalpha;
+ out << " = new " << JavaSignatureOf(variable->GetType(), typenames) << "(";
+ if (parcel->IsVintfStability()) {
+ out << "android.os.Parcelable.PARCELABLE_STABILITY_VINTF";
+ } else {
+ out << "android.os.Parcelable.PARCELABLE_STABILITY_LOCAL";
+ }
+ out << ")";
+ out << std::noboolalpha;
}
out << ";\n";
parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(out.str()));
}
std::ostringstream out;
+ if (parcel->IsJavaOnlyImmutable()) {
+ auto builder_class = std::make_shared<Class>();
+ builder_class->modifiers = PUBLIC | FINAL | STATIC;
+ builder_class->what = Class::CLASS;
+ builder_class->type = "Builder";
+
+ out.str("");
+ for (const auto& variable : parcel->GetFields()) {
+ out << "private " << JavaSignatureOf(variable->GetType(), typenames) << " "
+ << variable->GetName();
+ if (variable->GetDefaultValue()) {
+ out << " = " << variable->ValueString(ConstantValueDecorator);
+ }
+ out << ";\n";
+ out << "public Builder " << setter_name(*variable) << "("
+ << JavaSignatureOf(variable->GetType(), typenames) << " " << variable->GetName()
+ << ") {\n"
+ << " "
+ << "this." << variable->GetName() << " = " << variable->GetName() << ";\n"
+ << " return this;\n"
+ << "}\n";
+ }
+ out << "public " << parcel->GetCanonicalName() << " build() {\n"
+ << " return new " << parcel->GetCanonicalName() << "(";
+ std::vector<std::string> variables;
+ std::transform(parcel->GetFields().begin(), parcel->GetFields().end(),
+ std::back_inserter(variables), [](const auto& f) { return f->GetName(); });
+ out << base::Join(variables, ", ") << ");\n"
+ << "}\n";
+ builder_class->elements.push_back(std::make_shared<LiteralClassElement>(out.str()));
+ parcel_class->elements.push_back(builder_class);
+ }
+ if (parcel->IsVintfStability()) {
+ parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(
+ "@Override\n public final int getStability() { return "
+ "android.os.Parcelable.PARCELABLE_STABILITY_VINTF; }\n"));
+ }
+
+ out.str("");
out << "public static final android.os.Parcelable.Creator<" << parcel->GetName() << "> CREATOR = "
<< "new android.os.Parcelable.Creator<" << parcel->GetName() << ">() {\n";
out << " @Override\n";
out << " public " << parcel->GetName()
<< " createFromParcel(android.os.Parcel _aidl_source) {\n";
- out << " " << parcel->GetName() << " _aidl_out = new " << parcel->GetName() << "();\n";
- out << " _aidl_out.readFromParcel(_aidl_source);\n";
- out << " return _aidl_out;\n";
+ if (parcel->IsJavaOnlyImmutable()) {
+ out << " return internalCreateFromParcel(_aidl_source);\n";
+ } else {
+ out << " " << parcel->GetName() << " _aidl_out = new " << parcel->GetName() << "();\n";
+ out << " _aidl_out.readFromParcel(_aidl_source);\n";
+ out << " return _aidl_out;\n";
+ }
out << " }\n";
out << " @Override\n";
out << " public " << parcel->GetName() << "[] newArray(int _aidl_size) {\n";
@@ -220,29 +516,79 @@
parcel_class->elements.push_back(write_method);
- auto read_method = std::make_shared<Method>();
- read_method->modifiers = PUBLIC | FINAL;
- read_method->returnType = "void";
- read_method->name = "readFromParcel";
- read_method->parameters.push_back(parcel_variable);
- read_method->statements = std::make_shared<StatementBlock>();
+ if (parcel->IsJavaOnlyImmutable()) {
+ auto constructor = std::make_shared<Method>();
+ constructor->modifiers = PUBLIC;
+ constructor->name = parcel->GetName();
+ constructor->statements = std::make_shared<StatementBlock>();
+ for (const auto& field : parcel->GetFields()) {
+ constructor->parameters.push_back(std::make_shared<Variable>(
+ JavaSignatureOf(field->GetType(), typenames), field->GetName()));
+ out.str("");
+ out << "this." << field->GetName() << " = ";
+ if (field->GetType().GetName() == "List") {
+ out << field->GetName() << " == null ? null : java.util.Collections.unmodifiableList("
+ << field->GetName() << ");\n";
+ } else if (field->GetType().GetName() == "Map") {
+ out << field->GetName() << " == null ? null : java.util.Collections.unmodifiableMap("
+ << field->GetName() << ");\n";
+ } else {
+ out << field->GetName() << ";\n";
+ }
+ constructor->statements->Add(std::make_shared<LiteralStatement>(out.str()));
+ }
+ parcel_class->elements.push_back(constructor);
+ }
+
+ // For an immutable parcelable, generate internalCreateFromParcel method.
+ // Otherwise, generate readFromParcel method.
+ auto read_or_create_method = std::make_shared<Method>();
+ if (parcel->IsJavaOnlyImmutable()) {
+ auto constructor = std::make_shared<Method>();
+ read_or_create_method->modifiers = PRIVATE | STATIC;
+ read_or_create_method->returnType = parcel->GetName();
+ read_or_create_method->name = "internalCreateFromParcel";
+ read_or_create_method->parameters.push_back(parcel_variable);
+ read_or_create_method->statements = std::make_shared<StatementBlock>();
+ } else {
+ read_or_create_method->modifiers = PUBLIC | FINAL;
+ read_or_create_method->returnType = "void";
+ read_or_create_method->name = "readFromParcel";
+ read_or_create_method->parameters.push_back(parcel_variable);
+ read_or_create_method->statements = std::make_shared<StatementBlock>();
+ }
out.str("");
+ const string builder_variable = "_aidl_parcelable_builder";
+ if (parcel->IsJavaOnlyImmutable()) {
+ out << "Builder " << builder_variable << " = new Builder();\n";
+ }
out << "int _aidl_start_pos = _aidl_parcel.dataPosition();\n"
<< "int _aidl_parcelable_size = _aidl_parcel.readInt();\n"
- << "if (_aidl_parcelable_size < 0) return;\n"
- << "try {\n";
+ << "try {\n"
+ << " if (_aidl_parcelable_size < 0) return";
+ if (parcel->IsJavaOnlyImmutable()) {
+ out << " " << builder_variable << ".build()";
+ }
+ out << ";\n";
- read_method->statements->Add(std::make_shared<LiteralStatement>(out.str()));
+ read_or_create_method->statements->Add(std::make_shared<LiteralStatement>(out.str()));
out.str("");
- out << " if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;\n";
+ out << " if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return";
+ if (parcel->IsJavaOnlyImmutable()) {
+ out << " " << builder_variable << ".build()";
+ }
+ out << ";\n";
- std::shared_ptr<LiteralStatement> sizeCheck = nullptr;
+ std::shared_ptr<LiteralStatement> sizeCheck = std::make_shared<LiteralStatement>(out.str());
// keep this across different fields in order to create the classloader
// at most once.
bool is_classloader_created = false;
for (const auto& field : parcel->GetFields()) {
+ read_or_create_method->statements->Add(sizeCheck);
+ const auto field_variable_name =
+ (parcel->IsJavaOnlyImmutable() ? "_aidl_temp_" : "") + field->GetName();
string code;
CodeWriterPtr writer = CodeWriter::ForString(&code);
CodeGeneratorContext context{
@@ -250,36 +596,59 @@
.typenames = typenames,
.type = field->GetType(),
.parcel = parcel_variable->name,
- .var = field->GetName(),
+ .var = field_variable_name,
.is_classloader_created = &is_classloader_created,
};
context.writer.Indent();
+ if (parcel->IsJavaOnlyImmutable()) {
+ context.writer.Write("%s %s;\n", JavaSignatureOf(field->GetType(), typenames).c_str(),
+ field_variable_name.c_str());
+ }
CreateFromParcelFor(context);
+ if (parcel->IsJavaOnlyImmutable()) {
+ context.writer.Write("%s.%s(%s);\n", builder_variable.c_str(), setter_name(*field).c_str(),
+ field_variable_name.c_str());
+ }
writer->Close();
- read_method->statements->Add(std::make_shared<LiteralStatement>(code));
- if (!sizeCheck) sizeCheck = std::make_shared<LiteralStatement>(out.str());
- read_method->statements->Add(sizeCheck);
+ read_or_create_method->statements->Add(std::make_shared<LiteralStatement>(code));
}
out.str("");
out << "} finally {\n"
- << " _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);\n"
- << "}\n";
+ << " if (_aidl_start_pos > (Integer.MAX_VALUE - _aidl_parcelable_size)) {\n"
+ << " throw new android.os.BadParcelableException(\"Overflow in the size of "
+ "parcelable\");\n"
+ << " }\n"
+ << " _aidl_parcel.setDataPosition(_aidl_start_pos + _aidl_parcelable_size);\n";
+ if (parcel->IsJavaOnlyImmutable()) {
+ out << " return " << builder_variable << ".build();\n";
+ }
+ out << "}\n";
- read_method->statements->Add(std::make_shared<LiteralStatement>(out.str()));
+ read_or_create_method->statements->Add(std::make_shared<LiteralStatement>(out.str()));
- parcel_class->elements.push_back(read_method);
+ parcel_class->elements.push_back(read_or_create_method);
- auto method = CodeWriter::RunWith(GenerateDerivedMethods, *parcel, typenames);
- parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(method));
+ string constants;
+ generate_constant_declarations(*CodeWriter::ForString(&constants), *parcel);
+ parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(constants));
- 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("toString")) {
+ string to_string;
+ GenerateToString(*CodeWriter::ForString(&to_string), *parcel, typenames);
+ parcel_class->elements.push_back(std::make_shared<LiteralClassElement>(to_string));
+ }
+
+ 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;
}
@@ -292,14 +661,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(),
@@ -310,6 +678,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();
}
@@ -323,19 +947,62 @@
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) {
std::vector<std::string> result;
- const AidlAnnotation* unsupported_app_usage = a.UnsupportedAppUsage();
if (a.IsHide()) {
result.emplace_back("@android.annotation.Hide");
}
+
+ const AidlAnnotation* unsupported_app_usage = a.UnsupportedAppUsage();
if (unsupported_app_usage != nullptr) {
result.emplace_back("@android.compat.annotation.UnsupportedAppUsage" +
generate_java_unsupportedappusage_parameters(*unsupported_app_usage));
}
+
+ 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;
}
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 01e88db..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"
@@ -29,7 +30,6 @@
#include <utility>
#include <vector>
-#include <android-base/macros.h>
#include <android-base/stringprintf.h>
using android::base::Join;
@@ -63,8 +63,6 @@
std::vector<std::shared_ptr<Variable>> vars_;
std::string base_;
int index_;
-
- DISALLOW_COPY_AND_ASSIGN(VariableFactory);
};
// =================================================
@@ -73,11 +71,18 @@
StubClass(const AidlInterface* interfaceType, const Options& options);
~StubClass() override = default;
+ // non-copyable, non-movable
+ StubClass(const StubClass&) = delete;
+ StubClass(StubClass&&) = delete;
+ StubClass& operator=(const StubClass&) = delete;
+ StubClass& operator=(StubClass&&) = delete;
+
std::shared_ptr<Variable> transact_code;
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;
@@ -98,8 +103,6 @@
std::shared_ptr<Variable> transact_descriptor;
const Options& options_;
-
- DISALLOW_COPY_AND_ASSIGN(StubClass);
};
StubClass::StubClass(const AidlInterface* interfaceType, const Options& options)
@@ -115,20 +118,6 @@
this->extends = "android.os.Binder";
this->interfaces.push_back(interfaceType->GetCanonicalName());
- // descriptor
- auto descriptor = std::make_shared<Field>(
- STATIC | FINAL | PRIVATE, std::make_shared<Variable>("java.lang.String", "DESCRIPTOR"));
- if (options.IsStructured()) {
- // mangle the interface name at build time and demangle it at runtime, to avoid
- // being renamed by jarjar. See b/153843174
- std::string name = interfaceType->GetCanonicalName();
- std::replace(name.begin(), name.end(), '.', '$');
- descriptor->value = "\"" + name + "\".replace('$', '.')";
- } else {
- descriptor->value = "\"" + interfaceType->GetCanonicalName() + "\"";
- }
- this->elements.push_back(descriptor);
-
// ctor
auto ctor = std::make_shared<Method>();
ctor->modifiers = PUBLIC;
@@ -206,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() {
@@ -217,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()) {
@@ -398,30 +390,29 @@
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()) {
- decl->parameters.push_back(
- std::make_shared<Variable>(JavaSignatureOf(arg->GetType(), typenames), arg->GetName()));
+ auto var = std::make_shared<Variable>(JavaSignatureOf(arg->GetType(), typenames), arg->GetName());
+ var->annotations = JavaAnnotationsFor(arg->GetType());
+ decl->parameters.push_back(var);
}
decl->exceptions.push_back("android.os.RemoteException");
@@ -433,10 +424,29 @@
std::shared_ptr<Variable> transact_data,
std::shared_ptr<Variable> transact_reply,
const AidlTypenames& typenames,
- std::shared_ptr<StatementBlock> statements,
+ std::shared_ptr<StatementBlock> statement_block,
std::shared_ptr<StubClass> stubClass, const Options& options) {
- std::shared_ptr<TryStatement> tryStatement;
- std::shared_ptr<FinallyStatement> finallyStatement;
+ // try and finally
+ auto tryStatement = std::make_shared<TryStatement>();
+ auto finallyStatement = std::make_shared<FinallyStatement>();
+ auto& statements = statement_block;
+
+ if (options.GenTraces()) {
+ statements->Add(tryStatement);
+ statements->Add(finallyStatement);
+ statements = tryStatement->statements;
+ tryStatement->statements->Add(std::make_shared<MethodCall>(
+ std::make_shared<LiteralExpression>("android.os.Trace"), "traceBegin",
+ std::vector<std::shared_ptr<Expression>>{
+ std::make_shared<LiteralExpression>("android.os.Trace.TRACE_TAG_AIDL"),
+ std::make_shared<StringLiteralExpression>("AIDL::java::" + iface.GetName() +
+ "::" + method.GetName() + "::server")}));
+ finallyStatement->statements->Add(std::make_shared<MethodCall>(
+ std::make_shared<LiteralExpression>("android.os.Trace"), "traceEnd",
+ std::vector<std::shared_ptr<Expression>>{
+ std::make_shared<LiteralExpression>("android.os.Trace.TRACE_TAG_AIDL")}));
+ }
+
auto realCall = std::make_shared<MethodCall>(THIS_VALUE, method.GetName());
// interface token validation is the very first thing we do
@@ -481,33 +491,9 @@
}
}
- if (options.GenTraces()) {
- // try and finally, but only when generating trace code
- tryStatement = std::make_shared<TryStatement>();
- finallyStatement = std::make_shared<FinallyStatement>();
-
- tryStatement->statements->Add(std::make_shared<MethodCall>(
- std::make_shared<LiteralExpression>("android.os.Trace"), "traceBegin",
- std::vector<std::shared_ptr<Expression>>{
- std::make_shared<LiteralExpression>("android.os.Trace.TRACE_TAG_AIDL"),
- std::make_shared<StringLiteralExpression>(iface.GetName() + "::" + method.GetName() +
- "::server")}));
-
- finallyStatement->statements->Add(std::make_shared<MethodCall>(
- std::make_shared<LiteralExpression>("android.os.Trace"), "traceEnd",
- std::vector<std::shared_ptr<Expression>>{
- std::make_shared<LiteralExpression>("android.os.Trace.TRACE_TAG_AIDL")}));
- }
-
// the real call
if (method.GetType().GetName() == "void") {
- if (options.GenTraces()) {
- statements->Add(tryStatement);
- tryStatement->statements->Add(realCall);
- statements->Add(finallyStatement);
- } else {
- statements->Add(realCall);
- }
+ statements->Add(realCall);
if (!oneway) {
// report that there were no exceptions
@@ -517,14 +503,7 @@
} else {
auto _result =
std::make_shared<Variable>(JavaSignatureOf(method.GetType(), typenames), "_result");
- if (options.GenTraces()) {
- statements->Add(std::make_shared<VariableDeclaration>(_result));
- statements->Add(tryStatement);
- tryStatement->statements->Add(std::make_shared<Assignment>(_result, realCall));
- statements->Add(finallyStatement);
- } else {
statements->Add(std::make_shared<VariableDeclaration>(_result, realCall));
- }
if (!oneway) {
// report that there were no exceptions
@@ -560,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,
@@ -596,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);
}
}
@@ -605,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();
@@ -620,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");
@@ -645,8 +629,8 @@
std::make_shared<LiteralExpression>("android.os.Trace"), "traceBegin",
std::vector<std::shared_ptr<Expression>>{
std::make_shared<LiteralExpression>("android.os.Trace.TRACE_TAG_AIDL"),
- std::make_shared<StringLiteralExpression>(iface.GetName() + "::" + method.GetName() +
- "::client")}));
+ std::make_shared<StringLiteralExpression>("AIDL::java::" + iface.GetName() +
+ "::" + method.GetName() + "::client")}));
}
// the interface identifier token: the DESCRIPTOR constant, marshalled as a
@@ -676,32 +660,55 @@
}
}
+ 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));
- // If the transaction returns false, which means UNKNOWN_TRANSACTION, fall
- // back to the local method in the default impl, if set before.
+ // If the transaction returns false, which means UNKNOWN_TRANSACTION, fall back to the local
+ // method in the default impl, if set before. Otherwise, throw a RuntimeException if the interface
+ // is versioned. We can't throw the exception for unversioned interface because that would be an
+ // app breaking change.
vector<string> arg_names;
for (const auto& arg : method.GetArguments()) {
arg_names.emplace_back(arg->GetName());
}
bool has_return_type = method.GetType().GetName() != "void";
- tryStatement->statements->Add(std::make_shared<LiteralStatement>(
- android::base::StringPrintf(has_return_type ? "if (!_status && getDefaultImpl() != null) {\n"
- " return getDefaultImpl().%s(%s);\n"
- "}\n"
- : "if (!_status && getDefaultImpl() != null) {\n"
- " getDefaultImpl().%s(%s);\n"
- " return;\n"
- "}\n",
- method.GetName().c_str(), Join(arg_names, ", ").c_str())));
+
+ auto checkDefaultImpl = std::make_shared<IfStatement>();
+ checkDefaultImpl->expression = std::make_shared<LiteralExpression>("getDefaultImpl() != null");
+ if (has_return_type) {
+ checkDefaultImpl->statements->Add(std::make_shared<LiteralStatement>(
+ android::base::StringPrintf("return getDefaultImpl().%s(%s);\n", method.GetName().c_str(),
+ Join(arg_names, ", ").c_str())));
+ } else {
+ checkDefaultImpl->statements->Add(std::make_shared<LiteralStatement>(
+ android::base::StringPrintf("getDefaultImpl().%s(%s);\n", method.GetName().c_str(),
+ Join(arg_names, ", ").c_str())));
+ checkDefaultImpl->statements->Add(std::make_shared<LiteralStatement>("return;\n"));
+ }
+ if (options.Version() > 0) {
+ checkDefaultImpl->elseif = std::make_shared<IfStatement>();
+ checkDefaultImpl->elseif->statements->Add(
+ std::make_shared<LiteralStatement>(android::base::StringPrintf(
+ "throw new android.os.RemoteException(\"Method %s is unimplemented.\");\n",
+ method.GetName().c_str())));
+ }
+
+ auto checkTransactionError = std::make_shared<IfStatement>();
+ checkTransactionError->expression = std::make_shared<LiteralExpression>("!_status");
+ checkTransactionError->statements->Add(checkDefaultImpl);
+
+ tryStatement->statements->Add(checkTransactionError);
// throw back exceptions.
if (_reply) {
@@ -826,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);
@@ -836,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);
}
}
@@ -911,7 +918,8 @@
}
}
-static void generate_interface_descriptors(std::shared_ptr<StubClass> stub,
+static void generate_interface_descriptors(const Options& options, const AidlInterface* iface,
+ Class* interface, std::shared_ptr<StubClass> stub,
std::shared_ptr<ProxyClass> proxy) {
// the interface descriptor transaction handler
auto c = std::make_shared<Case>("INTERFACE_TRANSACTION");
@@ -919,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>();
@@ -930,6 +938,29 @@
getDesc->statements->Add(
std::make_shared<ReturnStatement>(std::make_shared<LiteralExpression>("DESCRIPTOR")));
proxy->elements.push_back(getDesc);
+
+ // add the DESCRIPTOR field to the interface class
+ Class* classToAddDescriptor = interface;
+ static std::set<std::string> greylist = {
+#include "hiddenapi-greylist"
+ };
+ if (greylist.find(iface->GetCanonicalName()) != greylist.end()) {
+ // For app compatibility, we keep DESCRIPTOR to the stub class for
+ // the interfaces that are in the greylist.
+ classToAddDescriptor = stub.get();
+ }
+ auto descriptor = std::make_shared<Field>(
+ STATIC | FINAL | PUBLIC, std::make_shared<Variable>("java.lang.String", "DESCRIPTOR"));
+ std::string name = iface->GetDescriptor();
+ if (options.IsStructured()) {
+ // mangle the interface name at build time and demangle it at runtime, to avoid
+ // being renamed by jarjar. See b/153843174
+ std::replace(name.begin(), name.end(), '.', '$');
+ descriptor->value = "\"" + name + "\".replace('$', '.')";
+ } else {
+ descriptor->value = "\"" + name + "\"";
+ }
+ classToAddDescriptor->elements.push_back(descriptor);
}
// Check whether (some) methods in this interface should be "outlined," that
@@ -945,7 +976,7 @@
static void compute_outline_methods(const AidlInterface* iface,
const std::shared_ptr<StubClass> stub, size_t outline_threshold,
size_t non_outline_count) {
- CHECK_LE(non_outline_count, outline_threshold);
+ AIDL_FATAL_IF(non_outline_count > outline_threshold, iface);
// We'll outline (create sub methods) if there are more than min_methods
// cases.
stub->transact_outline = iface->GetMethods().size() > outline_threshold;
@@ -953,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());
}
@@ -972,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();
@@ -1003,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
@@ -1044,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;
@@ -1086,34 +1117,12 @@
stub->elements.push_back(proxy);
// stub and proxy support for getInterfaceDescriptor()
- generate_interface_descriptors(stub, proxy);
+ 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));
- }
- 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: {
- generate_int_constant(interface.get(), constant->GetName(),
- constant->ValueString(ConstantValueDecorator));
- break;
- }
- default: {
- LOG(FATAL) << "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 274d283..c87c5c6 100644
--- a/generate_ndk.cpp
+++ b/generate_ndk.cpp
@@ -20,8 +20,9 @@
#include "aidl_language.h"
#include "aidl_to_cpp_common.h"
#include "aidl_to_ndk.h"
+#include "logging.h"
-#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
namespace android {
namespace aidl {
@@ -36,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,
@@ -44,56 +56,62 @@
const string i_header = options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::RAW);
unique_ptr<CodeWriter> i_writer(io_delegate.GetCodeWriter(i_header));
GenerateInterfaceHeader(*i_writer, types, defined_type, options);
- CHECK(i_writer->Close());
+ AIDL_FATAL_IF(!i_writer->Close(), i_header);
const string bp_header =
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::CLIENT);
unique_ptr<CodeWriter> bp_writer(io_delegate.GetCodeWriter(bp_header));
GenerateClientHeader(*bp_writer, types, defined_type, options);
- CHECK(bp_writer->Close());
+ AIDL_FATAL_IF(!bp_writer->Close(), bp_header);
const string bn_header =
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::SERVER);
unique_ptr<CodeWriter> bn_writer(io_delegate.GetCodeWriter(bn_header));
GenerateServerHeader(*bn_writer, types, defined_type, options);
- CHECK(bn_writer->Close());
+ AIDL_FATAL_IF(!bn_writer->Close(), bn_header);
unique_ptr<CodeWriter> source_writer = io_delegate.GetCodeWriter(output_file);
GenerateSource(*source_writer, types, defined_type, options);
- CHECK(source_writer->Close());
+ 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);
unique_ptr<CodeWriter> header_writer(io_delegate.GetCodeWriter(header_path));
GenerateParcelHeader(*header_writer, types, defined_type, options);
- CHECK(header_writer->Close());
+
+ unique_ptr<CodeWriter> source_writer(io_delegate.GetCodeWriter(output_file));
+ if (defined_type.IsGeneric()) {
+ // Need to write source to header if this is a template
+ GenerateParcelSource(*header_writer, types, defined_type, options);
+ } else {
+ GenerateParcelSource(*source_writer, types, defined_type, options);
+ }
+ (source_writer->Close());
+ AIDL_FATAL_IF(!header_writer->Close(), header_path);
const string bp_header =
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::CLIENT);
unique_ptr<CodeWriter> bp_writer(io_delegate.GetCodeWriter(bp_header));
*bp_writer << "#error TODO(b/111362593) defined_types do not have bp classes\n";
- CHECK(bp_writer->Close());
+ AIDL_FATAL_IF(!bp_writer->Close(), bp_header);
const string bn_header =
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::SERVER);
unique_ptr<CodeWriter> bn_writer(io_delegate.GetCodeWriter(bn_header));
*bn_writer << "#error TODO(b/111362593) defined_types do not have bn classes\n";
- CHECK(bn_writer->Close());
-
- unique_ptr<CodeWriter> source_writer = io_delegate.GetCodeWriter(output_file);
- GenerateParcelSource(*source_writer, types, defined_type, options);
- CHECK(source_writer->Close());
+ AIDL_FATAL_IF(!bn_writer->Close(), bn_header);
}
void GenerateNdkParcelDeclaration(const std::string& filename, const IoDelegate& io_delegate) {
CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
*code_writer
<< "// This file is intentionally left blank as placeholder for parcel declaration.\n";
- CHECK(code_writer->Close());
+ AIDL_FATAL_IF(!code_writer->Close(), filename);
}
void GenerateNdkEnumDeclaration(const string& output_file, const Options& options,
@@ -103,31 +121,37 @@
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::RAW);
unique_ptr<CodeWriter> header_writer(io_delegate.GetCodeWriter(header_path));
GenerateEnumHeader(*header_writer, types, defined_type, options);
- CHECK(header_writer->Close());
+ AIDL_FATAL_IF(!header_writer->Close(), header_path);
const string bp_header =
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::CLIENT);
unique_ptr<CodeWriter> bp_writer(io_delegate.GetCodeWriter(bp_header));
*bp_writer << "#error TODO(b/111362593) enums do not have bp classes\n";
- CHECK(bp_writer->Close());
+ AIDL_FATAL_IF(!bp_writer->Close(), bp_header);
const string bn_header =
options.OutputHeaderDir() + NdkHeaderFile(defined_type, ClassNames::SERVER);
unique_ptr<CodeWriter> bn_writer(io_delegate.GetCodeWriter(bn_header));
*bn_writer << "#error TODO(b/111362593) enums do not have bn classes\n";
- CHECK(bn_writer->Close());
+ AIDL_FATAL_IF(!bn_writer->Close(), bn_header);
unique_ptr<CodeWriter> source_writer = io_delegate.GetCodeWriter(output_file);
*source_writer
<< "// This file is intentionally left blank as placeholder for enum declaration.\n";
- CHECK(source_writer->Close());
+ AIDL_FATAL_IF(!source_writer->Close(), output_file);
}
void GenerateNdk(const string& output_file, const Options& options, const AidlTypenames& types,
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;
}
@@ -148,7 +172,7 @@
return;
}
- CHECK(false) << "Unrecognized type sent for NDK cpp generation.";
+ AIDL_FATAL(defined_type) << "Unrecognized type sent for NDK cpp generation.";
}
namespace internals {
@@ -182,25 +206,91 @@
out << "#include <android/binder_stability.h>\n";
out << "#endif // BINDER_STABILITY_SUPPORT\n";
- types.IterateTypes([&](const AidlDefinedType& other_defined_type) {
- if (&other_defined_type == &defined_type) return;
+ if (defined_type.IsSensitiveData()) {
+ out << "#include <android/binder_parcel_platform.h>\n";
+ out << "#include <android/binder_ibinder_platform.h>\n";
+ }
- if (other_defined_type.AsInterface() != nullptr) {
- out << "#include <"
- << NdkHeaderFile(other_defined_type, ClassNames::RAW, false /*use_os_sep*/) << ">\n";
- } else if (other_defined_type.AsStructuredParcelable() != nullptr) {
- out << "#include <"
- << NdkHeaderFile(other_defined_type, ClassNames::RAW, false /*use_os_sep*/) << ">\n";
- } else if (other_defined_type.AsParcelable() != nullptr) {
- out << "#include \"" << other_defined_type.AsParcelable()->GetCppHeader() << "\"\n";
- } else if (other_defined_type.AsEnumDeclaration() != nullptr) {
- out << "#include <"
- << NdkHeaderFile(other_defined_type, ClassNames::RAW, false /*use_os_sep*/) << ">\n";
- } else {
- AIDL_FATAL(defined_type) << "Unrecognized type.";
+ auto headerFilePath = [&types](const AidlTypeSpecifier& typespec) -> std::string {
+ const AidlDefinedType* type = types.TryGetDefinedType(typespec.GetName());
+ if (type == nullptr) {
+ // could be a primitive type.
+ return "";
}
- });
+
+ if (type->AsInterface() != nullptr) {
+ 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) {
+ return NdkHeaderFile(*type, ClassNames::RAW, false /*use_os_sep*/);
+ } else {
+ AIDL_FATAL(*type) << "Unrecognized type.";
+ return "";
+ }
+ };
+
+ 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()) {
+ visit(method->GetType());
+ for (const auto& argument : method->GetArguments()) {
+ visit(argument->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()) {
+ 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) {
+ visit(enum_decl->GetBackingType());
+ }
+
+ for (const auto& path : includes) {
+ if (path == "") {
+ continue;
+ }
+ out << "#include <" << path << ">\n";
+ }
}
+
static void GenerateSourceIncludes(CodeWriter& out, const AidlTypenames& types,
const AidlDefinedType& /*defined_type*/) {
out << "#include <android/binder_parcel_utils.h>\n";
@@ -217,54 +307,36 @@
});
}
-static void GenerateConstantDeclarations(CodeWriter& out, const AidlInterface& interface) {
- for (const auto& constant : interface.GetConstantDeclarations()) {
- const AidlConstantValue& value = constant->GetValue();
- CHECK(value.GetType() != AidlConstantValue::Type::UNARY &&
- value.GetType() != AidlConstantValue::Type::BINARY);
- 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();
- CHECK(value.GetType() != AidlConstantValue::Type::UNARY &&
- value.GetType() != AidlConstantValue::Type::BINARY);
- 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();
- CHECK(value.GetType() != AidlConstantValue::Type::UNARY &&
- value.GetType() != AidlConstantValue::Type::BINARY);
+ 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";
}
@@ -274,6 +346,9 @@
void GenerateSource(CodeWriter& out, const AidlTypenames& types, const AidlInterface& defined_type,
const Options& options) {
GenerateSourceIncludes(out, types, defined_type);
+ if (options.GenLog()) {
+ out << "#include <android/binder_to_string.h>\n";
+ }
out << "\n";
EnterNdkNamespace(out, defined_type);
@@ -325,8 +400,16 @@
out << cpp::GenLogBeforeExecute(ClassName(defined_type, ClassNames::CLIENT), method,
false /* isServer */, true /* isNdk */);
}
+ if (options.GenTraces()) {
+ 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()) {
@@ -341,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";
@@ -349,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";
@@ -362,8 +451,9 @@
out << "if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ";
out << iface << "::getDefaultImpl()) {\n";
out.Indent();
- out << "return " << iface << "::getDefaultImpl()->" << method.GetName() << "(";
+ out << "_aidl_status = " << iface << "::getDefaultImpl()->" << method.GetName() << "(";
out << NdkArgList(types, method, FormatArgNameOnly) << ");\n";
+ out << "goto _aidl_status_return;\n";
out.Dedent();
out << "}\n";
@@ -373,7 +463,7 @@
out << "_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());\n";
StatusCheckGoto(out);
- out << "if (!AStatus_isOk(_aidl_status.get())) return _aidl_status;\n\n";
+ out << "if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;\n";
}
if (method.GetType().GetName() != "void") {
@@ -396,11 +486,13 @@
out << "_aidl_error:\n";
out << "_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));\n";
+ out << "_aidl_status_return:\n";
if (options.GenLog()) {
out << cpp::GenLogAfterExecute(ClassName(defined_type, ClassNames::CLIENT), defined_type,
method, "_aidl_status", "_aidl_return", false /* isServer */,
true /* isNdk */);
}
+
out << "return _aidl_status;\n";
out.Dedent();
out << "}\n";
@@ -419,6 +511,11 @@
out << NdkNameOf(types, method.GetType(), StorageMode::STACK) << " _aidl_return;\n";
}
out << "\n";
+ if (options.GenTraces()) {
+ out << "ScopedTrace _aidl_trace(\"AIDL::" << to_string(options.TargetLanguage())
+ << "::" << ClassName(defined_type, ClassNames::INTERFACE) << "::" << method.GetName()
+ << "::server\");\n";
+ }
for (const auto& arg : method.GetArguments()) {
const std::string var_name = cpp::BuildVarName(*arg);
@@ -430,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()) {
@@ -476,7 +574,26 @@
const AidlInterface& defined_type, const Options& options) {
const std::string clazz = ClassName(defined_type, ClassNames::INTERFACE);
const std::string bn_clazz = ClassName(defined_type, ClassNames::SERVER);
-
+ if (options.GenTraces()) {
+ out << "class ScopedTrace {\n";
+ out.Indent();
+ out << "public:\n"
+ << "inline explicit ScopedTrace(const char* name) {\n"
+ << "ATrace_beginSection(name);\n"
+ << "}\n"
+ << "inline ~ScopedTrace() {\n"
+ << "ATrace_endSection();\n"
+ << "}\n";
+ 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, "
@@ -507,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);
@@ -515,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()) {
@@ -531,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();
@@ -578,12 +699,12 @@
const std::string bp_clazz = ClassName(defined_type, ClassNames::CLIENT);
out << "// Source for " << clazz << "\n";
- out << "const char* " << clazz << "::" << kDescriptor << " = \""
- << defined_type.GetCanonicalName() << "\";\n";
+ out << "const char* " << clazz << "::" << kDescriptor << " = \"" << defined_type.GetDescriptor()
+ << "\";\n";
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
@@ -621,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";
@@ -704,22 +825,28 @@
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";
}
+ if (options.GenTraces()) {
+ out << "#include <android/trace.h>\n";
+ }
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) {
@@ -731,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";
@@ -749,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";
@@ -761,15 +891,16 @@
continue;
}
if (method->GetName() == kGetInterfaceVersion && options.Version() > 0) {
- out << NdkMethodDecl(types, *method) << " final override;\n";
+ out << NdkMethodDecl(types, *method) << " final;\n";
} else if (method->GetName() == kGetInterfaceHash && !options.Hash().empty()) {
- out << NdkMethodDecl(types, *method) << " final override;\n";
+ out << NdkMethodDecl(types, *method) << " final;\n";
} else {
AIDL_FATAL(defined_type) << "Meta method '" << method->GetName() << "' is unimplemented.";
}
}
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";
@@ -789,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";
@@ -800,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";
@@ -815,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
@@ -823,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";
@@ -838,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()) {
@@ -865,18 +1009,41 @@
out << "#pragma once\n";
out << "#include <android/binder_interface_utils.h>\n";
- out << "\n";
+ out << "#include <android/binder_parcelable_utils.h>\n";
+
+ // used by toString()
+ out << "#include <android/binder_to_string.h>\n";
GenerateHeaderIncludes(out, types, defined_type);
EnterNdkNamespace(out, defined_type);
- out << "class " << clazz << " {\n";
+ 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";
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) {
+ out << " __attribute__((aligned (" << std::to_string(alignment) << ")))";
+ }
+ }
if (variable->GetDefaultValue()) {
out << " = " << variable->ValueString(ConstantValueDecorator);
}
@@ -885,6 +1052,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);
@@ -892,7 +1069,14 @@
void GenerateParcelSource(CodeWriter& out, const AidlTypenames& types,
const AidlStructuredParcelable& defined_type,
const Options& /*options*/) {
- const std::string clazz = ClassName(defined_type, ClassNames::RAW);
+ 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());
+ }
out << "#include \"" << NdkHeaderFile(defined_type, ClassNames::RAW, false /*use_os_sep*/)
<< "\"\n";
@@ -900,33 +1084,39 @@
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();
out << "int32_t _aidl_parcelable_size;\n";
out << "int32_t _aidl_start_pos = AParcel_getDataPosition(parcel);\n";
out << "binder_status_t _aidl_ret_status = AParcel_readInt32(parcel, &_aidl_parcelable_size);\n";
+ out << "if (_aidl_start_pos > INT32_MAX - _aidl_parcelable_size) return STATUS_BAD_VALUE;\n";
out << "if (_aidl_parcelable_size < 0) return STATUS_BAD_VALUE;\n";
StatusCheckReturn(out);
for (const auto& variable : defined_type.GetFields()) {
- out << "_aidl_ret_status = ";
- ReadFromParcelFor({out, types, variable->GetType(), "parcel", "&" + variable->GetName()});
- out << ";\n";
- StatusCheckReturn(out);
out << "if (AParcel_getDataPosition(parcel) - _aidl_start_pos >= _aidl_parcelable_size) {\n"
<< " AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);\n"
<< " return _aidl_ret_status;\n"
<< "}\n";
+ out << "_aidl_ret_status = ";
+ ReadFromParcelFor({out, types, variable->GetType(), "parcel", "&" + variable->GetName()});
+ out << ";\n";
+ StatusCheckReturn(out);
}
out << "AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);\n"
<< "return _aidl_ret_status;\n";
out.Dedent();
out << "}\n";
+ out << cpp::TemplateDecl(defined_type);
out << "binder_status_t " << clazz << "::writeToParcel(AParcel* parcel) const {\n";
out.Indent();
out << "binder_status_t _aidl_ret_status;\n";
@@ -953,10 +1143,141 @@
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 <android/binder_to_string.h>\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 =
+ "[[nodiscard]] 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()) {
@@ -990,7 +1311,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
new file mode 100644
index 0000000..3817f64
--- /dev/null
+++ b/generate_rust.cpp
@@ -0,0 +1,822 @@
+/*
+ * 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 "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 "aidl_to_cpp_common.h"
+#include "aidl_to_rust.h"
+#include "code_writer.h"
+#include "comments.h"
+#include "logging.h"
+
+using android::base::Join;
+using std::ostringstream;
+using std::shared_ptr;
+using std::string;
+using std::unique_ptr;
+using std::vector;
+
+namespace android {
+namespace aidl {
+namespace rust {
+
+static constexpr const char kArgumentPrefix[] = "_arg_";
+static constexpr const char kGetInterfaceVersion[] = "getInterfaceVersion";
+static constexpr const char kGetInterfaceHash[] = "getInterfaceHash";
+
+void GenerateMangledAlias(CodeWriter& out, const AidlDefinedType* type) {
+ ostringstream alias;
+ for (const auto& component : type->GetSplitPackage()) {
+ alias << "_" << component.size() << "_" << component;
+ }
+ alias << "_" << type->GetName().size() << "_" << type->GetName();
+ out << "pub(crate) mod mangled { pub use super::" << type->GetName() << " as " << alias.str()
+ << "; }\n";
+}
+
+string BuildArg(const AidlArgument& arg, const AidlTypenames& typenames) {
+ // We pass in parameters that are not primitives by const reference.
+ // Arrays get passed in as slices, which is handled in RustNameOf.
+ auto arg_mode = ArgumentStorageMode(arg, typenames);
+ auto arg_type = RustNameOf(arg.GetType(), typenames, arg_mode);
+ return kArgumentPrefix + arg.GetName() + ": " + arg_type;
+}
+
+string BuildMethod(const AidlMethod& method, const AidlTypenames& typenames) {
+ auto method_type = RustNameOf(method.GetType(), typenames, StorageMode::VALUE);
+ auto return_type = string{"binder::public_api::Result<"} + method_type + ">";
+ string parameters = "&self";
+ for (const std::unique_ptr<AidlArgument>& arg : method.GetArguments()) {
+ parameters += ", ";
+ parameters += BuildArg(*arg, typenames);
+ }
+ return "fn " + method.GetName() + "(" + parameters + ") -> " + return_type;
+}
+
+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();
+
+ if (!method.IsUserDefined()) {
+ if (method.GetName() == kGetInterfaceVersion && options.Version() > 0) {
+ // Check if the version is in the cache
+ out << "let _aidl_version = "
+ "self.cached_version.load(std::sync::atomic::Ordering::Relaxed);\n";
+ out << "if _aidl_version != -1 { return Ok(_aidl_version); }\n";
+ }
+
+ if (method.GetName() == kGetInterfaceHash && !options.Hash().empty()) {
+ out << "{\n";
+ out << " let _aidl_hash_lock = self.cached_hash.lock().unwrap();\n";
+ out << " if let Some(ref _aidl_hash) = *_aidl_hash_lock {\n";
+ out << " return Ok(_aidl_hash.clone());\n";
+ out << " }\n";
+ out << "}\n";
+ }
+ }
+
+ // Call transact()
+ vector<string> flags;
+ if (method.IsOneway()) flags.push_back("binder::FLAG_ONEWAY");
+ if (iface.IsSensitiveData()) flags.push_back("binder::FLAG_CLEAR_BUF");
+ flags.push_back("binder::FLAG_PRIVATE_LOCAL");
+
+ 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();
+ if (arg->IsIn()) {
+ // If the argument is already a reference, don't reference it again
+ // (unless we turned it into an Option<&T>)
+ auto ref_mode = ArgumentReferenceMode(*arg, typenames);
+ if (IsReference(ref_mode)) {
+ out << "_aidl_data.write(" << arg_name << ")?;\n";
+ } else {
+ out << "_aidl_data.write(&" << arg_name << ")?;\n";
+ }
+ } else if (arg->GetType().IsArray()) {
+ // For out-only arrays, send the array size
+ if (arg->GetType().IsNullable()) {
+ out << "_aidl_data.write_slice_size(" << arg_name << ".as_deref())?;\n";
+ } else {
+ out << "_aidl_data.write_slice_size(Some(" << arg_name << "))?;\n";
+ }
+ }
+ }
+
+ // Return Ok(()) if all the `_aidl_data.write(...)?;` calls pass
+ out << "Ok(())\n";
+ out.Dedent();
+ out << "});\n";
+
+ // Check for UNKNOWN_TRANSACTION and call the default impl
+ 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();
+ }
+ 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";
+
+ string return_val = "()";
+ if (!method.IsOneway()) {
+ // Check for errors
+ out << "let _aidl_status: binder::Status = _aidl_reply.read()?;\n";
+ out << "if !_aidl_status.is_ok() { return Err(_aidl_status); }\n";
+
+ // Return reply value
+ if (method.GetType().GetName() != "void") {
+ auto return_type = RustNameOf(method.GetType(), typenames, StorageMode::VALUE);
+ out << "let _aidl_return: " << return_type << " = _aidl_reply.read()?;\n";
+ return_val = "_aidl_return";
+
+ if (!method.IsUserDefined()) {
+ if (method.GetName() == kGetInterfaceVersion && options.Version() > 0) {
+ out << "self.cached_version.store(_aidl_return, std::sync::atomic::Ordering::Relaxed);\n";
+ }
+ if (method.GetName() == kGetInterfaceHash && !options.Hash().empty()) {
+ out << "*self.cached_hash.lock().unwrap() = Some(_aidl_return.clone());\n";
+ }
+ }
+ }
+
+ for (const AidlArgument* arg : method.GetOutArguments()) {
+ out << "*" << kArgumentPrefix << arg->GetName() << " = _aidl_reply.read()?;\n";
+ }
+ }
+
+ // Return the result
+ out << "Ok(" << return_val << ")\n";
+ out.Dedent();
+ out << "}\n";
+}
+
+void GenerateServerTransaction(CodeWriter& out, const AidlMethod& method,
+ const AidlTypenames& typenames) {
+ out << "transactions::" << method.GetName() << " => {\n";
+ out.Indent();
+
+ string args;
+ for (const auto& arg : method.GetArguments()) {
+ string arg_name = kArgumentPrefix + arg->GetName();
+ StorageMode arg_mode;
+ if (arg->IsIn()) {
+ arg_mode = StorageMode::VALUE;
+ } else {
+ // We need a value we can call Default::default() on
+ arg_mode = StorageMode::DEFAULT_VALUE;
+ }
+ auto arg_type = RustNameOf(arg->GetType(), typenames, arg_mode);
+
+ string arg_mut = arg->IsOut() ? "mut " : "";
+ string arg_init = arg->IsIn() ? "_aidl_data.read()?" : "Default::default()";
+ out << "let " << arg_mut << arg_name << ": " << arg_type << " = " << arg_init << ";\n";
+ if (!arg->IsIn() && arg->GetType().IsArray()) {
+ // _aidl_data.resize_[nullable_]out_vec(&mut _arg_foo)?;
+ auto resize_name = arg->GetType().IsNullable() ? "resize_nullable_out_vec" : "resize_out_vec";
+ out << "_aidl_data." << resize_name << "(&mut " << arg_name << ")?;\n";
+ }
+
+ auto ref_mode = ArgumentReferenceMode(*arg, typenames);
+ if (!args.empty()) {
+ args += ", ";
+ }
+ args += TakeReference(ref_mode, arg_name);
+ }
+ out << "let _aidl_return = _aidl_service." << method.GetName() << "(" << args << ");\n";
+
+ if (!method.IsOneway()) {
+ out << "match &_aidl_return {\n";
+ out.Indent();
+ out << "Ok(_aidl_return) => {\n";
+ out.Indent();
+ out << "_aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;\n";
+ if (method.GetType().GetName() != "void") {
+ out << "_aidl_reply.write(_aidl_return)?;\n";
+ }
+
+ // Serialize out arguments
+ for (const AidlArgument* arg : method.GetOutArguments()) {
+ string arg_name = kArgumentPrefix + arg->GetName();
+
+ auto& arg_type = arg->GetType();
+ if (!arg->IsIn() && arg_type.IsArray() && arg_type.GetName() == "ParcelFileDescriptor") {
+ // We represent arrays of ParcelFileDescriptor as
+ // Vec<Option<ParcelFileDescriptor>> when they're out-arguments,
+ // but we need all of them to be initialized to Some; if there's
+ // any None, return UNEXPECTED_NULL (this is what libbinder_ndk does)
+ out << "if " << arg_name << ".iter().any(Option::is_none) { "
+ << "return Err(binder::StatusCode::UNEXPECTED_NULL); }\n";
+ } else if (!arg->IsIn() && !TypeHasDefault(arg_type, typenames)) {
+ // Unwrap out-only arguments that we wrapped in Option<T>
+ out << "let " << arg_name << " = " << arg_name
+ << ".ok_or(binder::StatusCode::UNEXPECTED_NULL)?;\n";
+ }
+
+ out << "_aidl_reply.write(&" << arg_name << ")?;\n";
+ }
+ out.Dedent();
+ out << "}\n";
+ out << "Err(_aidl_status) => _aidl_reply.write(_aidl_status)?\n";
+ out.Dedent();
+ out << "}\n";
+ }
+ out << "Ok(())\n";
+ out.Dedent();
+ out << "}\n";
+}
+
+void GenerateServerItems(CodeWriter& out, const AidlInterface* iface,
+ const AidlTypenames& typenames) {
+ auto trait_name = ClassName(*iface, cpp::ClassNames::INTERFACE);
+ auto server_name = ClassName(*iface, cpp::ClassNames::SERVER);
+
+ // Forward all IFoo functions from Binder to the inner object
+ out << "impl " << trait_name << " for binder::Binder<" << server_name << "> {\n";
+ out.Indent();
+ for (const auto& method : iface->GetMethods()) {
+ string args;
+ for (const std::unique_ptr<AidlArgument>& arg : method->GetArguments()) {
+ if (!args.empty()) {
+ args += ", ";
+ }
+ args += kArgumentPrefix;
+ args += arg->GetName();
+ }
+ out << BuildMethod(*method, typenames) << " { "
+ << "self.0." << method->GetName() << "(" << args << ") }\n";
+ }
+ out.Dedent();
+ out << "}\n";
+
+ out << "fn on_transact("
+ "_aidl_service: &dyn "
+ << trait_name
+ << ", "
+ "_aidl_code: binder::TransactionCode, "
+ "_aidl_data: &binder::parcel::Parcel, "
+ "_aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {\n";
+ out.Indent();
+ out << "match _aidl_code {\n";
+ out.Indent();
+ for (const auto& method : iface->GetMethods()) {
+ GenerateServerTransaction(out, *method, typenames);
+ }
+ out << "_ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)\n";
+ out.Dedent();
+ out << "}\n";
+ out.Dedent();
+ 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) {
+ CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
+
+ *code_writer << "#![allow(non_upper_case_globals)]\n";
+ *code_writer << "#![allow(non_snake_case)]\n";
+ // Import IBinderInternal for transact()
+ *code_writer << "#[allow(unused_imports)] use binder::IBinderInternal;\n";
+
+ auto trait_name = ClassName(*iface, cpp::ClassNames::INTERFACE);
+ auto client_name = ClassName(*iface, cpp::ClassNames::CLIENT);
+ auto server_name = ClassName(*iface, cpp::ClassNames::SERVER);
+ *code_writer << "use binder::declare_binder_interface;\n";
+ *code_writer << "declare_binder_interface! {\n";
+ code_writer->Indent();
+ *code_writer << trait_name << "[\"" << iface->GetDescriptor() << "\"] {\n";
+ code_writer->Indent();
+ *code_writer << "native: " << server_name << "(on_transact),\n";
+ *code_writer << "proxy: " << client_name << " {\n";
+ code_writer->Indent();
+ if (options.Version() > 0) {
+ string comma = options.Hash().empty() ? "" : ",";
+ *code_writer << "cached_version: "
+ "std::sync::atomic::AtomicI32 = "
+ "std::sync::atomic::AtomicI32::new(-1)"
+ << comma << "\n";
+ }
+ if (!options.Hash().empty()) {
+ *code_writer << "cached_hash: "
+ "std::sync::Mutex<Option<String>> = "
+ "std::sync::Mutex::new(None)\n";
+ }
+ code_writer->Dedent();
+ *code_writer << "},\n";
+ code_writer->Dedent();
+ if (iface->IsVintfStability()) {
+ *code_writer << "stability: binder::Stability::Vintf,\n";
+ }
+ *code_writer << "}\n";
+ 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 { \""
+ << iface->GetDescriptor() << "\" }\n";
+
+ for (const auto& method : iface->GetMethods()) {
+ // Generate the method
+ GenerateDeprecated(*code_writer, *method);
+ if (method->IsUserDefined()) {
+ *code_writer << BuildMethod(*method, typenames) << ";\n";
+ } else {
+ // Generate default implementations for meta methods
+ *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";
+ }
+ }
+
+ // Emit the default implementation code inside the trait
+ auto default_trait_name = ClassName(*iface, cpp::ClassNames::DEFAULT_IMPL);
+ auto default_ref_name = default_trait_name + "Ref";
+ *code_writer << "fn getDefaultImpl()"
+ << " -> " << default_ref_name << " where Self: Sized {\n";
+ *code_writer << " DEFAULT_IMPL.lock().unwrap().clone()\n";
+ *code_writer << "}\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";
+ code_writer->Indent();
+ for (const auto& method : iface->GetMethods()) {
+ // Generate the transaction code constant
+ *code_writer << "pub const " << method->GetName()
+ << ": binder::TransactionCode = "
+ "binder::FIRST_CALL_TRANSACTION + " +
+ std::to_string(method->GetId()) + ";\n";
+ }
+ code_writer->Dedent();
+ *code_writer << "}\n";
+
+ // Emit the default implementation code outside the trait
+ *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_ref_name
+ << "> = std::sync::Mutex::new(None);\n";
+ *code_writer << "}\n";
+
+ // Emit the interface constants
+ GenerateConstantDeclarations(*code_writer, *iface, typenames);
+
+ GenerateMangledAlias(*code_writer, iface);
+
+ // Emit VERSION and HASH
+ // These need to be top-level item constants instead of associated consts
+ // because the latter are incompatible with trait objects, see
+ // https://doc.rust-lang.org/reference/items/traits.html#object-safety
+ if (options.Version() > 0) {
+ *code_writer << "pub const VERSION: i32 = " << std::to_string(options.Version()) << ";\n";
+ }
+ if (!options.Hash().empty()) {
+ *code_writer << "pub const HASH: &str = \"" << options.Hash() << "\";\n";
+ }
+
+ // Generate the client-side methods
+ *code_writer << "impl " << trait_name << " for " << client_name << " {\n";
+ code_writer->Indent();
+ for (const auto& method : iface->GetMethods()) {
+ GenerateClientMethod(*code_writer, *iface, *method, typenames, options, trait_name);
+ }
+ code_writer->Dedent();
+ *code_writer << "}\n";
+
+ // Generate the server-side methods
+ GenerateServerItems(*code_writer, iface, typenames);
+
+ 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();
+ out << "fn default() -> Self {\n";
+ out.Indent();
+ out << "Self {\n";
+ out.Indent();
+ for (const auto& variable : parcel->GetFields()) {
+ if (variable->GetDefaultValue()) {
+ out << variable->GetName() << ": " << variable->ValueString(ConstantValueDecorator) << ",\n";
+ } else {
+ out << variable->GetName() << ": Default::default(),\n";
+ }
+ }
+ out.Dedent();
+ out << "}\n";
+ out.Dedent();
+ out << "}\n";
+ out.Dedent();
+ out << "}\n";
+}
+
+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";
+ out << "if start_pos.checked_add(parcelable_size).is_none() {\n";
+ out << " return Err(binder::StatusCode::BAD_VALUE);\n";
+ out << "}\n";
+
+ // Pre-emit the common field prologue code, shared between all fields:
+ ostringstream prologue;
+ prologue << "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
+ prologue << " return Ok(Some(result));\n";
+ prologue << "}\n";
+ string prologue_str = prologue.str();
+
+ out << "let mut result = Self::default();\n";
+ for (const auto& variable : parcel->GetFields()) {
+ out << prologue_str;
+ if (!TypeHasDefault(variable->GetType(), typenames)) {
+ out << "result." << variable->GetName() << " = Some(parcel.read()?);\n";
+ } else {
+ out << "result." << variable->GetName() << " = parcel.read()?;\n";
+ }
+ }
+ // Now we read all fields.
+ // Skip remaining data in case we're reading from a newer version
+ out << "unsafe {\n";
+ out << " parcel.set_data_position(start_pos + parcelable_size)?;\n";
+ out << "}\n";
+ 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";
+ out << " <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)\n";
+ out << " }\n";
+ out << "}\n";
+
+ out << "impl binder::parcel::SerializeArray for " << parcel->GetName() << " {}\n";
+
+ out << "impl binder::parcel::SerializeOption for " << parcel->GetName() << " {\n";
+ out.Indent();
+ out << "fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> "
+ "binder::Result<()> {\n";
+ out.Indent();
+ out << "let this = if let Some(this) = this {\n";
+ out << " parcel.write(&1i32)?;\n";
+ out << " this\n";
+ out << "} else {\n";
+ out << " return parcel.write(&0i32);\n";
+ out << "};\n";
+
+ GenerateParcelSerializeBody(out, parcel, typenames);
+
+ out.Dedent();
+ out << "}\n";
+ out.Dedent();
+ out << "}\n";
+}
+
+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";
+ out << " <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)\n";
+ out << " .transpose()\n";
+ out << " .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))\n";
+ out << " }\n";
+ out << "}\n";
+
+ out << "impl binder::parcel::DeserializeArray for " << parcel->GetName() << " {}\n";
+
+ out << "impl binder::parcel::DeserializeOption for " << parcel->GetName() << " {\n";
+ out.Indent();
+ out << "fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> "
+ "{\n";
+ out.Indent();
+ out << "let status: i32 = parcel.read()?;\n";
+ out << "if status == 0 { return Ok(None); }\n";
+
+ GenerateParcelDeserializeBody(out, parcel, typenames);
+
+ out.Dedent();
+ out << "}\n";
+ out.Dedent();
+ out << "}\n";
+}
+
+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);
+
+ // Debug is always derived because all Rust AIDL types implement it
+ // ParcelFileDescriptor doesn't support any of the others because
+ // it's a newtype over std::fs::File which only implements Debug
+ vector<string> derives{"Debug"};
+ const AidlAnnotation* derive_annotation = parcel->RustDerive();
+ if (derive_annotation != nullptr) {
+ for (const auto& name_and_param : derive_annotation->AnnotationParams(ConstantValueDecorator)) {
+ if (name_and_param.second == "true") {
+ derives.push_back(name_and_param.first);
+ }
+ }
+ }
+
+ *code_writer << "#[derive(" << Join(derives, ", ") << ")]\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;
+}
+
+bool GenerateRustEnumDeclaration(const string& filename, const AidlEnumDeclaration* enum_decl,
+ const AidlTypenames& typenames, const IoDelegate& io_delegate) {
+ CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
+
+ 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
+ << " {\n";
+ code_writer->Indent();
+ for (const auto& enumerator : enum_decl->GetEnumerators()) {
+ auto value = enumerator->GetValue()->ValueString(aidl_backing_type, ConstantValueDecorator);
+ *code_writer << enumerator->GetName() << " = " << value << ",\n";
+ }
+ code_writer->Dedent();
+ *code_writer << "} }\n";
+
+ GenerateMangledAlias(*code_writer, enum_decl);
+
+ return true;
+}
+
+bool GenerateRust(const string& filename, const AidlDefinedType* defined_type,
+ const AidlTypenames& typenames, const IoDelegate& io_delegate,
+ const Options& options) {
+ if (const AidlStructuredParcelable* parcelable = defined_type->AsStructuredParcelable();
+ parcelable != nullptr) {
+ 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);
+ }
+
+ if (const AidlInterface* interface = defined_type->AsInterface(); interface != nullptr) {
+ return GenerateRustInterface(filename, interface, typenames, io_delegate, options);
+ }
+
+ AIDL_FATAL(filename) << "Unrecognized type sent for Rust generation.";
+ return false;
+}
+
+} // namespace rust
+} // namespace aidl
+} // namespace android
diff --git a/generate_rust.h b/generate_rust.h
new file mode 100644
index 0000000..35daf9b
--- /dev/null
+++ b/generate_rust.h
@@ -0,0 +1,35 @@
+/*
+ * 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 "aidl_language.h"
+#include "io_delegate.h"
+#include "options.h"
+
+#include <string>
+
+namespace android {
+namespace aidl {
+namespace rust {
+
+bool GenerateRust(const std::string& filename, const AidlDefinedType* iface,
+ const AidlTypenames& typenames, const IoDelegate& io_delegate,
+ const Options& options);
+
+} // namespace rust
+} // namespace aidl
+} // namespace android
diff --git a/hiddenapi-greylist b/hiddenapi-greylist
new file mode 100644
index 0000000..282e9c9
--- /dev/null
+++ b/hiddenapi-greylist
@@ -0,0 +1,539 @@
+"android.accessibilityservice.IAccessibilityServiceClient",
+"android.accessibilityservice.IAccessibilityServiceConnection",
+"android.accounts.IAccountAuthenticator",
+"android.accounts.IAccountAuthenticatorResponse",
+"android.accounts.IAccountManager",
+"android.accounts.IAccountManagerResponse",
+"android.app.admin.IDeviceAdminService",
+"android.app.admin.IDevicePolicyManager",
+"android.app.backup.IBackupManager",
+"android.app.backup.IBackupManagerMonitor",
+"android.app.backup.IBackupObserver",
+"android.app.backup.IFullBackupRestoreObserver",
+"android.app.backup.IRestoreObserver",
+"android.app.backup.IRestoreSession",
+"android.app.backup.ISelectBackupTransportCallback",
+"android.app.IActivityController",
+"android.app.IActivityManager",
+"android.app.IActivityPendingResult",
+"android.app.IAlarmCompleteListener",
+"android.app.IAlarmListener",
+"android.app.IAlarmManager",
+"android.app.IApplicationThread",
+"android.app.IAppTask",
+"android.app.IAssistDataReceiver",
+"android.app.IBackupAgent",
+"android.app.IEphemeralResolver",
+"android.app.IInputForwarder",
+"android.app.IInstantAppResolver",
+"android.app.IInstrumentationWatcher",
+"android.app.INotificationManager",
+"android.app.IProcessObserver",
+"android.app.ISearchManager",
+"android.app.ISearchManagerCallback",
+"android.app.IServiceConnection",
+"android.app.IStopUserCallback",
+"android.app.ITaskStackListener",
+"android.app.ITransientNotification",
+"android.app.IUiAutomationConnection",
+"android.app.IUidObserver",
+"android.app.IUiModeManager",
+"android.app.IUserSwitchObserver",
+"android.app.IWallpaperManager",
+"android.app.IWallpaperManagerCallback",
+"android.app.job.IJobCallback",
+"android.app.job.IJobScheduler",
+"android.app.job.IJobService",
+"android.app.slice.ISliceListener",
+"android.app.slice.ISliceManager",
+"android.app.trust.IStrongAuthTracker",
+"android.app.trust.ITrustListener",
+"android.app.trust.ITrustManager",
+"android.app.usage.ICacheQuotaService",
+"android.app.usage.IStorageStatsManager",
+"android.app.usage.IUsageStatsManager",
+"android.bluetooth.IBluetooth",
+"android.bluetooth.IBluetoothA2dp",
+"android.bluetooth.IBluetoothA2dpSink",
+"android.bluetooth.IBluetoothAvrcpController",
+"android.bluetooth.IBluetoothAvrcpTarget",
+"android.bluetooth.IBluetoothCallback",
+"android.bluetooth.IBluetoothGatt",
+"android.bluetooth.IBluetoothGattCallback",
+"android.bluetooth.IBluetoothGattServerCallback",
+"android.bluetooth.IBluetoothHeadset",
+"android.bluetooth.IBluetoothHeadsetClient",
+"android.bluetooth.IBluetoothHeadsetPhone",
+"android.bluetooth.IBluetoothHealth",
+"android.bluetooth.IBluetoothHealthCallback",
+"android.bluetooth.IBluetoothHearingAid",
+"android.bluetooth.IBluetoothHidDevice",
+"android.bluetooth.IBluetoothHidDeviceCallback",
+"android.bluetooth.IBluetoothHidHost",
+"android.bluetooth.IBluetoothManager",
+"android.bluetooth.IBluetoothManagerCallback",
+"android.bluetooth.IBluetoothMap",
+"android.bluetooth.IBluetoothMapClient",
+"android.bluetooth.IBluetoothPan",
+"android.bluetooth.IBluetoothPbap",
+"android.bluetooth.IBluetoothPbapClient",
+"android.bluetooth.IBluetoothProfileServiceConnection",
+"android.bluetooth.IBluetoothSap",
+"android.bluetooth.IBluetoothSocketManager",
+"android.bluetooth.IBluetoothStateChangeCallback",
+"android.bluetooth.le.IAdvertisingSetCallback",
+"android.bluetooth.le.IPeriodicAdvertisingCallback",
+"android.bluetooth.le.IScannerCallback",
+"android.companion.ICompanionDeviceDiscoveryService",
+"android.companion.ICompanionDeviceDiscoveryServiceCallback",
+"android.companion.ICompanionDeviceManager",
+"android.companion.IFindDeviceCallback",
+"android.content.IClipboard",
+"android.content.IContentService",
+"android.content.IIntentReceiver",
+"android.content.IIntentSender",
+"android.content.IOnPrimaryClipChangedListener",
+"android.content.IRestrictionsManager",
+"android.content.ISyncAdapter",
+"android.content.ISyncAdapterUnsyncableAccountCallback",
+"android.content.ISyncContext",
+"android.content.ISyncServiceAdapter",
+"android.content.ISyncStatusObserver",
+"android.content.om.IOverlayManager",
+"android.content.pm.dex.IArtManager",
+"android.content.pm.dex.ISnapshotRuntimeProfileCallback",
+"android.content.pm.ICrossProfileApps",
+"android.content.pm.IDexModuleRegisterCallback",
+"android.content.pm.ILauncherApps",
+"android.content.pm.IOnAppsChangedListener",
+"android.content.pm.IOnPermissionsChangeListener",
+"android.content.pm.IOtaDexopt",
+"android.content.pm.IPackageDataObserver",
+"android.content.pm.IPackageDeleteObserver",
+"android.content.pm.IPackageDeleteObserver2",
+"android.content.pm.IPackageInstaller",
+"android.content.pm.IPackageInstallerCallback",
+"android.content.pm.IPackageInstallerSession",
+"android.content.pm.IPackageInstallObserver2",
+"android.content.pm.IPackageManager",
+"android.content.pm.IPackageManagerNative",
+"android.content.pm.IPackageMoveObserver",
+"android.content.pm.IPackageStatsObserver",
+"android.content.pm.IPinItemRequest",
+"android.content.pm.IShortcutService",
+"android.content.pm.permission.IRuntimePermissionPresenter",
+"android.database.IContentObserver",
+"android.hardware.biometrics.IBiometricPromptReceiver",
+"android.hardware.camera2.ICameraDeviceCallbacks",
+"android.hardware.camera2.ICameraDeviceUser",
+"android.hardware.display.IDisplayManager",
+"android.hardware.display.IDisplayManagerCallback",
+"android.hardware.display.IVirtualDisplayCallback",
+"android.hardware.fingerprint.IFingerprintClientActiveCallback",
+"android.hardware.fingerprint.IFingerprintService",
+"android.hardware.fingerprint.IFingerprintServiceLockoutResetCallback",
+"android.hardware.fingerprint.IFingerprintServiceReceiver",
+"android.hardware.hdmi.IHdmiControlCallback",
+"android.hardware.hdmi.IHdmiControlService",
+"android.hardware.hdmi.IHdmiDeviceEventListener",
+"android.hardware.hdmi.IHdmiHotplugEventListener",
+"android.hardware.hdmi.IHdmiInputChangeListener",
+"android.hardware.hdmi.IHdmiMhlVendorCommandListener",
+"android.hardware.hdmi.IHdmiRecordListener",
+"android.hardware.hdmi.IHdmiSystemAudioModeChangeListener",
+"android.hardware.hdmi.IHdmiVendorCommandListener",
+"android.hardware.ICamera",
+"android.hardware.ICameraClient",
+"android.hardware.ICameraService",
+"android.hardware.ICameraServiceListener",
+"android.hardware.ICameraServiceProxy",
+"android.hardware.IConsumerIrService",
+"android.hardware.input.IInputDevicesChangedListener",
+"android.hardware.input.IInputManager",
+"android.hardware.input.ITabletModeChangedListener",
+"android.hardware.ISerialManager",
+"android.hardware.location.IActivityRecognitionHardware",
+"android.hardware.location.IActivityRecognitionHardwareClient",
+"android.hardware.location.IActivityRecognitionHardwareSink",
+"android.hardware.location.IActivityRecognitionHardwareWatcher",
+"android.hardware.location.IContextHubCallback",
+"android.hardware.location.IContextHubClient",
+"android.hardware.location.IContextHubClientCallback",
+"android.hardware.location.IContextHubService",
+"android.hardware.location.IContextHubTransactionCallback",
+"android.hardware.location.IGeofenceHardware",
+"android.hardware.location.IGeofenceHardwareCallback",
+"android.hardware.location.IGeofenceHardwareMonitorCallback",
+"android.hardware.radio.IAnnouncementListener",
+"android.hardware.radio.ICloseHandle",
+"android.hardware.radio.IRadioService",
+"android.hardware.radio.ITuner",
+"android.hardware.radio.ITunerCallback",
+"android.hardware.soundtrigger.IRecognitionStatusCallback",
+"android.hardware.usb.IUsbManager",
+"android.location.IBatchedLocationCallback",
+"android.location.ICountryDetector",
+"android.location.ICountryListener",
+"android.location.IFusedGeofenceHardware",
+"android.location.IGeocodeProvider",
+"android.location.IGeofenceProvider",
+"android.location.IGnssMeasurementsListener",
+"android.location.IGnssNavigationMessageListener",
+"android.location.IGnssStatusListener",
+"android.location.IGnssStatusProvider",
+"android.location.IGpsGeofenceHardware",
+"android.location.ILocationListener",
+"android.location.ILocationManager",
+"android.location.INetInitiatedListener",
+"android.media.audiopolicy.IAudioPolicyCallback",
+"android.media.IAudioFocusDispatcher",
+"android.media.IAudioRoutesObserver",
+"android.media.IAudioServerStateDispatcher",
+"android.media.IAudioService",
+"android.media.IMediaHTTPConnection",
+"android.media.IMediaHTTPService",
+"android.media.IMediaResourceMonitor",
+"android.media.IMediaRouterClient",
+"android.media.IMediaRouterService",
+"android.media.IMediaScannerListener",
+"android.media.IMediaScannerService",
+"android.media.IPlaybackConfigDispatcher",
+"android.media.IPlayer",
+"android.media.IRecordingConfigDispatcher",
+"android.media.IRemoteDisplayCallback",
+"android.media.IRemoteDisplayProvider",
+"android.media.IRemoteVolumeController",
+"android.media.IRemoteVolumeObserver",
+"android.media.IRingtonePlayer",
+"android.media.ISessionTokensListener",
+"android.media.IVolumeController",
+"android.media.midi.IBluetoothMidiService",
+"android.media.midi.IMidiDeviceListener",
+"android.media.midi.IMidiDeviceOpenCallback",
+"android.media.midi.IMidiDeviceServer",
+"android.media.midi.IMidiManager",
+"android.media.projection.IMediaProjection",
+"android.media.projection.IMediaProjectionCallback",
+"android.media.projection.IMediaProjectionManager",
+"android.media.projection.IMediaProjectionWatcherCallback",
+"android.media.session.IActiveSessionsListener",
+"android.media.session.ICallback",
+"android.media.session.IOnMediaKeyListener",
+"android.media.session.IOnVolumeKeyLongPressListener",
+"android.media.session.ISession",
+"android.media.session.ISessionCallback",
+"android.media.session.ISessionController",
+"android.media.session.ISessionControllerCallback",
+"android.media.session.ISessionManager",
+"android.media.soundtrigger.ISoundTriggerDetectionService",
+"android.media.soundtrigger.ISoundTriggerDetectionServiceClient",
+"android.media.tv.ITvInputClient",
+"android.media.tv.ITvInputHardware",
+"android.media.tv.ITvInputHardwareCallback",
+"android.media.tv.ITvInputManager",
+"android.media.tv.ITvInputManagerCallback",
+"android.media.tv.ITvInputService",
+"android.media.tv.ITvInputServiceCallback",
+"android.media.tv.ITvInputSession",
+"android.media.tv.ITvInputSessionCallback",
+"android.media.tv.ITvRemoteProvider",
+"android.media.tv.ITvRemoteServiceInput",
+"android.net.ICaptivePortal",
+"android.net.IConnectivityManager",
+"android.net.IEthernetManager",
+"android.net.IEthernetServiceListener",
+"android.net.IIpConnectivityMetrics",
+"android.net.IIpSecService",
+"android.net.INetd",
+"android.net.INetdEventCallback",
+"android.net.INetworkManagementEventObserver",
+"android.net.INetworkPolicyListener",
+"android.net.INetworkPolicyManager",
+"android.net.INetworkRecommendationProvider",
+"android.net.INetworkScoreCache",
+"android.net.INetworkScoreService",
+"android.net.INetworkStatsService",
+"android.net.INetworkStatsSession",
+"android.net.ITetheringStatsProvider",
+"android.net.nsd.INsdManager",
+"android.net.sip.ISipService",
+"android.net.sip.ISipSession",
+"android.net.sip.ISipSessionListener",
+"android.net.wifi.aware.IWifiAwareDiscoverySessionCallback",
+"android.net.wifi.aware.IWifiAwareEventCallback",
+"android.net.wifi.aware.IWifiAwareMacAddressProvider",
+"android.net.wifi.aware.IWifiAwareManager",
+"android.net.wifi.hotspot2.IProvisioningCallback",
+"android.net.wifi.ISoftApCallback",
+"android.net.wifi.IWifiManager",
+"android.net.wifi.IWifiScanner",
+"android.net.wifi.p2p.IWifiP2pManager",
+"android.net.wifi.rtt.IRttCallback",
+"android.net.wifi.rtt.IWifiRttManager",
+"android.nfc.IAppCallback",
+"android.nfc.INfcAdapter",
+"android.nfc.INfcAdapterExtras",
+"android.nfc.INfcCardEmulation",
+"android.nfc.INfcDta",
+"android.nfc.INfcFCardEmulation",
+"android.nfc.INfcTag",
+"android.nfc.INfcUnlockHandler",
+"android.nfc.ITagRemovedCallback",
+"android.os.IBatteryPropertiesListener",
+"android.os.IBatteryPropertiesRegistrar",
+"android.os.ICancellationSignal",
+"android.os.IDeviceIdentifiersPolicyService",
+"android.os.IDeviceIdleController",
+"android.os.IHardwarePropertiesManager",
+"android.os.IIncidentManager",
+"android.os.IIncidentReportStatusListener",
+"android.os.IInstalld",
+"android.os.IMaintenanceActivityListener",
+"android.os.IMessenger",
+"android.os.INetworkActivityListener",
+"android.os.INetworkManagementService",
+"android.os.IPermissionController",
+"android.os.IPowerManager",
+"android.os.IProcessInfoService",
+"android.os.IProgressListener",
+"android.os.IRecoverySystem",
+"android.os.IRecoverySystemProgressListener",
+"android.os.IRemoteCallback",
+"android.os.ISchedulingPolicyService",
+"android.os.IStatsCompanionService",
+"android.os.IStatsManager",
+"android.os.IStoraged",
+"android.os.ISystemUpdateManager",
+"android.os.IThermalEventListener",
+"android.os.IThermalService",
+"android.os.IUpdateEngine",
+"android.os.IUpdateEngineCallback",
+"android.os.IUpdateLock",
+"android.os.IUserManager",
+"android.os.IVibratorService",
+"android.os.IVold",
+"android.os.IVoldListener",
+"android.os.IVoldTaskListener",
+"android.os.storage.IObbActionListener",
+"android.os.storage.IStorageEventListener",
+"android.os.storage.IStorageManager",
+"android.os.storage.IStorageShutdownObserver",
+"android.print.ILayoutResultCallback",
+"android.print.IPrintDocumentAdapter",
+"android.print.IPrintDocumentAdapterObserver",
+"android.print.IPrinterDiscoveryObserver",
+"android.print.IPrintJobStateChangeListener",
+"android.print.IPrintManager",
+"android.print.IPrintServicesChangeListener",
+"android.print.IPrintSpooler",
+"android.print.IPrintSpoolerCallbacks",
+"android.print.IPrintSpoolerClient",
+"android.print.IWriteResultCallback",
+"android.printservice.IPrintService",
+"android.printservice.IPrintServiceClient",
+"android.printservice.recommendation.IRecommendationsChangeListener",
+"android.printservice.recommendation.IRecommendationService",
+"android.printservice.recommendation.IRecommendationServiceCallbacks",
+"android.se.omapi.ISecureElementChannel",
+"android.se.omapi.ISecureElementListener",
+"android.se.omapi.ISecureElementReader",
+"android.se.omapi.ISecureElementService",
+"android.se.omapi.ISecureElementSession",
+"android.security.IConfirmationPromptCallback",
+"android.security.IKeyChainAliasCallback",
+"android.security.IKeyChainService",
+"android.security.IKeystoreService",
+"android.security.keymaster.IKeyAttestationApplicationIdProvider",
+"android.service.autofill.IAutofillFieldClassificationService",
+"android.service.autofill.IAutoFillService",
+"android.service.autofill.IFillCallback",
+"android.service.autofill.ISaveCallback",
+"android.service.carrier.ICarrierMessagingCallback",
+"android.service.carrier.ICarrierMessagingService",
+"android.service.carrier.ICarrierService",
+"android.service.chooser.IChooserTargetResult",
+"android.service.chooser.IChooserTargetService",
+"android.service.dreams.IDreamManager",
+"android.service.dreams.IDreamService",
+"android.service.euicc.IDeleteSubscriptionCallback",
+"android.service.euicc.IDownloadSubscriptionCallback",
+"android.service.euicc.IEraseSubscriptionsCallback",
+"android.service.euicc.IEuiccService",
+"android.service.euicc.IGetDefaultDownloadableSubscriptionListCallback",
+"android.service.euicc.IGetDownloadableSubscriptionMetadataCallback",
+"android.service.euicc.IGetEidCallback",
+"android.service.euicc.IGetEuiccInfoCallback",
+"android.service.euicc.IGetEuiccProfileInfoListCallback",
+"android.service.euicc.IGetOtaStatusCallback",
+"android.service.euicc.IOtaStatusChangedCallback",
+"android.service.euicc.IRetainSubscriptionsForFactoryResetCallback",
+"android.service.euicc.ISwitchToSubscriptionCallback",
+"android.service.euicc.IUpdateSubscriptionNicknameCallback",
+"android.service.media.IMediaBrowserService",
+"android.service.media.IMediaBrowserServiceCallbacks",
+"android.service.notification.IConditionListener",
+"android.service.notification.IConditionProvider",
+"android.service.notification.INotificationListener",
+"android.service.notification.IStatusBarNotificationHolder",
+"android.service.oemlock.IOemLockService",
+"android.service.persistentdata.IPersistentDataBlockService",
+"android.service.quicksettings.IQSService",
+"android.service.quicksettings.IQSTileService",
+"android.service.resolver.IResolverRankerResult",
+"android.service.resolver.IResolverRankerService",
+"android.service.settings.suggestions.ISuggestionService",
+"android.service.textclassifier.ITextClassificationCallback",
+"android.service.textclassifier.ITextClassifierService",
+"android.service.textclassifier.ITextLinksCallback",
+"android.service.textclassifier.ITextSelectionCallback",
+"android.service.trust.ITrustAgentService",
+"android.service.trust.ITrustAgentServiceCallback",
+"android.service.voice.IVoiceInteractionService",
+"android.service.voice.IVoiceInteractionSession",
+"android.service.voice.IVoiceInteractionSessionService",
+"android.service.vr.IPersistentVrStateCallbacks",
+"android.service.vr.IVrListener",
+"android.service.vr.IVrManager",
+"android.service.vr.IVrStateCallbacks",
+"android.service.wallpaper.IWallpaperConnection",
+"android.service.wallpaper.IWallpaperEngine",
+"android.service.wallpaper.IWallpaperService",
+"android.speech.IRecognitionListener",
+"android.speech.IRecognitionService",
+"android.speech.tts.ITextToSpeechCallback",
+"android.speech.tts.ITextToSpeechService",
+"android.telephony.data.IDataService",
+"android.telephony.data.IDataServiceCallback",
+"android.telephony.INetworkService",
+"android.telephony.INetworkServiceCallback",
+"android.telephony.mbms.IDownloadProgressListener",
+"android.telephony.mbms.IDownloadStatusListener",
+"android.telephony.mbms.IMbmsDownloadSessionCallback",
+"android.telephony.mbms.IMbmsStreamingSessionCallback",
+"android.telephony.mbms.IStreamingServiceCallback",
+"android.telephony.mbms.vendor.IMbmsDownloadService",
+"android.telephony.mbms.vendor.IMbmsStreamingService",
+"android.view.accessibility.IAccessibilityInteractionConnection",
+"android.view.accessibility.IAccessibilityInteractionConnectionCallback",
+"android.view.accessibility.IAccessibilityManager",
+"android.view.accessibility.IAccessibilityManagerClient",
+"android.view.autofill.IAutoFillManager",
+"android.view.autofill.IAutoFillManagerClient",
+"android.view.autofill.IAutofillWindowPresenter",
+"android.view.IApplicationToken",
+"android.view.IAppTransitionAnimationSpecsFuture",
+"android.view.IDockedStackListener",
+"android.view.IGraphicsStats",
+"android.view.IGraphicsStatsCallback",
+"android.view.IInputFilter",
+"android.view.IInputFilterHost",
+"android.view.IOnKeyguardExitResult",
+"android.view.IPinnedStackController",
+"android.view.IPinnedStackListener",
+"android.view.IRecentsAnimationController",
+"android.view.IRecentsAnimationRunner",
+"android.view.IRemoteAnimationFinishedCallback",
+"android.view.IRemoteAnimationRunner",
+"android.view.IRotationWatcher",
+"android.view.IWallpaperVisibilityListener",
+"android.view.IWindow",
+"android.view.IWindowFocusObserver",
+"android.view.IWindowId",
+"android.view.IWindowManager",
+"android.view.IWindowSession",
+"android.view.IWindowSessionCallback",
+"android.webkit.IWebViewUpdateService",
+"com.android.ims.ImsConfigListener",
+"com.android.ims.internal.IImsCallSession",
+"com.android.ims.internal.IImsCallSessionListener",
+"com.android.ims.internal.IImsConfig",
+"com.android.ims.internal.IImsEcbm",
+"com.android.ims.internal.IImsEcbmListener",
+"com.android.ims.internal.IImsExternalCallStateListener",
+"com.android.ims.internal.IImsFeatureStatusCallback",
+"com.android.ims.internal.IImsMMTelFeature",
+"com.android.ims.internal.IImsMultiEndpoint",
+"com.android.ims.internal.IImsRcsFeature",
+"com.android.ims.internal.IImsRegistrationListener",
+"com.android.ims.internal.IImsService",
+"com.android.ims.internal.IImsServiceController",
+"com.android.ims.internal.IImsServiceFeatureCallback",
+"com.android.ims.internal.IImsStreamMediaSession",
+"com.android.ims.internal.IImsUt",
+"com.android.ims.internal.IImsUtListener",
+"com.android.ims.internal.IImsVideoCallCallback",
+"com.android.ims.internal.IImsVideoCallProvider",
+"com.android.ims.internal.uce.options.IOptionsListener",
+"com.android.ims.internal.uce.options.IOptionsService",
+"com.android.ims.internal.uce.presence.IPresenceListener",
+"com.android.ims.internal.uce.presence.IPresenceService",
+"com.android.ims.internal.uce.uceservice.IUceListener",
+"com.android.ims.internal.uce.uceservice.IUceService",
+"com.android.internal.app.IAppOpsActiveCallback",
+"com.android.internal.app.IAppOpsCallback",
+"com.android.internal.app.IAppOpsService",
+"com.android.internal.app.IBatteryStats",
+"com.android.internal.app.IMediaContainerService",
+"com.android.internal.app.ISoundTriggerService",
+"com.android.internal.app.IVoiceInteractionManagerService",
+"com.android.internal.app.IVoiceInteractionSessionListener",
+"com.android.internal.app.IVoiceInteractionSessionShowCallback",
+"com.android.internal.app.IVoiceInteractor",
+"com.android.internal.app.IVoiceInteractorCallback",
+"com.android.internal.app.IVoiceInteractorRequest",
+"com.android.internal.appwidget.IAppWidgetHost",
+"com.android.internal.appwidget.IAppWidgetService",
+"com.android.internal.backup.IBackupTransport",
+"com.android.internal.backup.IObbBackupService",
+"com.android.internal.location.ILocationProvider",
+"com.android.internal.net.INetworkWatchlistManager",
+"com.android.internal.os.IDropBoxManagerService",
+"com.android.internal.os.IParcelFileDescriptorFactory",
+"com.android.internal.os.IResultReceiver",
+"com.android.internal.os.IShellCallback",
+"com.android.internal.policy.IKeyguardDismissCallback",
+"com.android.internal.policy.IKeyguardDrawnCallback",
+"com.android.internal.policy.IKeyguardExitCallback",
+"com.android.internal.policy.IKeyguardService",
+"com.android.internal.policy.IKeyguardStateCallback",
+"com.android.internal.policy.IShortcutService",
+"com.android.internal.statusbar.IStatusBar",
+"com.android.internal.statusbar.IStatusBarService",
+"com.android.internal.telecom.ICallScreeningAdapter",
+"com.android.internal.telecom.ICallScreeningService",
+"com.android.internal.telecom.IConnectionService",
+"com.android.internal.telecom.IConnectionServiceAdapter",
+"com.android.internal.telecom.IInCallAdapter",
+"com.android.internal.telecom.IInCallService",
+"com.android.internal.telecom.ITelecomService",
+"com.android.internal.telecom.IVideoCallback",
+"com.android.internal.telecom.IVideoProvider",
+"com.android.internal.telecom.RemoteServiceCallback",
+"com.android.internal.telephony.IApnSourceService",
+"com.android.internal.telephony.ICarrierConfigLoader",
+"com.android.internal.telephony.IMms",
+"com.android.internal.telephony.IOnSubscriptionsChangedListener",
+"com.android.internal.telephony.IPhoneStateListener",
+"com.android.internal.telephony.IPhoneSubInfo",
+"com.android.internal.telephony.ISms",
+"com.android.internal.telephony.ISub",
+"com.android.internal.telephony.ITelephonyRegistry",
+"com.android.internal.telephony.IWapPushManager",
+"com.android.internal.textservice.ISpellCheckerService",
+"com.android.internal.textservice.ISpellCheckerServiceCallback",
+"com.android.internal.textservice.ISpellCheckerSession",
+"com.android.internal.textservice.ISpellCheckerSessionListener",
+"com.android.internal.textservice.ITextServicesManager",
+"com.android.internal.textservice.ITextServicesSessionListener",
+"com.android.internal.view.IDragAndDropPermissions",
+"com.android.internal.view.IInputContext",
+"com.android.internal.view.IInputContextCallback",
+"com.android.internal.view.IInputMethod",
+"com.android.internal.view.IInputMethodClient",
+"com.android.internal.view.IInputMethodManager",
+"com.android.internal.view.IInputMethodSession",
+"com.android.internal.view.IInputSessionCallback",
+"com.android.internal.widget.ICheckCredentialProgressCallback",
+"com.android.internal.widget.ILockSettings",
+"com.android.internal.widget.IRemoteViewsFactory",
+"com.android.internal.telephony.ITelephony"
diff --git a/import_resolver.cpp b/import_resolver.cpp
index 10cc4e4..1bf2794 100644
--- a/import_resolver.cpp
+++ b/import_resolver.cpp
@@ -16,6 +16,7 @@
#include "import_resolver.h"
#include "aidl_language.h"
+#include "logging.h"
#include <algorithm>
@@ -78,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/import_resolver.h b/import_resolver.h
index 0a34e05..e52843e 100644
--- a/import_resolver.h
+++ b/import_resolver.h
@@ -20,8 +20,6 @@
#include <string>
#include <vector>
-#include <android-base/macros.h>
-
#include "io_delegate.h"
namespace android {
@@ -34,6 +32,12 @@
const std::vector<std::string>& input_files);
virtual ~ImportResolver() = default;
+ // non-copyable, non-movable
+ ImportResolver(const ImportResolver&) = delete;
+ ImportResolver(ImportResolver&&) = delete;
+ ImportResolver& operator=(const ImportResolver&) = delete;
+ ImportResolver& operator=(ImportResolver&&) = delete;
+
// Resolve the canonical name for a class to a file that exists
// in one of the import paths given to the ImportResolver.
std::string FindImportFile(const std::string& canonical_name) const;
@@ -43,8 +47,6 @@
const std::string& input_file_name_;
std::vector<std::string> import_paths_;
std::vector<std::string> input_files_;
-
- DISALLOW_COPY_AND_ASSIGN(ImportResolver);
};
} // namespace aidl
diff --git a/io_delegate.cpp b/io_delegate.cpp
index 4b2e00a..45ef65a 100644
--- a/io_delegate.cpp
+++ b/io_delegate.cpp
@@ -22,6 +22,8 @@
#ifdef _WIN32
#include <direct.h>
+#include <windows.h>
+#undef ERROR
#else
#include <dirent.h>
#include <sys/stat.h>
@@ -38,6 +40,8 @@
using std::unique_ptr;
using std::vector;
+using android::base::Error;
+using android::base::Result;
using android::base::Split;
namespace android {
@@ -49,7 +53,7 @@
char buf[4096];
DWORD path_len = GetFullPathName(path.c_str(), sizeof(buf), buf, nullptr);
if (path_len <= 0 || path_len >= sizeof(buf)) {
- LOG(ERROR) << "Failed to GetFullPathName(" << path << ")";
+ AIDL_ERROR(path) << "Failed to GetFullPathName";
return false;
}
*absolute_path = buf;
@@ -59,8 +63,7 @@
#else
if (path.empty()) {
- LOG(ERROR) << "Giving up on finding an absolute path to represent the "
- "empty string.";
+ AIDL_ERROR(path) << "Giving up on finding an absolute path to represent the empty string.";
return false;
}
if (path[0] == OS_PATH_SEPARATOR) {
@@ -70,8 +73,8 @@
char buf[4096];
if (getcwd(buf, sizeof(buf)) == nullptr) {
- LOG(ERROR) << "Path of current working directory does not fit in "
- << sizeof(buf) << " bytes";
+ AIDL_ERROR(path) << "Path of current working directory does not fit in " << sizeof(buf)
+ << " bytes";
return false;
}
@@ -138,8 +141,7 @@
#endif
// On darwin when you try to mkdir("/", ...) we get EISDIR.
if (!success && (errno != EEXIST && errno != EISDIR)) {
- LOG(ERROR) << "Error while creating " << base_dir << ": "
- << strerror(errno);
+ AIDL_ERROR(caller_base_dir) << "Error while creating " << base_dir << ": " << strerror(errno);
return false;
}
}
@@ -194,32 +196,50 @@
}
#ifdef _WIN32
-vector<string> IoDelegate::ListFiles(const string&) const {
- vector<string> result;
- return result;
+Result<vector<string>> IoDelegate::ListFiles(const string&) const {
+ return Error() << "File listing not implemented on Windows";
}
#else
-static void add_list_files(const string& dirname, vector<string>* result) {
- CHECK(result != nullptr);
+static Result<void> add_list_files(const string& dirname, vector<string>* result) {
+ AIDL_FATAL_IF(result == nullptr, dirname);
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(dirname.c_str()), closedir);
- if (dir != nullptr) {
- while (struct dirent* ent = readdir(dir.get())) {
- if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
- continue;
+
+ if (dir == nullptr) {
+ return Error() << "Failed to read directory '" << dirname << "': " << strerror(errno);
+ }
+
+ while (true) {
+ errno = 0;
+ struct dirent* ent = readdir(dir.get());
+ if (ent == nullptr) {
+ if (errno != 0) {
+ return Error() << "Failed to read directory entry in '" << dirname
+ << "': " << strerror(errno);
}
- if (ent->d_type == DT_REG) {
- result->emplace_back(dirname + OS_PATH_SEPARATOR + ent->d_name);
- } else if (ent->d_type == DT_DIR) {
- add_list_files(dirname + OS_PATH_SEPARATOR + ent->d_name, result);
+ break;
+ }
+
+ if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
+ continue;
+ }
+ if (ent->d_type == DT_REG) {
+ result->emplace_back(dirname + OS_PATH_SEPARATOR + ent->d_name);
+ } else if (ent->d_type == DT_DIR) {
+ if (auto ret = add_list_files(dirname + OS_PATH_SEPARATOR + ent->d_name, result); !ret.ok()) {
+ return ret;
}
}
}
+
+ return Result<void>();
}
-vector<string> IoDelegate::ListFiles(const string& dir) const {
+Result<vector<string>> IoDelegate::ListFiles(const string& dir) const {
vector<string> result;
- add_list_files(dir, &result);
+ if (auto ret = add_list_files(dir, &result); !ret.ok()) {
+ return ret.error();
+ }
return result;
}
#endif
diff --git a/io_delegate.h b/io_delegate.h
index a53bb8f..6c1ef96 100644
--- a/io_delegate.h
+++ b/io_delegate.h
@@ -16,12 +16,12 @@
#pragma once
-#include <android-base/macros.h>
-
#include <memory>
#include <string>
#include <vector>
+#include <android-base/result.h>
+
#include "code_writer.h"
#include "line_reader.h"
@@ -33,6 +33,11 @@
IoDelegate() = default;
virtual ~IoDelegate() = default;
+ IoDelegate(const IoDelegate&) = delete;
+ IoDelegate(IoDelegate&&) = delete;
+ IoDelegate& operator=(const IoDelegate&) = delete;
+ IoDelegate& operator=(IoDelegate&&) = delete;
+
// Stores an absolute version of |path| to |*absolute_path|,
// possibly prefixing it with the current working directory.
// Returns false and does not set |*absolute_path| on error.
@@ -55,14 +60,12 @@
virtual void RemovePath(const std::string& file_path) const;
- virtual std::vector<std::string> ListFiles(const std::string& dir) const;
+ virtual android::base::Result<std::vector<std::string>> ListFiles(const std::string& dir) const;
private:
// Create the directory when path is a dir or the parent directory when
// path is a file. Path is a dir if it ends with the path separator.
bool CreateDirForPath(const std::string& path) const;
-
- DISALLOW_COPY_AND_ASSIGN(IoDelegate);
}; // class IoDelegate
} // namespace aidl
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/line_reader.cpp b/line_reader.cpp
index 66446c0..dedca20 100644
--- a/line_reader.cpp
+++ b/line_reader.cpp
@@ -34,6 +34,12 @@
input_stream_.close();
}
+ // non-copyable, non-movable
+ FileLineReader(const FileLineReader&) = delete;
+ FileLineReader(FileLineReader&&) = delete;
+ FileLineReader& operator=(const FileLineReader&) = delete;
+ FileLineReader& operator=(FileLineReader&&) = delete;
+
bool Init(const std::string& file_path) {
input_stream_.open(file_path, ifstream::in | ifstream::binary);
return input_stream_.is_open() && input_stream_.good();
@@ -50,8 +56,6 @@
private:
ifstream input_stream_;
-
- DISALLOW_COPY_AND_ASSIGN(FileLineReader);
}; // class FileLineReader
class MemoryLineReader : public LineReader {
@@ -59,6 +63,12 @@
explicit MemoryLineReader(const string& contents) : input_stream_(contents) {}
~MemoryLineReader() override = default;
+ // non-copyable, non-movable
+ MemoryLineReader(const MemoryLineReader&) = delete;
+ MemoryLineReader(MemoryLineReader&&) = delete;
+ MemoryLineReader& operator=(const MemoryLineReader&) = delete;
+ MemoryLineReader& operator=(MemoryLineReader&&) = delete;
+
bool ReadLine(string* line) override {
if (!input_stream_.good()) {
return false;
@@ -70,8 +80,6 @@
private:
istringstream input_stream_;
-
- DISALLOW_COPY_AND_ASSIGN(MemoryLineReader);
}; // class MemoryLineReader
unique_ptr<LineReader> LineReader::ReadFromFile(const string& file_path) {
diff --git a/line_reader.h b/line_reader.h
index 5883af4..0b81a60 100644
--- a/line_reader.h
+++ b/line_reader.h
@@ -19,8 +19,6 @@
#include <memory>
#include <string>
-#include <android-base/macros.h>
-
namespace android {
namespace aidl {
@@ -28,15 +26,18 @@
public:
LineReader() = default;
virtual ~LineReader() = default;
+
+ LineReader(const LineReader&) = delete;
+ LineReader(LineReader&&) = delete;
+ LineReader& operator=(const LineReader&) = delete;
+ LineReader& operator=(LineReader&&) = delete;
+
virtual bool ReadLine(std::string* line) = 0;
static std::unique_ptr<LineReader> ReadFromFile(
const std::string& file_path);
static std::unique_ptr<LineReader> ReadFromMemory(
const std::string& contents);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LineReader);
}; // class LineReader
} // namespace aidl
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
new file mode 100644
index 0000000..3c75565
--- /dev/null
+++ b/logging.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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 "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 c853d85..e540105 100644
--- a/logging.h
+++ b/logging.h
@@ -16,9 +16,64 @@
#pragma once
-// We must include windows.h before android-base/logging.h on Windows.
-#ifdef _WIN32
-#include <windows.h>
-#endif
+#include <iostream>
+#include <string>
-#include <android-base/logging.h>
+#include "location.h"
+
+class AidlNode;
+
+// Generic point for printing any error in the AIDL compiler.
+class AidlErrorLog {
+ public:
+ enum Severity { NO_OP, WARNING, ERROR, FATAL };
+
+ 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(Severity severity, const std::unique_ptr<T>& node) : AidlErrorLog(severity, *node) {}
+ ~AidlErrorLog();
+
+ // AidlErrorLog is a single use object. No need to copy
+ AidlErrorLog(const AidlErrorLog&) = delete;
+ AidlErrorLog& operator=(const AidlErrorLog&) = delete;
+
+ // 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:
+ std::ostream* os_;
+ Severity severity_;
+ const AidlLocation location_;
+ const std::string suffix_;
+ static bool sHadError;
+};
+
+// A class used to make it obvious to clang that code is going to abort. This
+// informs static analyses of the aborting behavior of `AIDL_FATAL`, and
+// helps generate slightly faster/smaller code.
+class AidlAbortOnDestruction {
+ public:
+ __attribute__((noreturn)) ~AidlAbortOnDestruction() { abort(); }
+};
+
+#define AIDL_ERROR(CONTEXT) ::AidlErrorLog(AidlErrorLog::ERROR, (CONTEXT))
+#define AIDL_FATAL(CONTEXT) \
+ (::AidlAbortOnDestruction(), ::AidlErrorLog(AidlErrorLog::FATAL, (CONTEXT)))
+#define AIDL_FATAL_IF(CONDITION, CONTEXT) \
+ if (CONDITION) AIDL_FATAL(CONTEXT) << "Bad internal state: " << #CONDITION << ": "
diff --git a/main.cpp b/main.cpp
index 10b9274..69ba060 100644
--- a/main.cpp
+++ b/main.cpp
@@ -15,60 +15,32 @@
*/
#include "aidl.h"
-#include "aidl_checkapi.h"
#include "io_delegate.h"
#include "logging.h"
#include "options.h"
#include <iostream>
+using android::aidl::Options;
+
#ifdef AIDL_CPP_BUILD
constexpr Options::Language kDefaultLang = Options::Language::CPP;
#else
constexpr Options::Language kDefaultLang = Options::Language::JAVA;
#endif
-using android::aidl::Options;
-
-int process_options(const Options& options) {
- android::aidl::IoDelegate io_delegate;
- switch (options.GetTask()) {
- case Options::Task::COMPILE:
- return android::aidl::compile_aidl(options, io_delegate);
- case Options::Task::PREPROCESS:
- return android::aidl::preprocess_aidl(options, io_delegate) ? 0 : 1;
- case Options::Task::DUMP_API:
- return android::aidl::dump_api(options, io_delegate) ? 0 : 1;
- case Options::Task::CHECK_API:
- return android::aidl::check_api(options, io_delegate) ? 0 : 1;
- case Options::Task::DUMP_MAPPINGS:
- return android::aidl::dump_mappings(options, io_delegate) ? 0 : 1;
- default:
- LOG(FATAL) << "aidl: internal error" << std::endl;
- return 1;
- }
-}
-
int main(int argc, char* argv[]) {
- android::base::InitLogging(argv);
- LOG(DEBUG) << "aidl starting";
-
Options options(argc, argv, kDefaultLang);
if (!options.Ok()) {
- std::cerr << options.GetErrorMessage();
- std::cerr << options.GetUsage();
+ AIDL_ERROR(options.GetErrorMessage()) << options.GetUsage();
return 1;
}
- int ret = process_options(options);
+ // Only minimal functionality should go here, so that as much of possible of
+ // the aidl compiler is mocked with the single function `aidl_entry`
- // compiler invariants
-
- // once AIDL_ERROR/AIDL_FATAL are used everywhere instead of std::cerr/LOG, we
- // can make this assertion in both directions.
- if (ret == 0) {
- AIDL_FATAL_IF(AidlError::hadError(), "Compiler success, but error emitted");
- }
+ android::aidl::IoDelegate io_delegate;
+ int ret = aidl_entry(options, io_delegate);
return ret;
}
diff --git a/metadata/Android.bp b/metadata/Android.bp
index 245c366..064ed5d 100644
--- a/metadata/Android.bp
+++ b/metadata/Android.bp
@@ -1,5 +1,14 @@
// build time C++ available list of all AIDL interfaces in the tree
-cc_library {
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "system_tools_aidl_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
+cc_test_library {
name: "libaidlmetadata",
host_supported: true,
srcs: [":aidl_metadata_in_cpp"],
@@ -8,6 +17,14 @@
cflags: ["-O0"],
}
+cc_library_headers {
+ name: "libaidlmetadata_headers",
+ product_available: true,
+ recovery_available: true,
+ host_supported: true,
+ export_include_dirs: ["include"],
+}
+
// private impl below
cc_binary {
@@ -29,3 +46,16 @@
visibility: [":__subpackages__"],
out: ["metadata.cpp"],
}
+
+cc_test_host {
+ name: "libaidlmetadata_test",
+ static_libs: [
+ "libaidlmetadata",
+ "libgmock",
+ ],
+ srcs: ["test.cpp"],
+ test_options: {
+ unit_test: true,
+ },
+ test_suites: ["general-tests"],
+}
diff --git a/metadata/include/aidl/metadata.h b/metadata/include/aidl/metadata.h
index 55272ab..a9f9f43 100644
--- a/metadata/include/aidl/metadata.h
+++ b/metadata/include/aidl/metadata.h
@@ -28,7 +28,7 @@
// stability of interface (e.g. "vintf")
std::string stability;
- // list of types e.g. android.hardware.foo::IFoo
+ // list of types e.g. android.hardware.foo.IFoo
std::vector<std::string> types;
// list of all hashes
diff --git a/metadata/parser.cpp b/metadata/parser.cpp
index 32be53e..7334554 100644
--- a/metadata/parser.cpp
+++ b/metadata/parser.cpp
@@ -27,12 +27,13 @@
const std::string path = argv[1];
Json::Value root;
- Json::Reader reader;
+ Json::CharReaderBuilder builder;
std::ifstream stream(path);
- if (!reader.parse(stream, root)) {
+ std::string errorMessage;
+ if (!Json::parseFromStream(builder, stream, &root, &errorMessage)) {
std::cerr << "Failed to read interface metadata file: " << path << std::endl
- << reader.getFormattedErrorMessages() << std::endl;
+ << errorMessage << std::endl;
return EXIT_FAILURE;
}
diff --git a/metadata/test.cpp b/metadata/test.cpp
new file mode 100644
index 0000000..67d08b2
--- /dev/null
+++ b/metadata/test.cpp
@@ -0,0 +1,43 @@
+/*
+ * 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 <aidl/metadata.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <optional>
+
+using ::android::AidlInterfaceMetadata;
+using ::testing::ElementsAre;
+
+static std::optional<AidlInterfaceMetadata> metadataForModule(const std::string& name) {
+ for (const AidlInterfaceMetadata& info : AidlInterfaceMetadata::all()) {
+ if (name == info.name) return info;
+ }
+ return std::nullopt;
+}
+
+TEST(AidlMetadata, HasTestInstances) {
+ const auto& info = metadataForModule("test-piece-1");
+ ASSERT_NE(info, std::nullopt);
+ EXPECT_EQ(info->stability, "");
+ EXPECT_THAT(info->types,
+ ElementsAre("some_package.IFoo", "some_package.Thing",
+ "some_package.sub_package.IFoo", "some_package.sub_package.SubThing"));
+ EXPECT_THAT(info->hashes, ElementsAre("13e24b2fac6a979971819fba2ab0d6d7c4182122",
+ "dc2a9292847e43b4360bb183f7491f0e9895eaa9",
+ "54f935920ab0934c242145cf00f9852ae3f5a63e"));
+}
diff --git a/options.cpp b/options.cpp
index b79c361..b383052 100644
--- a/options.cpp
+++ b/options.cpp
@@ -27,20 +27,26 @@
#include <string>
#include <android-base/strings.h>
+#include "aidl_language.h"
using android::base::Split;
using android::base::Trim;
using std::endl;
using std::string;
+#ifndef PLATFORM_SDK_VERSION
+#define PLATFORM_SDK_VERSION "<UNKNOWN>"
+#endif
+
namespace android {
namespace aidl {
string Options::GetUsage() const {
std::ostringstream sstr;
+ sstr << "AIDL Compiler: built for platform SDK version " << PLATFORM_SDK_VERSION << endl;
sstr << "usage:" << endl
- << myname_ << " --lang={java|cpp|ndk} [OPTION]... INPUT..." << endl
- << " Generate Java or C++ files for AIDL file(s)." << endl
+ << myname_ << " --lang={java|cpp|ndk|rust} [OPTION]... INPUT..." << endl
+ << " Generate Java, C++ or Rust files for AIDL file(s)." << endl
<< endl
<< myname_ << " --preprocess OUTPUT INPUT..." << endl
<< " Create an AIDL file having declarations of AIDL file(s)." << endl
@@ -49,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;
@@ -64,6 +70,10 @@
sstr << myname_ << " [OPTION]... INPUT HEADER_DIR OUTPUT" << endl
<< " Generate C++ headers and source for an AIDL file." << endl
<< endl;
+ } else if (language_ == Options::Language::RUST) {
+ sstr << myname_ << " [OPTION]... INPUT [OUTPUT]" << endl
+ << " Generate Rust file for an AIDL file." << endl
+ << endl;
}
sstr << "OPTION:" << endl
@@ -114,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
@@ -135,6 +155,24 @@
return sstr.str();
}
+string to_string(Options::Language language) {
+ switch (language) {
+ case Options::Language::CPP:
+ return "cpp";
+ case Options::Language::JAVA:
+ return "java";
+ case Options::Language::NDK:
+ return "ndk";
+ case Options::Language::RUST:
+ return "rust";
+ case Options::Language::UNSPECIFIED:
+ return "unspecified";
+ default:
+ AIDL_FATAL(AIDL_LOCATION_HERE)
+ << "Unexpected Options::Language enumerator: " << static_cast<size_t>(language);
+ }
+}
+
bool Options::StabilityFromString(const std::string& stability, Stability* out_stability) {
if (stability == "vintf") {
*out_stability = Stability::VINTF;
@@ -163,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) {
@@ -173,7 +215,8 @@
{"preprocess", no_argument, 0, 's'},
#ifndef _WIN32
{"dumpapi", no_argument, 0, 'u'},
- {"checkapi", no_argument, 0, 'A'},
+ {"no_license", no_argument, 0, 'x'},
+ {"checkapi", optional_argument, 0, 'A'},
#endif
{"apimapping", required_argument, 0, 'i'},
{"include", required_argument, 0, 'I'},
@@ -189,12 +232,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
@@ -219,6 +261,9 @@
} else if (lang == "ndk") {
language_ = Options::Language::NDK;
task_ = Options::Task::COMPILE;
+ } else if (lang == "rust") {
+ language_ = Options::Language::RUST;
+ task_ = Options::Task::COMPILE;
} else {
error_message_ << "Unsupported language: '" << lang << "'" << endl;
return;
@@ -236,11 +281,24 @@
task_ = Options::Task::DUMP_API;
}
break;
+ case 'x':
+ dump_no_license_ = true;
+ break;
case 'A':
if (task_ != Options::Task::UNSPECIFIED) {
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
@@ -322,9 +380,6 @@
output_file_ = Trim(optarg);
task_ = Task::DUMP_MAPPINGS;
break;
- case 'P':
- gen_parcelable_to_string_ = true;
- break;
default:
std::cerr << GetUsage();
exit(1);
@@ -338,7 +393,7 @@
error_message_ << "No input file" << endl;
return;
}
- if (language_ == Options::Language::JAVA) {
+ if (language_ == Options::Language::JAVA || language_ == Options::Language::RUST) {
input_files_.emplace_back(argv[optind++]);
if (argc - optind >= 1) {
output_file_ = argv[optind++];
@@ -346,13 +401,13 @@
// 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")) {
output_file_ = output_file_.substr(0, output_file_.length() - strlen(".aidl"));
}
- output_file_ += ".java";
+ output_file_ += (language_ == Options::Language::JAVA) ? ".java" : ".rs";
}
} else if (IsCppOutput()) {
input_files_.emplace_back(argv[optind++]);
@@ -419,6 +474,17 @@
return;
}
}
+ if (language_ == Options::Language::RUST && task_ == Options::Task::COMPILE) {
+ if (output_dir_.empty()) {
+ error_message_ << "Output directory is not set. Set with --out." << endl;
+ return;
+ }
+ if (!output_header_dir_.empty()) {
+ error_message_ << "Header output directory is set, which does not make "
+ << "sense for Rust." << endl;
+ return;
+ }
+ }
}
if (task_ == Options::Task::COMPILE) {
for (const string& input : input_files_) {
@@ -460,13 +526,71 @@
}
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;
}
}
- CHECK(output_dir_.empty() || output_dir_.back() == OS_PATH_SEPARATOR);
- CHECK(output_header_dir_.empty() || output_header_dir_.back() == OS_PATH_SEPARATOR);
+ AIDL_FATAL_IF(!output_dir_.empty() && output_dir_.back() != OS_PATH_SEPARATOR, output_dir_);
+ AIDL_FATAL_IF(!output_header_dir_.empty() && output_header_dir_.back() != OS_PATH_SEPARATOR,
+ 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
diff --git a/options.h b/options.h
index 73d33bb..11a5e59 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 };
+ 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,7 +145,7 @@
bool GenLog() const { return gen_log_; }
- bool GenParcelableToString() const { return gen_parcelable_to_string_; }
+ bool DumpNoLicense() const { return dump_no_license_; }
bool Ok() const { return error_message_.stream_.str().empty(); }
@@ -135,6 +155,8 @@
bool GenApiMapping() const { return task_ == Task::DUMP_MAPPINGS; }
+ 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.
size_t onTransact_outline_threshold_{275u};
@@ -147,6 +169,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_;
@@ -165,9 +188,12 @@
int version_ = 0;
string hash_ = "";
bool gen_log_ = false;
- bool gen_parcelable_to_string_ = false;
+ bool dump_no_license_ = 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 97b4c0c..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) {
@@ -237,8 +206,29 @@
EXPECT_EQ(string{"src_out/"}, options->OutputDir());
}
-TEST(OptionsTests, ParsesCompileJavaInvalid) {
+TEST(OptionsTests, ParsesCompileRust) {
+ const char* argv[] = {
+ "aidl", "--lang=rust", kCompileCommandIncludePath,
+ "-o src_out", kCompileCommandInput, nullptr,
+ };
+ unique_ptr<Options> options = GetOptions(argv);
+ EXPECT_EQ(Options::Task::COMPILE, options->GetTask());
+ EXPECT_EQ(Options::Language::RUST, options->TargetLanguage());
+ EXPECT_EQ(false, options->FailOnParcelable());
+ EXPECT_EQ(1u, options->ImportDirs().size());
+ EXPECT_EQ(0u, options->PreprocessedFiles().size());
+ EXPECT_EQ(string{kCompileCommandInput}, options->InputFiles().front());
+ EXPECT_EQ(string{""}, options->OutputFile());
+ EXPECT_EQ(string{""}, options->OutputHeaderDir());
+ EXPECT_EQ(string{"src_out/"}, options->OutputDir());
+ EXPECT_EQ(false, options->AutoDepFile());
+ EXPECT_EQ(false, options->DependencyFileNinja());
+}
+
+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",
@@ -249,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",
@@ -257,6 +252,7 @@
nullptr,
};
EXPECT_EQ(false, GetOptions(arg_with_header_dir)->Ok());
+ EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
}
TEST(OptionsTests, ParsesCompileCppMultiInput) {
@@ -287,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",
@@ -299,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",
@@ -312,6 +315,134 @@
nullptr,
};
EXPECT_EQ(false, GetOptions(arg_with_no_header_dir)->Ok());
+ EXPECT_THAT(GetCapturedStderr(), testing::HasSubstr(expected_error));
+}
+
+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",
+ kCompileCommandIncludePath,
+ "directory/input1.aidl",
+ "directory/input2.aidl",
+ "directory/input3.aidl",
+ 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",
+ "-h header_out", "directory/input1.aidl", "directory/input2.aidl", "directory/input3.aidl",
+ 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
new file mode 100644
index 0000000..721979f
--- /dev/null
+++ b/parser.cpp
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2019, 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 "parser.h"
+#include "aidl_language_y.h"
+#include "logging.h"
+
+void yylex_init(void**);
+void yylex_destroy(void*);
+void yyset_in(FILE* f, void*);
+int yyparse(Parser*);
+YY_BUFFER_STATE yy_scan_buffer(char*, size_t, void*);
+void yy_delete_buffer(YY_BUFFER_STATE, void*);
+
+std::unique_ptr<Parser> Parser::Parse(const std::string& filename,
+ const android::aidl::IoDelegate& io_delegate,
+ AidlTypenames& typenames) {
+ // Make sure we can read the file first, before trashing previous state.
+ unique_ptr<string> raw_buffer = io_delegate.GetFileContents(filename);
+ if (raw_buffer == nullptr) {
+ AIDL_ERROR(filename) << "Error while opening file for parsing";
+ return nullptr;
+ }
+
+ // We're going to scan this buffer in place, and yacc demands we put two
+ // nulls at the end.
+ raw_buffer->append(2u, '\0');
+
+ std::unique_ptr<Parser> parser(new Parser(filename, *raw_buffer, typenames));
+
+ if (yy::parser(parser.get()).parse() != 0 || parser->HasError()) {
+ return nullptr;
+ }
+
+ return parser;
+}
+
+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 (!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;
+}
+
+Parser::Parser(const std::string& filename, std::string& raw_buffer,
+ android::aidl::AidlTypenames& typenames)
+ : filename_(filename), typenames_(typenames) {
+ yylex_init(&scanner_);
+ buffer_ = yy_scan_buffer(&raw_buffer[0], raw_buffer.length(), scanner_);
+}
+
+Parser::~Parser() {
+ yy_delete_buffer(buffer_, scanner_);
+ yylex_destroy(scanner_);
+}
diff --git a/parser.h b/parser.h
new file mode 100644
index 0000000..e2dea08
--- /dev/null
+++ b/parser.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019, 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 "aidl_language.h"
+#include "aidl_typenames.h"
+#include "comments.h"
+#include "io_delegate.h"
+#include "logging.h"
+#include "options.h"
+
+#include <memory>
+#include <string>
+#include <vector>
+
+struct yy_buffer_state;
+typedef yy_buffer_state* YY_BUFFER_STATE;
+
+class AidlToken {
+ public:
+ AidlToken(const std::string& text, android::aidl::Comments comments)
+ : text_(text), comments_(std::move(comments)) {}
+ ~AidlToken() = default;
+
+ AidlToken(const AidlToken&) = delete;
+ AidlToken(AidlToken&&) = delete;
+ AidlToken& operator=(const AidlToken&) = delete;
+ AidlToken& operator=(AidlToken&&) = delete;
+
+ const std::string& GetText() const { return text_; }
+ const android::aidl::Comments& GetComments() const { return comments_; }
+
+ template <typename T>
+ void Append(T&& text) {
+ text_ += std::forward<T>(text);
+ }
+
+ private:
+ std::string text_;
+ android::aidl::Comments comments_;
+};
+
+using TypeResolver = std::function<bool(const AidlDocument*, AidlTypeSpecifier*)>;
+
+class Parser {
+ public:
+ // non-copyable, non-assignable
+ Parser(const Parser&) = delete;
+ Parser& operator=(const Parser&) = delete;
+
+ ~Parser();
+
+ // Parse contents of file |filename|. Should only be called once.
+ static std::unique_ptr<Parser> Parse(const std::string& filename,
+ const android::aidl::IoDelegate& io_delegate,
+ AidlTypenames& typenames);
+
+ void AddError() { error_++; }
+ bool HasError() const { return error_ != 0; }
+
+ 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_; }
+
+ void DeferResolution(AidlTypeSpecifier* typespec) {
+ unresolved_typespecs_.emplace_back(typespec);
+ }
+
+ const vector<AidlTypeSpecifier*>& GetUnresolvedTypespecs() const { return unresolved_typespecs_; }
+
+ 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.
+ document_ = document.get();
+ if (!typenames_.AddDocument(std::move(document))) {
+ document_ = nullptr;
+ AddError();
+ }
+ }
+
+ const AidlDocument& ParsedDocument() const {
+ AIDL_FATAL_IF(HasError(), FileName());
+ return *document_;
+ }
+
+ private:
+ explicit Parser(const std::string& filename, std::string& raw_buffer,
+ android::aidl::AidlTypenames& typenames);
+
+ std::string filename_;
+ std::string package_;
+ AidlTypenames& typenames_;
+
+ void* scanner_ = nullptr;
+ YY_BUFFER_STATE buffer_;
+ int error_ = 0;
+
+ vector<AidlTypeSpecifier*> unresolved_typespecs_;
+ const AidlDocument* document_;
+};
diff --git a/run_integration_tests.sh b/run_integration_tests.sh
new file mode 100755
index 0000000..1cfd1c1
--- /dev/null
+++ b/run_integration_tests.sh
@@ -0,0 +1,37 @@
+#!/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 -ex
+
+# TODO(b/156942077): when this test was converted to atest, we lost the ability
+# to see test results on stdout, and we can't print out the gtest results on
+# stderr because it breaks python test parsing. So, this file is added to help
+# run integration tests.
+
+$ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode \
+ MODULES-IN-system-tools-aidl
+
+adb root
+adb wait-for-device
+adb sync data
+adb push \
+ ${ANDROID_PRODUCT_OUT}/testcases/aidl_test_java_service/*/aidl_test_java_service.jar \
+ /data/framework/aidl_test_java_service.jar
+adb push \
+ ${ANDROID_PRODUCT_OUT}/testcases/aidl_test_java_client/*/aidl_test_java_client.jar \
+ /data/framework/aidl_test_java_client.jar
+
+${ANDROID_BUILD_TOP}/system/tools/aidl/tests/aidl_integration_test.py
diff --git a/runtests.sh b/runtests.sh
deleted file mode 100755
index 5f99122..0000000
--- a/runtests.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-# 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.
-
-if [ -z $ANDROID_BUILD_TOP ]; then
- echo "You need to source and lunch before you can use this script"
- exit 1
-fi
-
-echo "Running tests"
-set -ex
-
-$ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode \
- MODULES-IN-system-tools-aidl
-
-
-${ANDROID_HOST_OUT}/nativetest64/aidl_unittests/aidl_unittests
-
-adb root
-adb sync data
-adb install -r \
- ${ANDROID_PRODUCT_OUT}/system/app/aidl_test_services/aidl_test_services.apk
-${ANDROID_BUILD_TOP}/system/tools/aidl/tests/integration-test.py
diff --git a/runtests_asan.sh b/runtests_asan.sh
deleted file mode 100755
index b796fba..0000000
--- a/runtests_asan.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2019 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.
-
-export ASAN_OPTIONS=""
-export SANITIZE_HOST=address
-
-./runtests.sh
-
diff --git a/tests/aidl_integration_test.py b/tests/aidl_integration_test.py
new file mode 100755
index 0000000..ca767f4
--- /dev/null
+++ b/tests/aidl_integration_test.py
@@ -0,0 +1,241 @@
+#!/usr/bin/env python3
+
+import pipes
+import re
+import subprocess
+import sys
+import unittest
+
+BITNESS_32 = ("", "32")
+BITNESS_64 = ("64", "64")
+
+APP_PROCESS_FOR_PRETTY_BITNESS = 'app_process%s'
+NATIVE_TEST_SERVICE_FOR_BITNESS = ' /data/nativetest%s/aidl_test_service/aidl_test_service%s'
+CPP_TEST_CLIENT_FOR_BITNESS = ' /data/nativetest%s/aidl_test_client/aidl_test_client%s'
+NDK_TEST_CLIENT_FOR_BITNESS = ' /data/nativetest%s/aidl_test_client_ndk/aidl_test_client_ndk%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 AidlTestsJava.java
+INSTRUMENTATION_SUCCESS_PATTERN = r'TEST SUCCESS\n$'
+
+class TestFail(Exception):
+ """Raised on test failures."""
+ pass
+
+def pretty_bitness(bitness):
+ """Returns a human readable version of bitness, corresponding to BITNESS_* variable"""
+ return bitness[-1]
+
+class ShellResult(object):
+ """Represents the result of running a shell command."""
+
+ def __init__(self, exit_status, stdout, stderr):
+ """Construct an instance.
+
+ Args:
+ exit_status: integer exit code of shell command
+ stdout: string stdout of shell command
+ stderr: string stderr of shell command
+ """
+ self.stdout = stdout
+ self.stderr = stderr
+ self.exit_status = exit_status
+
+ def printable_string(self):
+ """Get a string we could print to the logs and understand."""
+ output = []
+ output.append('stdout:')
+ for line in self.stdout.splitlines():
+ output.append(' > %s' % line)
+ output.append('stderr:')
+ for line in self.stderr.splitlines():
+ output.append(' > %s' % line)
+ return '\n'.join(output)
+
+
+class AdbHost(object):
+ """Represents a device connected via ADB."""
+
+ def run(self, command, background=False, ignore_status=False):
+ """Run a command on the device via adb shell.
+
+ Args:
+ command: string containing a shell command to run.
+ background: True iff we should run this command in the background.
+ ignore_status: True iff we should ignore the command's exit code.
+
+ Returns:
+ instance of ShellResult.
+
+ Raises:
+ subprocess.CalledProcessError on command exit != 0.
+ """
+ if background:
+ command = '( %s ) </dev/null >/dev/null 2>&1 &' % command
+ return self.adb('shell %s' % pipes.quote(command),
+ ignore_status=ignore_status)
+
+ def adb(self, command, ignore_status=False):
+ """Run an ADB command (e.g. `adb sync`).
+
+ Args:
+ command: string containing command to run
+ ignore_status: True iff we should ignore the command's exit code.
+
+ Returns:
+ instance of ShellResult.
+
+ Raises:
+ subprocess.CalledProcessError on command exit != 0.
+ """
+ command = 'adb %s' % command
+ p = subprocess.Popen(command, shell=True, close_fds=True,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
+ stdout, stderr = p.communicate()
+ if not ignore_status and p.returncode:
+ raise subprocess.CalledProcessError(p.returncode, command)
+ return ShellResult(p.returncode, stdout, stderr)
+
+class NativeServer:
+ def __init__(self, host, bitness):
+ self.name = "%s_bit_native_server" % pretty_bitness(bitness)
+ self.host = host
+ self.binary = NATIVE_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)
+
+class NativeClient:
+ def cleanup(self):
+ self.host.run('killall %s' % self.binary, ignore_status=True)
+ def run(self):
+ result = self.host.run(self.binary + ' --gtest_color=yes', ignore_status=True)
+ print(result.printable_string())
+ if result.exit_status:
+ raise TestFail(result.stdout)
+
+class CppClient(NativeClient):
+ def __init__(self, host, bitness):
+ self.name = "%s_bit_cpp_client" % pretty_bitness(bitness)
+ self.host = host
+ self.binary = CPP_TEST_CLIENT_FOR_BITNESS % bitness
+
+class NdkClient(NativeClient):
+ def __init__(self, host, bitness):
+ self.name = "%s_bit_ndk_client" % pretty_bitness(bitness)
+ self.host = host
+ self.binary = NDK_TEST_CLIENT_FOR_BITNESS % bitness
+
+class JavaServer:
+ def __init__(self, host, bitness):
+ self.name = "java_server_%s" % pretty_bitness(bitness)
+ self.host = host
+ self.bitness = bitness
+ def cleanup(self):
+ self.host.run('killall ' + APP_PROCESS_FOR_PRETTY_BITNESS % pretty_bitness(self.bitness),
+ ignore_status=True)
+ def run(self):
+ return self.host.run('CLASSPATH=/data/framework/aidl_test_java_service.jar '
+ + APP_PROCESS_FOR_PRETTY_BITNESS % pretty_bitness(self.bitness) +
+ ' /data/framework android.aidl.service.TestServiceServer',
+ background=True)
+
+class JavaClient:
+ def __init__(self, host, bitness):
+ self.name = "java_client_%s" % pretty_bitness(bitness)
+ self.host = host
+ self.bitness = bitness
+ def cleanup(self):
+ self.host.run('killall ' + APP_PROCESS_FOR_PRETTY_BITNESS % pretty_bitness(self.bitness),
+ ignore_status=True)
+ def run(self):
+ result = self.host.run('CLASSPATH=/data/framework/aidl_test_java_client.jar '
+ + APP_PROCESS_FOR_PRETTY_BITNESS % pretty_bitness(self.bitness) +
+ ' /data/framework android.aidl.tests.AidlJavaTests')
+ print(result.printable_string())
+ 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") != "":
+ bitnesses += [BITNESS_32]
+ if getprop(host, "ro.product.cpu.abilist64") != "":
+ bitnesses += [BITNESS_64]
+ return bitnesses
+
+# tests added dynamically below
+class TestAidl(unittest.TestCase):
+ pass
+
+def make_test(client, server):
+ def test(self):
+ try:
+ client.cleanup()
+ server.cleanup()
+ server.run()
+ client.run()
+ finally:
+ client.cleanup()
+ server.cleanup()
+ return test
+
+if __name__ == '__main__':
+ host = AdbHost()
+ bitnesses = supported_bitnesses(host)
+ if len(bitnesses) == 0:
+ print("No clients installed")
+ exit(1)
+
+ clients = []
+ servers = []
+
+ for bitness in bitnesses:
+ clients += [NdkClient(host, bitness)]
+
+ clients += [CppClient(host, bitness)]
+ servers += [NativeServer(host, bitness)]
+
+ clients += [JavaClient(host, bitness)]
+ servers += [JavaServer(host, bitness)]
+
+ clients += [RustClient(host, bitness)]
+ servers += [RustServer(host, bitness)]
+
+ for client in clients:
+ for server in servers:
+ test_name = 'test_%s_to_%s' % (client.name, server.name)
+ test = make_test(client, server)
+ setattr(TestAidl, test_name, test)
+
+ suite = unittest.TestLoader().loadTestsFromTestCase(TestAidl)
+ sys.exit(not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful())
diff --git a/tests/aidl_integration_test.xml b/tests/aidl_integration_test.xml
new file mode 100644
index 0000000..6f4f686
--- /dev/null
+++ b/tests/aidl_integration_test.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Runs AIDL on-device integration tests.">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-native" />
+
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <!-- We would like to abort, but currently there is not a simple way to specify installation of both bitnesses of targets. -->
+ <option name="abort-on-push-failure" value="false"/>
+
+ <option name="push" value="aidl_test_client32->/data/nativetest/aidl_test_client/aidl_test_client32" />
+ <option name="push" value="aidl_test_client64->/data/nativetest64/aidl_test_client/aidl_test_client64" />
+
+ <option name="push" value="aidl_test_client_ndk32->/data/nativetest/aidl_test_client_ndk/aidl_test_client_ndk32" />
+ <option name="push" value="aidl_test_client_ndk64->/data/nativetest64/aidl_test_client_ndk/aidl_test_client_ndk64" />
+
+ <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="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" />
+
+ <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_client.jar->/data/framework/aidl_test_java_client.jar" />
+ <option name="push" value="aidl_test_java_service.jar->/data/framework/aidl_test_java_service.jar" />
+
+ <option name="cleanup" value="true" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.python.PythonBinaryHostTest" >
+ <option name="par-file-name" value="aidl_integration_test" />
+ <option name="test-timeout" value="2m" />
+ </test>
+</configuration>
+
diff --git a/tests/aidl_parser_fuzzer.cpp b/tests/aidl_parser_fuzzer.cpp
index 43da866..cbae184 100644
--- a/tests/aidl_parser_fuzzer.cpp
+++ b/tests/aidl_parser_fuzzer.cpp
@@ -18,6 +18,7 @@
#include "fake_io_delegate.h"
#include "options.h"
+#include <fuzzer/FuzzedDataProvider.h>
#include <iostream>
#ifdef FUZZ_LOG
@@ -28,9 +29,31 @@
using android::aidl::test::FakeIoDelegate;
-void fuzz(const std::string& langOpt, const std::string& content) {
- // TODO: fuzz multiple files
- // TODO: fuzz arguments
+void fuzz(const FakeIoDelegate& io, const std::vector<std::string>& args) {
+ if (kFuzzLog) {
+ std::cout << "cmd: ";
+ for (const std::string& arg : args) {
+ std::cout << arg << " ";
+ }
+ std::cout << std::endl;
+
+ for (const auto& [f, input] : io.InputFiles()) {
+ std::cout << "INPUT " << f << ": " << input << std::endl;
+ }
+ }
+
+ int ret = android::aidl::aidl_entry(Options::From(args), io);
+ if (ret != 0) return;
+
+ if (kFuzzLog) {
+ for (const auto& [f, output] : io.OutputFiles()) {
+ std::cout << "OUTPUT " << f << ": " << std::endl;
+ std::cout << output << std::endl;
+ }
+ }
+}
+
+void fuzzLang(const std::string& langOpt, const std::string& content) {
FakeIoDelegate io;
io.SetFileContents("a/path/Foo.aidl", content);
@@ -40,41 +63,25 @@
args.emplace_back("-b");
args.emplace_back("-I .");
args.emplace_back("-o out");
- // corresponding items also in aidl_parser_fuzzer.dict
+ // corresponding package also in aidl_parser_fuzzer.dict
args.emplace_back("a/path/Foo.aidl");
- if (kFuzzLog) {
- std::cout << "lang: " << langOpt << " content: " << content << std::endl;
- }
-
- int ret = android::aidl::compile_aidl(Options::From(args), io);
- if (ret != 0) return;
-
- if (kFuzzLog) {
- for (const std::string& f : io.ListOutputFiles()) {
- std::string output;
- if (io.GetWrittenContents(f, &output)) {
- std::cout << "OUTPUT " << f << ": " << std::endl;
- std::cout << output << std::endl;
- }
- }
- }
+ fuzz(io, args);
}
-void fuzz(uint8_t options, const std::string& content) {
- // keeping a byte of options we can use for various flags in the future (do
- // not remove or add unless absolutely necessary in order to preserve the
- // corpus).
- (void)options;
+void fuzzCheckApi(const std::string& a, const std::string& b) {
+ FakeIoDelegate io;
+ io.SetFileContents("a/path/Foo.aidl", a);
+ io.SetFileContents("b/path/Foo.aidl", b);
- // Process for each backend.
- //
- // This is unfortunate because we are parsing multiple times, but we want to
- // check generation of content for each backend. If output fails in one
- // backend, it's likely to fail in another.
- fuzz("ndk", content);
- fuzz("cpp", content);
- fuzz("java", content);
+ std::vector<std::string> args;
+ args.emplace_back("aidl");
+ args.emplace_back("--checkapi");
+ // corresponding package also in aidl_parser_fuzzer.dict
+ args.emplace_back("a/path/");
+ args.emplace_back("b/path/");
+
+ fuzz(io, args);
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
@@ -86,12 +93,21 @@
// of the language w/o hitting a stack overflow.
if (size > 2000) return 0;
- uint8_t options = *data;
- data++;
- size--;
+ FuzzedDataProvider provider = FuzzedDataProvider(data, size);
- std::string content(reinterpret_cast<const char*>(data), size);
- fuzz(options, content);
+ if (provider.ConsumeBool()) {
+ std::string content = provider.ConsumeRemainingBytesAsString();
+
+ fuzzLang("ndk", content);
+ fuzzLang("cpp", content);
+ fuzzLang("java", content);
+ fuzzLang("rust", content);
+ } else {
+ std::string contentA = provider.ConsumeRandomLengthString();
+ std::string contentB = provider.ConsumeRemainingBytesAsString();
+
+ fuzzCheckApi(contentA, contentB);
+ }
return 0;
}
diff --git a/tests/aidl_parser_fuzzer.dict b/tests/aidl_parser_fuzzer.dict
index 1f882a0..ef5fa8b 100644
--- a/tests/aidl_parser_fuzzer.dict
+++ b/tests/aidl_parser_fuzzer.dict
@@ -12,6 +12,7 @@
" interface "
" oneway "
" enum "
+" union "
# types
" void "
@@ -24,29 +25,54 @@
" 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 "
" publicAlternatives "
" trackingBug "
" type "
+" Copy "
+" Clone "
+" PartialOrd "
+" Ord "
+" PartialEq "
+" Eq "
+" Clone "
+" Hash "
# ignorable imports
" android.os.IInterface "
@@ -58,5 +84,6 @@
# specific to fuzzer
" a.path "
+" b.path "
" Foo "
diff --git a/tests/aidl_test_client.cpp b/tests/aidl_test_client.cpp
index 678edc5..00fe331 100644
--- a/tests/aidl_test_client.cpp
+++ b/tests/aidl_test_client.cpp
@@ -14,107 +14,9 @@
* limitations under the License.
*/
-#include <iostream>
+#include "gtest/gtest.h"
-#include <android-base/logging.h>
-#include <binder/IServiceManager.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-#include "aidl_test_client_defaultimpl.h"
-#include "aidl_test_client_file_descriptors.h"
-#include "aidl_test_client_nullables.h"
-#include "aidl_test_client_parcelables.h"
-#include "aidl_test_client_primitives.h"
-#include "aidl_test_client_service_exceptions.h"
-#include "aidl_test_client_utf8_strings.h"
-
-// libutils:
-using android::OK;
-using android::sp;
-using android::status_t;
-using android::String16;
-
-// libbinder:
-using android::getService;
-
-// generated
-using android::aidl::tests::ITestService;
-
-using std::cerr;
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-const char kServiceName[] = "android.aidl.tests.ITestService";
-
-bool GetService(sp<ITestService>* service) {
- cout << "Retrieving test service binder" << endl;
- status_t status = getService(String16(kServiceName), service);
- if (status != OK) {
- cerr << "Failed to get service binder: '" << kServiceName
- << "' status=" << status << endl;
- return false;
- }
- return true;
-}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-/* Runs all the test cases in aidl_test_client_*.cpp files. */
-int main(int /* argc */, char * argv []) {
- android::base::InitLogging(argv, android::base::StderrLogger);
- sp<ITestService> service;
- namespace client_tests = android::aidl::tests::client;
-
- if (!client_tests::GetService(&service)) return 1;
-
- if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1;
-
- if (!client_tests::ConfirmReverseArrays(service)) return 1;
-
- if (!client_tests::ConfirmReverseLists(service)) return 1;
-
- if (!client_tests::ConfirmReverseBinderLists(service)) return 1;
-
- if (!client_tests::ConfirmSimpleParcelables(service)) return 1;
-
- if (!client_tests::ConfirmPersistableBundles(service)) return 1;
-
- if (!client_tests::ConfirmIntfConstantExpressions(service)) return 1;
-
- if (!client_tests::ConfirmStructuredParcelables(service)) return 1;
-
- if (!client_tests::ConfirmStructuredParcelablesEquality(service)) return 1;
-
- if (!client_tests::ConfirmFileDescriptors(service)) return 1;
-
- if (!client_tests::ConfirmFileDescriptorArrays(service)) return 1;
-
- if (!client_tests::ConfirmParcelFileDescriptors(service)) return 1;
-
- if (!client_tests::ConfirmParcelFileDescriptorArrays(service)) return 1;
-
- if (!client_tests::ConfirmServiceSpecificExceptions(service)) return 1;
-
- if (!client_tests::ConfirmNullables(service)) return 1;
-
- if (!client_tests::ConfirmUtf8InCppStringRepeat(service)) return 1;
-
- if (!client_tests::ConfirmUtf8InCppStringArrayReverse(service)) return 1;
-
- if (!client_tests::ConfirmUtf8InCppStringListReverse(service)) return 1;
-
- if (!client_tests::ConfirmDefaultImpl(service)) return 1;
-
- return 0;
+int main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/tests/aidl_test_client.h b/tests/aidl_test_client.h
new file mode 100644
index 0000000..9dc17c1
--- /dev/null
+++ b/tests/aidl_test_client.h
@@ -0,0 +1,56 @@
+/*
+ * 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 <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::BackendType;
+using android::aidl::tests::ICppJavaTests;
+using android::aidl::tests::ITestService;
+
+class AidlTest : public testing::Test {
+ public:
+ void SetUp() override {
+ using android::getService;
+ using android::OK;
+ using android::String16;
+
+ 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);
+
+ status = service->getBackendType(&backend);
+ ASSERT_TRUE(status.isOk()) << status;
+
+ if (backend != BackendType::RUST) {
+ ASSERT_NE(cpp_java_tests, nullptr);
+ }
+ }
+
+ BackendType backend;
+ sp<ITestService> service;
+ sp<ICppJavaTests> cpp_java_tests;
+};
diff --git a/tests/aidl_test_client_defaultimpl.cpp b/tests/aidl_test_client_defaultimpl.cpp
index 7c4cc6f..32e35d8 100644
--- a/tests/aidl_test_client_defaultimpl.cpp
+++ b/tests/aidl_test_client_defaultimpl.cpp
@@ -13,58 +13,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "aidl_test_client.h"
+#include "gmock/gmock.h"
-#include "aidl_test_client_defaultimpl.h"
+using android::binder::Status;
-#include <iostream>
+using android::aidl::tests::ITestService;
+using android::aidl::tests::ITestServiceDefault;
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
+using testing::Eq;
-static const int32_t kExpectedArgValue = 100;
-static const int32_t kExpectedReturnValue = 200;
+static constexpr int32_t kExpectedArgValue = 100;
+static constexpr int32_t kExpectedReturnValue = 200;
-bool ConfirmDefaultImpl(const sp<ITestService>& s) {
- class Def : public android::aidl::tests::ITestServiceDefault {
- android::binder::Status UnimplementedMethod(int32_t arg, int32_t* _aidl_return) override {
- if (arg != kExpectedArgValue) {
- std::cerr << "Argument to UnimplementedMethod is expected to be " << kExpectedArgValue
- << ", "
- << "but got " << arg << std::endl;
- return android::binder::Status::fromStatusT(android::FAILED_TRANSACTION);
- }
- *_aidl_return = kExpectedReturnValue;
- return android::binder::Status::ok();
- }
- };
+static int numCalled = 0;
+static int32_t gotArgument = 0;
- bool success = android::aidl::tests::ITestService::setDefaultImpl(std::make_unique<Def>());
- if (!success) {
- std::cerr << "Failed to set default impl for ITestService" << std::endl;
- return false;
+struct Def : public ITestServiceDefault {
+ Status UnimplementedMethod(int32_t arg, int32_t* _aidl_return) override {
+ numCalled++;
+ gotArgument = arg;
+ *_aidl_return = kExpectedReturnValue;
+ return android::binder::Status::ok();
}
+};
- int32_t ret;
- android::binder::Status status = s->UnimplementedMethod(kExpectedArgValue, &ret);
- if (!status.isOk()) {
- std::cerr << "Call to UnimplementedMethod() has failed. status=" << status.toString8()
- << std::endl;
- return false;
- }
+TEST_F(AidlTest, defaultImpl) {
+ std::unique_ptr<ITestService> defImpl = std::make_unique<Def>();
+ auto ret = ITestService::setDefaultImpl(std::move(defImpl));
+ ASSERT_TRUE(ret);
- if (ret != kExpectedReturnValue) {
- std::cerr << "Return value from UnimplementedMethod is expected to be " << kExpectedReturnValue
- << ", "
- << "but got " << ret << std::endl;
- return false;
- }
-
- return true;
+ int32_t returned_value;
+ auto status = service->UnimplementedMethod(kExpectedArgValue, &returned_value);
+ ASSERT_TRUE(status.isOk()) << status;
+ ASSERT_THAT(numCalled, Eq(1));
+ ASSERT_THAT(gotArgument, Eq(kExpectedArgValue));
+ ASSERT_THAT(returned_value, Eq(kExpectedReturnValue));
}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
diff --git a/tests/aidl_test_client_defaultimpl.h b/tests/aidl_test_client_defaultimpl.h
deleted file mode 100644
index ed602b7..0000000
--- a/tests/aidl_test_client_defaultimpl.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ANDROID_AIDL_TESTS_CLIENT_DEFAULTIMPL_H
-#define ANDROID_AIDL_TESTS_CLIENT_DEFAULTIMPL_H
-
-#include "android/aidl/tests/ITestService.h"
-
-#include <utils/StrongPointer.h>
-
-// Tests for default impl
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmDefaultImpl(const sp<ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_DEFAULTIMPL_H
diff --git a/tests/aidl_test_client_file_descriptors.cpp b/tests/aidl_test_client_file_descriptors.cpp
index 6e51869..041ba09 100644
--- a/tests/aidl_test_client_file_descriptors.cpp
+++ b/tests/aidl_test_client_file_descriptors.cpp
@@ -14,226 +14,142 @@
* limitations under the License.
*/
-#include "aidl_test_client_file_descriptors.h"
-#include <iostream>
#include <vector>
- #include <errno.h>
-#include <string.h>
+#include <errno.h>
#include <unistd.h>
#include <android-base/unique_fd.h>
#include <binder/ParcelFileDescriptor.h>
-// libbase
-using android::base::unique_fd;
+#include "aidl_test_client.h"
+#include "gmock/gmock.h"
-// libutils:
using android::sp;
-
-// libbinder:
+using android::base::unique_fd;
using android::binder::Status;
-
-// generated
-using android::aidl::tests::ITestService;
-
using android::os::ParcelFileDescriptor;
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::string;
-using std::vector;
+using testing::Eq;
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
+struct FdTest : public AidlTest {
+ void DoPipe(unique_fd* read_side, unique_fd* write_side) {
+ int fds[2];
+ int ret = pipe(fds);
+ ASSERT_THAT(ret, Eq(0));
-#define FdByName(_fd) #_fd, _fd
-
-bool DoWrite(const string& name, const unique_fd& fd, const string& buf) {
- int wrote;
-
- while ((wrote = write(fd.get(), buf.data(), buf.size())) < 0 && errno == EINTR);
-
- if (wrote == (signed)buf.size()) {
- return true;
+ read_side->reset(fds[0]);
+ write_side->reset(fds[1]);
}
- if (wrote < 0) {
- cerr << "Error writing to file descriptor '" << name << "': "
- << strerror(errno) << endl;
- } else {
- cerr << "File descriptor '" << name << "'accepted short data." << endl;
+ void WriteStringToFd(const std::string& str, const unique_fd& fd) {
+ int wrote;
+ while ((wrote = write(fd.get(), str.data(), str.size())) < 0 && errno == EINTR)
+ ;
+ ASSERT_THAT(wrote, Eq((signed)str.size()));
}
- return false;
-}
+ void ReadFdToStringAndCompare(const unique_fd& fd, const std::string& str) {
+ size_t length = str.size();
+ int got;
+ std::string buf;
+ buf.resize(length);
-bool DoRead(const string& name, const unique_fd& fd, const string& expected) {
- size_t length = expected.size();
- int got;
- string buf;
- buf.resize(length);
-
- while ((got = read(fd.get(), &buf[0], length)) < 0 && errno == EINTR);
-
- if (got < 0) {
- cerr << "Error reading from '" << name << "': " << strerror(errno) << endl;
- return false;
+ while ((got = read(fd.get(), &buf[0], length)) < 0 && errno == EINTR)
+ ;
+ ASSERT_THAT(buf, Eq(str));
}
+};
- if (buf != expected) {
- cerr << "Expected '" << expected << "' got '" << buf << "'" << endl;
- return false;
- }
+TEST_F(FdTest, fileDescriptor) {
+ if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
- return true;
-}
-
-bool DoPipe(unique_fd* read_side, unique_fd* write_side) {
- int fds[2];
- unique_fd return_fd;
-
- if (pipe(fds)) {
- cout << "Error creating pipes: " << strerror(errno) << endl;
- return false;
- }
-
- read_side->reset(fds[0]);
- write_side->reset(fds[1]);
- return true;
-}
-
-bool ConfirmFileDescriptors(const sp<ITestService>& s) {
- Status status;
- cout << "Confirming passing and returning file descriptors works." << endl;
-
- unique_fd return_fd;
unique_fd read_fd;
unique_fd write_fd;
+ DoPipe(&read_fd, &write_fd);
- if (!DoPipe(&read_fd, &write_fd)) {
- return false;
- }
-
- status = s->RepeatFileDescriptor(std::move(write_fd), &return_fd);
-
- if (!status.isOk()) {
- cerr << "Could not repeat file descriptors." << endl;
- return false;
- }
+ unique_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
* should be atomic and non-blocking so long as the total size doesn't exceed
* PIPE_BUF. We thus play a bit fast and loose with failure modes here.
*/
-
- bool ret =
- DoWrite(FdByName(return_fd), "ReturnString") &&
- DoRead(FdByName(read_fd), "ReturnString");
-
- return ret;
+ WriteStringToFd("ReturnString", return_fd);
+ ReadFdToStringAndCompare(read_fd, "ReturnString");
}
-bool ConfirmFileDescriptorArrays(const sp<ITestService>& s) {
- Status status;
- cout << "Confirming passing and returning file descriptor arrays works." << endl;
+TEST_F(FdTest, fileDescriptorArray) {
+ if (!cpp_java_tests) GTEST_SKIP() << "Service does not support the CPP/Java-only tests.";
- vector<unique_fd> array;
+ std::vector<unique_fd> array;
array.resize(2);
+ DoPipe(&array[0], &array[1]);
- if (!DoPipe(&array[0], &array[1])) {
- return false;
+ std::vector<unique_fd> repeated;
+
+ if (backend == BackendType::JAVA) {
+ // other backends might require these to be valid FDs (not -1), since this
+ // isn't @nullable, but they don't require this to already be the correct
+ // size
+ repeated = std::vector<unique_fd>(array.size());
}
- vector<unique_fd> repeated;
- vector<unique_fd> reversed;
+ std::vector<unique_fd> reversed;
+ auto status = cpp_java_tests->ReverseFileDescriptorArray(array, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status;
- status = s->ReverseFileDescriptorArray(array, &repeated, &reversed);
-
- if (!status.isOk()) {
- cerr << "Could not reverse file descriptor array." << endl;
- return false;
- }
-
- bool ret =
- DoWrite(FdByName(array[1]), "First") &&
- DoWrite(FdByName(repeated[1]), "Second") &&
- DoWrite(FdByName(reversed[0]), "Third") &&
- DoRead(FdByName(reversed[1]), "FirstSecondThird");
-
- return ret;
+ WriteStringToFd("First", array[1]);
+ WriteStringToFd("Second", repeated[1]);
+ WriteStringToFd("Third", reversed[0]);
+ ReadFdToStringAndCompare(reversed[1], "FirstSecondThird");
}
-bool ConfirmParcelFileDescriptors(const sp<ITestService>& s) {
- Status status;
- cout << "Confirming passing and returning parcel file descriptors works." << endl;
-
+TEST_F(FdTest, parcelFileDescriptor) {
unique_fd read_fd;
unique_fd write_fd;
-
- if (!DoPipe(&read_fd, &write_fd)) {
- return false;
- }
+ DoPipe(&read_fd, &write_fd);
ParcelFileDescriptor return_fd;
-
- status = s->RepeatParcelFileDescriptor(ParcelFileDescriptor(std::move(write_fd)), &return_fd);
-
- if (!status.isOk()) {
- cerr << "Could not repeat parcel file descriptors." << endl;
- return false;
- }
+ auto status =
+ service->RepeatParcelFileDescriptor(ParcelFileDescriptor(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
* should be atomic and non-blocking so long as the total size doesn't exceed
* PIPE_BUF. We thus play a bit fast and loose with failure modes here.
*/
-
- bool ret = DoWrite(FdByName(return_fd.release()), "ReturnString") &&
- DoRead(FdByName(read_fd), "ReturnString");
-
- return ret;
+ WriteStringToFd("ReturnString", return_fd.release());
+ ReadFdToStringAndCompare(read_fd, "ReturnString");
}
-bool ConfirmParcelFileDescriptorArrays(const sp<ITestService>& s) {
- Status status;
- cout << "Confirming passing and returning parcel file descriptor arrays works." << endl;
-
- vector<unique_fd> array;
+TEST_F(FdTest, parcelFileDescriptorArray) {
+ std::vector<unique_fd> array;
array.resize(2);
+ DoPipe(&array[0], &array[1]);
- if (!DoPipe(&array[0], &array[1])) {
- return false;
- }
-
- vector<ParcelFileDescriptor> input;
+ std::vector<ParcelFileDescriptor> input;
for (auto& fd : array) {
input.push_back(ParcelFileDescriptor(std::move(fd)));
}
- vector<ParcelFileDescriptor> repeated;
- vector<ParcelFileDescriptor> reversed;
+ std::vector<ParcelFileDescriptor> repeated;
- status = s->ReverseParcelFileDescriptorArray(input, &repeated, &reversed);
-
- if (!status.isOk()) {
- cerr << "Could not reverse file descriptor array." << endl;
- return false;
+ if (backend == BackendType::JAVA) {
+ // other backends might require these to be valid FDs (not -1), since this
+ // isn't @nullable, but they don't require this to already be the correct
+ // size
+ repeated = std::vector<ParcelFileDescriptor>(array.size());
}
- bool ret = DoWrite(FdByName(input[1].release()), "First") &&
- DoWrite(FdByName(repeated[1].release()), "Second") &&
- DoWrite(FdByName(reversed[0].release()), "Third") &&
- DoRead(FdByName(input[0].release()), "FirstSecondThird");
+ std::vector<ParcelFileDescriptor> reversed;
+ auto status = service->ReverseParcelFileDescriptorArray(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status;
- return ret;
+ WriteStringToFd("First", input[1].release());
+ WriteStringToFd("Second", repeated[1].release());
+ WriteStringToFd("Third", reversed[0].release());
+ ReadFdToStringAndCompare(input[0].release(), "FirstSecondThird");
}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
diff --git a/tests/aidl_test_client_file_descriptors.h b/tests/aidl_test_client_file_descriptors.h
deleted file mode 100644
index 03da0f1..0000000
--- a/tests/aidl_test_client_file_descriptors.h
+++ /dev/null
@@ -1,40 +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 ANDROID_AIDL_TESTS_CLIENT_FILE_DESCRIPTORS_H
-#define ANDROID_AIDL_TESTS_CLIENT_FILE_DESCRIPTORS_H
-
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-// Tests for passing and returning file descriptors.
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmFileDescriptors(const sp<ITestService>& s);
-bool ConfirmFileDescriptorArrays(const sp<ITestService>& s);
-bool ConfirmParcelFileDescriptors(const sp<ITestService>& s);
-bool ConfirmParcelFileDescriptorArrays(const sp<ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_FILE_DESCRIPTORS_H
diff --git a/tests/aidl_test_client_loggable_interface.cpp b/tests/aidl_test_client_loggable_interface.cpp
new file mode 100644
index 0000000..a06469b
--- /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", "(null)"},
+ {"pfdValue", "(null)"},
+ {"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", "(null)"},
+ {"pfdArray", "[]"}}));
+}
diff --git a/tests/aidl_test_client_ndk_loggable_interface.cpp b/tests/aidl_test_client_ndk_loggable_interface.cpp
new file mode 100644
index 0000000..4b9f095
--- /dev/null
+++ b/tests/aidl_test_client_ndk_loggable_interface.cpp
@@ -0,0 +1,142 @@
+/*
+ * 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 <aidl/android/aidl/loggable/ILoggableInterface.h>
+
+#include <android/binder_auto_utils.h>
+#include <android/binder_manager.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <aidl/android/aidl/loggable/BpLoggableInterface.h>
+#include <aidl/android/aidl/tests/BackendType.h>
+#include <aidl/android/aidl/tests/ITestService.h>
+
+using aidl::android::aidl::loggable::BpLoggableInterface;
+using aidl::android::aidl::loggable::Data;
+using aidl::android::aidl::loggable::Enum;
+using aidl::android::aidl::loggable::ILoggableInterface;
+using aidl::android::aidl::tests::BackendType;
+using aidl::android::aidl::tests::ITestService;
+using std::optional;
+using std::pair;
+using std::shared_ptr;
+using std::string;
+using std::vector;
+using testing::Eq;
+
+struct AidlTest : testing::Test {
+ template <typename T>
+ std::shared_ptr<T> getService() {
+ ndk::SpAIBinder binder = ndk::SpAIBinder(AServiceManager_getService(T::descriptor));
+ return T::fromBinder(binder);
+ }
+};
+
+TEST_F(AidlTest, LoggableInterface) {
+ std::shared_ptr<ITestService> service = getService<ITestService>();
+ ASSERT_NE(nullptr, service.get());
+
+ BackendType backendType;
+ ndk::ScopedAStatus status = service->getBackendType(&backendType);
+ EXPECT_TRUE(status.isOk()) << status.getDescription();
+ if (backendType != BackendType::CPP) GTEST_SKIP();
+
+ shared_ptr<ILoggableInterface> loggable = getService<ILoggableInterface>();
+ ASSERT_NE(nullptr, loggable.get());
+
+ 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};
+ string stringValue("def");
+ vector<string> stringArray{string("ghi"), string("jkl")};
+ vector<string> listValue{string("mno")};
+ Data dataValue;
+ dataValue.num = 42;
+ dataValue.str = "abc";
+ dataValue.nestedUnion = "def";
+ dataValue.nestedEnum = Enum::FOO;
+ ndk::SpAIBinder binderValue;
+ ndk::ScopedFileDescriptor pfdValue;
+ vector<ndk::ScopedFileDescriptor> pfdArray;
+ vector<string> _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<string>{string("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>>{
+ {"in_boolValue", "true"},
+ {"in_boolArray", "[false, true]"},
+ {"in_byteValue", "41"},
+ {"in_byteArray", "[42, 43]"},
+ {"in_charValue", "x"},
+ {"in_charArray", "[a, b, c]"},
+ {"in_intValue", "44"},
+ {"in_intArray", "[45, 46]"},
+ {"in_longValue", "47"},
+ {"in_longArray", "[48, 49]"},
+ {"in_floatValue", "50.000000"},
+ {"in_floatArray", "[51.000000, 52.000000]"},
+ {"in_doubleValue", "52.000000"},
+ {"in_doubleArray", "[53.000000, 54.000000]"},
+ {"in_stringValue", "def"},
+ {"in_stringArray", "[ghi, jkl]"},
+ {"in_listValue", "[mno]"},
+ {"in_dataValue",
+ "Data{num: 42, str: abc, nestedUnion: Union{str: def}, nestedEnum: FOO}"},
+ {"in_binderValue", "(null)"},
+ {"in_pfdValue", "(null)"},
+ {"in_pfdArray", "[]"},
+ }));
+ EXPECT_THAT(log.output_args,
+ Eq(vector<pair<string, string>>{{"in_boolArray", "[false, true]"},
+ {"in_byteArray", "[42, 43]"},
+ {"in_charArray", "[a, b, c]"},
+ {"in_intArray", "[45, 46]"},
+ {"in_longArray", "[48, 49]"},
+ {"in_floatArray", "[51.000000, 52.000000]"},
+ {"in_doubleArray", "[53.000000, 54.000000]"},
+ {"in_stringArray", "[ghi, jkl]"},
+ {"in_listValue", "[mno]"},
+ {"in_pfdValue", "(null)"},
+ {"in_pfdArray", "[]"}}));
+}
diff --git a/tests/aidl_test_client_ndk_versioned_interface.cpp b/tests/aidl_test_client_ndk_versioned_interface.cpp
new file mode 100644
index 0000000..9d34b8c
--- /dev/null
+++ b/tests/aidl_test_client_ndk_versioned_interface.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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 <aidl/android/aidl/versioned/tests/IFooInterface.h>
+
+#include <android/binder_auto_utils.h>
+#include <android/binder_manager.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using aidl::android::aidl::versioned::tests::BazUnion;
+using aidl::android::aidl::versioned::tests::Foo;
+using aidl::android::aidl::versioned::tests::IFooInterface;
+using std::optional;
+using std::pair;
+using std::shared_ptr;
+using std::string;
+using std::vector;
+using testing::Eq;
+
+struct VersionedInterfaceTest : ::testing::Test {
+ void SetUp() override {
+ ndk::SpAIBinder binder = ndk::SpAIBinder(AServiceManager_getService(IFooInterface::descriptor));
+ versioned = IFooInterface::fromBinder(binder);
+ ASSERT_NE(nullptr, versioned);
+ }
+ shared_ptr<IFooInterface> versioned;
+};
+
+TEST_F(VersionedInterfaceTest, getInterfaceVersion) {
+ int32_t version;
+ auto status = versioned->getInterfaceVersion(&version);
+ EXPECT_TRUE(status.isOk()) << status.getDescription();
+ EXPECT_EQ(1, version);
+}
+
+TEST_F(VersionedInterfaceTest, getInterfaceHash) {
+ string hash;
+ auto status = versioned->getInterfaceHash(&hash);
+ EXPECT_TRUE(status.isOk()) << status.getDescription();
+ EXPECT_EQ("9e7be1859820c59d9d55dd133e71a3687b5d2e5b", hash);
+}
+
+TEST_F(VersionedInterfaceTest, arrayOfParcelableWithNewField) {
+ vector<Foo> foos(42);
+ int32_t length;
+ auto status = versioned->returnsLengthOfFooArray(foos, &length);
+ EXPECT_TRUE(status.isOk()) << status.getDescription();
+ EXPECT_EQ(42, length);
+}
+
+TEST_F(VersionedInterfaceTest, readDataCorrectlyAfterParcelableWithNewField) {
+ Foo inFoo, inoutFoo, outFoo;
+ int32_t ret;
+ auto status = versioned->ignoreParcelablesAndRepeatInt(inFoo, &inoutFoo, &outFoo, 43, &ret);
+ EXPECT_TRUE(status.isOk()) << status.getDescription();
+ EXPECT_EQ(43, ret);
+}
\ No newline at end of file
diff --git a/tests/aidl_test_client_nullables.cpp b/tests/aidl_test_client_nullables.cpp
index f4eab3a..9a931f8 100644
--- a/tests/aidl_test_client_nullables.cpp
+++ b/tests/aidl_test_client_nullables.cpp
@@ -14,291 +14,176 @@
* limitations under the License.
*/
-#include "aidl_test_client_nullables.h"
-
-#include <utils/String16.h>
-
-#include <iostream>
-#include <memory>
-#include <string>
+#include <optional>
#include <vector>
-// libutils:
+#include <utils/String16.h>
+#include <utils/String8.h>
+
+#include "aidl_test_client.h"
+#include "gmock/gmock.h"
+
+using android::BBinder;
+using android::IBinder;
using android::sp;
using android::String16;
-
-// libbinder:
+using android::String8;
using android::binder::Status;
-// generated
+using android::aidl::tests::BackendType;
using android::aidl::tests::ByteEnum;
+using android::aidl::tests::INamedCallback;
using android::aidl::tests::IntEnum;
using android::aidl::tests::ITestService;
using android::aidl::tests::LongEnum;
using android::aidl::tests::SimpleParcelable;
+using android::aidl::tests::StructuredParcelable;
-using std::string;
-using std::unique_ptr;
-using std::vector;
-using std::cout;
-using std::cerr;
-using std::endl;
+using testing::Eq;
+using testing::Ne;
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
+struct RepeatNullableTest : public AidlTest {
+ template <typename T>
+ void DoTest(Status (ITestService::*func)(const std::optional<T>&, std::optional<T>*),
+ std::optional<T> input) {
+ std::optional<T> output;
+ auto status = (*service.*func)(input, &output);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(output.has_value());
+ ASSERT_THAT(*output, Eq(*input));
-namespace {
-template<typename T>
-bool ValuesEqual(const unique_ptr<T>& in, const unique_ptr<T>& out) {
- return *in == *out;
+ input.reset();
+ status = (*service.*func)(input, &output);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_FALSE(output.has_value());
+ }
+};
+
+TEST_F(RepeatNullableTest, intArray) {
+ DoTest(&ITestService::RepeatNullableIntArray, std::make_optional(std::vector<int32_t>{1, 2, 3}));
}
-template<>
-bool ValuesEqual<vector<unique_ptr<String16>>>(
- const unique_ptr<vector<unique_ptr<String16>>>& in,
- const unique_ptr<vector<unique_ptr<String16>>>& out) {
- if (!in) {
- return !out;
- }
-
- if (!out) {
- return false;
- }
-
- if (in->size() != out->size()) {
- return false;
- }
-
- for (size_t i = 0; i < in->size(); i++) {
- const unique_ptr<String16>& a = (*in)[i];
- const unique_ptr<String16>& b = (*out)[i];
-
- if (!(a || b)) {
- continue;
- }
-
- if (!(a && b)) {
- return false;
- }
-
- if (*a != *b) {
- return false;
- }
- }
-
- return true;
+TEST_F(RepeatNullableTest, byteEnumArray) {
+ DoTest(&ITestService::RepeatNullableByteEnumArray,
+ std::make_optional(std::vector<ByteEnum>{ByteEnum::FOO, ByteEnum::BAR}));
}
-template<typename T>
-bool ConfirmNullableType(const sp<ITestService>& s, const string& type_name,
- unique_ptr<T> in,
- Status(ITestService::*func)(const unique_ptr<T>&,
- unique_ptr<T>*)) {
- cout << "... Confirming nullables for " << type_name << " ..." << endl;
- Status status;
- unique_ptr<T> out;
-
- status = (*s.*func)(in, &out);
-
- if (!status.isOk()) {
- cerr << "Could not repeat nullable " << type_name << "." << endl;
- return false;
- }
-
- if (!out) {
- cerr << "Got back null when repeating " << type_name << "." << endl;
- return false;
- }
-
- if (!ValuesEqual(in, out)) {
- cerr << "Got back a non-matching value when repeating " << type_name
- << "." << endl;
- return false;
- }
-
- in.reset();
- status = (*s.*func)(in, &out);
-
- if (!status.isOk()) {
- cerr << "Could not repeat null as " << type_name << "." << endl;
- return false;
- }
-
- if (out) {
- cerr << "Got back a value when sent null for " << type_name << "."
- << endl;
- return false;
- }
-
- return true;
+TEST_F(RepeatNullableTest, intEnumArray) {
+ DoTest(&ITestService::RepeatNullableIntEnumArray,
+ std::make_optional(std::vector<IntEnum>{IntEnum::FOO, IntEnum::BAR}));
}
-bool CheckAppropriateIBinderHandling(const sp<ITestService>& s) {
-
- Status status;
- sp<IBinder> binder = new BBinder();
- sp<IBinder> null_binder = nullptr;
- unique_ptr<vector<sp<IBinder>>> list_with_nulls(
- new vector<sp<IBinder>>{binder, null_binder});
- unique_ptr<vector<sp<IBinder>>> list_without_nulls(
- new vector<sp<IBinder>>{binder, binder});
-
- // Methods without @nullable throw up when given null binders
- if (s->TakesAnIBinder(null_binder).exceptionCode() !=
- binder::Status::EX_NULL_POINTER) {
- cerr << "Did not receive expected null exception on line: "
- << __LINE__ << endl;
- return false;
- }
- if (s->TakesAnIBinderList(*list_with_nulls).exceptionCode() !=
- binder::Status::EX_NULL_POINTER) {
- cerr << "Did not receive expected null exception on line: "
- << __LINE__ << endl;
- return false;
- }
-
- // But those same methods are fine with valid binders
- if (!s->TakesAnIBinder(binder).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
- if (!s->TakesAnIBinderList(*list_without_nulls).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
-
- // And methods with @nullable don't care.
- if (!s->TakesANullableIBinder(null_binder).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
- if (!s->TakesANullableIBinder(binder).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
- if (!s->TakesANullableIBinderList(list_with_nulls).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
- if (!s->TakesANullableIBinderList(list_without_nulls).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
-
- return true;
+TEST_F(RepeatNullableTest, longEnumArray) {
+ DoTest(&ITestService::RepeatNullableLongEnumArray,
+ std::make_optional(std::vector<LongEnum>{LongEnum::FOO, LongEnum::BAR}));
}
-bool CheckAppropriateIInterfaceHandling(const sp<ITestService>& s) {
+TEST_F(RepeatNullableTest, string) {
+ DoTest(&ITestService::RepeatNullableString, std::optional<String16>("Blooob"));
+}
+TEST_F(RepeatNullableTest, stringArray) {
+ std::vector<std::optional<String16>> input;
+ input.push_back(String16("Wat"));
+ input.push_back(String16("Blooob"));
+ input.push_back(String16("Wat"));
+ input.push_back(std::nullopt);
+ input.push_back(String16("YEAH"));
+ input.push_back(String16("OKAAAAY"));
+
+ DoTest(&ITestService::RepeatNullableStringList, std::make_optional(input));
+}
+
+TEST_F(RepeatNullableTest, parcelable) {
+ 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) {
+ auto status = service->TakesAnIBinder(nullptr);
+
+ if (backend == BackendType::JAVA) {
+ ASSERT_TRUE(status.isOk()) << status;
+ } else {
+ ASSERT_THAT(status.exceptionCode(), Eq(android::binder::Status::EX_NULL_POINTER)) << status;
+ }
+}
+
+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 = cpp_java_tests->TakesAnIBinderList(input);
+
+ if (backend == BackendType::JAVA) {
+ ASSERT_TRUE(status.isOk()) << status;
+ } else {
+ ASSERT_THAT(status.exceptionCode(), Eq(android::binder::Status::EX_NULL_POINTER));
+ }
+}
+
+TEST_F(AidlTest, nonNullBinder) {
+ sp<IBinder> input = new BBinder();
+ auto status = service->TakesAnIBinder(input);
+ ASSERT_TRUE(status.isOk());
+}
+
+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 = cpp_java_tests->TakesAnIBinderList(input);
+ ASSERT_TRUE(status.isOk());
+}
+
+TEST_F(AidlTest, nullBinderToAnnotatedMethod) {
+ auto status = service->TakesANullableIBinder(nullptr);
+ ASSERT_TRUE(status.isOk());
+}
+
+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 = cpp_java_tests->TakesANullableIBinderList(input);
+ ASSERT_TRUE(status.isOk());
+}
+
+TEST_F(AidlTest, nonNullBinderToAnnotatedMethod) {
+ sp<IBinder> input = new BBinder();
+ auto status = service->TakesANullableIBinder(input);
+ ASSERT_TRUE(status.isOk());
+}
+
+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 = cpp_java_tests->TakesANullableIBinderList(input);
+ ASSERT_TRUE(status.isOk());
+}
+
+TEST_F(AidlTest, interface) {
sp<INamedCallback> callback;
- if (!s->GetCallback(false, &callback).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
- if (callback.get() == nullptr) {
- cerr << "Expected to receive a non-null binder on line: "
- << __LINE__ << endl;
- return false;
- }
- if (!s->GetCallback(true, &callback).isOk()) {
- cerr << "Received unexpected exception on line "
- << __LINE__ << endl;
- return false;
- }
- if (callback.get() != nullptr) {
- cerr << "Expected to receive a null binder on line: "
- << __LINE__ << endl;
- return false;
- }
- return true;
+ auto status = service->GetCallback(false, &callback);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_THAT(callback.get(), Ne(nullptr));
}
-} // namespace
-
-bool ConfirmNullables(const sp<ITestService>& s) {
- Status status;
- cout << "Confirming passing and returning nullable values works." << endl;
-
- if (!ConfirmNullableType(s, "integer array",
- unique_ptr<vector<int32_t>>(
- new vector<int32_t>({1,2,3})),
- &ITestService::RepeatNullableIntArray)) {
- return false;
- }
-
- if (!ConfirmNullableType(
- s, "byte enum array",
- unique_ptr<vector<ByteEnum>>(new vector<ByteEnum>({ByteEnum::FOO, ByteEnum::BAR})),
- &ITestService::RepeatNullableByteEnumArray)) {
- return false;
- }
-
- if (!ConfirmNullableType(
- s, "int enum array",
- unique_ptr<vector<IntEnum>>(new vector<IntEnum>({IntEnum::FOO, IntEnum::BAR})),
- &ITestService::RepeatNullableIntEnumArray)) {
- return false;
- }
-
- if (!ConfirmNullableType(
- s, "long enum array",
- unique_ptr<vector<LongEnum>>(new vector<LongEnum>({LongEnum::FOO, LongEnum::BAR})),
- &ITestService::RepeatNullableLongEnumArray)) {
- return false;
- }
-
- if (!ConfirmNullableType(s, "string",
- unique_ptr<String16>(new String16("Blooob")),
- &ITestService::RepeatNullableString)) {
- return false;
- }
-
- unique_ptr<vector<unique_ptr<String16>>> test_string_array(
- new vector<unique_ptr<String16>>());
- test_string_array->push_back(unique_ptr<String16>(new String16("Wat")));
- test_string_array->push_back(unique_ptr<String16>(
- new String16("Blooob")));
- test_string_array->push_back(unique_ptr<String16>(new String16("Wat")));
- test_string_array->push_back(unique_ptr<String16>(nullptr));
- test_string_array->push_back(unique_ptr<String16>(new String16("YEAH")));
- test_string_array->push_back(unique_ptr<String16>(
- new String16("OKAAAAY")));
-
- if (!ConfirmNullableType(s, "string array", std::move(test_string_array),
- &ITestService::RepeatNullableStringList)) {
- return false;
- }
-
- if (!ConfirmNullableType(s, "parcelable",
- unique_ptr<SimpleParcelable>(
- new SimpleParcelable("Booya", 42)),
- &ITestService::RepeatNullableParcelable)) {
- return false;
- }
-
- if (!CheckAppropriateIBinderHandling(s)) {
- cerr << "Handled null IBinders poorly." << endl;
- return false;
- }
-
- if (!CheckAppropriateIInterfaceHandling(s)) {
- cerr << "Handled nullable IInterface instances poorly." << endl;
- return false;
- }
-
- return true;
+TEST_F(AidlTest, nullInterface) {
+ sp<INamedCallback> callback;
+ auto status = service->GetCallback(true, &callback);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_THAT(callback.get(), Eq(nullptr));
}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
diff --git a/tests/aidl_test_client_nullables.h b/tests/aidl_test_client_nullables.h
deleted file mode 100644
index 807aa4e..0000000
--- a/tests/aidl_test_client_nullables.h
+++ /dev/null
@@ -1,37 +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 ANDROID_AIDL_TESTS_CLIENT_NULLABLES_H
-#define ANDROID_AIDL_TESTS_CLIENT_NULLABLES_H
-
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-// Tests for passing and returning file descriptors.
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmNullables(const sp<ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_NULLABLES_H
diff --git a/tests/aidl_test_client_parcelables.cpp b/tests/aidl_test_client_parcelables.cpp
index cc89270..5d00aa8 100644
--- a/tests/aidl_test_client_parcelables.cpp
+++ b/tests/aidl_test_client_parcelables.cpp
@@ -14,84 +14,95 @@
* limitations under the License.
*/
-#include "aidl_test_client_parcelables.h"
+#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 <iostream>
+#include <string>
#include <vector>
-// libutils:
+using android::IInterface;
using android::sp;
-
-// libbinder:
-using android::binder::Status;
-
-// generated
+using android::String16;
using android::aidl::tests::ConstantExpressionEnum;
+using android::aidl::tests::GenericStructuredParcelable;
+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::cout;
-using std::endl;
+using std::string;
using std::vector;
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmSimpleParcelables(const sp<ITestService>& s) {
- cout << "Confirming passing and returning SimpleParcelable objects works."
- << endl;
+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 = s->RepeatSimpleParcelable(input, &out_param, &returned);
- if (!status.isOk()) {
- cout << "Binder call failed." << endl;
- return false;
- }
- if (input != out_param || input != returned) {
- cout << "Failed to repeat SimpleParcelable objects." << endl;
- return false;
- }
+ Status status = cpp_java_tests->RepeatSimpleParcelable(input, &out_param, &returned);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
+ EXPECT_EQ(input, out_param) << input.toString() << " " << out_param.toString();
+ EXPECT_EQ(input, returned) << input.toString() << " " << returned.toString();
+}
- cout << "Attempting to reverse an array of SimpleParcelable objects." << endl;
+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 = 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;
+ if (backend == BackendType::JAVA) {
+ repeated = vector<SimpleParcelable>(original.size());
+ }
vector<SimpleParcelable> reversed;
- status = s->ReverseSimpleParcelables(original, &repeated, &reversed);
- if (!status.isOk()) {
- cout << "Binder call failed." << endl;
- return false;
- }
- std::reverse(reversed.begin(), reversed.end());
- if (repeated != original || reversed != original) {
- cout << "Failed to reverse an array of SimpleParcelable objects." << endl;
- return false;
- }
+ Status status = cpp_java_tests->ReverseSimpleParcelables(original, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
- return true;
+ EXPECT_EQ(repeated, original);
+
+ std::reverse(reversed.begin(), reversed.end());
+ EXPECT_EQ(reversed, original);
}
-bool ConfirmPersistableBundles(const sp<ITestService>& s) {
- cout << "Confirming passing and returning PersistableBundle objects works."
- << endl;
+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 = s->RepeatPersistableBundle(empty_bundle, &returned);
- if (!status.isOk()) {
- cout << "Binder call failed for empty PersistableBundle." << endl;
- return false;
- }
- if (empty_bundle != returned) {
- cout << "Failed to repeat empty PersistableBundle." << endl;
- return false;
- }
+ Status status = cpp_java_tests->RepeatPersistableBundle(empty_bundle, &returned);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
+ EXPECT_EQ(empty_bundle, returned);
+}
- PersistableBundle non_empty_bundle;
+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);
non_empty_bundle.putLong(String16("test_long"), 34359738368L);
@@ -110,18 +121,14 @@
non_empty_bundle.putPersistableBundle(String16("test_persistable_bundle"),
nested_bundle);
- status = s->RepeatPersistableBundle(non_empty_bundle, &returned);
- if (!status.isOk()) {
- cout << "Binder call failed. " << endl;
- return false;
- }
- if (non_empty_bundle != returned) {
- cout << "Failed to repeat PersistableBundle object." << endl;
- return false;
- }
+ Status status = cpp_java_tests->RepeatPersistableBundle(non_empty_bundle, &returned);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
+ EXPECT_EQ(non_empty_bundle, returned);
+}
- cout << "Attempting to reverse an array of PersistableBundle objects."
- << endl;
+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;
@@ -131,276 +138,381 @@
const vector<PersistableBundle> original{first, second, third};
vector<PersistableBundle> repeated;
+ if (backend == BackendType::JAVA) {
+ repeated = vector<PersistableBundle>(original.size());
+ }
vector<PersistableBundle> reversed;
- status = s->ReversePersistableBundles(original, &repeated, &reversed);
- if (!status.isOk()) {
- cout << "Binder call failed." << endl;
- return false;
- }
- std::reverse(reversed.begin(), reversed.end());
- if (repeated != original || reversed != original) {
- cout << "Failed to reverse an array of PersistableBundle objects." << endl;
- return false;
- }
+ Status status = cpp_java_tests->ReversePersistableBundles(original, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
- return true;
+ EXPECT_EQ(repeated, original);
+
+ std::reverse(reversed.begin(), reversed.end());
+ EXPECT_EQ(reversed, original);
}
-bool ConfirmStructuredParcelablesEquality(const sp<ITestService>& s) {
+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
StructuredParcelable parcelable1;
StructuredParcelable parcelable2;
parcelable1.f = 11;
parcelable2.f = 11;
- s->FillOutStructuredParcelable(&parcelable1);
- s->FillOutStructuredParcelable(&parcelable2);
+ service->FillOutStructuredParcelable(&parcelable1);
+ service->FillOutStructuredParcelable(&parcelable2);
sp<INamedCallback> callback1;
sp<INamedCallback> callback2;
- s->GetOtherTestService(String16("callback1"), &callback1);
- s->GetOtherTestService(String16("callback2"), &callback2);
+ service->GetOtherTestService(String16("callback1"), &callback1);
+ service->GetOtherTestService(String16("callback2"), &callback2);
parcelable1.ibinder = IInterface::asBinder(callback1);
parcelable2.ibinder = IInterface::asBinder(callback1);
- if (parcelable1 != parcelable2) {
- cout << "parcelable1 and parcelable2 should be same." << endl;
- return false;
- }
+ EXPECT_EQ(parcelable1, parcelable2);
+
parcelable1.f = 0;
- if (parcelable1 >= parcelable2) {
- cout << "parcelable1 and parcelable2 should be different because of shouldContainThreeFs"
- << endl;
- return false;
- }
+ EXPECT_LT(parcelable1, parcelable2);
parcelable1.f = 11;
parcelable1.shouldBeJerry = "Jarry";
- if (!(parcelable1 < parcelable2)) {
- cout << "parcelable1 and parcelable2 should be different because of shouldContainThreeFs"
- << endl;
- return false;
- }
+ EXPECT_LT(parcelable1, parcelable2);
parcelable1.shouldBeJerry = "Jerry";
parcelable2.shouldContainThreeFs = {};
- if (parcelable1 <= parcelable2) {
- cout << "parcelable1 and parcelable2 should be different because of shouldContainThreeFs"
- << endl;
- return false;
- }
+ EXPECT_GT(parcelable1, parcelable2);
parcelable2.shouldContainThreeFs = {parcelable2.f, parcelable2.f, parcelable2.f};
parcelable2.shouldBeIntBar = IntEnum::FOO;
- if (!(parcelable1 > parcelable2)) {
- cout << "parcelable1 and parcelable2 should be different because of shouldBeIntBar" << endl;
- return false;
- }
+ EXPECT_GT(parcelable1, parcelable2);
parcelable2.shouldBeIntBar = IntEnum::BAR;
parcelable2.ibinder = IInterface::asBinder(callback2);
- if (parcelable1 == parcelable2) {
- cout << "parcelable1 and parcelable2 should be different because of ibinder" << endl;
- return false;
- }
- return true;
+ EXPECT_NE(parcelable1, parcelable2);
}
-bool ConfirmStructuredParcelables(const sp<ITestService>& s) {
- bool success = true;
+TEST_F(AidlTest, ConfirmStructuredParcelables) {
constexpr int kDesiredValue = 23;
StructuredParcelable parcelable;
parcelable.f = kDesiredValue;
- if (parcelable.stringDefaultsToFoo != String16("foo")) {
- cout << "stringDefaultsToFoo should be 'foo' but is " << parcelable.stringDefaultsToFoo << endl;
- return false;
- }
- if (parcelable.byteDefaultsToFour != 4) {
- cout << "byteDefaultsToFour should be 4 but is " << parcelable.byteDefaultsToFour << endl;
- return false;
- }
- if (parcelable.intDefaultsToFive != 5) {
- cout << "intDefaultsToFive should be 5 but is " << parcelable.intDefaultsToFive << endl;
- return false;
- }
- if (parcelable.longDefaultsToNegativeSeven != -7) {
- cout << "longDefaultsToNegativeSeven should be -7 but is "
- << parcelable.longDefaultsToNegativeSeven << endl;
- return false;
- }
- if (!parcelable.booleanDefaultsToTrue) {
- cout << "booleanDefaultsToTrue isn't true" << endl;
- return false;
- }
- if (parcelable.charDefaultsToC != 'C') {
- cout << "charDefaultsToC is " << parcelable.charDefaultsToC << endl;
- return false;
- }
- if (parcelable.floatDefaultsToPi != 3.14f) {
- cout << "floatDefaultsToPi is " << parcelable.floatDefaultsToPi << endl;
- return false;
- }
- if (parcelable.doubleWithDefault != -3.14e17) {
- cout << "doubleWithDefault is " << parcelable.doubleWithDefault << " but should be -3.14e17"
- << endl;
- return false;
- }
- if (parcelable.arrayDefaultsTo123.size() != 3) {
- cout << "arrayDefaultsTo123 is of length " << parcelable.arrayDefaultsTo123.size() << endl;
- return false;
- }
- for (int i = 0; i < 3; i++) {
- if (parcelable.arrayDefaultsTo123[i] != i + 1) {
- cout << "arrayDefaultsTo123[" << i << "] is " << parcelable.arrayDefaultsTo123[i]
- << " but should be " << i + 1 << endl;
- return false;
- }
- }
- if (!parcelable.arrayDefaultsToEmpty.empty()) {
- cout << "arrayDefaultsToEmpty is not empty " << parcelable.arrayDefaultsToEmpty.size() << endl;
- return false;
- }
+ EXPECT_EQ(parcelable.stringDefaultsToFoo, String16("foo"));
+ EXPECT_EQ(parcelable.byteDefaultsToFour, 4);
+ EXPECT_EQ(parcelable.intDefaultsToFive, 5);
+ EXPECT_EQ(parcelable.longDefaultsToNegativeSeven, -7);
+ EXPECT_EQ(parcelable.booleanDefaultsToTrue, true);
+ EXPECT_EQ(parcelable.charDefaultsToC, 'C');
+ EXPECT_TRUE(parcelable.floatDefaultsToPi == 3.14f) << parcelable.floatDefaultsToPi;
+ EXPECT_TRUE(parcelable.doubleWithDefault == -3.14e17) << parcelable.doubleWithDefault;
- s->FillOutStructuredParcelable(&parcelable);
+ EXPECT_EQ(parcelable.boolDefault, false);
+ EXPECT_EQ(parcelable.byteDefault, 0);
+ EXPECT_EQ(parcelable.intDefault, 0);
+ EXPECT_EQ(parcelable.longDefault, 0);
+ EXPECT_EQ(parcelable.floatDefault, 0.0f);
+ EXPECT_EQ(parcelable.doubleDefault, 0.0);
- if (parcelable.shouldContainThreeFs.size() != 3) {
- cout << "shouldContainThreeFs is of length " << parcelable.shouldContainThreeFs.size() << endl;
- return false;
- }
+ ASSERT_EQ(parcelable.arrayDefaultsTo123.size(), 3u);
+ EXPECT_EQ(parcelable.arrayDefaultsTo123[0], 1);
+ EXPECT_EQ(parcelable.arrayDefaultsTo123[1], 2);
+ EXPECT_EQ(parcelable.arrayDefaultsTo123[2], 3);
+ EXPECT_TRUE(parcelable.arrayDefaultsToEmpty.empty());
- for (int i = 0; i < 3; i++) {
- if (parcelable.shouldContainThreeFs[i] != kDesiredValue) {
- cout << "shouldContainThreeFs[" << i << "] is " << parcelable.shouldContainThreeFs[i]
- << " but should be " << kDesiredValue << endl;
- return false;
- }
- }
+ EXPECT_EQ(parcelable.defaultWithFoo, IntEnum::FOO);
- if (parcelable.shouldBeJerry != "Jerry") {
- cout << "shouldBeJerry should be 'Jerry' but is " << parcelable.shouldBeJerry << endl;
- return false;
- }
+ service->FillOutStructuredParcelable(&parcelable);
- if (parcelable.int32_min != INT32_MIN) {
- cout << "int32_min should be " << INT32_MIN << "but is " << parcelable.int32_min << endl;
- return false;
- }
+ ASSERT_EQ(parcelable.shouldContainThreeFs.size(), 3u);
+ EXPECT_EQ(parcelable.shouldContainThreeFs[0], kDesiredValue);
+ EXPECT_EQ(parcelable.shouldContainThreeFs[1], kDesiredValue);
+ EXPECT_EQ(parcelable.shouldContainThreeFs[2], kDesiredValue);
- if (parcelable.int32_max != INT32_MAX) {
- cout << "int32_max should be " << INT32_MAX << "but is " << parcelable.int32_max << endl;
- return false;
- }
-
- if (parcelable.int64_max != INT64_MAX) {
- cout << "int64_max should be " << INT64_MAX << "but is " << parcelable.int64_max << endl;
- return false;
- }
-
- if (parcelable.hexInt32_neg_1 != -1) {
- cout << "hexInt32_neg_1 should be -1 but is " << parcelable.hexInt32_neg_1 << endl;
- return false;
- }
+ EXPECT_EQ(parcelable.shouldBeJerry, "Jerry");
+ EXPECT_EQ(parcelable.int32_min, INT32_MIN);
+ EXPECT_EQ(parcelable.int32_max, INT32_MAX);
+ EXPECT_EQ(parcelable.int64_max, INT64_MAX);
+ EXPECT_EQ(parcelable.hexInt32_neg_1, -1);
for (size_t ndx = 0; ndx < parcelable.int32_1.size(); ndx++) {
- if (parcelable.int32_1[ndx] != 1) {
- cout << "int32_1[" << ndx << "] should be 1 but is " << parcelable.int32_1[ndx] << endl;
- success = false;
- }
- }
- if (!success) {
- return false;
+ EXPECT_EQ(parcelable.int32_1[ndx], 1) << ndx;
}
for (size_t ndx = 0; ndx < parcelable.int64_1.size(); ndx++) {
- if (parcelable.int64_1[ndx] != 1) {
- cout << "int64_1[" << ndx << "] should be 1 but is " << parcelable.int64_1[ndx] << endl;
- success = false;
- }
- }
- if (!success) {
- return false;
+ EXPECT_EQ(parcelable.int64_1[ndx], 1) << ndx;
}
- if (static_cast<int>(parcelable.hexInt32_pos_1) != 1) {
- cout << "hexInt32_pos_1 should be 1 but is " << parcelable.hexInt32_pos_1 << endl;
- return false;
- }
+ EXPECT_EQ(parcelable.hexInt32_pos_1, 1);
+ EXPECT_EQ(parcelable.hexInt64_pos_1, 1);
- if (parcelable.hexInt64_pos_1 != 1) {
- cout << "hexInt64_pos_1 should be 1 but is " << parcelable.hexInt64_pos_1 << endl;
- return false;
- }
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_1), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_2), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_3), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_4), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_5), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_6), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_7), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_8), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_9), 1);
+ EXPECT_EQ(static_cast<int>(parcelable.const_exprs_10), 1);
- if (static_cast<int>(parcelable.const_exprs_1) != 1) {
- cout << "parcelable.const_exprs_1 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_1) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_2) != 1) {
- cout << "parcelable.const_exprs_2 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_2) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_3) != 1) {
- cout << "parcelable.const_exprs_3 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_3) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_4) != 1) {
- cout << "parcelable.const_exprs_4 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_4) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_5) != 1) {
- cout << "parcelable.const_exprs_5 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_5) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_6) != 1) {
- cout << "parcelable.const_exprs_6 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_6) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_7) != 1) {
- cout << "parcelable.const_exprs_7 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_7) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_8) != 1) {
- cout << "parcelable.const_exprs_8 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_8) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_9) != 1) {
- cout << "parcelable.const_exprs_9 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_9) << endl;
- return false;
- }
- if (static_cast<int>(parcelable.const_exprs_10) != 1) {
- cout << "parcelable.const_exprs_10 should be 1 but is "
- << static_cast<int>(parcelable.const_exprs_10) << endl;
- return false;
- }
+ EXPECT_EQ(parcelable.addString1, "hello world!");
+ EXPECT_EQ(parcelable.addString2, "The quick brown fox jumps over the lazy dog.");
- if (parcelable.addString1 != "hello world!") {
- cout << "parcelable.addString1 should be \"hello world!\" but is \"" << parcelable.addString1
- << "\"" << endl;
- return false;
- }
- if (parcelable.addString2 != "The quick brown fox jumps over the lazy dog.") {
- cout << "parcelable.addString2 should be \"The quick brown fox jumps over the lazy dog.\""
- " but is \""
- << parcelable.addString2 << "\"" << endl;
- return false;
- }
+ EXPECT_EQ(StructuredParcelable::BIT0 | StructuredParcelable::BIT2,
+ parcelable.shouldSetBit0AndBit2);
- return true;
+ EXPECT_EQ(parcelable.u->get<Union::ns>(), vector<int32_t>({1, 2, 3}));
+ EXPECT_EQ(parcelable.shouldBeConstS1->get<Union::s>(), Union::S1());
}
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
+TEST_F(AidlTest, EmptyParcelableHolder) {
+ using namespace android::aidl::tests::extension;
+ android::Parcel parcel;
+ {
+ ExtendableParcelable ep;
+ ep.writeToParcel(&parcel);
+ std::shared_ptr<MyExt> emptyExt;
+ ep.ext.getParcelable(&emptyExt);
+ EXPECT_FALSE(emptyExt);
+ }
+ {
+ parcel.setDataPosition(0);
+ ExtendableParcelable ep;
+ ep.readFromParcel(&parcel);
+ 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;
+ ext.a = 42;
+ ext.b = "EXT";
+
+ MyExt2 ext2;
+ ext2.a = 42;
+ ext2.b.a = 24;
+ ext2.b.b = "INEXT";
+ ext2.c = "EXT2";
+ android::Parcel parcel;
+ {
+ ExtendableParcelable ep;
+ ep.a = 1;
+ ep.b = "a";
+ ep.c = 42L;
+
+ EXPECT_TRUE(ep.ext.setParcelable(ext) == android::OK);
+ EXPECT_TRUE(ep.ext2.setParcelable(ext2) == android::OK);
+
+ 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.";
+
+ std::shared_ptr<MyExt> actualExt;
+ ep.ext.getParcelable(&actualExt);
+ std::shared_ptr<MyExt2> actualExt2;
+ ep.ext2.getParcelable(&actualExt2);
+
+ EXPECT_TRUE(actualExt);
+ EXPECT_TRUE(actualExt2);
+
+ EXPECT_EQ(ext, *actualExt);
+ EXPECT_EQ(ext2, *actualExt2);
+
+ ep.writeToParcel(&parcel);
+ }
+
+ parcel.setDataPosition(0);
+ {
+ ExtendableParcelable ep;
+ ep.readFromParcel(&parcel);
+
+ 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.";
+
+ std::shared_ptr<MyExt> actualExt;
+ ep.ext.getParcelable(&actualExt);
+ std::shared_ptr<MyExt2> actualExt2;
+ ep.ext2.getParcelable(&actualExt2);
+
+ std::shared_ptr<MyExt> emptyExt;
+ ep.ext2.getParcelable(&emptyExt);
+ EXPECT_FALSE(emptyExt);
+
+ EXPECT_TRUE(actualExt);
+ EXPECT_TRUE(actualExt2);
+
+ EXPECT_EQ(ext, *actualExt);
+ 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_parcelables.h b/tests/aidl_test_client_parcelables.h
deleted file mode 100644
index 3031ad4..0000000
--- a/tests/aidl_test_client_parcelables.h
+++ /dev/null
@@ -1,40 +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 ANDROID_AIDL_TESTS_CLIENT_PARCELABLES_H
-#define ANDROID_AIDL_TESTS_CLIENT_PARCELABLES_H
-
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-// Tests for passing and returning parcelable types.
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmSimpleParcelables(const sp<ITestService>& s);
-bool ConfirmPersistableBundles(const sp<ITestService>& s);
-bool ConfirmStructuredParcelables(const sp<ITestService>& s);
-bool ConfirmStructuredParcelablesEquality(const sp<ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_PARCELABLES_H
diff --git a/tests/aidl_test_client_primitives.cpp b/tests/aidl_test_client_primitives.cpp
index beadf96..f15b67e 100644
--- a/tests/aidl_test_client_primitives.cpp
+++ b/tests/aidl_test_client_primitives.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#include "aidl_test_client_primitives.h"
-
-#include <iostream>
-#include <iterator>
#include <vector>
#include <utils/String16.h>
@@ -28,435 +24,261 @@
#include "android/aidl/tests/IntEnum.h"
#include "android/aidl/tests/LongEnum.h"
-#include "test_helpers.h"
+#include "aidl_test_client.h"
+#include "gmock/gmock.h"
-// libutils:
+using android::IBinder;
using android::sp;
using android::String16;
using android::String8;
-
-// libbinder:
using android::binder::Status;
// generated
-using android::aidl::tests::ITestService;
+using android::aidl::tests::ByteEnum;
using android::aidl::tests::INamedCallback;
+using android::aidl::tests::IntEnum;
+using android::aidl::tests::ITestService;
+using android::aidl::tests::LongEnum;
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::vector;
+using testing::Eq;
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmPrimitiveRepeat(const sp<ITestService>& s) {
- cout << "Confirming passing and returning primitives works." << endl;
-
- if (!RepeatPrimitive(s, &ITestService::RepeatBoolean, true) ||
- !RepeatPrimitive(s, &ITestService::RepeatByte, int8_t{-128}) ||
- !RepeatPrimitive(s, &ITestService::RepeatChar, char16_t{'A'}) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, int32_t{1 << 30}) ||
- !RepeatPrimitive(s, &ITestService::RepeatLong, int64_t{1LL << 60}) ||
- !RepeatPrimitive(s, &ITestService::RepeatFloat, float{1.0f / 3.0f}) ||
- !RepeatPrimitive(s, &ITestService::RepeatDouble, double{1.0 / 3.0}) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT2) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT3) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT4) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT5) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT6) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT7) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT8) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT9) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT10) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT11) ||
- !RepeatPrimitive(s, &ITestService::RepeatInt, ITestService::TEST_CONSTANT12) ||
- !RepeatPrimitive(s, &ITestService::RepeatByteEnum, ByteEnum::FOO) ||
- !RepeatPrimitive(s, &ITestService::RepeatIntEnum, IntEnum::BAR) ||
- !RepeatPrimitive(s, &ITestService::RepeatLongEnum, LongEnum::FOO)) {
- return false;
+struct AidlPrimitiveTest : public AidlTest {
+ template <typename T, typename U, typename V>
+ void DoTest(Status (ITestService::*func)(T, U*), V input) {
+ U repeated;
+ auto status = (*service.*func)(input, &repeated);
+ ASSERT_TRUE(status.isOk()) << status;
+ ASSERT_THAT(repeated, Eq(input));
}
- vector<String16> inputs = {
- String16("Deliver us from evil."),
- String16(),
- String16("\0\0", 2),
+ template <typename T>
+ void DoTest(Status (ITestService::*func)(const std::vector<T>&, std::vector<T>*, std::vector<T>*),
+ const std::vector<T>& input) {
+ // must be preallocated for Java servers
+ std::vector<T> repeated(input.size());
+ std::vector<T> reversed;
+ auto status = (*service.*func)(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status;
+ ASSERT_THAT(repeated, Eq(input));
+
+ std::vector<T> reversed_input(input);
+ std::reverse(reversed_input.begin(), reversed_input.end());
+ ASSERT_THAT(reversed, Eq(reversed_input));
+ }
+};
+
+TEST_F(AidlPrimitiveTest, aBoolean) {
+ DoTest(&ITestService::RepeatBoolean, true);
+}
+
+TEST_F(AidlPrimitiveTest, aByte) {
+ DoTest(&ITestService::RepeatByte, int8_t{-128});
+}
+
+TEST_F(AidlPrimitiveTest, aChar) {
+ DoTest(&ITestService::RepeatChar, char16_t{'A'});
+}
+
+TEST_F(AidlPrimitiveTest, aInt) {
+ DoTest(&ITestService::RepeatInt, int32_t{1 << 30});
+}
+
+TEST_F(AidlPrimitiveTest, aLong) {
+ DoTest(&ITestService::RepeatLong, int64_t{1LL << 60});
+}
+
+TEST_F(AidlPrimitiveTest, aFloat) {
+ DoTest(&ITestService::RepeatFloat, float{1.0f / 3.0f});
+}
+
+TEST_F(AidlPrimitiveTest, aDouble) {
+ 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,
+ ITestService::TEST_CONSTANT4, ITestService::TEST_CONSTANT5, ITestService::TEST_CONSTANT6,
+ ITestService::TEST_CONSTANT7, ITestService::TEST_CONSTANT8, ITestService::TEST_CONSTANT9,
+ ITestService::TEST_CONSTANT10, ITestService::TEST_CONSTANT11, ITestService::TEST_CONSTANT12};
+ for (auto sent : consts) {
+ DoTest(&ITestService::RepeatInt, sent);
+ }
+}
+
+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),
// This is actually two unicode code points:
// U+10437: The 'small letter yee' character in the deseret alphabet
// U+20AC: A euro sign
- String16("\xD8\x01\xDC\x37\x20\xAC"),
- ITestService::STRING_TEST_CONSTANT(),
- ITestService::STRING_TEST_CONSTANT2(),
- };
- for (const auto& input : inputs) {
- String16 reply;
- Status status = s->RepeatString(input, &reply);
- if (!status.isOk() || input != reply) {
- cerr << "Failed while requesting service to repeat String16=\""
- << String8(input).string()
- << "\". Got status=" << status.toString8() << endl;
- return false;
- }
+ String16("\xD8\x01\xDC\x37\x20\xAC"), ITestService::STRING_TEST_CONSTANT(),
+ ITestService::STRING_TEST_CONSTANT2()};
+ for (auto sent : strings) {
+ DoTest(&ITestService::RepeatString, sent);
}
- return true;
}
-bool ConfirmReverseArrays(const sp<ITestService>& s) {
- cout << "Confirming passing and returning arrays works." << endl;
-
- if (!ReverseArray(s, &ITestService::ReverseBoolean, {true, false, false}) ||
- !ReverseArray(s, &ITestService::ReverseByte, {uint8_t{255}, uint8_t{0}, uint8_t{127}}) ||
- !ReverseArray(s, &ITestService::ReverseChar, {char16_t{'A'}, char16_t{'B'}, char16_t{'C'}}) ||
- !ReverseArray(s, &ITestService::ReverseInt, {1, 2, 3}) ||
- !ReverseArray(s, &ITestService::ReverseLong, {-1LL, 0LL, int64_t{1LL << 60}}) ||
- !ReverseArray(s, &ITestService::ReverseFloat, {-0.3f, -0.7f, 8.0f}) ||
- !ReverseArray(s, &ITestService::ReverseDouble, {1.0 / 3.0, 1.0 / 7.0, 42.0}) ||
- !ReverseArray(s, &ITestService::ReverseString,
- {String16{"f"}, String16{"a"}, String16{"b"}}) ||
- !ReverseArray(s, &ITestService::ReverseByteEnum,
- {ByteEnum::FOO, ByteEnum::BAR, ByteEnum::BAR}) ||
- !ReverseArray(s, &ITestService::ReverseByteEnum,
- {std::begin(::android::enum_range<ByteEnum>()),
- std::end(::android::enum_range<ByteEnum>())}) ||
- !ReverseArray(s, &ITestService::ReverseIntEnum, {IntEnum::FOO, IntEnum::BAR, IntEnum::BAR}) ||
- !ReverseArray(s, &ITestService::ReverseLongEnum,
- {LongEnum::FOO, LongEnum::BAR, LongEnum::BAR})) {
- return false;
- }
-
- return true;
+TEST_F(AidlPrimitiveTest, booleanArray) {
+ DoTest(&ITestService::ReverseBoolean, {true, false, false});
}
-bool ConfirmReverseLists(const sp<ITestService>& s) {
- cout << "Confirming passing and returning List<T> works." << endl;
-
- if (!ReverseArray(s, &ITestService::ReverseStringList,
- {String16{"f"}, String16{"a"}, String16{"b"}})) {
- return false;
- }
-
- return true;
+TEST_F(AidlPrimitiveTest, byteArrvay) {
+ DoTest(&ITestService::ReverseByte, {uint8_t{255}, uint8_t{0}, uint8_t{127}});
}
-bool ConfirmReverseBinderLists(const sp<ITestService>& s) {
- Status status;
- cout << "Confirming passing and returning List<T> works with binders." << endl;
+TEST_F(AidlPrimitiveTest, charArray) {
+ DoTest(&ITestService::ReverseChar, {char16_t{'A'}, char16_t{'B'}, char16_t{'C'}});
+}
- vector<String16> names = {
- String16{"Larry"},
- String16{"Curly"},
- String16{"Moe"}
- };
+TEST_F(AidlPrimitiveTest, intArray) {
+ DoTest(&ITestService::ReverseInt, {1, 2, 3});
+}
- vector<sp<IBinder>> input;
+TEST_F(AidlPrimitiveTest, longArrayr) {
+ DoTest(&ITestService::ReverseLong, {-1LL, 0LL, int64_t{1LL << 60}});
+}
+TEST_F(AidlPrimitiveTest, floatArrays) {
+ DoTest(&ITestService::ReverseFloat, {-0.3f, -0.7f, 8.0f});
+}
+
+TEST_F(AidlPrimitiveTest, doubleArray) {
+ DoTest(&ITestService::ReverseDouble, {1.0 / 3.0, 1.0 / 7.0, 42.0});
+}
+
+TEST_F(AidlPrimitiveTest, stringArray) {
+ DoTest(&ITestService::ReverseString, {String16{"f"}, String16{"a"}, String16{"b"}});
+}
+
+TEST_F(AidlPrimitiveTest, byteEnumArray) {
+ DoTest(&ITestService::ReverseByteEnum, {ByteEnum::FOO, ByteEnum::BAR, ByteEnum::BAR});
+}
+
+TEST_F(AidlPrimitiveTest, byteEnumArray2) {
+ DoTest(&ITestService::ReverseByteEnum, {std::begin(::android::enum_range<ByteEnum>()),
+ std::end(::android::enum_range<ByteEnum>())});
+}
+
+TEST_F(AidlPrimitiveTest, intEnumArray) {
+ DoTest(&ITestService::ReverseIntEnum, {IntEnum::FOO, IntEnum::BAR, IntEnum::BAR});
+}
+
+TEST_F(AidlPrimitiveTest, longEnumArray) {
+ DoTest(&ITestService::ReverseLongEnum, {LongEnum::FOO, LongEnum::BAR, LongEnum::BAR});
+}
+
+TEST_F(AidlPrimitiveTest, stringList) {
+ DoTest(&ITestService::ReverseStringList, {String16{"f"}, String16{"a"}, String16{"b"}});
+}
+
+TEST_F(AidlPrimitiveTest, binderArray) {
+ std::vector<String16> names = {String16{"Larry"}, String16{"Curly"}, String16{"Moe"}};
+
+ std::vector<sp<IBinder>> input;
for (int i = 0; i < 3; i++) {
sp<INamedCallback> got;
-
- status = s->GetOtherTestService(names[i], &got);
- if (!status.isOk()) {
- cerr << "Could not retrieve service for test." << endl;
- return false;
- }
-
+ auto status = service->GetOtherTestService(names[i], &got);
+ ASSERT_TRUE(status.isOk());
input.push_back(INamedCallback::asBinder(got));
}
- vector<sp<IBinder>> output;
- vector<sp<IBinder>> reversed;
+ 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(output.size(), Eq(3u));
+ ASSERT_THAT(reversed.size(), Eq(3u));
- status = s->ReverseNamedCallbackList(input, &output, &reversed);
- if (!status.isOk()) {
- cerr << "Failed to reverse named callback list." << endl;
- }
-
- if (output.size() != 3) {
- cerr << "ReverseNamedCallbackList gave repetition with wrong length." << endl;
- return false;
- }
-
- if (reversed.size() != 3) {
- cerr << "ReverseNamedCallbackList gave reversal with wrong length." << endl;
- return false;
- }
-
- for (int i = 0; i < 3; i++) {
- String16 ret;
- sp<INamedCallback> named_callback =
- android::interface_cast<INamedCallback>(output[i]);
- status = named_callback->GetName(&ret);
-
- if (!status.isOk()) {
- cerr << "Could not query INamedCallback from output" << endl;
- return false;
+ 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]));
}
- if (ret != names[i]) {
- cerr << "Output had wrong INamedCallback" << endl;
- return false;
+ 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>(reversed[i]);
- status = named_callback->GetName(&ret);
-
- if (!status.isOk()) {
- cerr << "Could not query INamedCallback from reversed output" << endl;
- return false;
- }
-
- if (ret != names[2 - i]) {
- cerr << "Reversed output had wrong INamedCallback" << endl;
- return false;
- }
- }
-
- return true;
}
-bool ConfirmIntfConstantExpressions(const sp<ITestService>& s) {
- (void)s;
- bool ret = true;
-
- if (ITestService::A1 != 1) {
- cerr << "ITestService::A1 should be 1 but is " << ITestService::A1 << endl;
- ret = false;
- }
- if (ITestService::A2 != 1) {
- cerr << "ITestService::A2 should be 1 but is " << ITestService::A2 << endl;
- ret = false;
- }
- if (ITestService::A3 != 1) {
- cerr << "ITestService::A3 should be 1 but is " << ITestService::A3 << endl;
- ret = false;
- }
- if (ITestService::A4 != 1) {
- cerr << "ITestService::A4 should be 1 but is " << ITestService::A4 << endl;
- ret = false;
- }
- if (ITestService::A5 != 1) {
- cerr << "ITestService::A5 should be 1 but is " << ITestService::A5 << endl;
- ret = false;
- }
- if (ITestService::A6 != 1) {
- cerr << "ITestService::A6 should be 1 but is " << ITestService::A6 << endl;
- ret = false;
- }
- if (ITestService::A7 != 1) {
- cerr << "ITestService::A7 should be 1 but is " << ITestService::A7 << endl;
- ret = false;
- }
- if (ITestService::A8 != 1) {
- cerr << "ITestService::A8 should be 1 but is " << ITestService::A8 << endl;
- ret = false;
- }
- if (ITestService::A9 != 1) {
- cerr << "ITestService::A9 should be 1 but is " << ITestService::A9 << endl;
- ret = false;
- }
- if (ITestService::A10 != 1) {
- cerr << "ITestService::A10 should be 1 but is " << ITestService::A10 << endl;
- ret = false;
- }
- if (ITestService::A11 != 1) {
- cerr << "ITestService::A11 should be 1 but is " << ITestService::A11 << endl;
- ret = false;
- }
- if (ITestService::A12 != 1) {
- cerr << "ITestService::A12 should be 1 but is " << ITestService::A12 << endl;
- ret = false;
- }
- if (ITestService::A13 != 1) {
- cerr << "ITestService::A13 should be 1 but is " << ITestService::A13 << endl;
- ret = false;
- }
- if (ITestService::A14 != 1) {
- cerr << "ITestService::A14 should be 1 but is " << ITestService::A14 << endl;
- ret = false;
- }
- if (ITestService::A15 != 1) {
- cerr << "ITestService::A15 should be 1 but is " << ITestService::A15 << endl;
- ret = false;
- }
- if (ITestService::A16 != 1) {
- cerr << "ITestService::A16 should be 1 but is " << ITestService::A16 << endl;
- ret = false;
- }
- if (ITestService::A17 != 1) {
- cerr << "ITestService::A17 should be 1 but is " << ITestService::A17 << endl;
- ret = false;
- }
- if (ITestService::A18 != 1) {
- cerr << "ITestService::A18 should be 1 but is " << ITestService::A18 << endl;
- ret = false;
- }
- if (ITestService::A19 != 1) {
- cerr << "ITestService::A19 should be 1 but is " << ITestService::A19 << endl;
- ret = false;
- }
- if (ITestService::A20 != 1) {
- cerr << "ITestService::A20 should be 1 but is " << ITestService::A20 << endl;
- ret = false;
- }
- if (ITestService::A21 != 1) {
- cerr << "ITestService::A21 should be 1 but is " << ITestService::A21 << endl;
- ret = false;
- }
- if (ITestService::A22 != 1) {
- cerr << "ITestService::A22 should be 1 but is " << ITestService::A22 << endl;
- ret = false;
- }
- if (ITestService::A23 != 1) {
- cerr << "ITestService::A23 should be 1 but is " << ITestService::A23 << endl;
- ret = false;
- }
- if (ITestService::A24 != 1) {
- cerr << "ITestService::A24 should be 1 but is " << ITestService::A24 << endl;
- ret = false;
- }
- if (ITestService::A25 != 1) {
- cerr << "ITestService::A25 should be 1 but is " << ITestService::A25 << endl;
- ret = false;
- }
- if (ITestService::A26 != 1) {
- cerr << "ITestService::A26 should be 1 but is " << ITestService::A26 << endl;
- ret = false;
- }
- if (ITestService::A27 != 1) {
- cerr << "ITestService::A27 should be 1 but is " << ITestService::A27 << endl;
- ret = false;
- }
- if (ITestService::A28 != 1) {
- cerr << "ITestService::A28 should be 1 but is " << ITestService::A28 << endl;
- ret = false;
- }
- if (ITestService::A29 != 1) {
- cerr << "ITestService::A29 should be 1 but is " << ITestService::A29 << endl;
- ret = false;
- }
- if (ITestService::A30 != 1) {
- cerr << "ITestService::A30 should be 1 but is " << ITestService::A30 << endl;
- ret = false;
- }
- if (ITestService::A31 != 1) {
- cerr << "ITestService::A31 should be 1 but is " << ITestService::A31 << endl;
- ret = false;
- }
- if (ITestService::A32 != 1) {
- cerr << "ITestService::A32 should be 1 but is " << ITestService::A32 << endl;
- ret = false;
- }
- if (ITestService::A33 != 1) {
- cerr << "ITestService::A33 should be 1 but is " << ITestService::A33 << endl;
- ret = false;
- }
- if (ITestService::A34 != 1) {
- cerr << "ITestService::A34 should be 1 but is " << ITestService::A34 << endl;
- ret = false;
- }
- if (ITestService::A35 != 1) {
- cerr << "ITestService::A35 should be 1 but is " << ITestService::A35 << endl;
- ret = false;
- }
- if (ITestService::A36 != 1) {
- cerr << "ITestService::A36 should be 1 but is " << ITestService::A36 << endl;
- ret = false;
- }
- if (ITestService::A37 != 1) {
- cerr << "ITestService::A37 should be 1 but is " << ITestService::A37 << endl;
- ret = false;
- }
- if (ITestService::A38 != 1) {
- cerr << "ITestService::A38 should be 1 but is " << ITestService::A38 << endl;
- ret = false;
- }
- if (ITestService::A39 != 1) {
- cerr << "ITestService::A39 should be 1 but is " << ITestService::A39 << endl;
- ret = false;
- }
- if (ITestService::A40 != 1) {
- cerr << "ITestService::A40 should be 1 but is " << ITestService::A40 << endl;
- ret = false;
- }
- if (ITestService::A41 != 1) {
- cerr << "ITestService::A41 should be 1 but is " << ITestService::A41 << endl;
- ret = false;
- }
- if (ITestService::A42 != 1) {
- cerr << "ITestService::A42 should be 1 but is " << ITestService::A42 << endl;
- ret = false;
- }
- if (ITestService::A43 != 1) {
- cerr << "ITestService::A43 should be 1 but is " << ITestService::A43 << endl;
- ret = false;
- }
- if (ITestService::A44 != 1) {
- cerr << "ITestService::A44 should be 1 but is " << ITestService::A44 << endl;
- ret = false;
- }
- if (ITestService::A45 != 1) {
- cerr << "ITestService::A45 should be 1 but is " << ITestService::A45 << endl;
- ret = false;
- }
- if (ITestService::A46 != 1) {
- cerr << "ITestService::A46 should be 1 but is " << ITestService::A46 << endl;
- ret = false;
- }
- if (ITestService::A47 != 1) {
- cerr << "ITestService::A47 should be 1 but is " << ITestService::A47 << endl;
- ret = false;
- }
- if (ITestService::A48 != 1) {
- cerr << "ITestService::A48 should be 1 but is " << ITestService::A48 << endl;
- ret = false;
- }
- if (ITestService::A49 != 1) {
- cerr << "ITestService::A49 should be 1 but is " << ITestService::A49 << endl;
- ret = false;
- }
- if (ITestService::A50 != 1) {
- cerr << "ITestService::A50 should be 1 but is " << ITestService::A50 << endl;
- ret = false;
- }
- if (ITestService::A51 != 1) {
- cerr << "ITestService::A51 should be 1 but is " << ITestService::A51 << endl;
- ret = false;
- }
- if (ITestService::A52 != 1) {
- cerr << "ITestService::A52 should be 1 but is " << ITestService::A52 << endl;
- ret = false;
- }
- if (ITestService::A53 != 1) {
- cerr << "ITestService::A53 should be 1 but is " << ITestService::A53 << endl;
- ret = false;
- }
- if (ITestService::A54 != 1) {
- cerr << "ITestService::A54 should be 1 but is " << ITestService::A54 << endl;
- ret = false;
- }
- if (ITestService::A55 != 1) {
- cerr << "ITestService::A55 should be 1 but is " << ITestService::A55 << endl;
- ret = false;
- }
- if (ITestService::A56 != 1) {
- cerr << "ITestService::A56 should be 1 but is " << ITestService::A56 << endl;
- ret = false;
- }
- if (ITestService::A57 != 1) {
- cerr << "ITestService::A57 should be 1 but is " << ITestService::A57 << endl;
- ret = false;
- }
-
- return ret;
+TEST_F(AidlPrimitiveTest, constantExpressions) {
+ EXPECT_THAT(ITestService::A1, Eq(1));
+ EXPECT_THAT(ITestService::A2, Eq(1));
+ EXPECT_THAT(ITestService::A3, Eq(1));
+ EXPECT_THAT(ITestService::A4, Eq(1));
+ EXPECT_THAT(ITestService::A5, Eq(1));
+ EXPECT_THAT(ITestService::A6, Eq(1));
+ EXPECT_THAT(ITestService::A7, Eq(1));
+ EXPECT_THAT(ITestService::A8, Eq(1));
+ EXPECT_THAT(ITestService::A9, Eq(1));
+ EXPECT_THAT(ITestService::A10, Eq(1));
+ EXPECT_THAT(ITestService::A11, Eq(1));
+ EXPECT_THAT(ITestService::A12, Eq(1));
+ EXPECT_THAT(ITestService::A13, Eq(1));
+ EXPECT_THAT(ITestService::A14, Eq(1));
+ EXPECT_THAT(ITestService::A15, Eq(1));
+ EXPECT_THAT(ITestService::A16, Eq(1));
+ EXPECT_THAT(ITestService::A17, Eq(1));
+ EXPECT_THAT(ITestService::A18, Eq(1));
+ EXPECT_THAT(ITestService::A19, Eq(1));
+ EXPECT_THAT(ITestService::A20, Eq(1));
+ EXPECT_THAT(ITestService::A21, Eq(1));
+ EXPECT_THAT(ITestService::A22, Eq(1));
+ EXPECT_THAT(ITestService::A23, Eq(1));
+ EXPECT_THAT(ITestService::A24, Eq(1));
+ EXPECT_THAT(ITestService::A25, Eq(1));
+ EXPECT_THAT(ITestService::A26, Eq(1));
+ EXPECT_THAT(ITestService::A27, Eq(1));
+ EXPECT_THAT(ITestService::A28, Eq(1));
+ EXPECT_THAT(ITestService::A29, Eq(1));
+ EXPECT_THAT(ITestService::A30, Eq(1));
+ EXPECT_THAT(ITestService::A31, Eq(1));
+ EXPECT_THAT(ITestService::A32, Eq(1));
+ EXPECT_THAT(ITestService::A33, Eq(1));
+ EXPECT_THAT(ITestService::A34, Eq(1));
+ EXPECT_THAT(ITestService::A35, Eq(1));
+ EXPECT_THAT(ITestService::A36, Eq(1));
+ EXPECT_THAT(ITestService::A37, Eq(1));
+ EXPECT_THAT(ITestService::A38, Eq(1));
+ EXPECT_THAT(ITestService::A39, Eq(1));
+ EXPECT_THAT(ITestService::A40, Eq(1));
+ EXPECT_THAT(ITestService::A41, Eq(1));
+ EXPECT_THAT(ITestService::A42, Eq(1));
+ EXPECT_THAT(ITestService::A43, Eq(1));
+ EXPECT_THAT(ITestService::A44, Eq(1));
+ EXPECT_THAT(ITestService::A45, Eq(1));
+ EXPECT_THAT(ITestService::A46, Eq(1));
+ EXPECT_THAT(ITestService::A47, Eq(1));
+ EXPECT_THAT(ITestService::A48, Eq(1));
+ EXPECT_THAT(ITestService::A49, Eq(1));
+ EXPECT_THAT(ITestService::A50, Eq(1));
+ EXPECT_THAT(ITestService::A51, Eq(1));
+ EXPECT_THAT(ITestService::A52, Eq(1));
+ EXPECT_THAT(ITestService::A53, Eq(1));
+ EXPECT_THAT(ITestService::A54, Eq(1));
+ EXPECT_THAT(ITestService::A55, Eq(1));
+ EXPECT_THAT(ITestService::A56, Eq(1));
+ EXPECT_THAT(ITestService::A57, Eq(1));
}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
diff --git a/tests/aidl_test_client_primitives.h b/tests/aidl_test_client_primitives.h
deleted file mode 100644
index 0c2fef5..0000000
--- a/tests/aidl_test_client_primitives.h
+++ /dev/null
@@ -1,41 +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 ANDROID_AIDL_TESTS_CLIENT_PRIMITIVES_H
-#define ANDROID_AIDL_TESTS_CLIENT_PRIMITIVES_H
-
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-// Tests for passing and returning primitive types defined in the AIDL docs.
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmPrimitiveRepeat(const sp<ITestService>& s);
-bool ConfirmReverseArrays(const android::sp<ITestService>& s);
-bool ConfirmReverseLists(const android::sp<ITestService>& s);
-bool ConfirmReverseBinderLists(const android::sp<ITestService>& s);
-bool ConfirmIntfConstantExpressions(const sp<ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_PRIMITIVES_H
diff --git a/tests/aidl_test_client_renamed_interface.cpp b/tests/aidl_test_client_renamed_interface.cpp
new file mode 100644
index 0000000..7bb2296
--- /dev/null
+++ b/tests/aidl_test_client_renamed_interface.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 "aidl_test_client.h"
+#include "gmock/gmock.h"
+
+#include <android/aidl/tests/INewName.h>
+#include <android/aidl/tests/IOldName.h>
+
+using android::IInterface;
+using android::String16;
+using android::aidl::tests::INewName;
+using android::aidl::tests::IOldName;
+using testing::Eq;
+
+class RenamedInterfaceTest : public AidlTest {
+ public:
+ void SetUp() override {
+ AidlTest::SetUp();
+
+ ASSERT_TRUE(service->GetOldNameInterface(&oldName).isOk());
+ ASSERT_TRUE(service->GetNewNameInterface(&newName).isOk());
+ }
+
+ sp<IOldName> oldName;
+ sp<INewName> newName;
+};
+
+TEST_F(RenamedInterfaceTest, oldAsOld) {
+ ASSERT_THAT(String16("android.aidl.tests.IOldName"), oldName->getInterfaceDescriptor());
+ String16 realName;
+ ASSERT_TRUE(oldName->RealName(&realName).isOk());
+ ASSERT_THAT(String16("OldName"), realName);
+}
+
+TEST_F(RenamedInterfaceTest, newAsNew) {
+ ASSERT_THAT(String16("android.aidl.tests.IOldName"), newName->getInterfaceDescriptor());
+ String16 realName;
+ ASSERT_TRUE(newName->RealName(&realName).isOk());
+ ASSERT_THAT(String16("NewName"), realName);
+}
+
+TEST_F(RenamedInterfaceTest, oldAsNew) {
+ sp<INewName> oldAsNew = INewName::asInterface(IInterface::asBinder(oldName));
+ ASSERT_THAT(String16("android.aidl.tests.IOldName"), oldAsNew->getInterfaceDescriptor());
+ String16 realName;
+ ASSERT_TRUE(oldAsNew->RealName(&realName).isOk());
+ ASSERT_THAT(String16("OldName"), realName);
+}
+
+TEST_F(RenamedInterfaceTest, newAsOld) {
+ sp<IOldName> newAsOld = IOldName::asInterface(IInterface::asBinder(newName));
+ ASSERT_THAT(String16("android.aidl.tests.IOldName"), newAsOld->getInterfaceDescriptor());
+ String16 realName;
+ ASSERT_TRUE(newAsOld->RealName(&realName).isOk());
+ ASSERT_THAT(String16("NewName"), realName);
+}
diff --git a/tests/aidl_test_client_service_exceptions.cpp b/tests/aidl_test_client_service_exceptions.cpp
index 3f1f374..df3b29f 100644
--- a/tests/aidl_test_client_service_exceptions.cpp
+++ b/tests/aidl_test_client_service_exceptions.cpp
@@ -14,36 +14,26 @@
* limitations under the License.
*/
-#include "aidl_test_client_service_exceptions.h"
+#include "aidl_test_client.h"
+#include "gmock/gmock.h"
-#include <iostream>
-
-#include "binder/Status.h"
-
-using android::binder::Status;
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmServiceSpecificExceptions(const sp<ITestService>& s) {
- cout << "Confirming application exceptions work" << endl;
-
- for (int32_t i = -1; i < 2; ++i) {
- Status status = s->ThrowServiceException(i);
- if (status.exceptionCode() != Status::EX_SERVICE_SPECIFIC ||
- status.serviceSpecificErrorCode() != i) {
- return false;
- }
- }
-
- return true;
+TEST_F(AidlTest, onewayNoError) {
+ // oneway servers try to return an error
+ auto status = service->TestOneway();
+ EXPECT_TRUE(status.isOk()) << status;
}
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
+TEST_F(AidlTest, serviceSpecificException) {
+ if (backend == BackendType::JAVA) {
+ // TODO(b/169704480): investigate why this is returning 'unexpected null'
+ GTEST_SKIP() << "Broken in Java? b/169704480";
+ }
+
+ 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)) << status;
+ ASSERT_THAT(status.serviceSpecificErrorCode(), Eq(i)) << status;
+ }
+}
diff --git a/tests/aidl_test_client_service_exceptions.h b/tests/aidl_test_client_service_exceptions.h
deleted file mode 100644
index e4a1dd3..0000000
--- a/tests/aidl_test_client_service_exceptions.h
+++ /dev/null
@@ -1,37 +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 ANDROID_AIDL_TESTS_CLIENT_SERVICE_EXCEPTIONS_H
-#define ANDROID_AIDL_TESTS_CLIENT_SERVICE_EXCEPTIONS_H
-
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-// Tests for service specific exception support.
-bool ConfirmServiceSpecificExceptions(const sp<ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_SERVICE_EXCEPTIONS_H
diff --git a/tests/aidl_test_client_utf8_strings.cpp b/tests/aidl_test_client_utf8_strings.cpp
index 658759c..6e3602b 100644
--- a/tests/aidl_test_client_utf8_strings.cpp
+++ b/tests/aidl_test_client_utf8_strings.cpp
@@ -14,172 +14,135 @@
* limitations under the License.
*/
-#include "aidl_test_client_utf8_strings.h"
-
-#include <android-base/logging.h>
-#include <binder/Status.h>
-#include <utils/StrongPointer.h>
-
-#include <memory>
+#include <optional>
#include <string>
#include <vector>
-#include "android/aidl/tests/ITestService.h"
-#include "test_helpers.h"
+#include <utils/String16.h>
+#include <utils/String8.h>
-// libutils:
+#include "aidl_test_client.h"
+#include "gmock/gmock.h"
+
+using android::IBinder;
using android::sp;
-
-// libbinder:
+using android::String16;
+using android::String8;
using android::binder::Status;
-// generated
+using android::aidl::tests::BackendType;
using android::aidl::tests::ITestService;
-using std::unique_ptr;
-using std::string;
-using std::vector;
+using testing::Eq;
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmUtf8InCppStringRepeat(const sp<ITestService>& s) {
- const vector<string> utf8_inputs = {
- string("Deliver us from evil."),
- string(),
- string("\0\0", 2),
+TEST_F(AidlTest, repeatUtf8String) {
+ const std::vector<std::string> utf8_inputs = {
+ std::string("Deliver us from evil."),
+ std::string(),
+ std::string("\0\0", 2),
// Similarly, the utf8 encodings of the small letter yee and euro sign.
- string("\xF0\x90\x90\xB7\xE2\x82\xAC"),
+ std::string("\xF0\x90\x90\xB7\xE2\x82\xAC"),
ITestService::STRING_TEST_CONSTANT_UTF8(),
};
- LOG(INFO) << "Confirming repeating utf8 strings works.";
for (const auto& input : utf8_inputs) {
- string reply;
- Status status = s->RepeatUtf8CppString(input, &reply);
- if (!status.isOk() || input != reply) {
- LOG(ERROR) << "Failed while requesting service to repeat utf8 string=\""
- << input
- << "\". Got status=" << status.toString8()
- << " and output=" << reply;
- return false;
- }
+ std::string reply;
+ auto status = service->RepeatUtf8CppString(input, &reply);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_THAT(reply, Eq(input));
}
- unique_ptr<string> ret;
- Status repeat_null_status = s->RepeatNullableUtf8CppString(nullptr, &ret);
- if (!repeat_null_status.isOk() || ret) {
- LOG(ERROR) << "RepeatNullableUtf8CppString(null) did not return null";
- return false;
- }
+ std::optional<std::string> reply;
+ auto status = service->RepeatNullableUtf8CppString(std::nullopt, &reply);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_FALSE(reply.has_value());
for (const auto& input : utf8_inputs) {
- unique_ptr<string> reply;
- Status status = s->RepeatNullableUtf8CppString(
- unique_ptr<string>(new string(input)), &reply);
- if (!status.isOk()) {
- LOG(ERROR) << "Got status=" << status.toString8() << " while repeating "
- "nullable utf8 string " << input;
- return false;
- }
- if (!reply) {
- LOG(ERROR) << "Got null reply while repeating nullable utf8 string "
- << input;
- return false;
- }
- if (input != *reply) {
- LOG(ERROR) << "Failed while requesting service to repeat utf8 string=\""
- << input
- << "\". Got status=" << status.toString8()
- << " and output=" << *reply;
- return false;
- }
+ std::optional<std::string> reply;
+ auto status = service->RepeatNullableUtf8CppString(input, &reply);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(reply.has_value());
+ ASSERT_THAT(*reply, Eq(input));
}
-
- return true;
}
-bool ConfirmUtf8InCppStringArrayReverse(const sp<ITestService>& s) {
- LOG(INFO) << "Confirming passing and returning utf8 string arrays works.";
- if (!ReverseArray(s, &ITestService::ReverseUtf8CppString,
- {string{"a"}, string{}, string{"\xc3\xb8"}})) {
- return false;
+TEST_F(AidlTest, reverseUtf8StringArray) {
+ std::vector<std::string> input = {"a", "", "\xc3\xb8"};
+ decltype(input) repeated;
+ if (backend == BackendType::JAVA) {
+ repeated = decltype(input)(input.size());
}
+ decltype(input) reversed;
- return true;
+ auto status = service->ReverseUtf8CppString(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status;
+ ASSERT_THAT(repeated, Eq(input));
+
+ decltype(input) reversed_input(input);
+ std::reverse(reversed_input.begin(), reversed_input.end());
+ ASSERT_THAT(reversed, Eq(reversed_input));
}
-namespace {
+struct AidlStringArrayTest : public AidlTest {
+ void DoTest(
+ Status (ITestService::*func)(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>>>*)) {
+ std::optional<std::vector<std::optional<std::string>>> input;
+ decltype(input) repeated;
+ decltype(input) reversed;
-bool ConfirmUtf8InCppStringCollectionReverse(const sp<ITestService>& s,
- Status (ITestService::*m)(const unique_ptr<vector<unique_ptr<string>>>&,
- unique_ptr<vector<unique_ptr<string>>>*,
- unique_ptr<vector<unique_ptr<string>>>*)) {
- (void)m;
- LOG(INFO) << "Confirming reversing a list of utf8 strings works";
- unique_ptr<vector<unique_ptr<string>>> input, reversed, repeated;
- Status status = (s.get()->*m)(input, &reversed, &repeated);
- if (!status.isOk() || reversed || repeated) {
- LOG(ERROR) << "Reversing null list of utf8 strings failed.";
- return false;
- }
+ auto status = (*service.*func)(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status;
- input.reset(new vector<unique_ptr<string>>);
- input->emplace_back(new string("Deliver us from evil."));
- input->emplace_back(nullptr);
- input->emplace_back(new string("\xF0\x90\x90\xB7\xE2\x82\xAC"));
+ if (func == &ITestService::ReverseUtf8CppStringList && backend == BackendType::JAVA) {
+ // Java cannot clear the input variable to return a null value. It can
+ // only ever fill out a list.
+ ASSERT_TRUE(repeated.has_value());
+ } else {
+ ASSERT_FALSE(repeated.has_value());
+ }
- status = s->ReverseUtf8CppStringList(input, &repeated, &reversed);
- if (!status.isOk() || !reversed || !repeated) {
- LOG(ERROR) << "Reversing list of utf8 strings failed.";
- return false;
- }
- if (reversed->size() != input->size() || repeated->size() != input->size()) {
- LOG(ERROR) << "Bad output sizes.";
- return false;
- }
+ ASSERT_FALSE(reversed.has_value());
- for (size_t i = 0; i < input->size(); ++i) {
- const string* input_str = (*input)[i].get();
- const string* repeated_str = (*repeated)[i].get();
- const string* reversed_str = (*reversed)[(reversed->size() - 1) - i].get();
- if (!input_str) {
- if(repeated_str || reversed_str) {
- LOG(ERROR) << "Expected null values, but got non-null.";
- return false;
+ input = std::vector<std::optional<std::string>>();
+ input->push_back("Deliver us from evil.");
+ input->push_back(std::nullopt);
+ input->push_back("\xF0\x90\x90\xB7\xE2\x82\xAC");
+
+ // usable size needs to be initialized for Java
+ repeated = std::vector<std::optional<std::string>>(input->size());
+
+ status = (*service.*func)(input, &repeated, &reversed);
+ ASSERT_TRUE(status.isOk()) << status;
+ ASSERT_TRUE(reversed.has_value());
+ ASSERT_TRUE(repeated.has_value());
+ ASSERT_THAT(reversed->size(), Eq(input->size()));
+ ASSERT_THAT(repeated->size(), Eq(input->size()));
+
+ for (size_t i = 0; i < input->size(); i++) {
+ auto input_str = (*input)[i];
+ auto repeated_str = (*repeated)[i];
+ auto reversed_str = (*reversed)[(reversed->size() - 1) - i];
+ if (!input_str) {
+ ASSERT_FALSE(repeated_str.has_value());
+ ASSERT_FALSE(reversed_str.has_value());
+ // 3 nullptrs to strings. No need to compare values.
+ continue;
}
- // 3 nullptrs to strings. No need to compare values.
- continue;
- }
- if (!repeated_str || !reversed_str) {
- LOG(ERROR) << "Expected non-null values, but got null.";
- return false;
- }
- if (*input_str != *repeated_str || *input_str != *reversed_str) {
- LOG(ERROR) << "Expected '" << *input_str << "' but got "
- << "repeated='" << *repeated_str << "' and "
- << "reversed='" << *reversed_str;
- return false;
+ ASSERT_TRUE(repeated_str.has_value());
+ ASSERT_TRUE(reversed_str.has_value());
+
+ ASSERT_THAT(*repeated_str, Eq(*input_str));
+ ASSERT_THAT(*reversed_str, Eq(*input_str));
}
}
- return true;
+};
+
+TEST_F(AidlStringArrayTest, nullableList) {
+ DoTest(&ITestService::ReverseUtf8CppStringList);
}
-} // namespace
-
-bool ConfirmUtf8InCppStringListReverse(const sp<ITestService>& s) {
- return ConfirmUtf8InCppStringCollectionReverse(s,
- &ITestService::ReverseUtf8CppStringList);
+TEST_F(AidlStringArrayTest, nullableArray) {
+ DoTest(&ITestService::ReverseNullableUtf8CppString);
}
-
-bool ConfirmUtf8InCppNullableStringArrayReverse(const sp<ITestService>& s) {
- return ConfirmUtf8InCppStringCollectionReverse(s,
- &ITestService::ReverseNullableUtf8CppString);
-}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
diff --git a/tests/aidl_test_client_utf8_strings.h b/tests/aidl_test_client_utf8_strings.h
deleted file mode 100644
index a362fd5..0000000
--- a/tests/aidl_test_client_utf8_strings.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-#ifndef ANDROID_AIDL_TESTS_CLIENT_UTF8_STRINGS_H
-#define ANDROID_AIDL_TESTS_CLIENT_UTF8_STRINGS_H
-
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-// Tests for passing and returning utf8 strings.
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-bool ConfirmUtf8InCppStringRepeat(
- const android::sp<android::aidl::tests::ITestService>& s);
-bool ConfirmUtf8InCppStringArrayReverse(
- const android::sp<android::aidl::tests::ITestService>& s);
-bool ConfirmUtf8InCppStringListReverse(
- const android::sp<android::aidl::tests::ITestService>& s);
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#endif // ANDROID_AIDL_TESTS_CLIENT_UTF8_STRINGS_H
-
diff --git a/tests/aidl_test_client_versioned_interface.cpp b/tests/aidl_test_client_versioned_interface.cpp
new file mode 100644
index 0000000..c42a41b
--- /dev/null
+++ b/tests/aidl_test_client_versioned_interface.cpp
@@ -0,0 +1,86 @@
+/*
+ * 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/versioned/tests/IFooInterface.h>
+#include <binder/IServiceManager.h>
+#include <gtest/gtest.h>
+#include <utils/String16.h>
+
+#include "aidl_test_client.h"
+
+using android::OK;
+using android::sp;
+using android::String16;
+using android::aidl::versioned::tests::BazUnion;
+using android::aidl::versioned::tests::Foo;
+using android::aidl::versioned::tests::IFooInterface;
+
+class VersionedInterfaceTest : public AidlTest {
+ public:
+ void SetUp() override {
+ ASSERT_EQ(OK, android::getService(IFooInterface::descriptor, &versioned));
+ ASSERT_NE(nullptr, versioned);
+
+ AidlTest::SetUp();
+ }
+
+ sp<IFooInterface> versioned;
+};
+
+TEST_F(VersionedInterfaceTest, getInterfaceVersion) {
+ EXPECT_EQ(1, versioned->getInterfaceVersion());
+}
+
+TEST_F(VersionedInterfaceTest, getInterfaceHash) {
+ EXPECT_EQ("9e7be1859820c59d9d55dd133e71a3687b5d2e5b", versioned->getInterfaceHash());
+}
+
+TEST_F(VersionedInterfaceTest, noProblemWhenPassingAUnionWithOldField) {
+ std::string result;
+ auto status =
+ versioned->acceptUnionAndReturnString(BazUnion::make<BazUnion::intNum>(42), &result);
+ EXPECT_TRUE(status.isOk());
+ EXPECT_EQ("42", result);
+}
+
+TEST_F(VersionedInterfaceTest, errorWhenPassingAUnionWithNewField) {
+ std::string result;
+ auto status =
+ versioned->acceptUnionAndReturnString(BazUnion::make<BazUnion::longNum>(42L), &result);
+ EXPECT_FALSE(status.isOk());
+ // b/173458620 - Java and C++ return different errors
+ if (backend == BackendType::JAVA) {
+ EXPECT_EQ(::android::binder::Status::EX_ILLEGAL_ARGUMENT, status.exceptionCode()) << status;
+ } else {
+ EXPECT_EQ(::android::BAD_VALUE, status.transactionError()) << status;
+ }
+}
+
+TEST_F(VersionedInterfaceTest, arrayOfParcelableWithNewParam) {
+ std::vector<Foo> foos(42);
+ int32_t length;
+ auto status = versioned->returnsLengthOfFooArray(foos, &length);
+ EXPECT_TRUE(status.isOk());
+ EXPECT_EQ(42, length);
+}
+
+TEST_F(VersionedInterfaceTest, readDataCorrectlyAfterParcelableWithNewField) {
+ Foo inFoo, inoutFoo, outFoo;
+ int32_t ret;
+ auto status = versioned->ignoreParcelablesAndRepeatInt(inFoo, &inoutFoo, &outFoo, 43, &ret);
+ EXPECT_TRUE(status.isOk());
+ EXPECT_EQ(43, ret);
+}
\ No newline at end of file
diff --git a/tests/aidl_test_sentinel_searcher.cpp b/tests/aidl_test_sentinel_searcher.cpp
deleted file mode 100644
index e260366..0000000
--- a/tests/aidl_test_sentinel_searcher.cpp
+++ /dev/null
@@ -1,111 +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 <fstream>
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include <errno.h>
-#include <time.h>
-#include <unistd.h>
-
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::getline;
-using std::ifstream;
-using std::string;
-using std::vector;
-
-namespace {
-
-bool ReadLines(const string& input_file_path, vector<string>* lines) {
- ifstream watched_file(input_file_path);
- if (!watched_file.is_open()) {
- cerr << "Unable to open input file: " << input_file_path << endl;
- return false;
- }
-
- string line;
- while (getline(watched_file, line)) {
- lines->push_back(line);
- }
- watched_file.close();
- return true;
-}
-
-bool HasSentinel(const vector<string>& lines, const string& sentinel) {
- for (const auto& line : lines) {
- if (line.find(sentinel) != string::npos) {
- return true;
- }
- }
- return false;
-}
-
-} // namespace
-
-int main(int argc, const char* argv[]) {
- if (argc != 5) {
- cerr << "Invalid usage." << endl;
- cerr << argv[0]
- << " <timeout in seconds>"
- << " <input file path>"
- << " <success sentinel>"
- << " <failure sentinel>" << endl;
- return -EINVAL;
- }
- const string timeout_as_str = argv[1];
- const string input_file_path = argv[2];
- const string success_sentinel = argv[3];
- const string failure_sentinel = argv[4];
-
- const int timeout_seconds = atoi(timeout_as_str.c_str());
- if (timeout_seconds <= 0) {
- cerr << "Invalid timeout value (in seconds): " << timeout_as_str << endl;
- return -EINVAL;
- }
-
- int exit_code = 1;
- const time_t start_time = time(nullptr);
- vector<string> lines;
- while (true) {
- sleep(1);
- if (time(nullptr) - start_time > timeout_seconds) {
- cerr << "Timed out waiting for success/failure sentinel." << endl;
- break;
- }
- // Ignore errors when reading lines. The file may not immediately exist
- // because it takes the Java process some time to create it.
- lines.clear();
- ReadLines(input_file_path, &lines);
-
- if (HasSentinel(lines, success_sentinel)) {
- exit_code = 0;
- break;
- }
- if (HasSentinel(lines, failure_sentinel)) {
- break;
- }
- }
-
- cout << "Found output:" << endl;
- for (const auto& line : lines) {
- cout << " " << line << endl;
- }
- return exit_code;
-}
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index 113d1f5..22cd42b 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -15,6 +15,7 @@
*/
#include <map>
+#include <optional>
#include <sstream>
#include <string>
#include <vector>
@@ -30,14 +31,32 @@
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/Looper.h>
+#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"
#include "android/aidl/tests/BnNamedCallback.h"
#include "android/aidl/tests/INamedCallback.h"
+#include "android/aidl/versioned/tests/BnFooInterface.h"
+#include "android/aidl/versioned/tests/IFooInterface.h"
+
+#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"
@@ -51,6 +70,7 @@
using android::OK;
using android::sp;
using android::String16;
+using android::String8;
// libbinder:
using android::BnInterface;
@@ -62,21 +82,31 @@
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;
using android::aidl::tests::BnTestService;
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;
+using android::aidl::tests::IOldName;
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;
// Standard library
using std::map;
+using std::optional;
using std::string;
-using std::unique_ptr;
using std::vector;
namespace {
@@ -105,6 +135,150 @@
String16 name_;
};
+class OldName : public BnOldName {
+ public:
+ OldName() = default;
+ ~OldName() = default;
+
+ Status RealName(String16* output) override {
+ *output = String16("OldName");
+ return Status::ok();
+ }
+};
+
+class NewName : public BnNewName {
+ public:
+ NewName() = default;
+ ~NewName() = default;
+
+ Status RealName(String16* output) override {
+ *output = String16("NewName");
+ 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();
+}
+
+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;
+ ep2->b = ep.b;
+ std::shared_ptr<android::aidl::tests::extension::MyExt> myExt;
+ ep.ext.getParcelable(&myExt);
+ ep2->ext.setParcelable(myExt);
+
+ return Status::ok();
+ }
+};
+
class NativeService : public BnTestService {
public:
NativeService() {}
@@ -122,6 +296,10 @@
ALOGI("Repeating token %s", token_str.str().c_str());
}
+ Status TestOneway() override { return Status::fromStatusT(android::UNKNOWN_ERROR); }
+
+ Status Deprecated() override { return Status::ok(); }
+
Status RepeatBoolean(bool token, bool* _aidl_return) override {
LogRepeatedToken(token ? 1 : 0);
*_aidl_return = token;
@@ -178,45 +356,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 unique_ptr<T>& input,
- unique_ptr<T>* _aidl_return) {
- ALOGI("Repeating nullable value");
-
- _aidl_return->reset();
- if (input) {
- _aidl_return->reset(new T(*input));
- }
-
- return Status::ok();
- }
-
Status ReverseBoolean(const vector<bool>& input,
vector<bool>* repeated,
vector<bool>* _aidl_return) override {
@@ -269,18 +408,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 {
@@ -311,31 +438,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");
@@ -361,55 +463,38 @@
return Status::fromServiceSpecificError(code);
}
- Status RepeatNullableIntArray(const unique_ptr<vector<int32_t>>& input,
- unique_ptr<vector<int32_t>>* _aidl_return) {
+ Status RepeatNullableIntArray(const optional<vector<int32_t>>& input,
+ optional<vector<int32_t>>* _aidl_return) {
return RepeatNullable(input, _aidl_return);
}
- Status RepeatNullableByteEnumArray(const unique_ptr<vector<ByteEnum>>& input,
- unique_ptr<vector<ByteEnum>>* _aidl_return) {
+ Status RepeatNullableByteEnumArray(const optional<vector<ByteEnum>>& input,
+ optional<vector<ByteEnum>>* _aidl_return) {
return RepeatNullable(input, _aidl_return);
}
- Status RepeatNullableIntEnumArray(const unique_ptr<vector<IntEnum>>& input,
- unique_ptr<vector<IntEnum>>* _aidl_return) {
+ Status RepeatNullableIntEnumArray(const optional<vector<IntEnum>>& input,
+ optional<vector<IntEnum>>* _aidl_return) {
return RepeatNullable(input, _aidl_return);
}
- Status RepeatNullableLongEnumArray(const unique_ptr<vector<LongEnum>>& input,
- unique_ptr<vector<LongEnum>>* _aidl_return) {
+ Status RepeatNullableLongEnumArray(const optional<vector<LongEnum>>& input,
+ optional<vector<LongEnum>>* _aidl_return) {
return RepeatNullable(input, _aidl_return);
}
- Status RepeatNullableStringList(
- const unique_ptr<vector<unique_ptr<String16>>>& input,
- unique_ptr<vector<unique_ptr<String16>>>* _aidl_return) {
+ Status RepeatNullableStringList(const optional<vector<optional<String16>>>& input,
+ optional<vector<optional<String16>>>* _aidl_return) {
ALOGI("Repeating nullable string list");
- if (!input) {
- _aidl_return->reset();
- return Status::ok();
- }
-
- _aidl_return->reset(new vector<unique_ptr<String16>>);
-
- for (const auto& item : *input) {
- if (!item) {
- (*_aidl_return)->emplace_back(nullptr);
- } else {
- (*_aidl_return)->emplace_back(new String16(*item));
- }
- }
-
- return Status::ok();
- }
-
- Status RepeatNullableString(const unique_ptr<String16>& input,
- unique_ptr<String16>* _aidl_return) {
return RepeatNullable(input, _aidl_return);
}
- Status RepeatNullableParcelable(const unique_ptr<SimpleParcelable>& input,
- unique_ptr<SimpleParcelable>* _aidl_return) {
+ Status RepeatNullableString(const optional<String16>& input, optional<String16>* _aidl_return) {
+ return RepeatNullable(input, _aidl_return);
+ }
+
+ Status RepeatNullableParcelable(const optional<StructuredParcelable>& input,
+ optional<StructuredParcelable>* _aidl_return) {
return RepeatNullable(input, _aidl_return);
}
@@ -417,18 +502,10 @@
(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 unique_ptr<vector<sp<IBinder>>>& input) {
- (void)input;
- return Status::ok();
- }
Status RepeatUtf8CppString(const string& token,
string* _aidl_return) override {
@@ -437,16 +514,15 @@
return Status::ok();
}
- Status RepeatNullableUtf8CppString(
- const unique_ptr<string>& token,
- unique_ptr<string>* _aidl_return) override {
+ Status RepeatNullableUtf8CppString(const optional<string>& token,
+ optional<string>* _aidl_return) override {
if (!token) {
ALOGI("Received null @utf8InCpp string");
return Status::ok();
}
ALOGI("Repeating utf8 string '%s' of length=%zu",
token->c_str(), token->size());
- _aidl_return->reset(new string(*token));
+ *_aidl_return = token;
return Status::ok();
}
@@ -456,35 +532,22 @@
return ReverseArray(input, repeated, _aidl_return);
}
- Status ReverseNullableUtf8CppString(
- const unique_ptr<vector<unique_ptr<string>>>& input,
- unique_ptr<vector<unique_ptr<string>>>* repeated,
- unique_ptr<vector<unique_ptr<string>>>* _aidl_return) {
-
+ Status ReverseNullableUtf8CppString(const optional<vector<optional<string>>>& input,
+ optional<vector<optional<string>>>* repeated,
+ optional<vector<optional<string>>>* _aidl_return) {
return ReverseUtf8CppStringList(input, repeated, _aidl_return);
}
- Status ReverseUtf8CppStringList(
- const unique_ptr<vector<unique_ptr<::string>>>& input,
- unique_ptr<vector<unique_ptr<string>>>* repeated,
- unique_ptr<vector<unique_ptr<string>>>* _aidl_return) {
+ Status ReverseUtf8CppStringList(const optional<vector<optional<string>>>& input,
+ optional<vector<optional<string>>>* repeated,
+ optional<vector<optional<string>>>* _aidl_return) {
if (!input) {
ALOGI("Received null list of utf8 strings");
return Status::ok();
}
- _aidl_return->reset(new vector<unique_ptr<string>>);
- repeated->reset(new vector<unique_ptr<string>>);
-
- for (const auto& item : *input) {
- (*repeated)->emplace_back(nullptr);
- (*_aidl_return)->emplace_back(nullptr);
- if (item) {
- (*repeated)->back().reset(new string(*item));
- (*_aidl_return)->back().reset(new string(*item));
- }
- }
+ *_aidl_return = input;
+ *repeated = input;
std::reverse((*_aidl_return)->begin(), (*_aidl_return)->end());
-
return Status::ok();
}
@@ -495,8 +558,7 @@
return Status::ok();
}
- virtual ::android::binder::Status FillOutStructuredParcelable(
- ::android::aidl::tests::StructuredParcelable* parcelable) {
+ virtual ::android::binder::Status FillOutStructuredParcelable(StructuredParcelable* parcelable) {
parcelable->shouldBeJerry = "Jerry";
parcelable->shouldContainThreeFs = {parcelable->f, parcelable->f, parcelable->f};
parcelable->shouldBeByteBar = ByteEnum::BAR;
@@ -517,6 +579,10 @@
parcelable->const_exprs_9 = ConstantExpressionEnum::hexInt32_3;
parcelable->const_exprs_10 = ConstantExpressionEnum::hexInt64_1;
+ parcelable->shouldSetBit0AndBit2 = StructuredParcelable::BIT0 | StructuredParcelable::BIT2;
+
+ parcelable->u = Union::make<Union::ns>({1, 2, 3});
+ parcelable->shouldBeConstS1 = Union::S1();
return Status::ok();
}
@@ -524,9 +590,29 @@
LOG_ALWAYS_FATAL("UnimplementedMethod shouldn't be called");
}
+ Status GetOldNameInterface(sp<IOldName>* ret) {
+ *ret = new OldName;
+ return Status::ok();
+ }
+
+ Status GetNewNameInterface(sp<INewName>* ret) {
+ *ret = new NewName;
+ 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 + 53 /* UnimplementedMethod */) {
+ if (code == ::android::IBinder::FIRST_CALL_TRANSACTION + 0 /* UnimplementedMethod */) {
// pretend that UnimplementedMethod isn't implemented by this service.
return android::UNKNOWN_TRANSACTION;
} else {
@@ -538,6 +624,55 @@
map<String16, sp<INamedCallback>> service_map_;
};
+class VersionedService : public android::aidl::versioned::tests::BnFooInterface {
+ public:
+ VersionedService() {}
+ virtual ~VersionedService() = default;
+
+ 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();
+ }
+ Status returnsLengthOfFooArray(const vector<::android::aidl::versioned::tests::Foo>& foos,
+ int32_t* ret) override {
+ *ret = static_cast<int32_t>(foos.size());
+ return Status::ok();
+ }
+ Status ignoreParcelablesAndRepeatInt(const ::android::aidl::versioned::tests::Foo& inFoo,
+ ::android::aidl::versioned::tests::Foo* inoutFoo,
+ ::android::aidl::versioned::tests::Foo* outFoo,
+ int32_t value, int32_t* ret) override {
+ (void)inFoo;
+ (void)inoutFoo;
+ (void)outFoo;
+ *ret = value;
+ 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() {
android::sp<NativeService> service = new NativeService;
sp<Looper> looper(Looper::prepare(0 /* opts */));
@@ -556,8 +691,28 @@
return -1;
}
- defaultServiceManager()->addService(service->getInterfaceDescriptor(),
- service);
+ auto status = defaultServiceManager()->addService(service->getInterfaceDescriptor(), service);
+ if (status != OK) {
+ ALOGE("Failed to add service %s", String8(service->getInterfaceDescriptor()).c_str());
+ return -1;
+ }
+
+ android::sp<VersionedService> versionedService = new VersionedService;
+ status = defaultServiceManager()->addService(versionedService->getInterfaceDescriptor(),
+ versionedService);
+ if (status != OK) {
+ ALOGE("Failed to add service %s", String8(versionedService->getInterfaceDescriptor()).c_str());
+ 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) {
diff --git a/tests/android/aidl/loggable/Data.aidl b/tests/android/aidl/loggable/Data.aidl
new file mode 100644
index 0000000..63e8da4
--- /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 = Enum.FOO;
+}
diff --git a/tests/android/aidl/loggable/Enum.aidl b/tests/android/aidl/loggable/Enum.aidl
new file mode 100644
index 0000000..efdfa94
--- /dev/null
+++ b/tests/android/aidl/loggable/Enum.aidl
@@ -0,0 +1,3 @@
+package android.aidl.loggable;
+
+enum Enum { FOO = 42 }
diff --git a/tests/android/aidl/loggable/ILoggableInterface.aidl b/tests/android/aidl/loggable/ILoggableInterface.aidl
index 0b62df3..586ce34 100644
--- a/tests/android/aidl/loggable/ILoggableInterface.aidl
+++ b/tests/android/aidl/loggable/ILoggableInterface.aidl
@@ -1,15 +1,14 @@
package android.aidl.loggable;
+import android.aidl.loggable.Data;
interface ILoggableInterface {
- String[] LogThis(boolean boolValue, inout boolean[] boolArray,
- byte byteValue, inout byte[] byteArray,
- char charValue, inout char[] charArray,
- int intValue, inout int[] intArray,
- long longValue, inout long[] longArray,
- float floatValue, inout float[] floatArray,
- double doubleValue, inout double[] doubleArray,
- String stringValue, inout String[] stringArray,
- inout List<String> listValue,
- IBinder binderValue,
- inout ParcelFileDescriptor pfdValue, inout ParcelFileDescriptor[] pfdArray);
+ @SuppressWarnings(value={"inout-parameter", "out-array", "out-nullable"})
+ String[] LogThis(boolean boolValue, inout boolean[] boolArray, byte byteValue,
+ inout byte[] byteArray, char charValue, inout char[] charArray, int intValue,
+ inout int[] intArray, long longValue, inout long[] longArray, float floatValue,
+ inout float[] floatArray, double doubleValue, inout double[] doubleArray,
+ String stringValue, inout String[] stringArray, inout List<String> listValue,
+ 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..8e89808
--- /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;
+}
diff --git a/tests/android/aidl/tests/BackendType.aidl b/tests/android/aidl/tests/BackendType.aidl
new file mode 100644
index 0000000..56a6aa1
--- /dev/null
+++ b/tests/android/aidl/tests/BackendType.aidl
@@ -0,0 +1,8 @@
+package android.aidl.tests;
+
+enum BackendType {
+ CPP,
+ JAVA,
+ NDK,
+ RUST,
+}
diff --git a/tests/android/aidl/tests/ByteEnum.aidl b/tests/android/aidl/tests/ByteEnum.aidl
index 503ae8a..8934b52 100644
--- a/tests/android/aidl/tests/ByteEnum.aidl
+++ b/tests/android/aidl/tests/ByteEnum.aidl
@@ -21,9 +21,8 @@
*/
@Backing(type="byte")
enum ByteEnum {
- // Comment about FOO.
- FOO = 1,
- BAR = 2,
- BAZ,
+ // Comment about FOO.
+ FOO = 1,
+ BAR = 2,
+ BAZ,
}
-
diff --git a/tests/android/aidl/tests/ConstantExpressionEnum.aidl b/tests/android/aidl/tests/ConstantExpressionEnum.aidl
index 2fe4f61..413cf36 100644
--- a/tests/android/aidl/tests/ConstantExpressionEnum.aidl
+++ b/tests/android/aidl/tests/ConstantExpressionEnum.aidl
@@ -16,28 +16,28 @@
package android.aidl.tests;
+@SuppressWarnings(value={"const-name"})
@Backing(type="int")
enum ConstantExpressionEnum {
- // Should be all true / ones.
- // dec literals are either int or long
- decInt32_1 = (~(-1)) == 0,
- decInt32_2 = -(1 << 31) == (1 << 31),
- decInt64_1 = (~(-1L)) == 0,
- decInt64_2 = (~4294967295L) != 0,
- decInt64_3 = (~4294967295) != 0,
- decInt64_4 = -(1L << 63) == (1L << 63),
+ // Should be all true / ones.
+ // dec literals are either int or long
+ decInt32_1 = (~(-1)) == 0,
+ decInt32_2 = ~~(1 << 31) == (1 << 31),
+ decInt64_1 = (~(-1L)) == 0,
+ decInt64_2 = (~4294967295L) != 0,
+ decInt64_3 = (~4294967295) != 0,
+ decInt64_4 = ~~(1L << 63) == (1L << 63),
- // hex literals could be int or long
- // 0x7fffffff is int, hence can be negated
- hexInt32_1 = -0x7fffffff < 0,
+ // hex literals could be int or long
+ // 0x7fffffff is int, hence can be negated
+ hexInt32_1 = -0x7fffffff < 0,
- // 0x80000000 is int32_t max + 1
- hexInt32_2 = -0x80000000 < 0,
+ // 0x80000000 is int32_t max + 1
+ hexInt32_2 = 0x80000000 < 0,
- // 0xFFFFFFFF is int32_t, not long; if it were long then ~(long)0xFFFFFFFF != 0
- hexInt32_3 = ~0xFFFFFFFF == 0,
+ // 0xFFFFFFFF is int32_t, not long; if it were long then ~(long)0xFFFFFFFF != 0
+ hexInt32_3 = ~0xFFFFFFFF == 0,
- // 0x7FFFFFFFFFFFFFFF is long, hence can be negated
- hexInt64_1 = -0x7FFFFFFFFFFFFFFF < 0
+ // 0x7FFFFFFFFFFFFFFF is long, hence can be negated
+ hexInt64_1 = -0x7FFFFFFFFFFFFFFF < 0
}
-
diff --git a/tests/android/aidl/tests/DeprecatedEnum.aidl b/tests/android/aidl/tests/DeprecatedEnum.aidl
new file mode 100644
index 0000000..465a600
--- /dev/null
+++ b/tests/android/aidl/tests/DeprecatedEnum.aidl
@@ -0,0 +1,25 @@
+/*
+ * 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 android.aidl.tests;
+
+/** @deprecated test */
+@Backing(type="int")
+enum DeprecatedEnum {
+ A,
+ B,
+ C,
+}
diff --git a/tests/android/aidl/tests/DeprecatedParcelable.aidl b/tests/android/aidl/tests/DeprecatedParcelable.aidl
new file mode 100644
index 0000000..42737c4
--- /dev/null
+++ b/tests/android/aidl/tests/DeprecatedParcelable.aidl
@@ -0,0 +1,20 @@
+/*
+ * 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 android.aidl.tests;
+
+/** @deprecated test */
+parcelable DeprecatedParcelable {}
diff --git a/tests/android/aidl/tests/GenericStructuredParcelable.aidl b/tests/android/aidl/tests/GenericStructuredParcelable.aidl
new file mode 100644
index 0000000..066b24f
--- /dev/null
+++ b/tests/android/aidl/tests/GenericStructuredParcelable.aidl
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+@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..b0da53a
--- /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/IDeprecated.aidl b/tests/android/aidl/tests/IDeprecated.aidl
new file mode 100644
index 0000000..f143b69
--- /dev/null
+++ b/tests/android/aidl/tests/IDeprecated.aidl
@@ -0,0 +1,20 @@
+/*
+ * 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 android.aidl.tests;
+
+/** @deprecated test */
+interface IDeprecated {}
diff --git a/tests/android/aidl/tests/INamedCallback.aidl b/tests/android/aidl/tests/INamedCallback.aidl
index c295fef..003c16f 100644
--- a/tests/android/aidl/tests/INamedCallback.aidl
+++ b/tests/android/aidl/tests/INamedCallback.aidl
@@ -17,5 +17,5 @@
package android.aidl.tests;
interface INamedCallback {
- String GetName();
+ String GetName();
}
diff --git a/tests/android/aidl/tests/INewName.aidl b/tests/android/aidl/tests/INewName.aidl
new file mode 100644
index 0000000..d19500b
--- /dev/null
+++ b/tests/android/aidl/tests/INewName.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+@Descriptor(value="android.aidl.tests.IOldName")
+interface INewName {
+ String RealName();
+}
diff --git a/tests/android/aidl/tests/IOldName.aidl b/tests/android/aidl/tests/IOldName.aidl
new file mode 100644
index 0000000..fb27513
--- /dev/null
+++ b/tests/android/aidl/tests/IOldName.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+interface IOldName {
+ String RealName();
+}
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index 9b7f08c..1914a4c 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -16,190 +16,203 @@
package android.aidl.tests;
+import android.aidl.tests.BackendType;
import android.aidl.tests.ByteEnum;
import android.aidl.tests.INamedCallback;
+import android.aidl.tests.INewName;
+import android.aidl.tests.IOldName;
import android.aidl.tests.IntEnum;
import android.aidl.tests.LongEnum;
-import android.aidl.tests.SimpleParcelable;
import android.aidl.tests.StructuredParcelable;
-import android.os.PersistableBundle;
+@SuppressWarnings(value={"inout-parameter", "mixed-oneway", "out-array"})
+@SensitiveData
interface ITestService {
- // Test that constants are accessible
- const int TEST_CONSTANT = 42;
- const int TEST_CONSTANT2 = -42;
- const int TEST_CONSTANT3 = +42;
- const int TEST_CONSTANT4 = +4;
- const int TEST_CONSTANT5 = -4;
- const int TEST_CONSTANT6 = -0;
- const int TEST_CONSTANT7 = +0;
- const int TEST_CONSTANT8 = 0;
- const int TEST_CONSTANT9 = 0x56;
- const int TEST_CONSTANT10 = 0xa5;
- const int TEST_CONSTANT11 = 0xFA;
- const int TEST_CONSTANT12 = 0xffffffff;
+ // Test that constants are accessible
+ const int TEST_CONSTANT = 42;
+ const int TEST_CONSTANT2 = -42;
+ const int TEST_CONSTANT3 = +42;
+ const int TEST_CONSTANT4 = +4;
+ const int TEST_CONSTANT5 = -4;
+ const int TEST_CONSTANT6 = -0;
+ const int TEST_CONSTANT7 = +0;
+ const int TEST_CONSTANT8 = 0;
+ const int TEST_CONSTANT9 = 0x56;
+ const int TEST_CONSTANT10 = 0xa5;
+ const int TEST_CONSTANT11 = 0xFA;
+ const int TEST_CONSTANT12 = 0xffffffff;
- const String STRING_TEST_CONSTANT = "foo";
- const String STRING_TEST_CONSTANT2 = "bar";
+ const byte BYTE_TEST_CONSTANT = 17;
+ const long LONG_TEST_CONSTANT = 1L << 40;
- const @utf8InCpp String STRING_TEST_CONSTANT_UTF8 = "baz";
+ const String STRING_TEST_CONSTANT = "foo";
+ const String STRING_TEST_CONSTANT2 = "bar";
- // Test that primitives work as parameters and return types.
- boolean RepeatBoolean(boolean token);
- byte RepeatByte(byte token);
- char RepeatChar(char token);
- int RepeatInt(int token);
- long RepeatLong(long token);
- float RepeatFloat(float token);
- double RepeatDouble(double token);
- String RepeatString(String token);
- ByteEnum RepeatByteEnum(ByteEnum token);
- IntEnum RepeatIntEnum(IntEnum token);
- LongEnum RepeatLongEnum(LongEnum token);
+ const @utf8InCpp String STRING_TEST_CONSTANT_UTF8 = "baz";
- SimpleParcelable RepeatSimpleParcelable(in SimpleParcelable input,
- out SimpleParcelable repeat);
- PersistableBundle RepeatPersistableBundle(in PersistableBundle input);
+ // 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.
+ int UnimplementedMethod(int arg);
- // 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);
- char[] ReverseChar (in char[] input, out char[] repeated);
- int[] ReverseInt (in int[] input, out int[] repeated);
- long[] ReverseLong (in long[] input, out long[] repeated);
- float[] ReverseFloat (in float[] input, out float[] repeated);
- double[] ReverseDouble (in double[] input, out double[] repeated);
- String[] ReverseString (in String[] input, out String[] repeated);
- ByteEnum[] ReverseByteEnum (in ByteEnum[] input, out ByteEnum[] repeated);
- IntEnum[] ReverseIntEnum (in IntEnum[] input, out IntEnum[] repeated);
- LongEnum[] ReverseLongEnum (in LongEnum[] input, out LongEnum[] repeated);
+ /**
+ * @deprecated to make sure we have something in system/tools/aidl which does a compile check
+ * of deprecated and make sure this is reflected in goldens
+ */
+ void Deprecated();
- SimpleParcelable[] ReverseSimpleParcelables(in SimpleParcelable[] input,
- out SimpleParcelable[] repeated);
- PersistableBundle[] ReversePersistableBundles(
- in PersistableBundle[] input, out PersistableBundle[] repeated);
+ oneway void TestOneway();
- // Test that clients can send and receive Binders.
- INamedCallback GetOtherTestService(String name);
- boolean VerifyName(INamedCallback service, String name);
+ // Test that primitives work as parameters and return types.
+ boolean RepeatBoolean(boolean token);
+ byte RepeatByte(byte token);
+ char RepeatChar(char token);
+ int RepeatInt(int token);
+ long RepeatLong(long token);
+ float RepeatFloat(float token);
+ double RepeatDouble(double token);
+ String RepeatString(String token);
+ ByteEnum RepeatByteEnum(ByteEnum token);
+ IntEnum RepeatIntEnum(IntEnum token);
+ LongEnum RepeatLongEnum(LongEnum token);
- // 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);
+ // 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);
+ char[] ReverseChar(in char[] input, out char[] repeated);
+ int[] ReverseInt(in int[] input, out int[] repeated);
+ long[] ReverseLong(in long[] input, out long[] repeated);
+ float[] ReverseFloat(in float[] input, out float[] repeated);
+ double[] ReverseDouble(in double[] input, out double[] repeated);
+ String[] ReverseString(in String[] input, out String[] repeated);
+ ByteEnum[] ReverseByteEnum(in ByteEnum[] input, out ByteEnum[] repeated);
+ IntEnum[] ReverseIntEnum(in IntEnum[] input, out IntEnum[] repeated);
+ LongEnum[] ReverseLongEnum(in LongEnum[] input, out LongEnum[] repeated);
- FileDescriptor RepeatFileDescriptor(in FileDescriptor read);
- FileDescriptor[] ReverseFileDescriptorArray(in FileDescriptor[] input,
- out FileDescriptor[] repeated);
+ // Test that clients can send and receive Binders.
+ INamedCallback GetOtherTestService(String name);
+ boolean VerifyName(INamedCallback service, String name);
- ParcelFileDescriptor RepeatParcelFileDescriptor(in ParcelFileDescriptor read);
- ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(in ParcelFileDescriptor[] input,
- out ParcelFileDescriptor[] repeated);
+ // Test that List<T> types work correctly.
+ List<String> ReverseStringList(in List<String> input, out List<String> repeated);
- // Test that service specific exceptions work correctly.
- void ThrowServiceException(int code);
+ ParcelFileDescriptor RepeatParcelFileDescriptor(in ParcelFileDescriptor read);
+ ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(
+ in ParcelFileDescriptor[] input, out ParcelFileDescriptor[] repeated);
- // Test nullability
- @nullable int[] RepeatNullableIntArray(in @nullable int[] input);
- @nullable ByteEnum[] RepeatNullableByteEnumArray(in @nullable ByteEnum[] input);
- @nullable IntEnum[] RepeatNullableIntEnumArray(in @nullable IntEnum[] input);
- @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);
+ // Test that service specific exceptions work correctly.
+ void ThrowServiceException(int code);
- 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 nullability
+ @nullable int[] RepeatNullableIntArray(in @nullable int[] input);
+ @nullable ByteEnum[] RepeatNullableByteEnumArray(in @nullable ByteEnum[] input);
+ @nullable IntEnum[] RepeatNullableIntEnumArray(in @nullable IntEnum[] input);
+ @nullable LongEnum[] RepeatNullableLongEnumArray(in @nullable LongEnum[] input);
+ @nullable String RepeatNullableString(in @nullable String input);
+ @nullable List<String> RepeatNullableStringList(
+ in @nullable List<String> input);
+ @nullable StructuredParcelable RepeatNullableParcelable(
+ in @nullable StructuredParcelable input);
- // Test utf8 decoding from utf16 wire format
- @utf8InCpp String RepeatUtf8CppString(@utf8InCpp String token);
- @nullable @utf8InCpp String RepeatNullableUtf8CppString(
- @nullable @utf8InCpp String token);
+ void TakesAnIBinder(in IBinder input);
+ void TakesANullableIBinder(in @nullable IBinder input);
- @utf8InCpp String[] ReverseUtf8CppString (in @utf8InCpp String[] input,
- out @utf8InCpp String[] repeated);
+ // Test utf8 decoding from utf16 wire format
+ @utf8InCpp String RepeatUtf8CppString(@utf8InCpp String token);
+ @nullable @utf8InCpp String RepeatNullableUtf8CppString(
+ @nullable @utf8InCpp String token);
- @nullable @utf8InCpp String[] ReverseNullableUtf8CppString (
- in @nullable @utf8InCpp String[] input,
- out @nullable @utf8InCpp String[] repeated);
+ @utf8InCpp String[] ReverseUtf8CppString(
+ in @utf8InCpp String[] input, out @utf8InCpp String[] repeated);
- @nullable @utf8InCpp List<String> ReverseUtf8CppStringList(
- in @nullable @utf8InCpp List<String> input,
- out @nullable @utf8InCpp List<String> repeated);
+ @SuppressWarnings(value={"out-nullable"})
+ @nullable @utf8InCpp String[] ReverseNullableUtf8CppString(
+ in @nullable @utf8InCpp String[] input,
+ out @nullable @utf8InCpp String[] repeated);
- @nullable INamedCallback GetCallback(boolean return_null);
+ @SuppressWarnings(value={"out-nullable"})
+ @nullable @utf8InCpp List<String> ReverseUtf8CppStringList(
+ in @nullable @utf8InCpp List<String> input,
+ out @nullable @utf8InCpp List<String> repeated);
- // Since this paracelable has clearly defined default values, it would be
- // inefficient to use an IPC to fill it out in practice.
- void FillOutStructuredParcelable(inout StructuredParcelable parcel);
+ @nullable INamedCallback GetCallback(boolean return_null);
- // This is to emulate a method that is added after the service is implemented.
- // So the client cannot assume that 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
- // to actually implement this, but intercept the dispatch to the method
- // inside onTransact().
- int UnimplementedMethod(int arg);
+ // Since this paracelable has clearly defined default values, it would be
+ // inefficient to use an IPC to fill it out in practice.
+ void FillOutStructuredParcelable(inout StructuredParcelable parcel);
- // All these constant expressions should be equal to 1
- const int A1 = (~(-1)) == 0;
- const int A2 = -(1 << 31) == (1 << 31);
- const int A3 = -0x7fffffff < 0;
- const int A4 = -0x80000000 < 0;
- const int A5 = (1 + 0x7fffffff) == -2147483648;
- const int A6 = (1 << 31) == 0x80000000;
- const int A7 = (1 + 2) == 3;
- const int A8 = (8 - 9) == -1;
- const int A9 = (9 * 9) == 81;
- const int A10 = (29 / 3) == 9;
- const int A11 = (29 % 3) == 2;
- const int A12 = (0xC0010000 | 0xF00D) == (0xC001F00D);
- const int A13 = (10 | 6) == 14;
- const int A14 = (10 & 6) == 2;
- const int A15 = (10 ^ 6) == 12;
- const int A16 = 6 < 10;
- const int A17 = (10 < 10) == 0;
- const int A18 = (6 > 10) == 0;
- const int A19 = (10 > 10) == 0;
- const int A20 = 19 >= 10;
- const int A21 = 10 >= 10;
- const int A22 = 5 <= 10;
- const int A23 = (19 <= 10) == 0;
- const int A24 = 19 != 10;
- const int A25 = (10 != 10) == 0;
- const int A26 = (22 << 1) == 44;
- const int A27 = (11 >> 1) == 5;
- const int A28 = (1 || 0) == 1;
- const int A29 = (1 || 1) == 1;
- const int A30 = (0 || 0) == 0;
- const int A31 = (0 || 1) == 1;
- const int A32 = (1 && 0) == 0;
- const int A33 = (1 && 1) == 1;
- const int A34 = (0 && 0) == 0;
- const int A35 = (0 && 1) == 0;
- const int A36 = 4 == 4;
- const int A37 = -4 < 0;
- const int A38 = 0xffffffff == -1;
- const int A39 = 4 + 1 == 5;
- const int A40 = 2 + 3 - 4;
- const int A41 = 2 - 3 + 4 == 3;
- const int A42 = 1 == 4 == 0;
- const int A43 = 1 && 1;
- const int A44 = 1 || 1 && 0; // && higher than ||
- const int A45 = 1 < 2;
- const int A46 = !!((3 != 4 || (2 < 3 <= 3 > 4)) >= 0);
- const int A47 = !(1 == 7) && ((3 != 4 || (2 < 3 <= 3 > 4)) >= 0);
- const int A48 = (1 << 2) >= 0;
- const int A49 = (4 >> 1) == 2;
- const int A50 = (8 << -1) == 4;
- const int A51 = (1 << 31 >> 31) == -1;
- const int A52 = (1 | 16 >> 2) == 5;
- const int A53 = (0x0f ^ 0x33 & 0x99) == 0x1e; // & higher than ^
- const int A54 = (~42 & (1 << 3 | 16 >> 2) ^ 7) == 3;
- const int A55 = (2 + 3 - 4 * -7 / (10 % 3)) - 33 == 0;
- const int A56 = (2 + (-3&4 / 7)) == 2;
- const int A57 = (((((1 + 0)))));
+ // All these constant expressions should be equal to 1
+ const int A1 = (~(-1)) == 0;
+ const int A2 = ~~(1 << 31) == (1 << 31);
+ const int A3 = -0x7fffffff < 0;
+ const int A4 = 0x80000000 < 0;
+ const int A5 = 0x7fffffff == 2147483647;
+ const int A6 = (1 << 31) == 0x80000000;
+ const int A7 = (1 + 2) == 3;
+ const int A8 = (8 - 9) == -1;
+ const int A9 = (9 * 9) == 81;
+ const int A10 = (29 / 3) == 9;
+ const int A11 = (29 % 3) == 2;
+ const int A12 = (0xC0010000 | 0xF00D) == (0xC001F00D);
+ const int A13 = (10 | 6) == 14;
+ const int A14 = (10 & 6) == 2;
+ const int A15 = (10 ^ 6) == 12;
+ const int A16 = 6 < 10;
+ const int A17 = (10 < 10) == 0;
+ const int A18 = (6 > 10) == 0;
+ const int A19 = (10 > 10) == 0;
+ const int A20 = 19 >= 10;
+ const int A21 = 10 >= 10;
+ const int A22 = 5 <= 10;
+ const int A23 = (19 <= 10) == 0;
+ const int A24 = 19 != 10;
+ const int A25 = (10 != 10) == 0;
+ const int A26 = (22 << 1) == 44;
+ const int A27 = (11 >> 1) == 5;
+ const int A28 = (1 || 0) == 1;
+ const int A29 = (1 || 1) == 1;
+ const int A30 = (0 || 0) == 0;
+ const int A31 = (0 || 1) == 1;
+ const int A32 = (1 && 0) == 0;
+ const int A33 = (1 && 1) == 1;
+ const int A34 = (0 && 0) == 0;
+ const int A35 = (0 && 1) == 0;
+ const int A36 = 4 == 4;
+ const int A37 = -4 < 0;
+ const int A38 = 0xffffffff == -1;
+ const int A39 = 4 + 1 == 5;
+ const int A40 = 2 + 3 - 4;
+ const int A41 = 2 - 3 + 4 == 3;
+ const int A42 = 1 == 4 == 0;
+ const int A43 = 1 && 1;
+ const int A44 = 1 || 1 && 0; // && higher than ||
+ const int A45 = 1 < 2;
+ const int A46 = !!((3 != 4 || (2 < 3 <= 3 > 4)) >= 0);
+ const int A47 = !(1 == 7) && ((3 != 4 || (2 < 3 <= 3 > 4)) >= 0);
+ const int A48 = (1 << 2) >= 0;
+ const int A49 = (4 >> 1) == 2;
+ const int A50 = (8 << -1) == 4;
+ const int A51 = (1 << 30 >> 30) == 1;
+ const int A52 = (1 | 16 >> 2) == 5;
+ const int A53 = (0x0f ^ 0x33 & 0x99) == 0x1e; // & higher than ^
+ const int A54 = (~42 & (1 << 3 | 16 >> 2) ^ 7) == 3;
+ const int A55 = (2 + 3 - 4 * -7 / (10 % 3)) - 33 == 0;
+ const int A56 = (2 + (-3 & 4 / 7)) == 2;
+ const int A57 = (((((1 + 0)))));
+
+ IOldName GetOldNameInterface();
+ INewName GetNewNameInterface();
+
+ // Retrieve the ICppJavaTests if the server supports it
+ @nullable IBinder GetCppJavaTests();
+
+ BackendType getBackendType();
}
diff --git a/tests/android/aidl/tests/IntEnum.aidl b/tests/android/aidl/tests/IntEnum.aidl
index d3769ef..d9ae6b3 100644
--- a/tests/android/aidl/tests/IntEnum.aidl
+++ b/tests/android/aidl/tests/IntEnum.aidl
@@ -18,8 +18,7 @@
@Backing(type="int")
enum IntEnum {
- FOO = 1000,
- BAR = 2000,
- BAZ,
+ FOO = 1000,
+ BAR = 2000,
+ BAZ,
}
-
diff --git a/tests/android/aidl/tests/LongEnum.aidl b/tests/android/aidl/tests/LongEnum.aidl
index 9d7610b..2cd1707 100644
--- a/tests/android/aidl/tests/LongEnum.aidl
+++ b/tests/android/aidl/tests/LongEnum.aidl
@@ -18,8 +18,7 @@
@Backing(type="long")
enum LongEnum {
- FOO = 100000000000,
- BAR = 200000000000,
- BAZ,
+ FOO = 100000000000,
+ BAR = 200000000000,
+ BAZ,
}
-
diff --git a/tests/android/aidl/tests/ParcelableForToString.aidl b/tests/android/aidl/tests/ParcelableForToString.aidl
index 2ad414c..bbb56c7 100644
--- a/tests/android/aidl/tests/ParcelableForToString.aidl
+++ b/tests/android/aidl/tests/ParcelableForToString.aidl
@@ -16,8 +16,11 @@
package android.aidl.tests;
-import android.aidl.tests.OtherParcelableForToString;
+import android.aidl.tests.GenericStructuredParcelable;
import android.aidl.tests.IntEnum;
+import android.aidl.tests.OtherParcelableForToString;
+import android.aidl.tests.StructuredParcelable;
+import android.aidl.tests.Union;
@JavaDerive(toString=true)
parcelable ParcelableForToString {
@@ -38,8 +41,10 @@
List<String> stringList;
OtherParcelableForToString parcelableValue;
OtherParcelableForToString[] parcelableArray;
- IntEnum enumValue;
+ IntEnum enumValue = IntEnum.FOO;
IntEnum[] enumArray;
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 5e316ee..df66cd3 100644
--- a/tests/android/aidl/tests/StructuredParcelable.aidl
+++ b/tests/android/aidl/tests/StructuredParcelable.aidl
@@ -17,11 +17,14 @@
package android.aidl.tests;
import android.aidl.tests.ByteEnum;
+import android.aidl.tests.ConstantExpressionEnum;
import android.aidl.tests.IntEnum;
import android.aidl.tests.LongEnum;
-import android.aidl.tests.ConstantExpressionEnum;
+import android.aidl.tests.Union;
-@JavaDerive(toString=true)
+@SuppressWarnings(value={"enum-explicit-default"})
+@JavaDerive(toString=true, equals=true)
+@RustDerive(Clone=true, PartialEq=true)
parcelable StructuredParcelable {
int[] shouldContainThreeFs;
int f;
@@ -41,106 +44,113 @@
char charDefaultsToC = 'C';
float floatDefaultsToPi = 3.14f;
double doubleWithDefault = -3.14e17;
- int[] arrayDefaultsTo123 = { 1, 2, 3 };
- int[] arrayDefaultsToEmpty = { };
+ int[] arrayDefaultsTo123 = {
+ 1,
+ 2,
+ 3,
+ };
+ int[] arrayDefaultsToEmpty = {};
+
+ boolean boolDefault;
+ byte byteDefault;
+ int intDefault;
+ long longDefault;
+ float floatDefault;
+ double doubleDefault;
// parse checks only
double checkDoubleFromFloat = 3.14f;
- String[] checkStringArray1 = { "a", "b" };
- @utf8InCpp String[] checkStringArray2 = { "a", "b" };
+ String[] checkStringArray1 = {"a", "b"};
+ @utf8InCpp String[] checkStringArray2 = {"a", "b"};
// Add test to verify corner cases
int int32_min = -2147483648;
- int int32_max = 2147483647;
- long int64_max = 9223372036854775807;
+ int int32_max = 2147483647;
+ long int64_max = 9223372036854775807;
int hexInt32_neg_1 = 0xffffffff;
@nullable IBinder ibinder;
// Constant expressions that evaluate to 1
int[] int32_1 = {
- (~(-1)) == 0,
- -(1 << 31) == (1 << 31),
- -0x7fffffff < 0,
- -0x80000000 < 0,
+ (~(-1)) == 0,
+ ~~(1 << 31) == (1 << 31),
+ -0x7fffffff < 0,
+ 0x80000000 < 0,
- // both treated int32_t, sum = (int32_t)0x80000000 = -2147483648
- (1 + 0x7fffffff) == -2147483648,
+ 0x7fffffff == 2147483647,
- // Shifting for more than 31 bits are undefined. Not tested.
- (1 << 31) == 0x80000000,
+ // Shifting for more than 31 bits are undefined. Not tested.
+ (1 << 31) == 0x80000000,
- // Should be all true / ones.
- (1 + 2) == 3,
- (8 - 9) == -1,
- (9 * 9) == 81,
- (29 / 3) == 9,
- (29 % 3) == 2,
- (0xC0010000 | 0xF00D) == (0xC001F00D),
- (10 | 6) == 14,
- (10 & 6) == 2,
- (10 ^ 6) == 12,
- 6 < 10,
- (10 < 10) == 0,
- (6 > 10) == 0,
- (10 > 10) == 0,
- 19 >= 10,
- 10 >= 10,
- 5 <= 10,
- (19 <= 10) == 0,
- 19 != 10,
- (10 != 10) == 0,
- (22 << 1) == 44,
- (11 >> 1) == 5,
- (1 || 0) == 1,
- (1 || 1) == 1,
- (0 || 0) == 0,
- (0 || 1) == 1,
- (1 && 0) == 0,
- (1 && 1) == 1,
- (0 && 0) == 0,
- (0 && 1) == 0,
+ // Should be all true / ones.
+ (1 + 2) == 3,
+ (8 - 9) == -1,
+ (9 * 9) == 81,
+ (29 / 3) == 9,
+ (29 % 3) == 2,
+ (0xC0010000 | 0xF00D) == (0xC001F00D),
+ (10 | 6) == 14,
+ (10 & 6) == 2,
+ (10 ^ 6) == 12,
+ 6 < 10,
+ (10 < 10) == 0,
+ (6 > 10) == 0,
+ (10 > 10) == 0,
+ 19 >= 10,
+ 10 >= 10,
+ 5 <= 10,
+ (19 <= 10) == 0,
+ 19 != 10,
+ (10 != 10) == 0,
+ (22 << 1) == 44,
+ (11 >> 1) == 5,
+ (1 || 0) == 1,
+ (1 || 1) == 1,
+ (0 || 0) == 0,
+ (0 || 1) == 1,
+ (1 && 0) == 0,
+ (1 && 1) == 1,
+ (0 && 0) == 0,
+ (0 && 1) == 0,
- // precedence tests -- all 1s
- 4 == 4,
- -4 < 0,
- 0xffffffff == -1,
- 4 + 1 == 5,
- 2 + 3 - 4,
- 2 - 3 + 4 == 3,
- 1 == 4 == 0,
- 1 && 1,
- 1 || 1 && 0, // && higher than ||
- 1 < 2,
- !!((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
- !(1 == 7) && ((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
- (1 << 2) >= 0,
- (4 >> 1) == 2,
- (8 << -1) == 4,
- (1 << 31 >> 31) == -1,
- (1 | 16 >> 2) == 5,
- (0x0f ^ 0x33 & 0x99) == 0x1e, // & higher than ^
- (~42 & (1 << 3 | 16 >> 2) ^ 7) == 3,
- (2 + 3 - 4 * -7 / (10 % 3)) - 33 == 0,
- (2 + (-3&4 / 7)) == 2,
- (((((1 + 0)))))
+ // precedence tests -- all 1s
+ 4 == 4,
+ -4 < 0,
+ 0xffffffff == -1,
+ 4 + 1 == 5,
+ 2 + 3 - 4,
+ 2 - 3 + 4 == 3,
+ 1 == 4 == 0,
+ 1 && 1,
+ 1 || 1 && 0, // && higher than ||
+ 1 < 2,
+ !!((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
+ !(1 == 7) && ((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
+ (1 << 2) >= 0,
+ (4 >> 1) == 2,
+ (8 << -1) == 4,
+ (1 << 30 >> 30) == 1,
+ (1 | 16 >> 2) == 5,
+ (0x0f ^ 0x33 & 0x99) == 0x1e, // & higher than ^
+ (~42 & (1 << 3 | 16 >> 2) ^ 7) == 3,
+ (2 + 3 - 4 * -7 / (10 % 3)) - 33 == 0,
+ (2 + (-3 & 4 / 7)) == 2,
+ (((((1 + 0))))),
};
long[] int64_1 = {
- (~(-1)) == 0,
- (~4294967295) != 0,
- (~4294967295) != 0,
- -(1 << 63) == (1 << 63),
- -0x7FFFFFFFFFFFFFFF < 0,
+ (~(-1)) == 0,
+ (~4294967295) != 0,
+ (~4294967295) != 0,
+ ~~(1L << 63) == (1L << 63),
+ -0x7FFFFFFFFFFFFFFF < 0,
- // both treated int32_t, sum = (int64_t)(int32_t)0x80000000 = (int64_t)(-2147483648)
- (1 + 0x7fffffff) == -2147483648,
-
- // 0x80000000 is uint32_t, sum = (int64_t)(uint32_t)0x7fffffff = (int64_t)(2147483647)
- (0x80000000 - 1) == 2147483647,
- (0x80000000 + 1) == -2147483647,
- (1L << 63)+1 == -9223372036854775807,
- 0xfffffffff == 68719476735
+ 0x7fffffff == 2147483647,
+ 0xfffffffff == 68719476735,
+ 0xffffffffffffffff == -1,
+ (0xfL << 32L) == 0xf00000000,
+ (0xfL << 32) == 0xf00000000,
};
int hexInt32_pos_1 = -0xffffffff;
int hexInt64_pos_1 = -0xfffffffffff < 0;
@@ -157,7 +167,18 @@
ConstantExpressionEnum const_exprs_10;
// String expressions
- @utf8InCpp String addString1 = "hello" + " world!";
- @utf8InCpp String addString2 = "The quick brown fox jumps " + "over the lazy dog.";
-}
+ @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..bf1444e
--- /dev/null
+++ b/tests/android/aidl/tests/Union.aidl
@@ -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.
+ */
+
+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/android/aidl/tests/UnionWithFd.aidl b/tests/android/aidl/tests/UnionWithFd.aidl
new file mode 100644
index 0000000..5f59695
--- /dev/null
+++ b/tests/android/aidl/tests/UnionWithFd.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+union UnionWithFd {
+ int num;
+ ParcelFileDescriptor pfd;
+}
diff --git a/tests/android/aidl/tests/extension/ExtendableParcelable.aidl b/tests/android/aidl/tests/extension/ExtendableParcelable.aidl
new file mode 100644
index 0000000..c3dbfd3
--- /dev/null
+++ b/tests/android/aidl/tests/extension/ExtendableParcelable.aidl
@@ -0,0 +1,25 @@
+/*
+ * 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.extension;
+
+parcelable ExtendableParcelable {
+ int a;
+ @utf8InCpp String b;
+ ParcelableHolder ext;
+ long c;
+ ParcelableHolder ext2;
+}
diff --git a/tests/android/aidl/tests/extension/MyExt.aidl b/tests/android/aidl/tests/extension/MyExt.aidl
new file mode 100644
index 0000000..6605b8f
--- /dev/null
+++ b/tests/android/aidl/tests/extension/MyExt.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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.extension;
+
+parcelable MyExt {
+ int a;
+ @utf8InCpp String b;
+}
diff --git a/tests/android/aidl/tests/extension/MyExt2.aidl b/tests/android/aidl/tests/extension/MyExt2.aidl
new file mode 100644
index 0000000..3dff232
--- /dev/null
+++ b/tests/android/aidl/tests/extension/MyExt2.aidl
@@ -0,0 +1,25 @@
+/*
+ * 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.extension;
+
+import android.aidl.tests.extension.MyExt;
+
+parcelable MyExt2 {
+ int a;
+ MyExt b;
+ @utf8InCpp String c;
+}
diff --git a/tests/android/aidl/tests/extension/MyExtLike.aidl b/tests/android/aidl/tests/extension/MyExtLike.aidl
new file mode 100644
index 0000000..56778b5
--- /dev/null
+++ b/tests/android/aidl/tests/extension/MyExtLike.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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.extension;
+
+parcelable MyExtLike {
+ int a;
+ String b;
+}
diff --git a/tests/android/aidl/tests/generic/Baz.aidl b/tests/android/aidl/tests/generic/Baz.aidl
index 2244d98..293d4c3 100644
--- a/tests/android/aidl/tests/generic/Baz.aidl
+++ b/tests/android/aidl/tests/generic/Baz.aidl
@@ -18,4 +18,4 @@
parcelable Baz {
int a;
-}
\ No newline at end of file
+}
diff --git a/tests/android/aidl/tests/generic/IFaz.aidl b/tests/android/aidl/tests/generic/IFaz.aidl
index 127f3b7..e467f59 100644
--- a/tests/android/aidl/tests/generic/IFaz.aidl
+++ b/tests/android/aidl/tests/generic/IFaz.aidl
@@ -16,10 +16,12 @@
package android.aidl.tests.generic;
+import android.aidl.tests.IntEnum;
import android.aidl.tests.generic.Baz;
import android.aidl.tests.generic.Pair;
interface IFaz {
Pair<int, String> getPair();
Pair<Baz, Baz> getPair2();
-}
\ No newline at end of file
+ Pair<int, IntEnum> getPair3();
+}
diff --git a/tests/android/aidl/tests/generic/Pair.aidl b/tests/android/aidl/tests/generic/Pair.aidl
index 69e5ed9..7284a4d 100644
--- a/tests/android/aidl/tests/generic/Pair.aidl
+++ b/tests/android/aidl/tests/generic/Pair.aidl
@@ -16,4 +16,4 @@
package android.aidl.tests.generic;
-parcelable Pair<A, B>;
\ No newline at end of file
+parcelable Pair<A, B>;
diff --git a/tests/android/aidl/tests/immutable/Bar.aidl b/tests/android/aidl/tests/immutable/Bar.aidl
new file mode 100644
index 0000000..4fa0648
--- /dev/null
+++ b/tests/android/aidl/tests/immutable/Bar.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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.immutable;
+
+@JavaOnlyImmutable
+parcelable Bar {
+ String s = "bar";
+}
diff --git a/tests/android/aidl/tests/immutable/Foo.aidl b/tests/android/aidl/tests/immutable/Foo.aidl
new file mode 100644
index 0000000..b13377b
--- /dev/null
+++ b/tests/android/aidl/tests/immutable/Foo.aidl
@@ -0,0 +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.
+ */
+
+package android.aidl.tests.immutable;
+
+import android.aidl.tests.immutable.Bar;
+import android.aidl.tests.immutable.Union;
+
+@JavaOnlyImmutable
+parcelable Foo {
+ int a = 10;
+ Bar b;
+ List<Bar> c;
+ Map<String, Bar> d;
+ Bar[] e;
+ Union u;
+}
diff --git a/tests/android/aidl/tests/immutable/IBaz.aidl b/tests/android/aidl/tests/immutable/IBaz.aidl
new file mode 100644
index 0000000..1981b4a
--- /dev/null
+++ b/tests/android/aidl/tests/immutable/IBaz.aidl
@@ -0,0 +1,23 @@
+/*
+ * 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.immutable;
+
+import android.aidl.tests.immutable.Foo;
+
+interface IBaz {
+ Foo RepeatFoo(in Foo a);
+}
diff --git a/tests/android/aidl/tests/immutable/Union.aidl b/tests/android/aidl/tests/immutable/Union.aidl
new file mode 100644
index 0000000..99a08d4
--- /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;
+}
diff --git a/tests/android/aidl/tests/map/Bar.aidl b/tests/android/aidl/tests/map/Bar.aidl
index cbd95ef..9bd1a1d 100644
--- a/tests/android/aidl/tests/map/Bar.aidl
+++ b/tests/android/aidl/tests/map/Bar.aidl
@@ -17,6 +17,6 @@
package android.aidl.tests.map;
parcelable Bar {
- int a;
- String b;
-}
\ No newline at end of file
+ int a;
+ String b;
+}
diff --git a/tests/android/aidl/tests/map/Foo.aidl b/tests/android/aidl/tests/map/Foo.aidl
index 4bc3e91..74746d2 100644
--- a/tests/android/aidl/tests/map/Foo.aidl
+++ b/tests/android/aidl/tests/map/Foo.aidl
@@ -18,10 +18,15 @@
import android.aidl.tests.map.Bar;
import android.aidl.tests.map.IEmpty;
+import android.aidl.tests.map.IntEnum;
parcelable Foo {
- Map<String, Bar> barMap;
- Map<String, String> stringMap;
- Map<String, IEmpty> interfaceMap;
- Map<String, IBinder> ibinderMap;
+ Map<String, IntEnum[]> intEnumArrayMap;
+ Map<String, int[]> intArrayMap;
+ Map<String, Bar> barMap;
+ Map<String, Bar[]> barArrayMap;
+ Map<String, String> stringMap;
+ Map<String, String[]> stringArrayMap;
+ Map<String, IEmpty> interfaceMap;
+ Map<String, IBinder> ibinderMap;
}
diff --git a/tests/android/aidl/tests/map/IEmpty.aidl b/tests/android/aidl/tests/map/IEmpty.aidl
index c7f3f12..c425c43 100644
--- a/tests/android/aidl/tests/map/IEmpty.aidl
+++ b/tests/android/aidl/tests/map/IEmpty.aidl
@@ -16,5 +16,4 @@
package android.aidl.tests.map;
-interface IEmpty {
-}
+interface IEmpty {}
diff --git a/tests/android/aidl/tests/map/IntEnum.aidl b/tests/android/aidl/tests/map/IntEnum.aidl
new file mode 100644
index 0000000..27edeeb
--- /dev/null
+++ b/tests/android/aidl/tests/map/IntEnum.aidl
@@ -0,0 +1,24 @@
+/*
+ * 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 android.aidl.tests.map;
+
+@Backing(type="int")
+enum IntEnum {
+ FOO = 1000,
+ BAR = 2000,
+ BAZ,
+}
diff --git a/tests/android/aidl/tests/unions/EnumUnion.aidl b/tests/android/aidl/tests/unions/EnumUnion.aidl
new file mode 100644
index 0000000..5f9bb05
--- /dev/null
+++ b/tests/android/aidl/tests/unions/EnumUnion.aidl
@@ -0,0 +1,26 @@
+/*
+ * 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/android/aidl/tests/unions/UnionInUnion.aidl b/tests/android/aidl/tests/unions/UnionInUnion.aidl
new file mode 100644
index 0000000..b3ddf05
--- /dev/null
+++ b/tests/android/aidl/tests/unions/UnionInUnion.aidl
@@ -0,0 +1,25 @@
+/*
+ * 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 android.aidl.tests.unions;
+import android.aidl.tests.unions.EnumUnion;
+
+@JavaDerive(toString=true, equals=true)
+@RustDerive(Clone=true, PartialEq=true)
+union UnionInUnion {
+ EnumUnion first;
+ int second;
+}
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/const_value_binary_exp b/tests/corpus/const_value_binary_exp
new file mode 100644
index 0000000..d55f8d1
--- /dev/null
+++ b/tests/corpus/const_value_binary_exp
@@ -0,0 +1 @@
+¬interface a{const int O=4591016363&7;}enum F{p}
\ No newline at end of file
diff --git a/tests/corpus/duplicated_imports b/tests/corpus/duplicated_imports
new file mode 100644
index 0000000..e4073a7
--- /dev/null
+++ b/tests/corpus/duplicated_imports
@@ -0,0 +1 @@
+;import d;import d;
diff --git a/tests/corpus/enum_invalid_unary b/tests/corpus/enum_invalid_unary
new file mode 100644
index 0000000..c52f567
--- /dev/null
+++ b/tests/corpus/enum_invalid_unary
@@ -0,0 +1 @@
+ÿenum o{r=+""}
\ No newline at end of file
diff --git a/tests/corpus/enum_named_byte b/tests/corpus/enum_named_byte
new file mode 100644
index 0000000..3cf3ad6
--- /dev/null
+++ b/tests/corpus/enum_named_byte
@@ -0,0 +1 @@
+= import s;enum byte{p}enum s{p} enum oz{p2}parcelable e{e oy;oz y;}
\ 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/fails_only_in_java b/tests/corpus/fails_only_in_java
new file mode 100644
index 0000000..640a650
--- /dev/null
+++ b/tests/corpus/fails_only_in_java
@@ -0,0 +1 @@
+&enum l{p}parcelable e{Map y0;}
\ No newline at end of file
diff --git a/tests/corpus/ibinder_array b/tests/corpus/ibinder_array
new file mode 100644
index 0000000..853e41a
--- /dev/null
+++ b/tests/corpus/ibinder_array
@@ -0,0 +1 @@
+ enum F{p}parcelable e{IBinder[]y;}
diff --git a/tests/corpus/invalid_binary_op_types b/tests/corpus/invalid_binary_op_types
new file mode 100644
index 0000000..c9fb817
--- /dev/null
+++ b/tests/corpus/invalid_binary_op_types
@@ -0,0 +1 @@
+&enum l{p}parcelable e{Map y=.0&0;}
\ No newline at end of file
diff --git a/tests/corpus/invalid_type_after_valid_type b/tests/corpus/invalid_type_after_valid_type
new file mode 100644
index 0000000..6909cfc
--- /dev/null
+++ b/tests/corpus/invalid_type_after_valid_type
@@ -0,0 +1 @@
+ parcelable m{}t
diff --git a/tests/corpus/large_shift_overflow b/tests/corpus/large_shift_overflow
new file mode 100644
index 0000000..baa4ffb
--- /dev/null
+++ b/tests/corpus/large_shift_overflow
@@ -0,0 +1 @@
+ enum l{p}parcelable e{Map y=36<<-3922331256<<2237203310;}
diff --git a/tests/corpus/negative_left_shift b/tests/corpus/negative_left_shift
new file mode 100644
index 0000000..f7de8b3
--- /dev/null
+++ b/tests/corpus/negative_left_shift
@@ -0,0 +1 @@
+/ enum o {p=127L>>-1>>2>30>-81>>0>4>26L>>-1>-2>>1-8>1-30>>1>>-7L>>-1>>-2>>0>>-2>>1-8>>-30>>-2>>1-80>>-7>>6L>>-1>>0>4>26L>>-1>-2>>1-8>>-3>>-30>>-2>>2>>1>>1-8>>-30>>-2>>1-80>>-7>>6L>>-1>>0>4>2L>>-1>-2>>1-8>>-3>>-30>>-2>>2>>42>>1>>1-8>>-30>>-2>>1-80>>-7>>6L>>-17>>6L>>-1>>-1>>0>4>26L>>-1>-2>>1-8>>-30>>1>>-7L>>-1>>-2>>0>>-2>>1-8>>-30>>-2>>1-80>>-7>>6L>>-1>>0>4>26L>>-1>-2>>1-8>>-3>>-30>>-2>>2>>1>>1-8>>-30>>-2>>1-80>>-7>>6L>>-1>>0>4>2L>>-1>-2>>1-8>>-3>>-30>>-2>>2>>1-80>>-7>>6L>>-1>>0>4>26L>>-1>-2>>1-8>>-3>>-31>>0>4>26L>>-1>-80>>-7>>6L>>-1>>0>4>26L>>-1>-2>>1-3>>-3>>-30>>-2>>1-80>>-1-80>>-7>>6L>>-1>>0>4>26L>>-1>-2>>1}
\ No newline at end of file
diff --git a/tests/corpus/nullable_parcelable_array b/tests/corpus/nullable_parcelable_array
new file mode 100644
index 0000000..65cb0af
--- /dev/null
+++ b/tests/corpus/nullable_parcelable_array
@@ -0,0 +1 @@
+)enum r{r}parcelable e{@nullable e[]e;}
\ No newline at end of file
diff --git a/tests/corpus/nullable_pfd_array b/tests/corpus/nullable_pfd_array
new file mode 100644
index 0000000..a18ddd1
--- /dev/null
+++ b/tests/corpus/nullable_pfd_array
@@ -0,0 +1 @@
+ enum F{p}parcelable e{@nullable ParcelFileDescriptor[]y;}
\ No newline at end of file
diff --git a/tests/corpus/other_string_operation b/tests/corpus/other_string_operation
new file mode 100644
index 0000000..b04fcc2
--- /dev/null
+++ b/tests/corpus/other_string_operation
Binary files differ
diff --git a/tests/corpus/parcelable_holder_array b/tests/corpus/parcelable_holder_array
new file mode 100644
index 0000000..412866f
--- /dev/null
+++ b/tests/corpus/parcelable_holder_array
@@ -0,0 +1 @@
+Öenum Fo{prp}parcelable e{ ParcelableHolder []o;}
\ No newline at end of file
diff --git a/tests/corpus/shift_left_gt_leading_zeros b/tests/corpus/shift_left_gt_leading_zeros
new file mode 100644
index 0000000..402cf20
--- /dev/null
+++ b/tests/corpus/shift_left_gt_leading_zeros
@@ -0,0 +1 @@
+ enum o {p=06L>>-2>>-2L>>0-2>>-8-2>>0-21>>0-2>>-8-2>>0-2>>-6>>-9L>>0-2>>-6>>-2L>>0>1}
\ No newline at end of file
diff --git a/tests/corpus/shift_overflow b/tests/corpus/shift_overflow
new file mode 100644
index 0000000..647a254
--- /dev/null
+++ b/tests/corpus/shift_overflow
@@ -0,0 +1 @@
+Öenum o{x=4<<92}
\ No newline at end of file
diff --git a/tests/corpus/shift_right_64 b/tests/corpus/shift_right_64
new file mode 100644
index 0000000..7180d4d
--- /dev/null
+++ b/tests/corpus/shift_right_64
@@ -0,0 +1 @@
+/ enum o {p=1756L>>-1>>1>>-4>26L>>1>>-4>26>>-1>>1>>-100-1>>1>>-4>26>>-1>>1>>-100>4>>266>>-1>>1>>-1>>1>-2-8>>-2>>-1>>1>>-1>>-7L>>11>>-2>>0>>-28>>-30>>-2>>1-80>>-7>30>>-7<56L>>-1>>1>>-4>24>>-.1>>1>>-100-1>>1>>-4>26>>-1>>1>>-26>>-1>>1>>-4>26>>-1>>1>>-100-1>>1>>-4>26>>-1>>1>>-100>4>>26L>>0>>-2>>0064>26L>>-1}
\ 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 24458d6..0000000
--- a/tests/end_to_end_tests.cpp
+++ /dev/null
@@ -1,333 +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, 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, 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, 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);
-}
-
-} // namespace aidl
-} // namespace android
diff --git a/tests/fake_io_delegate.cpp b/tests/fake_io_delegate.cpp
index dc35c4d..a99a20a 100644
--- a/tests/fake_io_delegate.cpp
+++ b/tests/fake_io_delegate.cpp
@@ -23,6 +23,7 @@
#include "os.h"
#include "tests/test_util.h"
+using android::base::Result;
using android::base::StringAppendF;
using android::base::StringPrintf;
using std::string;
@@ -89,11 +90,11 @@
file_contents_[filename] = contents;
}
-vector<string> FakeIoDelegate::ListFiles(const string& dir) const {
+Result<vector<string>> FakeIoDelegate::ListFiles(const string& dir) const {
const string dir_name = dir.back() == OS_PATH_SEPARATOR ? dir : dir + OS_PATH_SEPARATOR;
vector<string> files;
for (auto it = file_contents_.begin(); it != file_contents_.end(); it++) {
- if (android::base::StartsWith(it->first, dir_name) && !it->second.empty()) {
+ if (android::base::StartsWith(it->first, dir_name)) {
files.emplace_back(it->first);
}
}
@@ -140,7 +141,7 @@
broken_files_.insert(path);
}
-bool FakeIoDelegate::GetWrittenContents(const string& path, string* content) {
+bool FakeIoDelegate::GetWrittenContents(const string& path, string* content) const {
const auto it = written_file_contents_.find(path);
if (it == written_file_contents_.end()) {
return false;
@@ -151,12 +152,12 @@
return true;
}
-std::vector<std::string> FakeIoDelegate::ListOutputFiles() {
- std::vector<std::string> out;
- for (const auto& [file, contents] : written_file_contents_) {
- out.push_back(file);
- }
- return out;
+const std::map<std::string, std::string>& FakeIoDelegate::InputFiles() const {
+ return file_contents_;
+}
+
+const std::map<std::string, std::string>& FakeIoDelegate::OutputFiles() const {
+ return written_file_contents_;
}
bool FakeIoDelegate::PathWasRemoved(const std::string& path) {
diff --git a/tests/fake_io_delegate.h b/tests/fake_io_delegate.h
index f077c0f..6f24678 100644
--- a/tests/fake_io_delegate.h
+++ b/tests/fake_io_delegate.h
@@ -13,11 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#ifndef AIDL_TESTS_FAKE_IO_DELEGATE_H_
-#define AIDL_TESTS_FAKE_IO_DELEGATE_H_
-
-#include <android-base/macros.h>
+#pragma once
#include <map>
#include <memory>
@@ -36,6 +32,12 @@
FakeIoDelegate() = default;
virtual ~FakeIoDelegate() = default;
+ // non-copyable, non-movable
+ FakeIoDelegate(const FakeIoDelegate&) = delete;
+ FakeIoDelegate(FakeIoDelegate&&) = delete;
+ FakeIoDelegate& operator=(const FakeIoDelegate&) = delete;
+ FakeIoDelegate& operator=(FakeIoDelegate&&) = delete;
+
// Overrides from the real IoDelegate
std::unique_ptr<std::string> GetFileContents(
const std::string& filename,
@@ -46,7 +48,7 @@
std::unique_ptr<CodeWriter> GetCodeWriter(
const std::string& file_path) const override;
void RemovePath(const std::string& file_path) const override;
- std::vector<std::string> ListFiles(const std::string& dir) const override;
+ android::base::Result<std::vector<std::string>> ListFiles(const std::string& dir) const override;
// Methods added to facilitate testing.
void SetFileContents(const std::string& filename,
@@ -59,8 +61,9 @@
void AddBrokenFilePath(const std::string& path);
// Returns true iff we've previously written to |path|.
// When we return true, we'll set *contents to the written string.
- bool GetWrittenContents(const std::string& path, std::string* content);
- std::vector<std::string> ListOutputFiles();
+ bool GetWrittenContents(const std::string& path, std::string* content) const;
+ const std::map<std::string, std::string>& InputFiles() const;
+ const std::map<std::string, std::string>& OutputFiles() const;
bool PathWasRemoved(const std::string& path);
@@ -78,12 +81,8 @@
// files in this list, we simulate I/O errors.
std::set<std::string> broken_files_;
mutable std::set<std::string> removed_files_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeIoDelegate);
}; // class FakeIoDelegate
} // namespace test
} // namespace aidl
} // namespace android
-
-#endif // AIDL_TESTS_FAKE_IO_DELEGATE_H_
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/DeprecatedEnum.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedEnum.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/DeprecatedEnum.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedEnum.cpp.d
new file mode 100644
index 0000000..6f9c39b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedEnum.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedParcelable.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedParcelable.cpp
new file mode 100644
index 0000000..ba4b15b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedParcelable.cpp
@@ -0,0 +1,35 @@
+#include <android/aidl/tests/DeprecatedParcelable.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+::android::status_t DeprecatedParcelable::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_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+ return _aidl_ret_status;
+}
+
+::android::status_t DeprecatedParcelable::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);
+ 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/DeprecatedParcelable.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedParcelable.cpp.d
new file mode 100644
index 0000000..f11d82f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedParcelable.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/DeprecatedParcelable.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedParcelable.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/IDeprecated.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IDeprecated.cpp
new file mode 100644
index 0000000..4adb4e7
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IDeprecated.cpp
@@ -0,0 +1,76 @@
+#include <android/aidl/tests/IDeprecated.h>
+#include <android/aidl/tests/BpDeprecated.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(Deprecated, "android.aidl.tests.IDeprecated")
+
+} // namespace tests
+
+} // namespace aidl
+
+} // namespace android
+#include <android/aidl/tests/BpDeprecated.h>
+#include <android/aidl/tests/BnDeprecated.h>
+#include <binder/Parcel.h>
+#include <android-base/macros.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BpDeprecated::BpDeprecated(const ::android::sp<::android::IBinder>& _aidl_impl)
+ : BpInterface<IDeprecated>(_aidl_impl){
+}
+
+} // namespace tests
+
+} // namespace aidl
+
+} // namespace android
+#include <android/aidl/tests/BnDeprecated.h>
+#include <binder/Parcel.h>
+#include <binder/Stability.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+BnDeprecated::BnDeprecated()
+{
+ ::android::internal::Stability::markCompilationUnit(this);
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+
+::android::status_t BnDeprecated::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;
+}
+
+#pragma clang diagnostic pop
+
+} // namespace tests
+
+} // namespace aidl
+
+} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IDeprecated.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IDeprecated.cpp.d
new file mode 100644
index 0000000..ef80a77
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IDeprecated.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/IDeprecated.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/IDeprecated.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..a1bb651
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INamedCallback.cpp
@@ -0,0 +1,125 @@
+#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;
+ _aidl_data.markForBinder(remoteStrong());
+ ::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..7dcc44f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/INewName.cpp
@@ -0,0 +1,125 @@
+#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;
+ _aidl_data.markForBinder(remoteStrong());
+ ::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..2988407
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/IOldName.cpp
@@ -0,0 +1,125 @@
+#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;
+ _aidl_data.markForBinder(remoteStrong());
+ ::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..f3cd198
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
@@ -0,0 +1,3506 @@
+#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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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::Deprecated() {
+ ::android::Parcel _aidl_data;
+ _aidl_data.markSensitive();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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_Deprecated, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+ if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+ return ITestService::getDefaultImpl()->Deprecated();
+ }
+ 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::TestOneway() {
+ ::android::Parcel _aidl_data;
+ _aidl_data.markSensitive();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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();
+ _aidl_data.markForBinder(remoteStrong());
+ ::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);
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+
+::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_Deprecated:
+ {
+ if (!(_aidl_data.checkInterface(this))) {
+ _aidl_ret_status = ::android::BAD_TYPE;
+ break;
+ }
+ ::android::binder::Status _aidl_status(Deprecated());
+ _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ break;
+ }
+ if (!_aidl_status.isOk()) {
+ 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;
+}
+
+#pragma clang diagnostic pop
+
+} // 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..a88d7b3
--- /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/INewName.aidl \
+ system/tools/aidl/tests/android/aidl/tests/IOldName.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
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..d6a7d64
--- /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;
+ 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(&field);
+ if (((_aidl_ret_status) != (::android::OK))) {
+ return _aidl_ret_status;
+ }
+ _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+ 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..7b40910
--- /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;
+ 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(&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;
+ }
+ _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+ 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..995e55a
--- /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/IntEnum.aidl \
+ system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+ system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.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..cc0f2f1
--- /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;
+ 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(&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;
+ }
+ _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+ 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..8d72a81
--- /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/ConstantExpressionEnum.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/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/android/aidl/tests/unions/UnionInUnion.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/UnionInUnion.cpp
new file mode 100644
index 0000000..8268de8
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/UnionInUnion.cpp
@@ -0,0 +1,56 @@
+#include <android/aidl/tests/unions/UnionInUnion.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+namespace unions {
+
+::android::status_t UnionInUnion::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 first: {
+ ::android::aidl::tests::unions::EnumUnion _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::aidl::tests::unions::EnumUnion>) {
+ set<first>(_aidl_value);
+ } else {
+ // NOLINTNEXTLINE(performance-move-const-arg)
+ set<first>(std::move(_aidl_value));
+ }
+ return ::android::OK; }
+ case second: {
+ 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<second>(_aidl_value);
+ } else {
+ // NOLINTNEXTLINE(performance-move-const-arg)
+ set<second>(std::move(_aidl_value));
+ }
+ return ::android::OK; }
+ }
+ return ::android::BAD_VALUE;
+}
+
+::android::status_t UnionInUnion::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 first: return _aidl_parcel->writeParcelable(get<first>());
+ case second: return _aidl_parcel->writeInt32(get<second>());
+ }
+ __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/UnionInUnion.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/UnionInUnion.cpp.d
new file mode 100644
index 0000000..6df64b5
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/UnionInUnion.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-cpp-source/gen/android/aidl/tests/unions/UnionInUnion.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/unions/UnionInUnion.aidl \
+ system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.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..a87dc2e
--- /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,
+};
+
+[[nodiscard]] 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/BnDeprecated.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecated.h
new file mode 100644
index 0000000..fc82d8b
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecated.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/tests/IDeprecated.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class __attribute__((deprecated("test"))) BnDeprecated : public ::android::BnInterface<IDeprecated> {
+public:
+ explicit BnDeprecated();
+ ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
+}; // class BnDeprecated
+
+} // namespace tests
+
+} // namespace aidl
+
+} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecatedEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecatedEnum.h
new file mode 100644
index 0000000..d717a4a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecatedEnum.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/BnDeprecatedParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecatedParcelable.h
new file mode 100644
index 0000000..ce72aa3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnDeprecatedParcelable.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/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..7035616
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
@@ -0,0 +1,73 @@
+#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_Deprecated = ::android::IBinder::FIRST_CALL_TRANSACTION + 1;
+ static constexpr uint32_t TRANSACTION_TestOneway = ::android::IBinder::FIRST_CALL_TRANSACTION + 2;
+ static constexpr uint32_t TRANSACTION_RepeatBoolean = ::android::IBinder::FIRST_CALL_TRANSACTION + 3;
+ static constexpr uint32_t TRANSACTION_RepeatByte = ::android::IBinder::FIRST_CALL_TRANSACTION + 4;
+ static constexpr uint32_t TRANSACTION_RepeatChar = ::android::IBinder::FIRST_CALL_TRANSACTION + 5;
+ static constexpr uint32_t TRANSACTION_RepeatInt = ::android::IBinder::FIRST_CALL_TRANSACTION + 6;
+ static constexpr uint32_t TRANSACTION_RepeatLong = ::android::IBinder::FIRST_CALL_TRANSACTION + 7;
+ static constexpr uint32_t TRANSACTION_RepeatFloat = ::android::IBinder::FIRST_CALL_TRANSACTION + 8;
+ static constexpr uint32_t TRANSACTION_RepeatDouble = ::android::IBinder::FIRST_CALL_TRANSACTION + 9;
+ static constexpr uint32_t TRANSACTION_RepeatString = ::android::IBinder::FIRST_CALL_TRANSACTION + 10;
+ static constexpr uint32_t TRANSACTION_RepeatByteEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 11;
+ static constexpr uint32_t TRANSACTION_RepeatIntEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 12;
+ static constexpr uint32_t TRANSACTION_RepeatLongEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 13;
+ static constexpr uint32_t TRANSACTION_ReverseBoolean = ::android::IBinder::FIRST_CALL_TRANSACTION + 14;
+ static constexpr uint32_t TRANSACTION_ReverseByte = ::android::IBinder::FIRST_CALL_TRANSACTION + 15;
+ static constexpr uint32_t TRANSACTION_ReverseChar = ::android::IBinder::FIRST_CALL_TRANSACTION + 16;
+ static constexpr uint32_t TRANSACTION_ReverseInt = ::android::IBinder::FIRST_CALL_TRANSACTION + 17;
+ static constexpr uint32_t TRANSACTION_ReverseLong = ::android::IBinder::FIRST_CALL_TRANSACTION + 18;
+ static constexpr uint32_t TRANSACTION_ReverseFloat = ::android::IBinder::FIRST_CALL_TRANSACTION + 19;
+ static constexpr uint32_t TRANSACTION_ReverseDouble = ::android::IBinder::FIRST_CALL_TRANSACTION + 20;
+ static constexpr uint32_t TRANSACTION_ReverseString = ::android::IBinder::FIRST_CALL_TRANSACTION + 21;
+ static constexpr uint32_t TRANSACTION_ReverseByteEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 22;
+ static constexpr uint32_t TRANSACTION_ReverseIntEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 23;
+ static constexpr uint32_t TRANSACTION_ReverseLongEnum = ::android::IBinder::FIRST_CALL_TRANSACTION + 24;
+ static constexpr uint32_t TRANSACTION_GetOtherTestService = ::android::IBinder::FIRST_CALL_TRANSACTION + 25;
+ static constexpr uint32_t TRANSACTION_VerifyName = ::android::IBinder::FIRST_CALL_TRANSACTION + 26;
+ static constexpr uint32_t TRANSACTION_ReverseStringList = ::android::IBinder::FIRST_CALL_TRANSACTION + 27;
+ static constexpr uint32_t TRANSACTION_RepeatParcelFileDescriptor = ::android::IBinder::FIRST_CALL_TRANSACTION + 28;
+ static constexpr uint32_t TRANSACTION_ReverseParcelFileDescriptorArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 29;
+ static constexpr uint32_t TRANSACTION_ThrowServiceException = ::android::IBinder::FIRST_CALL_TRANSACTION + 30;
+ static constexpr uint32_t TRANSACTION_RepeatNullableIntArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 31;
+ static constexpr uint32_t TRANSACTION_RepeatNullableByteEnumArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 32;
+ static constexpr uint32_t TRANSACTION_RepeatNullableIntEnumArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 33;
+ static constexpr uint32_t TRANSACTION_RepeatNullableLongEnumArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 34;
+ static constexpr uint32_t TRANSACTION_RepeatNullableString = ::android::IBinder::FIRST_CALL_TRANSACTION + 35;
+ static constexpr uint32_t TRANSACTION_RepeatNullableStringList = ::android::IBinder::FIRST_CALL_TRANSACTION + 36;
+ static constexpr uint32_t TRANSACTION_RepeatNullableParcelable = ::android::IBinder::FIRST_CALL_TRANSACTION + 37;
+ static constexpr uint32_t TRANSACTION_TakesAnIBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 38;
+ static constexpr uint32_t TRANSACTION_TakesANullableIBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 39;
+ static constexpr uint32_t TRANSACTION_RepeatUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 40;
+ static constexpr uint32_t TRANSACTION_RepeatNullableUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 41;
+ static constexpr uint32_t TRANSACTION_ReverseUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 42;
+ static constexpr uint32_t TRANSACTION_ReverseNullableUtf8CppString = ::android::IBinder::FIRST_CALL_TRANSACTION + 43;
+ static constexpr uint32_t TRANSACTION_ReverseUtf8CppStringList = ::android::IBinder::FIRST_CALL_TRANSACTION + 44;
+ static constexpr uint32_t TRANSACTION_GetCallback = ::android::IBinder::FIRST_CALL_TRANSACTION + 45;
+ static constexpr uint32_t TRANSACTION_FillOutStructuredParcelable = ::android::IBinder::FIRST_CALL_TRANSACTION + 46;
+ static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 47;
+ static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 48;
+ static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 49;
+ static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 50;
+ 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/BpDeprecated.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecated.h
new file mode 100644
index 0000000..88fb62d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecated.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/tests/IDeprecated.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class __attribute__((deprecated("test"))) BpDeprecated : public ::android::BpInterface<IDeprecated> {
+public:
+ explicit BpDeprecated(const ::android::sp<::android::IBinder>& _aidl_impl);
+ virtual ~BpDeprecated() = default;
+}; // class BpDeprecated
+
+} // namespace tests
+
+} // namespace aidl
+
+} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecatedEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecatedEnum.h
new file mode 100644
index 0000000..9c951e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecatedEnum.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/BpDeprecatedParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecatedParcelable.h
new file mode 100644
index 0000000..27af6b1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpDeprecatedParcelable.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/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..bee25bf
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
@@ -0,0 +1,75 @@
+#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 Deprecated() override __attribute__((deprecated("to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens")));
+ ::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..7b50010
--- /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,
+};
+
+[[nodiscard]] 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..b9abcb3
--- /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,
+};
+
+[[nodiscard]] 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/DeprecatedEnum.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/DeprecatedEnum.h
new file mode 100644
index 0000000..8de53cf
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/DeprecatedEnum.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 __attribute__((deprecated("test"))) DeprecatedEnum : int32_t {
+ A = 0,
+ B = 1,
+ C = 2,
+};
+
+[[nodiscard]] __attribute__((deprecated("test"))) static inline std::string toString(DeprecatedEnum val) {
+ switch(val) {
+ case DeprecatedEnum::A:
+ return "A";
+ case DeprecatedEnum::B:
+ return "B";
+ case DeprecatedEnum::C:
+ return "C";
+ 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::DeprecatedEnum, 3> __attribute__((deprecated("test"))) enum_values<::android::aidl::tests::DeprecatedEnum> = {
+ ::android::aidl::tests::DeprecatedEnum::A,
+ ::android::aidl::tests::DeprecatedEnum::B,
+ ::android::aidl::tests::DeprecatedEnum::C,
+};
+#pragma clang diagnostic pop
+
+} // namespace internal
+
+} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/DeprecatedParcelable.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/DeprecatedParcelable.h
new file mode 100644
index 0000000..59c7f20
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/DeprecatedParcelable.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <tuple>
+#include <utils/String16.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class __attribute__((deprecated("test"))) DeprecatedParcelable : public ::android::Parcelable {
+public:
+ inline bool operator!=(const DeprecatedParcelable&) const {
+ return std::tie() != std::tie();
+ }
+ inline bool operator<(const DeprecatedParcelable&) const {
+ return std::tie() < std::tie();
+ }
+ inline bool operator<=(const DeprecatedParcelable&) const {
+ return std::tie() <= std::tie();
+ }
+ inline bool operator==(const DeprecatedParcelable&) const {
+ return std::tie() == std::tie();
+ }
+ inline bool operator>(const DeprecatedParcelable&) const {
+ return std::tie() > std::tie();
+ }
+ inline bool operator>=(const DeprecatedParcelable&) const {
+ return std::tie() >= std::tie();
+ }
+
+ ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.DeprecatedParcelable");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "DeprecatedParcelable{";
+ os << "}";
+ return os.str();
+ }
+}; // class DeprecatedParcelable
+
+} // namespace tests
+
+} // namespace aidl
+
+} // 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..e655ee1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/GenericStructuredParcelable.h
@@ -0,0 +1,121 @@
+#pragma once
+
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cstdint>
+#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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.GenericStructuredParcelable");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "GenericStructuredParcelable{";
+ os << "a: " << ::android::internal::ToString(a);
+ os << ", b: " << ::android::internal::ToString(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;
+ 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(&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;
+ }
+ _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+ 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/IDeprecated.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IDeprecated.h
new file mode 100644
index 0000000..73931ea
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/IDeprecated.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/Status.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+namespace aidl {
+
+namespace tests {
+
+class __attribute__((deprecated("test"))) IDeprecated : public ::android::IInterface {
+public:
+ DECLARE_META_INTERFACE(Deprecated)
+}; // class IDeprecated
+
+class __attribute__((deprecated("test"))) IDeprecatedDefault : public IDeprecated {
+public:
+ ::android::IBinder* onAsBinder() override {
+ return nullptr;
+ }
+}; // class IDeprecatedDefault
+
+} // 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..9d91e0e
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
@@ -0,0 +1,328 @@
+#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 Deprecated() __attribute__((deprecated("to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens"))) = 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 Deprecated() override __attribute__((deprecated("to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens"))) {
+ 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..50b1b60
--- /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,
+};
+
+[[nodiscard]] 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..8caa3aa
--- /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,
+};
+
+[[nodiscard]] 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..7eb72e9
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/OtherParcelableForToString.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.OtherParcelableForToString");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "OtherParcelableForToString{";
+ os << "field: " << ::android::internal::ToString(field);
+ 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..39e64be
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ParcelableForToString.h
@@ -0,0 +1,107 @@
+#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 <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cstdint>
+#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 = ::android::aidl::tests::IntEnum(::android::aidl::tests::IntEnum::FOO);
+ ::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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.ParcelableForToString");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "ParcelableForToString{";
+ os << "intValue: " << ::android::internal::ToString(intValue);
+ os << ", intArray: " << ::android::internal::ToString(intArray);
+ os << ", longValue: " << ::android::internal::ToString(longValue);
+ os << ", longArray: " << ::android::internal::ToString(longArray);
+ os << ", doubleValue: " << ::android::internal::ToString(doubleValue);
+ os << ", doubleArray: " << ::android::internal::ToString(doubleArray);
+ os << ", floatValue: " << ::android::internal::ToString(floatValue);
+ os << ", floatArray: " << ::android::internal::ToString(floatArray);
+ os << ", byteValue: " << ::android::internal::ToString(byteValue);
+ os << ", byteArray: " << ::android::internal::ToString(byteArray);
+ os << ", booleanValue: " << ::android::internal::ToString(booleanValue);
+ os << ", booleanArray: " << ::android::internal::ToString(booleanArray);
+ os << ", stringValue: " << ::android::internal::ToString(stringValue);
+ os << ", stringArray: " << ::android::internal::ToString(stringArray);
+ os << ", stringList: " << ::android::internal::ToString(stringList);
+ os << ", parcelableValue: " << ::android::internal::ToString(parcelableValue);
+ os << ", parcelableArray: " << ::android::internal::ToString(parcelableArray);
+ os << ", enumValue: " << ::android::internal::ToString(enumValue);
+ os << ", enumArray: " << ::android::internal::ToString(enumArray);
+ os << ", nullArray: " << ::android::internal::ToString(nullArray);
+ os << ", nullList: " << ::android::internal::ToString(nullList);
+ os << ", parcelableGeneric: " << ::android::internal::ToString(parcelableGeneric);
+ os << ", unionValue: " << ::android::internal::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..795c81a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/StructuredParcelable.h
@@ -0,0 +1,175 @@
+#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 <android/binder_to_string.h>
+#include <binder/IBinder.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cstdint>
+#include <optional>
+#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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.StructuredParcelable");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "StructuredParcelable{";
+ os << "shouldContainThreeFs: " << ::android::internal::ToString(shouldContainThreeFs);
+ os << ", f: " << ::android::internal::ToString(f);
+ os << ", shouldBeJerry: " << ::android::internal::ToString(shouldBeJerry);
+ os << ", shouldBeByteBar: " << ::android::internal::ToString(shouldBeByteBar);
+ os << ", shouldBeIntBar: " << ::android::internal::ToString(shouldBeIntBar);
+ os << ", shouldBeLongBar: " << ::android::internal::ToString(shouldBeLongBar);
+ os << ", shouldContainTwoByteFoos: " << ::android::internal::ToString(shouldContainTwoByteFoos);
+ os << ", shouldContainTwoIntFoos: " << ::android::internal::ToString(shouldContainTwoIntFoos);
+ os << ", shouldContainTwoLongFoos: " << ::android::internal::ToString(shouldContainTwoLongFoos);
+ os << ", stringDefaultsToFoo: " << ::android::internal::ToString(stringDefaultsToFoo);
+ os << ", byteDefaultsToFour: " << ::android::internal::ToString(byteDefaultsToFour);
+ os << ", intDefaultsToFive: " << ::android::internal::ToString(intDefaultsToFive);
+ os << ", longDefaultsToNegativeSeven: " << ::android::internal::ToString(longDefaultsToNegativeSeven);
+ os << ", booleanDefaultsToTrue: " << ::android::internal::ToString(booleanDefaultsToTrue);
+ os << ", charDefaultsToC: " << ::android::internal::ToString(charDefaultsToC);
+ os << ", floatDefaultsToPi: " << ::android::internal::ToString(floatDefaultsToPi);
+ os << ", doubleWithDefault: " << ::android::internal::ToString(doubleWithDefault);
+ os << ", arrayDefaultsTo123: " << ::android::internal::ToString(arrayDefaultsTo123);
+ os << ", arrayDefaultsToEmpty: " << ::android::internal::ToString(arrayDefaultsToEmpty);
+ os << ", boolDefault: " << ::android::internal::ToString(boolDefault);
+ os << ", byteDefault: " << ::android::internal::ToString(byteDefault);
+ os << ", intDefault: " << ::android::internal::ToString(intDefault);
+ os << ", longDefault: " << ::android::internal::ToString(longDefault);
+ os << ", floatDefault: " << ::android::internal::ToString(floatDefault);
+ os << ", doubleDefault: " << ::android::internal::ToString(doubleDefault);
+ os << ", checkDoubleFromFloat: " << ::android::internal::ToString(checkDoubleFromFloat);
+ os << ", checkStringArray1: " << ::android::internal::ToString(checkStringArray1);
+ os << ", checkStringArray2: " << ::android::internal::ToString(checkStringArray2);
+ os << ", int32_min: " << ::android::internal::ToString(int32_min);
+ os << ", int32_max: " << ::android::internal::ToString(int32_max);
+ os << ", int64_max: " << ::android::internal::ToString(int64_max);
+ os << ", hexInt32_neg_1: " << ::android::internal::ToString(hexInt32_neg_1);
+ os << ", ibinder: " << ::android::internal::ToString(ibinder);
+ os << ", int32_1: " << ::android::internal::ToString(int32_1);
+ os << ", int64_1: " << ::android::internal::ToString(int64_1);
+ os << ", hexInt32_pos_1: " << ::android::internal::ToString(hexInt32_pos_1);
+ os << ", hexInt64_pos_1: " << ::android::internal::ToString(hexInt64_pos_1);
+ os << ", const_exprs_1: " << ::android::internal::ToString(const_exprs_1);
+ os << ", const_exprs_2: " << ::android::internal::ToString(const_exprs_2);
+ os << ", const_exprs_3: " << ::android::internal::ToString(const_exprs_3);
+ os << ", const_exprs_4: " << ::android::internal::ToString(const_exprs_4);
+ os << ", const_exprs_5: " << ::android::internal::ToString(const_exprs_5);
+ os << ", const_exprs_6: " << ::android::internal::ToString(const_exprs_6);
+ os << ", const_exprs_7: " << ::android::internal::ToString(const_exprs_7);
+ os << ", const_exprs_8: " << ::android::internal::ToString(const_exprs_8);
+ os << ", const_exprs_9: " << ::android::internal::ToString(const_exprs_9);
+ os << ", const_exprs_10: " << ::android::internal::ToString(const_exprs_10);
+ os << ", addString1: " << ::android::internal::ToString(addString1);
+ os << ", addString2: " << ::android::internal::ToString(addString2);
+ os << ", shouldSetBit0AndBit2: " << ::android::internal::ToString(shouldSetBit0AndBit2);
+ os << ", u: " << ::android::internal::ToString(u);
+ os << ", shouldBeConstS1: " << ::android::internal::ToString(shouldBeConstS1);
+ os << ", defaultWithFoo: " << ::android::internal::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..1dffabb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h
@@ -0,0 +1,137 @@
+#pragma once
+
+#include <android/aidl/tests/ByteEnum.h>
+#include <android/binder_to_string.h>
+#include <binder/IBinder.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <cstdint>
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit Union(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.Union");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Union{";
+ switch (getTag()) {
+ case ns: os << "ns: " << ::android::internal::ToString(get<ns>()); break;
+ case n: os << "n: " << ::android::internal::ToString(get<n>()); break;
+ case m: os << "m: " << ::android::internal::ToString(get<m>()); break;
+ case s: os << "s: " << ::android::internal::ToString(get<s>()); break;
+ case ibinder: os << "ibinder: " << ::android::internal::ToString(get<ibinder>()); break;
+ case ss: os << "ss: " << ::android::internal::ToString(get<ss>()); break;
+ case be: os << "be: " << ::android::internal::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..7e4021f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h
@@ -0,0 +1,123 @@
+#pragma once
+
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/ParcelFileDescriptor.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <cstdint>
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit UnionWithFd(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.UnionWithFd");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "UnionWithFd{";
+ switch (getTag()) {
+ case num: os << "num: " << ::android::internal::ToString(get<num>()); break;
+ case pfd: os << "pfd: " << ::android::internal::ToString(get<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/BnUnionInUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BnUnionInUnion.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/BnUnionInUnion.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/BpUnionInUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/BpUnionInUnion.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/BpUnionInUnion.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..3df7de2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h
@@ -0,0 +1,127 @@
+#pragma once
+
+#include <android/aidl/tests/IntEnum.h>
+#include <android/aidl/tests/LongEnum.h>
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit EnumUnion(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.unions.EnumUnion");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "EnumUnion{";
+ switch (getTag()) {
+ case intEnum: os << "intEnum: " << ::android::internal::ToString(get<intEnum>()); break;
+ case longEnum: os << "longEnum: " << ::android::internal::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/include/android/aidl/tests/unions/UnionInUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h
new file mode 100644
index 0000000..592cfe3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h
@@ -0,0 +1,127 @@
+#pragma once
+
+#include <android/aidl/tests/unions/EnumUnion.h>
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <cstdint>
+#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 UnionInUnion : public ::android::Parcelable {
+public:
+ inline bool operator!=(const UnionInUnion& rhs) const {
+ return _value != rhs._value;
+ }
+ inline bool operator<(const UnionInUnion& rhs) const {
+ return _value < rhs._value;
+ }
+ inline bool operator<=(const UnionInUnion& rhs) const {
+ return _value <= rhs._value;
+ }
+ inline bool operator==(const UnionInUnion& rhs) const {
+ return _value == rhs._value;
+ }
+ inline bool operator>(const UnionInUnion& rhs) const {
+ return _value > rhs._value;
+ }
+ inline bool operator>=(const UnionInUnion& rhs) const {
+ return _value >= rhs._value;
+ }
+
+ enum Tag : int32_t {
+ first = 0, // android.aidl.tests.unions.EnumUnion first;
+ second, // int second;
+ };
+
+ template<typename _Tp>
+ static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>;
+
+ UnionInUnion() : _value(std::in_place_index<first>, ::android::aidl::tests::unions::EnumUnion()) { }
+ UnionInUnion(const UnionInUnion&) = default;
+ UnionInUnion(UnionInUnion&&) = default;
+ UnionInUnion& operator=(const UnionInUnion&) = default;
+ UnionInUnion& operator=(UnionInUnion&&) = default;
+
+ template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ constexpr UnionInUnion(_Tp&& _arg)
+ : _value(std::forward<_Tp>(_arg)) {}
+
+ template <size_t _Np, typename... _Tp>
+ constexpr explicit UnionInUnion(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, std::forward<_Tp>(_args)...) {}
+
+ template <Tag _tag, typename... _Tp>
+ static UnionInUnion make(_Tp&&... _args) {
+ return UnionInUnion(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+ }
+
+ template <Tag _tag, typename _Tp, typename... _Up>
+ static UnionInUnion make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+ return UnionInUnion(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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.tests.unions.UnionInUnion");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "UnionInUnion{";
+ switch (getTag()) {
+ case first: os << "first: " << ::android::internal::ToString(get<first>()); break;
+ case second: os << "second: " << ::android::internal::ToString(get<second>()); break;
+ }
+ os << "}";
+ return os.str();
+ }
+private:
+ std::variant<::android::aidl::tests::unions::EnumUnion, int32_t> _value;
+}; // class UnionInUnion
+
+} // namespace unions
+
+} // namespace tests
+
+} // namespace aidl
+
+} // namespace android
diff --git a/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl-test-interface-cpp-source/gen/timestamp
similarity index 100%
rename from MODULE_LICENSE_APACHE2
rename to 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/DeprecatedEnum.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedEnum.java
new file mode 100644
index 0000000..143b87a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedEnum.java
@@ -0,0 +1,11 @@
+/*
+ * This file is auto-generated. DO NOT MODIFY.
+ */
+package android.aidl.tests;
+/** @deprecated test */
+@Deprecated
+public @interface DeprecatedEnum {
+ public static final int A = 0;
+ public static final int B = 1;
+ public static final int C = 2;
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedEnum.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedEnum.java.d
new file mode 100644
index 0000000..e471625
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedEnum.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedEnum.java : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java
new file mode 100644
index 0000000..f1444ba
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java
@@ -0,0 +1,48 @@
+/*
+ * This file is auto-generated. DO NOT MODIFY.
+ */
+package android.aidl.tests;
+/** @deprecated test */
+@Deprecated
+public class DeprecatedParcelable implements android.os.Parcelable
+{
+ public static final android.os.Parcelable.Creator<DeprecatedParcelable> CREATOR = new android.os.Parcelable.Creator<DeprecatedParcelable>() {
+ @Override
+ public DeprecatedParcelable createFromParcel(android.os.Parcel _aidl_source) {
+ DeprecatedParcelable _aidl_out = new DeprecatedParcelable();
+ _aidl_out.readFromParcel(_aidl_source);
+ return _aidl_out;
+ }
+ @Override
+ public DeprecatedParcelable[] newArray(int _aidl_size) {
+ return new DeprecatedParcelable[_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);
+ 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;
+ } 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;
+ return _mask;
+ }
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java.d
new file mode 100644
index 0000000..94f6de2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/DeprecatedParcelable.java : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedParcelable.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..94b6a2e
--- /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;
+ if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+ a = _aidl_parcel.readInt();
+ if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+ b = _aidl_parcel.readInt();
+ } 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/IDeprecated.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java
new file mode 100644
index 0000000..0290c7a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java
@@ -0,0 +1,98 @@
+/*
+ * This file is auto-generated. DO NOT MODIFY.
+ */
+package android.aidl.tests;
+/** @deprecated test */
+@Deprecated
+public interface IDeprecated extends android.os.IInterface
+{
+ /** Default implementation for IDeprecated. */
+ public static class Default implements android.aidl.tests.IDeprecated
+ {
+ @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.IDeprecated
+ {
+ /** Construct the stub at attach it to the interface. */
+ public Stub()
+ {
+ this.attachInterface(this, DESCRIPTOR);
+ }
+ /**
+ * Cast an IBinder object into an android.aidl.tests.IDeprecated interface,
+ * generating a proxy if needed.
+ */
+ public static android.aidl.tests.IDeprecated 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.IDeprecated))) {
+ return ((android.aidl.tests.IDeprecated)iin);
+ }
+ return new android.aidl.tests.IDeprecated.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)
+ {
+ default:
+ {
+ return super.onTransact(code, data, reply, flags);
+ }
+ }
+ }
+ private static class Proxy implements android.aidl.tests.IDeprecated
+ {
+ 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.aidl.tests.IDeprecated sDefaultImpl;
+ }
+ public static boolean setDefaultImpl(android.aidl.tests.IDeprecated 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.IDeprecated getDefaultImpl() {
+ return Stub.Proxy.sDefaultImpl;
+ }
+ }
+ public static final java.lang.String DESCRIPTOR = "android$aidl$tests$IDeprecated".replace('$', '.');
+}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java.d
new file mode 100644
index 0000000..f97a90c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/IDeprecated.java : \
+ system/tools/aidl/tests/android/aidl/tests/IDeprecated.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..4d6f9fd
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -0,0 +1,2493 @@
+/*
+ * 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;
+ }
+ /**
+ * @deprecated to make sure we have something in system/tools/aidl which does a compile check
+ * of deprecated and make sure this is reflected in goldens
+ */
+ @Override public void Deprecated() throws android.os.RemoteException
+ {
+ }
+ @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_Deprecated:
+ {
+ data.enforceInterface(descriptor);
+ this.Deprecated();
+ reply.writeNoException();
+ 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;
+ }
+ /**
+ * @deprecated to make sure we have something in system/tools/aidl which does a compile check
+ * of deprecated and make sure this is reflected in goldens
+ */
+ @Override public void Deprecated() 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);
+ boolean _status = mRemote.transact(Stub.TRANSACTION_Deprecated, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+ if (!_status) {
+ if (getDefaultImpl() != null) {
+ getDefaultImpl().Deprecated();
+ return;
+ }
+ }
+ _reply.readException();
+ }
+ finally {
+ _reply.recycle();
+ _data.recycle();
+ }
+ }
+ @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_Deprecated = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
+ static final int TRANSACTION_TestOneway = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
+ static final int TRANSACTION_RepeatBoolean = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
+ static final int TRANSACTION_RepeatByte = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
+ static final int TRANSACTION_RepeatChar = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
+ static final int TRANSACTION_RepeatInt = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
+ static final int TRANSACTION_RepeatLong = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
+ static final int TRANSACTION_RepeatFloat = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8);
+ static final int TRANSACTION_RepeatDouble = (android.os.IBinder.FIRST_CALL_TRANSACTION + 9);
+ static final int TRANSACTION_RepeatString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 10);
+ static final int TRANSACTION_RepeatByteEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 11);
+ static final int TRANSACTION_RepeatIntEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 12);
+ static final int TRANSACTION_RepeatLongEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 13);
+ static final int TRANSACTION_ReverseBoolean = (android.os.IBinder.FIRST_CALL_TRANSACTION + 14);
+ static final int TRANSACTION_ReverseByte = (android.os.IBinder.FIRST_CALL_TRANSACTION + 15);
+ static final int TRANSACTION_ReverseChar = (android.os.IBinder.FIRST_CALL_TRANSACTION + 16);
+ static final int TRANSACTION_ReverseInt = (android.os.IBinder.FIRST_CALL_TRANSACTION + 17);
+ static final int TRANSACTION_ReverseLong = (android.os.IBinder.FIRST_CALL_TRANSACTION + 18);
+ static final int TRANSACTION_ReverseFloat = (android.os.IBinder.FIRST_CALL_TRANSACTION + 19);
+ static final int TRANSACTION_ReverseDouble = (android.os.IBinder.FIRST_CALL_TRANSACTION + 20);
+ static final int TRANSACTION_ReverseString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 21);
+ static final int TRANSACTION_ReverseByteEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 22);
+ static final int TRANSACTION_ReverseIntEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 23);
+ static final int TRANSACTION_ReverseLongEnum = (android.os.IBinder.FIRST_CALL_TRANSACTION + 24);
+ static final int TRANSACTION_GetOtherTestService = (android.os.IBinder.FIRST_CALL_TRANSACTION + 25);
+ static final int TRANSACTION_VerifyName = (android.os.IBinder.FIRST_CALL_TRANSACTION + 26);
+ static final int TRANSACTION_ReverseStringList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 27);
+ static final int TRANSACTION_RepeatParcelFileDescriptor = (android.os.IBinder.FIRST_CALL_TRANSACTION + 28);
+ static final int TRANSACTION_ReverseParcelFileDescriptorArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 29);
+ static final int TRANSACTION_ThrowServiceException = (android.os.IBinder.FIRST_CALL_TRANSACTION + 30);
+ static final int TRANSACTION_RepeatNullableIntArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 31);
+ static final int TRANSACTION_RepeatNullableByteEnumArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 32);
+ static final int TRANSACTION_RepeatNullableIntEnumArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 33);
+ static final int TRANSACTION_RepeatNullableLongEnumArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 34);
+ static final int TRANSACTION_RepeatNullableString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 35);
+ static final int TRANSACTION_RepeatNullableStringList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 36);
+ static final int TRANSACTION_RepeatNullableParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 37);
+ static final int TRANSACTION_TakesAnIBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 38);
+ static final int TRANSACTION_TakesANullableIBinder = (android.os.IBinder.FIRST_CALL_TRANSACTION + 39);
+ static final int TRANSACTION_RepeatUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 40);
+ static final int TRANSACTION_RepeatNullableUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 41);
+ static final int TRANSACTION_ReverseUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 42);
+ static final int TRANSACTION_ReverseNullableUtf8CppString = (android.os.IBinder.FIRST_CALL_TRANSACTION + 43);
+ static final int TRANSACTION_ReverseUtf8CppStringList = (android.os.IBinder.FIRST_CALL_TRANSACTION + 44);
+ static final int TRANSACTION_GetCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 45);
+ static final int TRANSACTION_FillOutStructuredParcelable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 46);
+ static final int TRANSACTION_GetOldNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 47);
+ static final int TRANSACTION_GetNewNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 48);
+ static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 49);
+ static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 50);
+ 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;
+ /**
+ * @deprecated to make sure we have something in system/tools/aidl which does a compile check
+ * of deprecated and make sure this is reflected in goldens
+ */
+ @Deprecated
+ public void Deprecated() 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..1dc525b
--- /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/INewName.aidl \
+ system/tools/aidl/tests/android/aidl/tests/IOldName.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
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..a2824ee
--- /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;
+ if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) return;
+ field = _aidl_parcel.readString();
+ } 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..9c1bb13
--- /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 = android.aidl.tests.IntEnum.FOO;
+ 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;
+ if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) 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;
+ }
+ } 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..9a19eb6
--- /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/IntEnum.aidl \
+ system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+ system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.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..806a634
--- /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;
+ if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) 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();
+ } 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..5381770
--- /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/ConstantExpressionEnum.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/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/android/aidl/tests/unions/UnionInUnion.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java
new file mode 100644
index 0000000..a1457e0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java
@@ -0,0 +1,176 @@
+/*
+ * This file is auto-generated. DO NOT MODIFY.
+ */
+package android.aidl.tests.unions;
+
+public final class UnionInUnion implements android.os.Parcelable {
+ // tags for union fields
+ public final static int first = 0; // android.aidl.tests.unions.EnumUnion first;
+ public final static int second = 1; // int second;
+
+ private int _tag;
+ private Object _value;
+
+ public UnionInUnion() {
+ android.aidl.tests.unions.EnumUnion _value = null;
+ this._tag = first;
+ this._value = _value;
+ }
+
+ private UnionInUnion(android.os.Parcel _aidl_parcel) {
+ readFromParcel(_aidl_parcel);
+ }
+
+ private UnionInUnion(int _tag, Object _value) {
+ this._tag = _tag;
+ this._value = _value;
+ }
+
+ public int getTag() {
+ return _tag;
+ }
+
+ // android.aidl.tests.unions.EnumUnion first;
+
+ public static UnionInUnion first(android.aidl.tests.unions.EnumUnion _value) {
+ return new UnionInUnion(first, _value);
+ }
+
+ public android.aidl.tests.unions.EnumUnion getFirst() {
+ _assertTag(first);
+ return (android.aidl.tests.unions.EnumUnion) _value;
+ }
+
+ public void setFirst(android.aidl.tests.unions.EnumUnion _value) {
+ _set(first, _value);
+ }
+
+ // int second;
+
+ public static UnionInUnion second(int _value) {
+ return new UnionInUnion(second, _value);
+ }
+
+ public int getSecond() {
+ _assertTag(second);
+ return (int) _value;
+ }
+
+ public void setSecond(int _value) {
+ _set(second, _value);
+ }
+
+ public static final android.os.Parcelable.Creator<UnionInUnion> CREATOR = new android.os.Parcelable.Creator<UnionInUnion>() {
+ @Override
+ public UnionInUnion createFromParcel(android.os.Parcel _aidl_source) {
+ return new UnionInUnion(_aidl_source);
+ }
+ @Override
+ public UnionInUnion[] newArray(int _aidl_size) {
+ return new UnionInUnion[_aidl_size];
+ }
+ };
+
+ @Override
+ public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) {
+ _aidl_parcel.writeInt(_tag);
+ switch (_tag) {
+ case first:
+ if ((getFirst()!=null)) {
+ _aidl_parcel.writeInt(1);
+ getFirst().writeToParcel(_aidl_parcel, 0);
+ }
+ else {
+ _aidl_parcel.writeInt(0);
+ }
+ break;
+ case second:
+ _aidl_parcel.writeInt(getSecond());
+ break;
+ }
+ }
+
+ public void readFromParcel(android.os.Parcel _aidl_parcel) {
+ int _aidl_tag;
+ _aidl_tag = _aidl_parcel.readInt();
+ switch (_aidl_tag) {
+ case first: {
+ android.aidl.tests.unions.EnumUnion _aidl_value;
+ if ((0!=_aidl_parcel.readInt())) {
+ _aidl_value = android.aidl.tests.unions.EnumUnion.CREATOR.createFromParcel(_aidl_parcel);
+ }
+ else {
+ _aidl_value = null;
+ }
+ _set(_aidl_tag, _aidl_value);
+ return; }
+ case second: {
+ int _aidl_value;
+ _aidl_value = _aidl_parcel.readInt();
+ _set(_aidl_tag, _aidl_value);
+ return; }
+ }
+ throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag);
+ }
+
+ @Override
+ public int describeContents() {
+ int _mask = 0;
+ switch (getTag()) {
+ case first:
+ _mask |= describeContents(getFirst());
+ 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;
+ }
+
+ @Override
+ public String toString() {
+ switch (_tag) {
+ case first: return "android.aidl.tests.unions.UnionInUnion.first(" + (java.util.Objects.toString(getFirst())) + ")";
+ case second: return "android.aidl.tests.unions.UnionInUnion.second(" + (getSecond()) + ")";
+ }
+ 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 UnionInUnion)) return false;
+ UnionInUnion that = (UnionInUnion)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 first: return "first";
+ case second: return "second";
+ }
+ 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/UnionInUnion.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java.d
new file mode 100644
index 0000000..f5c2123
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java : \
+ system/tools/aidl/tests/android/aidl/tests/unions/UnionInUnion.aidl \
+ system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.aidl
diff --git a/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl-test-interface-java-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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/DeprecatedEnum.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedEnum.cpp
new file mode 100644
index 0000000..eb1d7cb
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedEnum.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/DeprecatedEnum.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedEnum.cpp.d
new file mode 100644
index 0000000..42ac6a3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedEnum.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedEnum.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedParcelable.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedParcelable.cpp
new file mode 100644
index 0000000..13fc6c2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedParcelable.cpp
@@ -0,0 +1,38 @@
+#include "aidl/android/aidl/tests/DeprecatedParcelable.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+const char* DeprecatedParcelable::descriptor = "android.aidl.tests.DeprecatedParcelable";
+
+binder_status_t DeprecatedParcelable::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;
+
+ AParcel_setDataPosition(parcel, _aidl_start_pos + _aidl_parcelable_size);
+ return _aidl_ret_status;
+}
+binder_status_t DeprecatedParcelable::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;
+
+ 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/DeprecatedParcelable.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedParcelable.cpp.d
new file mode 100644
index 0000000..168cf66
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedParcelable.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/DeprecatedParcelable.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedParcelable.aidl
diff --git a/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/GenericStructuredParcelable.cpp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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/IDeprecated.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IDeprecated.cpp
new file mode 100644
index 0000000..a6513c2
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IDeprecated.cpp
@@ -0,0 +1,86 @@
+#include <android/binder_parcel_utils.h>
+#include <aidl/android/aidl/tests/BpDeprecated.h>
+#include <aidl/android/aidl/tests/BnDeprecated.h>
+#include <aidl/android/aidl/tests/IDeprecated.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+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;
+ (void)_aidl_binder;
+ (void)_aidl_code;
+ return _aidl_ret_status;
+}
+
+static AIBinder_Class* _g_aidl_clazz = ::ndk::ICInterface::defineClass(IDeprecated::descriptor, _aidl_onTransact);
+
+#pragma clang diagnostic pop
+BpDeprecated::BpDeprecated(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
+BpDeprecated::~BpDeprecated() {}
+
+// Source for BnDeprecated
+BnDeprecated::BnDeprecated() {}
+BnDeprecated::~BnDeprecated() {}
+::ndk::SpAIBinder BnDeprecated::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 IDeprecated
+const char* IDeprecated::descriptor = "android.aidl.tests.IDeprecated";
+IDeprecated::IDeprecated() {}
+IDeprecated::~IDeprecated() {}
+
+
+std::shared_ptr<IDeprecated> IDeprecated::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<IDeprecated>(interface);
+ }
+ return ::ndk::SharedRefBase::make<BpDeprecated>(binder);
+}
+
+binder_status_t IDeprecated::writeToParcel(AParcel* parcel, const std::shared_ptr<IDeprecated>& instance) {
+ return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
+}
+binder_status_t IDeprecated::readFromParcel(const AParcel* parcel, std::shared_ptr<IDeprecated>* instance) {
+ ::ndk::SpAIBinder binder;
+ binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
+ if (status != STATUS_OK) return status;
+ *instance = IDeprecated::fromBinder(binder);
+ return STATUS_OK;
+}
+bool IDeprecated::setDefaultImpl(const std::shared_ptr<IDeprecated>& 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(!IDeprecated::default_impl);
+ if (impl) {
+ IDeprecated::default_impl = impl;
+ return true;
+ }
+ return false;
+}
+const std::shared_ptr<IDeprecated>& IDeprecated::getDefaultImpl() {
+ return IDeprecated::default_impl;
+}
+std::shared_ptr<IDeprecated> IDeprecated::default_impl = nullptr;
+::ndk::SpAIBinder IDeprecatedDefault::asBinder() {
+ return ::ndk::SpAIBinder();
+}
+bool IDeprecatedDefault::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/IDeprecated.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IDeprecated.cpp.d
new file mode 100644
index 0000000..5bc40c0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IDeprecated.cpp.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/IDeprecated.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/IDeprecated.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..515707a
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/ITestService.cpp
@@ -0,0 +1,3480 @@
+#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 {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+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 /*Deprecated*/): {
+
+ ::ndk::ScopedAStatus _aidl_status = _aidl_impl->Deprecated();
+ _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 + 2 /*TestOneway*/): {
+
+ ::ndk::ScopedAStatus _aidl_status = _aidl_impl->TestOneway();
+ _aidl_ret_status = STATUS_OK;
+ break;
+ }
+ case (FIRST_CALL_TRANSACTION + 3 /*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 + 4 /*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 + 5 /*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 + 6 /*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 + 7 /*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 + 8 /*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 + 9 /*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 + 10 /*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 + 11 /*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 + 12 /*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 + 13 /*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 + 14 /*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 + 15 /*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 + 16 /*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 + 17 /*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 + 18 /*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 + 19 /*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 + 20 /*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 + 21 /*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 + 22 /*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 + 23 /*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 + 24 /*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 + 25 /*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 + 26 /*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 + 27 /*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 + 28 /*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 + 29 /*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 + 30 /*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 + 31 /*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 + 32 /*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 + 33 /*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 + 34 /*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 + 35 /*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 + 36 /*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 + 37 /*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 + 38 /*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 + 39 /*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 + 40 /*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 + 41 /*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 + 42 /*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 + 43 /*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 + 44 /*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 + 45 /*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 + 46 /*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 + 47 /*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 + 48 /*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 + 49 /*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 + 50 /*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);
+
+#pragma clang diagnostic pop
+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::Deprecated() {
+ 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 /*Deprecated*/),
+ _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()->Deprecated();
+ 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::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 + 2 /*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 + 3 /*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 + 4 /*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 + 5 /*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 + 6 /*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 + 7 /*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 + 8 /*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 + 9 /*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 + 10 /*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 + 11 /*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 + 12 /*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 + 13 /*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 + 14 /*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 + 15 /*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 + 16 /*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 + 17 /*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 + 18 /*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 + 19 /*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 + 20 /*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 + 21 /*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 + 22 /*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 + 23 /*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 + 24 /*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 + 25 /*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 + 26 /*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 + 27 /*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 + 28 /*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 + 29 /*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 + 30 /*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 + 31 /*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 + 32 /*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 + 33 /*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 + 34 /*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 + 35 /*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 + 36 /*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 + 37 /*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 + 38 /*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 + 39 /*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 + 40 /*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 + 41 /*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 + 42 /*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 + 43 /*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 + 44 /*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 + 45 /*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 + 46 /*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 + 47 /*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 + 48 /*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 + 49 /*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 + 50 /*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::Deprecated() {
+ ::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..6014d3f
--- /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/INewName.aidl \
+ system/tools/aidl/tests/android/aidl/tests/IOldName.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
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..17322d8
--- /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;
+
+ 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, &field);
+ if (_aidl_ret_status != STATUS_OK) 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..a5ad0a7
--- /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;
+
+ 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, &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;
+
+ 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..69fcacb
--- /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/IntEnum.aidl \
+ system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+ system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.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..2d7588a
--- /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;
+
+ 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, &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;
+
+ 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..1b902e6
--- /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/ConstantExpressionEnum.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/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/android/aidl/tests/unions/UnionInUnion.cpp b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/UnionInUnion.cpp
new file mode 100644
index 0000000..79c36ff
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/UnionInUnion.cpp
@@ -0,0 +1,54 @@
+#include "aidl/android/aidl/tests/unions/UnionInUnion.h"
+
+#include <android/binder_parcel_utils.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+const char* UnionInUnion::descriptor = "android.aidl.tests.unions.UnionInUnion";
+
+binder_status_t UnionInUnion::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 first: {
+ ::aidl::android::aidl::tests::unions::EnumUnion _aidl_value;
+ if ((_aidl_ret_status = ::ndk::AParcel_readParcelable(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+ if constexpr (std::is_trivially_copyable_v<::aidl::android::aidl::tests::unions::EnumUnion>) {
+ set<first>(_aidl_value);
+ } else {
+ // NOLINTNEXTLINE(performance-move-const-arg)
+ set<first>(std::move(_aidl_value));
+ }
+ return STATUS_OK; }
+ case second: {
+ 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<second>(_aidl_value);
+ } else {
+ // NOLINTNEXTLINE(performance-move-const-arg)
+ set<second>(std::move(_aidl_value));
+ }
+ return STATUS_OK; }
+ }
+ return STATUS_BAD_VALUE;
+}
+binder_status_t UnionInUnion::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 first: return ::ndk::AParcel_writeParcelable(_parcel, get<first>());
+ case second: return AParcel_writeInt32(_parcel, get<second>());
+ }
+ __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/UnionInUnion.cpp.d b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/UnionInUnion.cpp.d
new file mode 100644
index 0000000..5b41318
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/UnionInUnion.cpp.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-ndk_platform-source/gen/android/aidl/tests/unions/UnionInUnion.cpp : \
+ system/tools/aidl/tests/android/aidl/tests/unions/UnionInUnion.aidl \
+ system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.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..6838ca7
--- /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,
+};
+
+[[nodiscard]] 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/BnDeprecated.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnDeprecated.h
new file mode 100644
index 0000000..0b6f042
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnDeprecated.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/IDeprecated.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class __attribute__((deprecated("test"))) BnDeprecated : public ::ndk::BnCInterface<IDeprecated> {
+public:
+ BnDeprecated();
+ virtual ~BnDeprecated();
+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/BnDeprecatedEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnDeprecatedEnum.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/BnDeprecatedEnum.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/BnDeprecatedParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BnDeprecatedParcelable.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/BnDeprecatedParcelable.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/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/BpDeprecated.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpDeprecated.h
new file mode 100644
index 0000000..ee9626d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpDeprecated.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "aidl/android/aidl/tests/IDeprecated.h"
+
+#include <android/binder_ibinder.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+class __attribute__((deprecated("test"))) BpDeprecated : public ::ndk::BpCInterface<IDeprecated> {
+public:
+ explicit BpDeprecated(const ::ndk::SpAIBinder& binder);
+ virtual ~BpDeprecated();
+
+};
+} // 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/BpDeprecatedEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpDeprecatedEnum.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/BpDeprecatedEnum.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/BpDeprecatedParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpDeprecatedParcelable.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/BpDeprecatedParcelable.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/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..30b0fa0
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/BpTestService.h
@@ -0,0 +1,71 @@
+#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 Deprecated() override __attribute__((deprecated("to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens")));
+ ::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..30ac9e5
--- /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,
+};
+
+[[nodiscard]] 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..1802d84
--- /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,
+};
+
+[[nodiscard]] 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/DeprecatedEnum.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/DeprecatedEnum.h
new file mode 100644
index 0000000..853c808
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/DeprecatedEnum.h
@@ -0,0 +1,52 @@
+#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 __attribute__((deprecated("test"))) DeprecatedEnum : int32_t {
+ A = 0,
+ B = 1,
+ C = 2,
+};
+
+[[nodiscard]] static inline std::string toString(DeprecatedEnum val) __attribute__((deprecated("test")));
+[[nodiscard]] static inline std::string toString(DeprecatedEnum val) {
+ switch(val) {
+ case DeprecatedEnum::A:
+ return "A";
+ case DeprecatedEnum::B:
+ return "B";
+ case DeprecatedEnum::C:
+ return "C";
+ 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::DeprecatedEnum, 3> __attribute__((deprecated("test"))) enum_values<aidl::android::aidl::tests::DeprecatedEnum> = {
+ aidl::android::aidl::tests::DeprecatedEnum::A,
+ aidl::android::aidl::tests::DeprecatedEnum::B,
+ aidl::android::aidl::tests::DeprecatedEnum::C,
+};
+#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/DeprecatedParcelable.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/DeprecatedParcelable.h
new file mode 100644
index 0000000..52719bc
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/DeprecatedParcelable.h
@@ -0,0 +1,56 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 __attribute__((deprecated("test"))) DeprecatedParcelable {
+public:
+ typedef std::false_type fixed_size;
+ static const char* descriptor;
+
+
+ binder_status_t readFromParcel(const AParcel* parcel);
+ binder_status_t writeToParcel(AParcel* parcel) const;
+
+ inline bool operator!=(const DeprecatedParcelable&) const {
+ return std::tie() != std::tie();
+ }
+ inline bool operator<(const DeprecatedParcelable&) const {
+ return std::tie() < std::tie();
+ }
+ inline bool operator<=(const DeprecatedParcelable&) const {
+ return std::tie() <= std::tie();
+ }
+ inline bool operator==(const DeprecatedParcelable&) const {
+ return std::tie() == std::tie();
+ }
+ inline bool operator>(const DeprecatedParcelable&) const {
+ return std::tie() > std::tie();
+ }
+ inline bool operator>=(const DeprecatedParcelable&) const {
+ return std::tie() >= std::tie();
+ }
+
+ static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "DeprecatedParcelable{";
+ 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/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..113aff4
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/GenericStructuredParcelable.h
@@ -0,0 +1,122 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 {
+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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "GenericStructuredParcelable{";
+ os << "a: " << ::android::internal::ToString(a);
+ os << ", b: " << ::android::internal::ToString(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;
+
+ 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, &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;
+
+ 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/IDeprecated.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IDeprecated.h
new file mode 100644
index 0000000..80d5589
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/IDeprecated.h
@@ -0,0 +1,41 @@
+#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 __attribute__((deprecated("test"))) IDeprecated : public ::ndk::ICInterface {
+public:
+ static const char* descriptor;
+ IDeprecated();
+ virtual ~IDeprecated();
+
+
+ static std::shared_ptr<IDeprecated> fromBinder(const ::ndk::SpAIBinder& binder);
+ static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<IDeprecated>& instance);
+ static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IDeprecated>* instance);
+ static bool setDefaultImpl(const std::shared_ptr<IDeprecated>& impl);
+ static const std::shared_ptr<IDeprecated>& getDefaultImpl();
+private:
+ static std::shared_ptr<IDeprecated> default_impl;
+};
+class __attribute__((deprecated("test"))) IDeprecatedDefault : public IDeprecated {
+public:
+ ::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/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..62f8132
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -0,0 +1,278 @@
+#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_Deprecated = FIRST_CALL_TRANSACTION + 1;
+ static constexpr uint32_t TRANSACTION_TestOneway = FIRST_CALL_TRANSACTION + 2;
+ static constexpr uint32_t TRANSACTION_RepeatBoolean = FIRST_CALL_TRANSACTION + 3;
+ static constexpr uint32_t TRANSACTION_RepeatByte = FIRST_CALL_TRANSACTION + 4;
+ static constexpr uint32_t TRANSACTION_RepeatChar = FIRST_CALL_TRANSACTION + 5;
+ static constexpr uint32_t TRANSACTION_RepeatInt = FIRST_CALL_TRANSACTION + 6;
+ static constexpr uint32_t TRANSACTION_RepeatLong = FIRST_CALL_TRANSACTION + 7;
+ static constexpr uint32_t TRANSACTION_RepeatFloat = FIRST_CALL_TRANSACTION + 8;
+ static constexpr uint32_t TRANSACTION_RepeatDouble = FIRST_CALL_TRANSACTION + 9;
+ static constexpr uint32_t TRANSACTION_RepeatString = FIRST_CALL_TRANSACTION + 10;
+ static constexpr uint32_t TRANSACTION_RepeatByteEnum = FIRST_CALL_TRANSACTION + 11;
+ static constexpr uint32_t TRANSACTION_RepeatIntEnum = FIRST_CALL_TRANSACTION + 12;
+ static constexpr uint32_t TRANSACTION_RepeatLongEnum = FIRST_CALL_TRANSACTION + 13;
+ static constexpr uint32_t TRANSACTION_ReverseBoolean = FIRST_CALL_TRANSACTION + 14;
+ static constexpr uint32_t TRANSACTION_ReverseByte = FIRST_CALL_TRANSACTION + 15;
+ static constexpr uint32_t TRANSACTION_ReverseChar = FIRST_CALL_TRANSACTION + 16;
+ static constexpr uint32_t TRANSACTION_ReverseInt = FIRST_CALL_TRANSACTION + 17;
+ static constexpr uint32_t TRANSACTION_ReverseLong = FIRST_CALL_TRANSACTION + 18;
+ static constexpr uint32_t TRANSACTION_ReverseFloat = FIRST_CALL_TRANSACTION + 19;
+ static constexpr uint32_t TRANSACTION_ReverseDouble = FIRST_CALL_TRANSACTION + 20;
+ static constexpr uint32_t TRANSACTION_ReverseString = FIRST_CALL_TRANSACTION + 21;
+ static constexpr uint32_t TRANSACTION_ReverseByteEnum = FIRST_CALL_TRANSACTION + 22;
+ static constexpr uint32_t TRANSACTION_ReverseIntEnum = FIRST_CALL_TRANSACTION + 23;
+ static constexpr uint32_t TRANSACTION_ReverseLongEnum = FIRST_CALL_TRANSACTION + 24;
+ static constexpr uint32_t TRANSACTION_GetOtherTestService = FIRST_CALL_TRANSACTION + 25;
+ static constexpr uint32_t TRANSACTION_VerifyName = FIRST_CALL_TRANSACTION + 26;
+ static constexpr uint32_t TRANSACTION_ReverseStringList = FIRST_CALL_TRANSACTION + 27;
+ static constexpr uint32_t TRANSACTION_RepeatParcelFileDescriptor = FIRST_CALL_TRANSACTION + 28;
+ static constexpr uint32_t TRANSACTION_ReverseParcelFileDescriptorArray = FIRST_CALL_TRANSACTION + 29;
+ static constexpr uint32_t TRANSACTION_ThrowServiceException = FIRST_CALL_TRANSACTION + 30;
+ static constexpr uint32_t TRANSACTION_RepeatNullableIntArray = FIRST_CALL_TRANSACTION + 31;
+ static constexpr uint32_t TRANSACTION_RepeatNullableByteEnumArray = FIRST_CALL_TRANSACTION + 32;
+ static constexpr uint32_t TRANSACTION_RepeatNullableIntEnumArray = FIRST_CALL_TRANSACTION + 33;
+ static constexpr uint32_t TRANSACTION_RepeatNullableLongEnumArray = FIRST_CALL_TRANSACTION + 34;
+ static constexpr uint32_t TRANSACTION_RepeatNullableString = FIRST_CALL_TRANSACTION + 35;
+ static constexpr uint32_t TRANSACTION_RepeatNullableStringList = FIRST_CALL_TRANSACTION + 36;
+ static constexpr uint32_t TRANSACTION_RepeatNullableParcelable = FIRST_CALL_TRANSACTION + 37;
+ static constexpr uint32_t TRANSACTION_TakesAnIBinder = FIRST_CALL_TRANSACTION + 38;
+ static constexpr uint32_t TRANSACTION_TakesANullableIBinder = FIRST_CALL_TRANSACTION + 39;
+ static constexpr uint32_t TRANSACTION_RepeatUtf8CppString = FIRST_CALL_TRANSACTION + 40;
+ static constexpr uint32_t TRANSACTION_RepeatNullableUtf8CppString = FIRST_CALL_TRANSACTION + 41;
+ static constexpr uint32_t TRANSACTION_ReverseUtf8CppString = FIRST_CALL_TRANSACTION + 42;
+ static constexpr uint32_t TRANSACTION_ReverseNullableUtf8CppString = FIRST_CALL_TRANSACTION + 43;
+ static constexpr uint32_t TRANSACTION_ReverseUtf8CppStringList = FIRST_CALL_TRANSACTION + 44;
+ static constexpr uint32_t TRANSACTION_GetCallback = FIRST_CALL_TRANSACTION + 45;
+ static constexpr uint32_t TRANSACTION_FillOutStructuredParcelable = FIRST_CALL_TRANSACTION + 46;
+ static constexpr uint32_t TRANSACTION_GetOldNameInterface = FIRST_CALL_TRANSACTION + 47;
+ static constexpr uint32_t TRANSACTION_GetNewNameInterface = FIRST_CALL_TRANSACTION + 48;
+ static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 49;
+ static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 50;
+
+ 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 Deprecated() __attribute__((deprecated("to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens"))) = 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 Deprecated() override __attribute__((deprecated("to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens")));
+ ::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..b5f9ac9
--- /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,
+};
+
+[[nodiscard]] 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..5081c89
--- /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,
+};
+
+[[nodiscard]] 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..ef75d71
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/OtherParcelableForToString.h
@@ -0,0 +1,58 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "OtherParcelableForToString{";
+ os << "field: " << ::android::internal::ToString(field);
+ 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..c74001d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/ParcelableForToString.h
@@ -0,0 +1,107 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 <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 = ::aidl::android::aidl::tests::IntEnum::FOO;
+ 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "ParcelableForToString{";
+ os << "intValue: " << ::android::internal::ToString(intValue);
+ os << ", intArray: " << ::android::internal::ToString(intArray);
+ os << ", longValue: " << ::android::internal::ToString(longValue);
+ os << ", longArray: " << ::android::internal::ToString(longArray);
+ os << ", doubleValue: " << ::android::internal::ToString(doubleValue);
+ os << ", doubleArray: " << ::android::internal::ToString(doubleArray);
+ os << ", floatValue: " << ::android::internal::ToString(floatValue);
+ os << ", floatArray: " << ::android::internal::ToString(floatArray);
+ os << ", byteValue: " << ::android::internal::ToString(byteValue);
+ os << ", byteArray: " << ::android::internal::ToString(byteArray);
+ os << ", booleanValue: " << ::android::internal::ToString(booleanValue);
+ os << ", booleanArray: " << ::android::internal::ToString(booleanArray);
+ os << ", stringValue: " << ::android::internal::ToString(stringValue);
+ os << ", stringArray: " << ::android::internal::ToString(stringArray);
+ os << ", stringList: " << ::android::internal::ToString(stringList);
+ os << ", parcelableValue: " << ::android::internal::ToString(parcelableValue);
+ os << ", parcelableArray: " << ::android::internal::ToString(parcelableArray);
+ os << ", enumValue: " << ::android::internal::ToString(enumValue);
+ os << ", enumArray: " << ::android::internal::ToString(enumArray);
+ os << ", nullArray: " << ::android::internal::ToString(nullArray);
+ os << ", nullList: " << ::android::internal::ToString(nullList);
+ os << ", parcelableGeneric: " << ::android::internal::ToString(parcelableGeneric);
+ os << ", unionValue: " << ::android::internal::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..01fd7a3
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/StructuredParcelable.h
@@ -0,0 +1,170 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 <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 };
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "StructuredParcelable{";
+ os << "shouldContainThreeFs: " << ::android::internal::ToString(shouldContainThreeFs);
+ os << ", f: " << ::android::internal::ToString(f);
+ os << ", shouldBeJerry: " << ::android::internal::ToString(shouldBeJerry);
+ os << ", shouldBeByteBar: " << ::android::internal::ToString(shouldBeByteBar);
+ os << ", shouldBeIntBar: " << ::android::internal::ToString(shouldBeIntBar);
+ os << ", shouldBeLongBar: " << ::android::internal::ToString(shouldBeLongBar);
+ os << ", shouldContainTwoByteFoos: " << ::android::internal::ToString(shouldContainTwoByteFoos);
+ os << ", shouldContainTwoIntFoos: " << ::android::internal::ToString(shouldContainTwoIntFoos);
+ os << ", shouldContainTwoLongFoos: " << ::android::internal::ToString(shouldContainTwoLongFoos);
+ os << ", stringDefaultsToFoo: " << ::android::internal::ToString(stringDefaultsToFoo);
+ os << ", byteDefaultsToFour: " << ::android::internal::ToString(byteDefaultsToFour);
+ os << ", intDefaultsToFive: " << ::android::internal::ToString(intDefaultsToFive);
+ os << ", longDefaultsToNegativeSeven: " << ::android::internal::ToString(longDefaultsToNegativeSeven);
+ os << ", booleanDefaultsToTrue: " << ::android::internal::ToString(booleanDefaultsToTrue);
+ os << ", charDefaultsToC: " << ::android::internal::ToString(charDefaultsToC);
+ os << ", floatDefaultsToPi: " << ::android::internal::ToString(floatDefaultsToPi);
+ os << ", doubleWithDefault: " << ::android::internal::ToString(doubleWithDefault);
+ os << ", arrayDefaultsTo123: " << ::android::internal::ToString(arrayDefaultsTo123);
+ os << ", arrayDefaultsToEmpty: " << ::android::internal::ToString(arrayDefaultsToEmpty);
+ os << ", boolDefault: " << ::android::internal::ToString(boolDefault);
+ os << ", byteDefault: " << ::android::internal::ToString(byteDefault);
+ os << ", intDefault: " << ::android::internal::ToString(intDefault);
+ os << ", longDefault: " << ::android::internal::ToString(longDefault);
+ os << ", floatDefault: " << ::android::internal::ToString(floatDefault);
+ os << ", doubleDefault: " << ::android::internal::ToString(doubleDefault);
+ os << ", checkDoubleFromFloat: " << ::android::internal::ToString(checkDoubleFromFloat);
+ os << ", checkStringArray1: " << ::android::internal::ToString(checkStringArray1);
+ os << ", checkStringArray2: " << ::android::internal::ToString(checkStringArray2);
+ os << ", int32_min: " << ::android::internal::ToString(int32_min);
+ os << ", int32_max: " << ::android::internal::ToString(int32_max);
+ os << ", int64_max: " << ::android::internal::ToString(int64_max);
+ os << ", hexInt32_neg_1: " << ::android::internal::ToString(hexInt32_neg_1);
+ os << ", ibinder: " << ::android::internal::ToString(ibinder);
+ os << ", int32_1: " << ::android::internal::ToString(int32_1);
+ os << ", int64_1: " << ::android::internal::ToString(int64_1);
+ os << ", hexInt32_pos_1: " << ::android::internal::ToString(hexInt32_pos_1);
+ os << ", hexInt64_pos_1: " << ::android::internal::ToString(hexInt64_pos_1);
+ os << ", const_exprs_1: " << ::android::internal::ToString(const_exprs_1);
+ os << ", const_exprs_2: " << ::android::internal::ToString(const_exprs_2);
+ os << ", const_exprs_3: " << ::android::internal::ToString(const_exprs_3);
+ os << ", const_exprs_4: " << ::android::internal::ToString(const_exprs_4);
+ os << ", const_exprs_5: " << ::android::internal::ToString(const_exprs_5);
+ os << ", const_exprs_6: " << ::android::internal::ToString(const_exprs_6);
+ os << ", const_exprs_7: " << ::android::internal::ToString(const_exprs_7);
+ os << ", const_exprs_8: " << ::android::internal::ToString(const_exprs_8);
+ os << ", const_exprs_9: " << ::android::internal::ToString(const_exprs_9);
+ os << ", const_exprs_10: " << ::android::internal::ToString(const_exprs_10);
+ os << ", addString1: " << ::android::internal::ToString(addString1);
+ os << ", addString2: " << ::android::internal::ToString(addString2);
+ os << ", shouldSetBit0AndBit2: " << ::android::internal::ToString(shouldSetBit0AndBit2);
+ os << ", u: " << ::android::internal::ToString(u);
+ os << ", shouldBeConstS1: " << ::android::internal::ToString(shouldBeConstS1);
+ os << ", defaultWithFoo: " << ::android::internal::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..b90f6c4
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/Union.h
@@ -0,0 +1,137 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.h>
+
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit Union(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Union{";
+ switch (getTag()) {
+ case ns: os << "ns: " << ::android::internal::ToString(get<ns>()); break;
+ case n: os << "n: " << ::android::internal::ToString(get<n>()); break;
+ case m: os << "m: " << ::android::internal::ToString(get<m>()); break;
+ case s: os << "s: " << ::android::internal::ToString(get<s>()); break;
+ case ibinder: os << "ibinder: " << ::android::internal::ToString(get<ibinder>()); break;
+ case ss: os << "ss: " << ::android::internal::ToString(get<ss>()); break;
+ case be: os << "be: " << ::android::internal::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..7d045ec
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
@@ -0,0 +1,125 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.h>
+
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit UnionWithFd(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "UnionWithFd{";
+ switch (getTag()) {
+ case num: os << "num: " << ::android::internal::ToString(get<num>()); break;
+ case pfd: os << "pfd: " << ::android::internal::ToString(get<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/BnUnionInUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BnUnionInUnion.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/BnUnionInUnion.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/BpUnionInUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/BpUnionInUnion.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/BpUnionInUnion.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..ef1345c
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
@@ -0,0 +1,129 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.h>
+
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit EnumUnion(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "EnumUnion{";
+ switch (getTag()) {
+ case intEnum: os << "intEnum: " << ::android::internal::ToString(get<intEnum>()); break;
+ case longEnum: os << "longEnum: " << ::android::internal::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/include/aidl/android/aidl/tests/unions/UnionInUnion.h b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
new file mode 100644
index 0000000..9d57be4
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
@@ -0,0 +1,128 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.h>
+
+#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/unions/EnumUnion.h>
+
+#ifndef __BIONIC__
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+class UnionInUnion {
+public:
+ typedef std::false_type fixed_size;
+ static const char* descriptor;
+
+ enum Tag : int32_t {
+ first = 0, // android.aidl.tests.unions.EnumUnion first;
+ second, // int second;
+ };
+
+ template<typename _Tp>
+ static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>;
+
+ UnionInUnion() : _value(std::in_place_index<first>, ::aidl::android::aidl::tests::unions::EnumUnion()) { }
+ UnionInUnion(const UnionInUnion&) = default;
+ UnionInUnion(UnionInUnion&&) = default;
+ UnionInUnion& operator=(const UnionInUnion&) = default;
+ UnionInUnion& operator=(UnionInUnion&&) = default;
+
+ template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ constexpr UnionInUnion(_Tp&& _arg)
+ : _value(std::forward<_Tp>(_arg)) {}
+
+ template <size_t _Np, typename... _Tp>
+ constexpr explicit UnionInUnion(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, std::forward<_Tp>(_args)...) {}
+
+ template <Tag _tag, typename... _Tp>
+ static UnionInUnion make(_Tp&&... _args) {
+ return UnionInUnion(std::in_place_index<_tag>, std::forward<_Tp>(_args)...);
+ }
+
+ template <Tag _tag, typename _Tp, typename... _Up>
+ static UnionInUnion make(std::initializer_list<_Tp> _il, _Up&&... _args) {
+ return UnionInUnion(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 UnionInUnion& rhs) const {
+ return _value != rhs._value;
+ }
+ inline bool operator<(const UnionInUnion& rhs) const {
+ return _value < rhs._value;
+ }
+ inline bool operator<=(const UnionInUnion& rhs) const {
+ return _value <= rhs._value;
+ }
+ inline bool operator==(const UnionInUnion& rhs) const {
+ return _value == rhs._value;
+ }
+ inline bool operator>(const UnionInUnion& rhs) const {
+ return _value > rhs._value;
+ }
+ inline bool operator>=(const UnionInUnion& rhs) const {
+ return _value >= rhs._value;
+ }
+
+ static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_LOCAL;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "UnionInUnion{";
+ switch (getTag()) {
+ case first: os << "first: " << ::android::internal::ToString(get<first>()); break;
+ case second: os << "second: " << ::android::internal::ToString(get<second>()); break;
+ }
+ os << "}";
+ return os.str();
+ }
+private:
+ std::variant<::aidl::android::aidl::tests::unions::EnumUnion, int32_t> _value;
+};
+} // namespace unions
+} // namespace tests
+} // namespace aidl
+} // namespace android
+} // namespace aidl
diff --git a/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl-test-interface-ndk_platform-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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/DeprecatedEnum.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs
new file mode 100644
index 0000000..0d45d7d
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs
@@ -0,0 +1,8 @@
+#![allow(non_upper_case_globals)]
+use binder::declare_binder_enum;
+declare_binder_enum! { DeprecatedEnum : i32 {
+ A = 0,
+ B = 1,
+ C = 2,
+} }
+pub(crate) mod mangled { pub use super::DeprecatedEnum as _7_android_4_aidl_5_tests_14_DeprecatedEnum; }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs.d
new file mode 100644
index 0000000..388f093
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedEnum.rs : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs
new file mode 100644
index 0000000..18ba875
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs
@@ -0,0 +1,55 @@
+#[derive(Debug)]
+#[deprecated = "test"]
+pub struct DeprecatedParcelable {
+}
+pub(crate) mod mangled { pub use super::DeprecatedParcelable as _7_android_4_aidl_5_tests_20_DeprecatedParcelable; }
+impl Default for DeprecatedParcelable {
+ fn default() -> Self {
+ Self {
+ }
+ }
+}
+impl binder::parcel::Serialize for DeprecatedParcelable {
+ 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 DeprecatedParcelable {}
+impl binder::parcel::SerializeOption for DeprecatedParcelable {
+ 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| {
+ Ok(())
+ })
+ }
+}
+impl binder::parcel::Deserialize for DeprecatedParcelable {
+ 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 DeprecatedParcelable {}
+impl binder::parcel::DeserializeOption for DeprecatedParcelable {
+ 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); }
+ if start_pos.checked_add(parcelable_size).is_none() {
+ return Err(binder::StatusCode::BAD_VALUE);
+ }
+ let mut result = Self::default();
+ unsafe {
+ parcel.set_data_position(start_pos + parcelable_size)?;
+ }
+ Ok(Some(result))
+ }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs.d
new file mode 100644
index 0000000..a257852
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/DeprecatedParcelable.rs : \
+ system/tools/aidl/tests/android/aidl/tests/DeprecatedParcelable.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..24fcd99
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/GenericStructuredParcelable.rs
@@ -0,0 +1,68 @@
+#[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); }
+ if start_pos.checked_add(parcelable_size).is_none() {
+ return Err(binder::StatusCode::BAD_VALUE);
+ }
+ let mut result = Self::default();
+ if (parcel.get_data_position() - start_pos) == parcelable_size {
+ return Ok(Some(result));
+ }
+ result.a = parcel.read()?;
+ if (parcel.get_data_position() - start_pos) == parcelable_size {
+ return Ok(Some(result));
+ }
+ result.b = parcel.read()?;
+ unsafe {
+ parcel.set_data_position(start_pos + parcelable_size)?;
+ }
+ 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/IDeprecated.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs
new file mode 100644
index 0000000..5920654
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs
@@ -0,0 +1,40 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinderInternal;
+use binder::declare_binder_interface;
+declare_binder_interface! {
+ IDeprecated["android.aidl.tests.IDeprecated"] {
+ native: BnDeprecated(on_transact),
+ proxy: BpDeprecated {
+ },
+ }
+}
+#[deprecated = "test"]
+pub trait IDeprecated: binder::Interface + Send {
+ fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.IDeprecated" }
+ fn getDefaultImpl() -> IDeprecatedDefaultRef where Self: Sized {
+ DEFAULT_IMPL.lock().unwrap().clone()
+ }
+ fn setDefaultImpl(d: IDeprecatedDefaultRef) -> IDeprecatedDefaultRef where Self: Sized {
+ std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+ }
+}
+pub trait IDeprecatedDefault: Send + Sync {
+}
+pub mod transactions {
+}
+pub type IDeprecatedDefaultRef = Option<std::sync::Arc<dyn IDeprecatedDefault>>;
+use lazy_static::lazy_static;
+lazy_static! {
+ static ref DEFAULT_IMPL: std::sync::Mutex<IDeprecatedDefaultRef> = std::sync::Mutex::new(None);
+}
+pub(crate) mod mangled { pub use super::IDeprecated as _7_android_4_aidl_5_tests_11_IDeprecated; }
+impl IDeprecated for BpDeprecated {
+}
+impl IDeprecated for binder::Binder<BnDeprecated> {
+}
+fn on_transact(_aidl_service: &dyn IDeprecated, _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)
+ }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs.d
new file mode 100644
index 0000000..dc96618
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs.d
@@ -0,0 +1,2 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/IDeprecated.rs : \
+ system/tools/aidl/tests/android/aidl/tests/IDeprecated.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..f8d1fba
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INamedCallback.rs
@@ -0,0 +1,71 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinderInternal;
+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 {
+ pub const GetName: binder::TransactionCode = binder::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, binder::FLAG_PRIVATE_LOCAL, |_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..70b6bd1
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/INewName.rs
@@ -0,0 +1,71 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinderInternal;
+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 {
+ pub const RealName: binder::TransactionCode = binder::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, binder::FLAG_PRIVATE_LOCAL, |_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..a61d664
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/IOldName.rs
@@ -0,0 +1,71 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinderInternal;
+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 {
+ pub const RealName: binder::TransactionCode = binder::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, binder::FLAG_PRIVATE_LOCAL, |_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..2e34dba
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
@@ -0,0 +1,1948 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_snake_case)]
+#[allow(unused_imports)] use binder::IBinderInternal;
+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>;
+ #[deprecated = "to make sure we have something in system/tools/aidl which does a compile check of deprecated and make sure this is reflected in goldens"]
+ fn Deprecated(&self) -> binder::public_api::Result<()>;
+ 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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>;
+ fn VerifyName(&self, _arg_service: &binder::Strong<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<binder::Strong<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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
+ fn GetNewNameInterface(&self) -> binder::public_api::Result<binder::Strong<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 Deprecated(&self) -> binder::public_api::Result<()> {
+ 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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> {
+ Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+ }
+ fn VerifyName(&self, _arg_service: &binder::Strong<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<binder::Strong<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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> {
+ Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+ }
+ fn GetNewNameInterface(&self) -> binder::public_api::Result<binder::Strong<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 {
+ pub const UnimplementedMethod: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 0;
+ pub const Deprecated: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 1;
+ pub const TestOneway: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 2;
+ pub const RepeatBoolean: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 3;
+ pub const RepeatByte: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 4;
+ pub const RepeatChar: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 5;
+ pub const RepeatInt: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 6;
+ pub const RepeatLong: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 7;
+ pub const RepeatFloat: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 8;
+ pub const RepeatDouble: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 9;
+ pub const RepeatString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 10;
+ pub const RepeatByteEnum: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 11;
+ pub const RepeatIntEnum: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 12;
+ pub const RepeatLongEnum: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 13;
+ pub const ReverseBoolean: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 14;
+ pub const ReverseByte: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 15;
+ pub const ReverseChar: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 16;
+ pub const ReverseInt: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 17;
+ pub const ReverseLong: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 18;
+ pub const ReverseFloat: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 19;
+ pub const ReverseDouble: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 20;
+ pub const ReverseString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 21;
+ pub const ReverseByteEnum: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 22;
+ pub const ReverseIntEnum: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 23;
+ pub const ReverseLongEnum: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 24;
+ pub const GetOtherTestService: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 25;
+ pub const VerifyName: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 26;
+ pub const ReverseStringList: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 27;
+ pub const RepeatParcelFileDescriptor: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 28;
+ pub const ReverseParcelFileDescriptorArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 29;
+ pub const ThrowServiceException: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 30;
+ pub const RepeatNullableIntArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 31;
+ pub const RepeatNullableByteEnumArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 32;
+ pub const RepeatNullableIntEnumArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 33;
+ pub const RepeatNullableLongEnumArray: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 34;
+ pub const RepeatNullableString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 35;
+ pub const RepeatNullableStringList: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 36;
+ pub const RepeatNullableParcelable: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 37;
+ pub const TakesAnIBinder: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 38;
+ pub const TakesANullableIBinder: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 39;
+ pub const RepeatUtf8CppString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 40;
+ pub const RepeatNullableUtf8CppString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 41;
+ pub const ReverseUtf8CppString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 42;
+ pub const ReverseNullableUtf8CppString: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 43;
+ pub const ReverseUtf8CppStringList: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 44;
+ pub const GetCallback: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 45;
+ pub const FillOutStructuredParcelable: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 46;
+ pub const GetOldNameInterface: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 47;
+ pub const GetNewNameInterface: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 48;
+ pub const GetCppJavaTests: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 49;
+ pub const getBackendType: binder::TransactionCode = binder::FIRST_CALL_TRANSACTION + 50;
+}
+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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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 Deprecated(&self) -> binder::public_api::Result<()> {
+ let _aidl_reply = self.binder.transact(transactions::Deprecated, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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.Deprecated();
+ }
+ }
+ let _aidl_reply = _aidl_reply?;
+ let _aidl_status: binder::Status = _aidl_reply.read()?;
+ if !_aidl_status.is_ok() { return Err(_aidl_status); }
+ Ok(())
+ }
+ fn TestOneway(&self) -> binder::public_api::Result<()> {
+ let _aidl_reply = self.binder.transact(transactions::TestOneway, binder::FLAG_ONEWAY | binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> {
+ let _aidl_reply = self.binder.transact(transactions::GetOtherTestService, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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: binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback> = _aidl_reply.read()?;
+ Ok(_aidl_return)
+ }
+ fn VerifyName(&self, _arg_service: &binder::Strong<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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>>> {
+ let _aidl_reply = self.binder.transact(transactions::GetCallback, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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<binder::Strong<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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> {
+ let _aidl_reply = self.binder.transact(transactions::GetOldNameInterface, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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: binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName> = _aidl_reply.read()?;
+ Ok(_aidl_return)
+ }
+ fn GetNewNameInterface(&self) -> binder::public_api::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
+ let _aidl_reply = self.binder.transact(transactions::GetNewNameInterface, binder::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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: binder::Strong<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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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::FLAG_CLEAR_BUF | binder::FLAG_PRIVATE_LOCAL, |_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 Deprecated(&self) -> binder::public_api::Result<()> { self.0.Deprecated() }
+ 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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_14_INamedCallback>> { self.0.GetOtherTestService(_arg_name) }
+ fn VerifyName(&self, _arg_service: &binder::Strong<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<binder::Strong<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<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> { self.0.GetOldNameInterface() }
+ fn GetNewNameInterface(&self) -> binder::public_api::Result<binder::Strong<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::Deprecated => {
+ let _aidl_return = _aidl_service.Deprecated();
+ 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::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: binder::Strong<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..573e399
--- /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/INewName.aidl \
+ system/tools/aidl/tests/android/aidl/tests/IOldName.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
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..d57775f
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/OtherParcelableForToString.rs
@@ -0,0 +1,61 @@
+#[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); }
+ if start_pos.checked_add(parcelable_size).is_none() {
+ return Err(binder::StatusCode::BAD_VALUE);
+ }
+ let mut result = Self::default();
+ if (parcel.get_data_position() - start_pos) == parcelable_size {
+ return Ok(Some(result));
+ }
+ result.field = parcel.read()?;
+ unsafe {
+ parcel.set_data_position(start_pos + parcelable_size)?;
+ }
+ 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..58b7d28
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ParcelableForToString.rs
@@ -0,0 +1,215 @@
+#[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: crate::mangled::_7_android_4_aidl_5_tests_7_IntEnum::FOO,
+ 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); }
+ if start_pos.checked_add(parcelable_size).is_none() {
+ return Err(binder::StatusCode::BAD_VALUE);
+ }
+ let mut result = Self::default();
+ if (parcel.get_data_position() - start_pos) == parcelable_size {
+ return Ok(Some(result));
+ }
+ 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()?;
+ unsafe {
+ parcel.set_data_position(start_pos + parcelable_size)?;
+ }
+ 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..de46179
--- /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/IntEnum.aidl \
+ system/tools/aidl/tests/android/aidl/tests/OtherParcelableForToString.aidl \
+ system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.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..72bc998
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/StructuredParcelable.rs
@@ -0,0 +1,428 @@
+#[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); }
+ if start_pos.checked_add(parcelable_size).is_none() {
+ return Err(binder::StatusCode::BAD_VALUE);
+ }
+ let mut result = Self::default();
+ if (parcel.get_data_position() - start_pos) == parcelable_size {
+ return Ok(Some(result));
+ }
+ 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()?;
+ unsafe {
+ parcel.set_data_position(start_pos + parcelable_size)?;
+ }
+ 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..7b17725
--- /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/ConstantExpressionEnum.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/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/android/aidl/tests/unions/UnionInUnion.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
new file mode 100644
index 0000000..7adee52
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
@@ -0,0 +1,65 @@
+#[derive(Debug, Clone, PartialEq)]
+pub enum UnionInUnion {
+ First(crate::mangled::_7_android_4_aidl_5_tests_6_unions_9_EnumUnion),
+ Second(i32),
+}
+pub(crate) mod mangled { pub use super::UnionInUnion as _7_android_4_aidl_5_tests_6_unions_12_UnionInUnion; }
+impl Default for UnionInUnion {
+ fn default() -> Self {
+ Self::First(Default::default())
+ }
+}
+impl binder::parcel::Serialize for UnionInUnion {
+ 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 UnionInUnion {}
+impl binder::parcel::SerializeOption for UnionInUnion {
+ 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::First(v) => {
+ parcel.write(&0i32)?;
+ parcel.write(v)
+ }
+ Self::Second(v) => {
+ parcel.write(&1i32)?;
+ parcel.write(v)
+ }
+ }
+ }
+}
+impl binder::parcel::Deserialize for UnionInUnion {
+ 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 UnionInUnion {}
+impl binder::parcel::DeserializeOption for UnionInUnion {
+ 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_6_unions_9_EnumUnion = parcel.read()?;
+ Ok(Some(Self::First(value)))
+ }
+ 1 => {
+ let value: i32 = parcel.read()?;
+ Ok(Some(Self::Second(value)))
+ }
+ _ => {
+ Err(binder::StatusCode::BAD_VALUE)
+ }
+ }
+ }
+}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs.d
new file mode 100644
index 0000000..f5b5366
--- /dev/null
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs.d
@@ -0,0 +1,3 @@
+out/soong/.intermediates/system/tools/aidl/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs : \
+ system/tools/aidl/tests/android/aidl/tests/unions/UnionInUnion.aidl \
+ system/tools/aidl/tests/android/aidl/tests/unions/EnumUnion.aidl
diff --git a/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl-test-interface-rust-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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..b38dae4
--- /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;
+ 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(&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;
+ }
+ _aidl_parcel->setDataPosition(_aidl_start_pos + _aidl_parcelable_size);
+ 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..931d9b1
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/android/aidl/loggable/ILoggableInterface.cpp
@@ -0,0 +1,512 @@
+#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;
+ _aidl_data.markForBinder(remoteStrong());
+ ::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", ::android::internal::ToString(boolValue));
+ _transaction_log.input_args.emplace_back("boolArray", ::android::internal::ToString(*boolArray));
+ _transaction_log.input_args.emplace_back("byteValue", ::android::internal::ToString(byteValue));
+ _transaction_log.input_args.emplace_back("byteArray", ::android::internal::ToString(*byteArray));
+ _transaction_log.input_args.emplace_back("charValue", ::android::internal::ToString(charValue));
+ _transaction_log.input_args.emplace_back("charArray", ::android::internal::ToString(*charArray));
+ _transaction_log.input_args.emplace_back("intValue", ::android::internal::ToString(intValue));
+ _transaction_log.input_args.emplace_back("intArray", ::android::internal::ToString(*intArray));
+ _transaction_log.input_args.emplace_back("longValue", ::android::internal::ToString(longValue));
+ _transaction_log.input_args.emplace_back("longArray", ::android::internal::ToString(*longArray));
+ _transaction_log.input_args.emplace_back("floatValue", ::android::internal::ToString(floatValue));
+ _transaction_log.input_args.emplace_back("floatArray", ::android::internal::ToString(*floatArray));
+ _transaction_log.input_args.emplace_back("doubleValue", ::android::internal::ToString(doubleValue));
+ _transaction_log.input_args.emplace_back("doubleArray", ::android::internal::ToString(*doubleArray));
+ _transaction_log.input_args.emplace_back("stringValue", ::android::internal::ToString(stringValue));
+ _transaction_log.input_args.emplace_back("stringArray", ::android::internal::ToString(*stringArray));
+ _transaction_log.input_args.emplace_back("listValue", ::android::internal::ToString(*listValue));
+ _transaction_log.input_args.emplace_back("dataValue", ::android::internal::ToString(dataValue));
+ _transaction_log.input_args.emplace_back("binderValue", ::android::internal::ToString(binderValue));
+ _transaction_log.input_args.emplace_back("pfdValue", ::android::internal::ToString(*pfdValue));
+ _transaction_log.input_args.emplace_back("pfdArray", ::android::internal::ToString(*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", ::android::internal::ToString(*boolArray));
+ _transaction_log.output_args.emplace_back("byteArray", ::android::internal::ToString(*byteArray));
+ _transaction_log.output_args.emplace_back("charArray", ::android::internal::ToString(*charArray));
+ _transaction_log.output_args.emplace_back("intArray", ::android::internal::ToString(*intArray));
+ _transaction_log.output_args.emplace_back("longArray", ::android::internal::ToString(*longArray));
+ _transaction_log.output_args.emplace_back("floatArray", ::android::internal::ToString(*floatArray));
+ _transaction_log.output_args.emplace_back("doubleArray", ::android::internal::ToString(*doubleArray));
+ _transaction_log.output_args.emplace_back("stringArray", ::android::internal::ToString(*stringArray));
+ _transaction_log.output_args.emplace_back("listValue", ::android::internal::ToString(*listValue));
+ _transaction_log.output_args.emplace_back("pfdValue", ::android::internal::ToString(*pfdValue));
+ _transaction_log.output_args.emplace_back("pfdArray", ::android::internal::ToString(*pfdArray));
+ _transaction_log.result = ::android::internal::ToString(*_aidl_return);
+ 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", ::android::internal::ToString(in_boolValue));
+ _transaction_log.input_args.emplace_back("in_boolArray", ::android::internal::ToString(in_boolArray));
+ _transaction_log.input_args.emplace_back("in_byteValue", ::android::internal::ToString(in_byteValue));
+ _transaction_log.input_args.emplace_back("in_byteArray", ::android::internal::ToString(in_byteArray));
+ _transaction_log.input_args.emplace_back("in_charValue", ::android::internal::ToString(in_charValue));
+ _transaction_log.input_args.emplace_back("in_charArray", ::android::internal::ToString(in_charArray));
+ _transaction_log.input_args.emplace_back("in_intValue", ::android::internal::ToString(in_intValue));
+ _transaction_log.input_args.emplace_back("in_intArray", ::android::internal::ToString(in_intArray));
+ _transaction_log.input_args.emplace_back("in_longValue", ::android::internal::ToString(in_longValue));
+ _transaction_log.input_args.emplace_back("in_longArray", ::android::internal::ToString(in_longArray));
+ _transaction_log.input_args.emplace_back("in_floatValue", ::android::internal::ToString(in_floatValue));
+ _transaction_log.input_args.emplace_back("in_floatArray", ::android::internal::ToString(in_floatArray));
+ _transaction_log.input_args.emplace_back("in_doubleValue", ::android::internal::ToString(in_doubleValue));
+ _transaction_log.input_args.emplace_back("in_doubleArray", ::android::internal::ToString(in_doubleArray));
+ _transaction_log.input_args.emplace_back("in_stringValue", ::android::internal::ToString(in_stringValue));
+ _transaction_log.input_args.emplace_back("in_stringArray", ::android::internal::ToString(in_stringArray));
+ _transaction_log.input_args.emplace_back("in_listValue", ::android::internal::ToString(in_listValue));
+ _transaction_log.input_args.emplace_back("in_dataValue", ::android::internal::ToString(in_dataValue));
+ _transaction_log.input_args.emplace_back("in_binderValue", ::android::internal::ToString(in_binderValue));
+ _transaction_log.input_args.emplace_back("in_pfdValue", ::android::internal::ToString(in_pfdValue));
+ _transaction_log.input_args.emplace_back("in_pfdArray", ::android::internal::ToString(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", ::android::internal::ToString(in_boolArray));
+ _transaction_log.output_args.emplace_back("in_byteArray", ::android::internal::ToString(in_byteArray));
+ _transaction_log.output_args.emplace_back("in_charArray", ::android::internal::ToString(in_charArray));
+ _transaction_log.output_args.emplace_back("in_intArray", ::android::internal::ToString(in_intArray));
+ _transaction_log.output_args.emplace_back("in_longArray", ::android::internal::ToString(in_longArray));
+ _transaction_log.output_args.emplace_back("in_floatArray", ::android::internal::ToString(in_floatArray));
+ _transaction_log.output_args.emplace_back("in_doubleArray", ::android::internal::ToString(in_doubleArray));
+ _transaction_log.output_args.emplace_back("in_stringArray", ::android::internal::ToString(in_stringArray));
+ _transaction_log.output_args.emplace_back("in_listValue", ::android::internal::ToString(in_listValue));
+ _transaction_log.output_args.emplace_back("in_pfdValue", ::android::internal::ToString(in_pfdValue));
+ _transaction_log.output_args.emplace_back("in_pfdArray", ::android::internal::ToString(in_pfdArray));
+ _transaction_log.result = ::android::internal::ToString(_aidl_return);
+ 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..4e6ca8c
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BnLoggableInterface.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <binder/IInterface.h>
+#include <android/aidl/loggable/ILoggableInterface.h>
+#include <functional>
+#include <android/binder_to_string.h>
+
+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;
+}; // 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..73219b8
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/BpLoggableInterface.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <utils/Errors.h>
+#include <android/aidl/loggable/ILoggableInterface.h>
+#include <functional>
+#include <android/binder_to_string.h>
+
+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;
+}; // 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..505a565
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Data.h
@@ -0,0 +1,66 @@
+#pragma once
+
+#include <android/aidl/loggable/Enum.h>
+#include <android/aidl/loggable/Union.h>
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cstdint>
+#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::aidl::loggable::Enum(::android::aidl::loggable::Enum::FOO);
+ ::android::status_t readFromParcel(const ::android::Parcel* _aidl_parcel) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.loggable.Data");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Data{";
+ os << "num: " << ::android::internal::ToString(num);
+ os << ", str: " << ::android::internal::ToString(str);
+ os << ", nestedUnion: " << ::android::internal::ToString(nestedUnion);
+ os << ", nestedEnum: " << ::android::internal::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..7b5982b
--- /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,
+};
+
+[[nodiscard]] 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..5891ba3
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h
@@ -0,0 +1,123 @@
+#pragma once
+
+#include <android/binder_to_string.h>
+#include <binder/Parcel.h>
+#include <binder/Status.h>
+#include <cassert>
+#include <cstdint>
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit Union(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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) final;
+ ::android::status_t writeToParcel(::android::Parcel* _aidl_parcel) const final;
+ static const ::android::String16& getParcelableDescriptor() {
+ static const ::android::StaticString16 DESCIPTOR (u"android.aidl.loggable.Union");
+ return DESCIPTOR;
+ }
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Union{";
+ switch (getTag()) {
+ case num: os << "num: " << ::android::internal::ToString(get<num>()); break;
+ case str: os << "str: " << ::android::internal::ToString(get<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/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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..4e1ebfd
--- /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 = android.aidl.loggable.Enum.FOO;
+ 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;
+ if (_aidl_parcel.dataPosition() - _aidl_start_pos >= _aidl_parcelable_size) 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();
+ } 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/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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..29ba3c3
--- /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;
+
+ 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, &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;
+
+ 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..4835f3b
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/android/aidl/loggable/ILoggableInterface.cpp
@@ -0,0 +1,467 @@
+#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>
+#include <android/binder_to_string.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+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", ::android::internal::ToString(in_boolValue));
+ _transaction_log.input_args.emplace_back("in_boolArray", ::android::internal::ToString(in_boolArray));
+ _transaction_log.input_args.emplace_back("in_byteValue", ::android::internal::ToString(in_byteValue));
+ _transaction_log.input_args.emplace_back("in_byteArray", ::android::internal::ToString(in_byteArray));
+ _transaction_log.input_args.emplace_back("in_charValue", ::android::internal::ToString(in_charValue));
+ _transaction_log.input_args.emplace_back("in_charArray", ::android::internal::ToString(in_charArray));
+ _transaction_log.input_args.emplace_back("in_intValue", ::android::internal::ToString(in_intValue));
+ _transaction_log.input_args.emplace_back("in_intArray", ::android::internal::ToString(in_intArray));
+ _transaction_log.input_args.emplace_back("in_longValue", ::android::internal::ToString(in_longValue));
+ _transaction_log.input_args.emplace_back("in_longArray", ::android::internal::ToString(in_longArray));
+ _transaction_log.input_args.emplace_back("in_floatValue", ::android::internal::ToString(in_floatValue));
+ _transaction_log.input_args.emplace_back("in_floatArray", ::android::internal::ToString(in_floatArray));
+ _transaction_log.input_args.emplace_back("in_doubleValue", ::android::internal::ToString(in_doubleValue));
+ _transaction_log.input_args.emplace_back("in_doubleArray", ::android::internal::ToString(in_doubleArray));
+ _transaction_log.input_args.emplace_back("in_stringValue", ::android::internal::ToString(in_stringValue));
+ _transaction_log.input_args.emplace_back("in_stringArray", ::android::internal::ToString(in_stringArray));
+ _transaction_log.input_args.emplace_back("in_listValue", ::android::internal::ToString(in_listValue));
+ _transaction_log.input_args.emplace_back("in_dataValue", ::android::internal::ToString(in_dataValue));
+ _transaction_log.input_args.emplace_back("in_binderValue", ::android::internal::ToString(in_binderValue));
+ _transaction_log.input_args.emplace_back("in_pfdValue", ::android::internal::ToString(in_pfdValue));
+ _transaction_log.input_args.emplace_back("in_pfdArray", ::android::internal::ToString(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", ::android::internal::ToString(in_boolArray));
+ _transaction_log.output_args.emplace_back("in_byteArray", ::android::internal::ToString(in_byteArray));
+ _transaction_log.output_args.emplace_back("in_charArray", ::android::internal::ToString(in_charArray));
+ _transaction_log.output_args.emplace_back("in_intArray", ::android::internal::ToString(in_intArray));
+ _transaction_log.output_args.emplace_back("in_longArray", ::android::internal::ToString(in_longArray));
+ _transaction_log.output_args.emplace_back("in_floatArray", ::android::internal::ToString(in_floatArray));
+ _transaction_log.output_args.emplace_back("in_doubleArray", ::android::internal::ToString(in_doubleArray));
+ _transaction_log.output_args.emplace_back("in_stringArray", ::android::internal::ToString(in_stringArray));
+ _transaction_log.output_args.emplace_back("in_listValue", ::android::internal::ToString(in_listValue));
+ _transaction_log.output_args.emplace_back("in_pfdValue", ::android::internal::ToString(in_pfdValue));
+ _transaction_log.output_args.emplace_back("in_pfdArray", ::android::internal::ToString(in_pfdArray));
+ _transaction_log.result = ::android::internal::ToString(_aidl_return);
+ 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", ::android::internal::ToString(in_boolValue));
+ _transaction_log.input_args.emplace_back("in_boolArray", ::android::internal::ToString(*in_boolArray));
+ _transaction_log.input_args.emplace_back("in_byteValue", ::android::internal::ToString(in_byteValue));
+ _transaction_log.input_args.emplace_back("in_byteArray", ::android::internal::ToString(*in_byteArray));
+ _transaction_log.input_args.emplace_back("in_charValue", ::android::internal::ToString(in_charValue));
+ _transaction_log.input_args.emplace_back("in_charArray", ::android::internal::ToString(*in_charArray));
+ _transaction_log.input_args.emplace_back("in_intValue", ::android::internal::ToString(in_intValue));
+ _transaction_log.input_args.emplace_back("in_intArray", ::android::internal::ToString(*in_intArray));
+ _transaction_log.input_args.emplace_back("in_longValue", ::android::internal::ToString(in_longValue));
+ _transaction_log.input_args.emplace_back("in_longArray", ::android::internal::ToString(*in_longArray));
+ _transaction_log.input_args.emplace_back("in_floatValue", ::android::internal::ToString(in_floatValue));
+ _transaction_log.input_args.emplace_back("in_floatArray", ::android::internal::ToString(*in_floatArray));
+ _transaction_log.input_args.emplace_back("in_doubleValue", ::android::internal::ToString(in_doubleValue));
+ _transaction_log.input_args.emplace_back("in_doubleArray", ::android::internal::ToString(*in_doubleArray));
+ _transaction_log.input_args.emplace_back("in_stringValue", ::android::internal::ToString(in_stringValue));
+ _transaction_log.input_args.emplace_back("in_stringArray", ::android::internal::ToString(*in_stringArray));
+ _transaction_log.input_args.emplace_back("in_listValue", ::android::internal::ToString(*in_listValue));
+ _transaction_log.input_args.emplace_back("in_dataValue", ::android::internal::ToString(in_dataValue));
+ _transaction_log.input_args.emplace_back("in_binderValue", ::android::internal::ToString(in_binderValue));
+ _transaction_log.input_args.emplace_back("in_pfdValue", ::android::internal::ToString(*in_pfdValue));
+ _transaction_log.input_args.emplace_back("in_pfdArray", ::android::internal::ToString(*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", ::android::internal::ToString(*in_boolArray));
+ _transaction_log.output_args.emplace_back("in_byteArray", ::android::internal::ToString(*in_byteArray));
+ _transaction_log.output_args.emplace_back("in_charArray", ::android::internal::ToString(*in_charArray));
+ _transaction_log.output_args.emplace_back("in_intArray", ::android::internal::ToString(*in_intArray));
+ _transaction_log.output_args.emplace_back("in_longArray", ::android::internal::ToString(*in_longArray));
+ _transaction_log.output_args.emplace_back("in_floatArray", ::android::internal::ToString(*in_floatArray));
+ _transaction_log.output_args.emplace_back("in_doubleArray", ::android::internal::ToString(*in_doubleArray));
+ _transaction_log.output_args.emplace_back("in_stringArray", ::android::internal::ToString(*in_stringArray));
+ _transaction_log.output_args.emplace_back("in_listValue", ::android::internal::ToString(*in_listValue));
+ _transaction_log.output_args.emplace_back("in_pfdValue", ::android::internal::ToString(*in_pfdValue));
+ _transaction_log.output_args.emplace_back("in_pfdArray", ::android::internal::ToString(*in_pfdArray));
+ _transaction_log.result = ::android::internal::ToString(*_aidl_return);
+ 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..ecc788e
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Data.h
@@ -0,0 +1,66 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 <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 = ::aidl::android::aidl::loggable::Enum::FOO;
+
+ 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Data{";
+ os << "num: " << ::android::internal::ToString(num);
+ os << ", str: " << ::android::internal::ToString(str);
+ os << ", nestedUnion: " << ::android::internal::ToString(nestedUnion);
+ os << ", nestedEnum: " << ::android::internal::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..1f02080
--- /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,
+};
+
+[[nodiscard]] 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..f53752a
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h
@@ -0,0 +1,125 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.h>
+
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit Union(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Union{";
+ switch (getTag()) {
+ case num: os << "num: " << ::android::internal::ToString(get<num>()); break;
+ case str: os << "str: " << ::android::internal::ToString(get<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/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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..29ba3c3
--- /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;
+
+ 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, &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;
+
+ 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..4835f3b
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/android/aidl/loggable/ILoggableInterface.cpp
@@ -0,0 +1,467 @@
+#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>
+#include <android/binder_to_string.h>
+
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+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", ::android::internal::ToString(in_boolValue));
+ _transaction_log.input_args.emplace_back("in_boolArray", ::android::internal::ToString(in_boolArray));
+ _transaction_log.input_args.emplace_back("in_byteValue", ::android::internal::ToString(in_byteValue));
+ _transaction_log.input_args.emplace_back("in_byteArray", ::android::internal::ToString(in_byteArray));
+ _transaction_log.input_args.emplace_back("in_charValue", ::android::internal::ToString(in_charValue));
+ _transaction_log.input_args.emplace_back("in_charArray", ::android::internal::ToString(in_charArray));
+ _transaction_log.input_args.emplace_back("in_intValue", ::android::internal::ToString(in_intValue));
+ _transaction_log.input_args.emplace_back("in_intArray", ::android::internal::ToString(in_intArray));
+ _transaction_log.input_args.emplace_back("in_longValue", ::android::internal::ToString(in_longValue));
+ _transaction_log.input_args.emplace_back("in_longArray", ::android::internal::ToString(in_longArray));
+ _transaction_log.input_args.emplace_back("in_floatValue", ::android::internal::ToString(in_floatValue));
+ _transaction_log.input_args.emplace_back("in_floatArray", ::android::internal::ToString(in_floatArray));
+ _transaction_log.input_args.emplace_back("in_doubleValue", ::android::internal::ToString(in_doubleValue));
+ _transaction_log.input_args.emplace_back("in_doubleArray", ::android::internal::ToString(in_doubleArray));
+ _transaction_log.input_args.emplace_back("in_stringValue", ::android::internal::ToString(in_stringValue));
+ _transaction_log.input_args.emplace_back("in_stringArray", ::android::internal::ToString(in_stringArray));
+ _transaction_log.input_args.emplace_back("in_listValue", ::android::internal::ToString(in_listValue));
+ _transaction_log.input_args.emplace_back("in_dataValue", ::android::internal::ToString(in_dataValue));
+ _transaction_log.input_args.emplace_back("in_binderValue", ::android::internal::ToString(in_binderValue));
+ _transaction_log.input_args.emplace_back("in_pfdValue", ::android::internal::ToString(in_pfdValue));
+ _transaction_log.input_args.emplace_back("in_pfdArray", ::android::internal::ToString(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", ::android::internal::ToString(in_boolArray));
+ _transaction_log.output_args.emplace_back("in_byteArray", ::android::internal::ToString(in_byteArray));
+ _transaction_log.output_args.emplace_back("in_charArray", ::android::internal::ToString(in_charArray));
+ _transaction_log.output_args.emplace_back("in_intArray", ::android::internal::ToString(in_intArray));
+ _transaction_log.output_args.emplace_back("in_longArray", ::android::internal::ToString(in_longArray));
+ _transaction_log.output_args.emplace_back("in_floatArray", ::android::internal::ToString(in_floatArray));
+ _transaction_log.output_args.emplace_back("in_doubleArray", ::android::internal::ToString(in_doubleArray));
+ _transaction_log.output_args.emplace_back("in_stringArray", ::android::internal::ToString(in_stringArray));
+ _transaction_log.output_args.emplace_back("in_listValue", ::android::internal::ToString(in_listValue));
+ _transaction_log.output_args.emplace_back("in_pfdValue", ::android::internal::ToString(in_pfdValue));
+ _transaction_log.output_args.emplace_back("in_pfdArray", ::android::internal::ToString(in_pfdArray));
+ _transaction_log.result = ::android::internal::ToString(_aidl_return);
+ 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", ::android::internal::ToString(in_boolValue));
+ _transaction_log.input_args.emplace_back("in_boolArray", ::android::internal::ToString(*in_boolArray));
+ _transaction_log.input_args.emplace_back("in_byteValue", ::android::internal::ToString(in_byteValue));
+ _transaction_log.input_args.emplace_back("in_byteArray", ::android::internal::ToString(*in_byteArray));
+ _transaction_log.input_args.emplace_back("in_charValue", ::android::internal::ToString(in_charValue));
+ _transaction_log.input_args.emplace_back("in_charArray", ::android::internal::ToString(*in_charArray));
+ _transaction_log.input_args.emplace_back("in_intValue", ::android::internal::ToString(in_intValue));
+ _transaction_log.input_args.emplace_back("in_intArray", ::android::internal::ToString(*in_intArray));
+ _transaction_log.input_args.emplace_back("in_longValue", ::android::internal::ToString(in_longValue));
+ _transaction_log.input_args.emplace_back("in_longArray", ::android::internal::ToString(*in_longArray));
+ _transaction_log.input_args.emplace_back("in_floatValue", ::android::internal::ToString(in_floatValue));
+ _transaction_log.input_args.emplace_back("in_floatArray", ::android::internal::ToString(*in_floatArray));
+ _transaction_log.input_args.emplace_back("in_doubleValue", ::android::internal::ToString(in_doubleValue));
+ _transaction_log.input_args.emplace_back("in_doubleArray", ::android::internal::ToString(*in_doubleArray));
+ _transaction_log.input_args.emplace_back("in_stringValue", ::android::internal::ToString(in_stringValue));
+ _transaction_log.input_args.emplace_back("in_stringArray", ::android::internal::ToString(*in_stringArray));
+ _transaction_log.input_args.emplace_back("in_listValue", ::android::internal::ToString(*in_listValue));
+ _transaction_log.input_args.emplace_back("in_dataValue", ::android::internal::ToString(in_dataValue));
+ _transaction_log.input_args.emplace_back("in_binderValue", ::android::internal::ToString(in_binderValue));
+ _transaction_log.input_args.emplace_back("in_pfdValue", ::android::internal::ToString(*in_pfdValue));
+ _transaction_log.input_args.emplace_back("in_pfdArray", ::android::internal::ToString(*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", ::android::internal::ToString(*in_boolArray));
+ _transaction_log.output_args.emplace_back("in_byteArray", ::android::internal::ToString(*in_byteArray));
+ _transaction_log.output_args.emplace_back("in_charArray", ::android::internal::ToString(*in_charArray));
+ _transaction_log.output_args.emplace_back("in_intArray", ::android::internal::ToString(*in_intArray));
+ _transaction_log.output_args.emplace_back("in_longArray", ::android::internal::ToString(*in_longArray));
+ _transaction_log.output_args.emplace_back("in_floatArray", ::android::internal::ToString(*in_floatArray));
+ _transaction_log.output_args.emplace_back("in_doubleArray", ::android::internal::ToString(*in_doubleArray));
+ _transaction_log.output_args.emplace_back("in_stringArray", ::android::internal::ToString(*in_stringArray));
+ _transaction_log.output_args.emplace_back("in_listValue", ::android::internal::ToString(*in_listValue));
+ _transaction_log.output_args.emplace_back("in_pfdValue", ::android::internal::ToString(*in_pfdValue));
+ _transaction_log.output_args.emplace_back("in_pfdArray", ::android::internal::ToString(*in_pfdArray));
+ _transaction_log.result = ::android::internal::ToString(*_aidl_return);
+ 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..ecc788e
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Data.h
@@ -0,0 +1,66 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.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 <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 = ::aidl::android::aidl::loggable::Enum::FOO;
+
+ 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Data{";
+ os << "num: " << ::android::internal::ToString(num);
+ os << ", str: " << ::android::internal::ToString(str);
+ os << ", nestedUnion: " << ::android::internal::ToString(nestedUnion);
+ os << ", nestedEnum: " << ::android::internal::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..1f02080
--- /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,
+};
+
+[[nodiscard]] 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..f53752a
--- /dev/null
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/include/aidl/android/aidl/loggable/Union.h
@@ -0,0 +1,125 @@
+#pragma once
+#include <android/binder_interface_utils.h>
+#include <android/binder_parcelable_utils.h>
+#include <android/binder_to_string.h>
+
+#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 <size_t _Np, typename... _Tp>
+ constexpr explicit Union(std::in_place_index_t<_Np>, _Tp&&... _args)
+ : _value(std::in_place_index<_Np>, 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;
+ inline std::string toString() const {
+ std::ostringstream os;
+ os << "Union{";
+ switch (getTag()) {
+ case num: os << "num: " << ::android::internal::ToString(get<num>()); break;
+ case str: os << "str: " << ::android::internal::ToString(get<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/MODULE_LICENSE_APACHE2 b/tests/golden_output/aidl_test_loggable_interface-ndk_platform-source/gen/timestamp
similarity index 100%
copy from MODULE_LICENSE_APACHE2
copy to 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..9729bd5
--- /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 "out/soong/.intermediates/system/tools/aidl/$i/timestamp"
+ 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/gen" "$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/integration-test.py b/tests/integration-test.py
deleted file mode 100755
index 32d1a8f..0000000
--- a/tests/integration-test.py
+++ /dev/null
@@ -1,203 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Test that aidl generates functional code by running it on an Android device.
-"""
-
-import argparse
-import pipes
-import subprocess
-import shlex
-
-JAVA_OUTPUT_READER_FOR_BITNESS = '/data/nativetest%s/aidl_test_sentinel_searcher/aidl_test_sentinel_searcher'
-NATIVE_TEST_CLIENT_FOR_BITNESS = ' /data/nativetest%s/aidl_test_client/aidl_test_client'
-NATIVE_TEST_SERVICE_FOR_BITNESS = ' /data/nativetest%s/aidl_test_service/aidl_test_service'
-
-TEST_FILTER_ALL = 'all'
-TEST_FILTER_JAVA = 'java'
-TEST_FILTER_NATIVE = 'native'
-
-JAVA_CLIENT_TIMEOUT_SECONDS = 30
-JAVA_LOG_FILE = '/data/data/android.aidl.tests/files/test-client.log'
-JAVA_SUCCESS_SENTINEL = '>>> Java Client Success <<<'
-JAVA_FAILURE_SENTINEL = '>>> Java Client Failure <<<'
-
-class TestFail(Exception):
- """Raised on test failures."""
- pass
-
-
-class ShellResult(object):
- """Represents the result of running a shell command."""
-
- def __init__(self, exit_status, stdout, stderr):
- """Construct an instance.
-
- Args:
- exit_status: integer exit code of shell command
- stdout: string stdout of shell command
- stderr: string stderr of shell command
- """
- self.stdout = stdout
- self.stderr = stderr
- self.exit_status = exit_status
-
- def printable_string(self):
- """Get a string we could print to the logs and understand."""
- output = []
- output.append('stdout:')
- for line in self.stdout.splitlines():
- output.append(' > %s' % line)
- output.append('stderr:')
- for line in self.stderr.splitlines():
- output.append(' > %s' % line)
- return '\n'.join(output)
-
-
-class AdbHost(object):
- """Represents a device connected via ADB."""
-
- def __init__(self, device_serial=None, verbose=None):
- """Construct an instance.
-
- Args:
- device_serial: options string serial number of attached device.
- verbose: True iff we should print out ADB commands we run.
- """
- self._device_serial = device_serial
- self._verbose = verbose
-
- def run(self, command, background=False, ignore_status=False):
- """Run a command on the device via adb shell.
-
- Args:
- command: string containing a shell command to run.
- background: True iff we should run this command in the background.
- ignore_status: True iff we should ignore the command's exit code.
-
- Returns:
- instance of ShellResult.
-
- Raises:
- subprocess.CalledProcessError on command exit != 0.
- """
- if background:
- command = '( %s ) </dev/null >/dev/null 2>&1 &' % command
- return self.adb('shell %s' % pipes.quote(command),
- ignore_status=ignore_status)
-
- def mktemp(self):
- """Make a temp file on the device.
-
- Returns:
- path to created file as a string
-
- Raises:
- subprocess.CalledProcessError on failure.
- """
- # Work around b/19635681
- result = self.run('source /system/etc/mkshrc && mktemp')
- return result.stdout.strip()
-
- def adb(self, command, ignore_status=False):
- """Run an ADB command (e.g. `adb sync`).
-
- Args:
- command: string containing command to run
- ignore_status: True iff we should ignore the command's exit code.
-
- Returns:
- instance of ShellResult.
-
- Raises:
- subprocess.CalledProcessError on command exit != 0.
- """
- command = 'adb %s' % command
- if self._verbose:
- print(command)
- p = subprocess.Popen(command, shell=True, close_fds=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- universal_newlines=True)
- stdout, stderr = p.communicate()
- if not ignore_status and p.returncode:
- raise subprocess.CalledProcessError(p.returncode, command)
- return ShellResult(p.returncode, stdout, stderr)
-
-def run_test(host, test_native, test_java):
- """Body of the test.
-
- Args:
- host: AdbHost object to run tests on
- test_native: True iff we should test native Binder clients.
- test_java: True iff we should test Java Binder clients.
- """
-
- print('Starting aidl integration testing...')
-
- if host.run('ls /data/nativetest64', ignore_status=True).exit_status:
- bitness = ""
- else:
- bitness = "64"
-
- JAVA_OUTPUT_READER = JAVA_OUTPUT_READER_FOR_BITNESS % bitness
- NATIVE_TEST_CLIENT = NATIVE_TEST_CLIENT_FOR_BITNESS % bitness
- NATIVE_TEST_SERVICE = NATIVE_TEST_SERVICE_FOR_BITNESS % bitness
-
- # Kill any previous test context
- host.run('rm -f %s' % JAVA_LOG_FILE, ignore_status=True)
- host.run('killall %s' % NATIVE_TEST_SERVICE, ignore_status=True)
-
- # Start up a native server
- host.run(NATIVE_TEST_SERVICE, background=True)
-
- # Start up clients
- if test_native:
- host.run('killall %s' % NATIVE_TEST_CLIENT, ignore_status=True)
- result = host.run(NATIVE_TEST_CLIENT, ignore_status=True)
- if result.exit_status:
- print(result.printable_string())
- raise TestFail('%s returned status code %d' %
- (NATIVE_TEST_CLIENT, result.exit_status))
-
- if test_java:
- host.run('am start -S -a android.intent.action.MAIN '
- '-n android.aidl.tests/.TestServiceClient '
- '--es sentinel.success "%s" '
- '--es sentinel.failure "%s"' %
- (JAVA_SUCCESS_SENTINEL, JAVA_FAILURE_SENTINEL))
- result = host.run('%s %d %s "%s" "%s"' %
- (JAVA_OUTPUT_READER, JAVA_CLIENT_TIMEOUT_SECONDS,
- JAVA_LOG_FILE, JAVA_SUCCESS_SENTINEL,
- JAVA_FAILURE_SENTINEL),
- ignore_status=True)
- if result.exit_status:
- print(result.printable_string())
- raise TestFail('Java client did not complete successfully.')
-
- host.run('killall %s' % NATIVE_TEST_SERVICE, ignore_status=True)
- host.run('killall android.aidl.tests', ignore_status=True)
-
- print('Success!')
-
-
-def main():
- """Main entry point."""
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument(
- '--test-filter', default=TEST_FILTER_ALL,
- choices=[TEST_FILTER_ALL, TEST_FILTER_JAVA, TEST_FILTER_NATIVE])
- parser.add_argument('--verbose', '-v', action='store_true', default=False)
- args = parser.parse_args()
- host = AdbHost(verbose=args.verbose)
- try:
- # Tragically, SELinux interferes with our testing
- host.run('setenforce 0')
- run_test(host,
- args.test_filter in (TEST_FILTER_ALL, TEST_FILTER_NATIVE),
- args.test_filter in (TEST_FILTER_ALL, TEST_FILTER_JAVA))
- finally:
- host.run('setenforce 1')
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/java/src/android/aidl/service/TestServiceServer.java b/tests/java/src/android/aidl/service/TestServiceServer.java
new file mode 100644
index 0000000..06ef6cc
--- /dev/null
+++ b/tests/java/src/android/aidl/service/TestServiceServer.java
@@ -0,0 +1,547 @@
+/*
+ * 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 android.aidl.service;
+
+import android.aidl.tests.BackendType;
+import android.aidl.tests.ByteEnum;
+import android.aidl.tests.ConstantExpressionEnum;
+import android.aidl.tests.GenericStructuredParcelable;
+import android.aidl.tests.ICppJavaTests;
+import android.aidl.tests.INamedCallback;
+import android.aidl.tests.INewName;
+import android.aidl.tests.IOldName;
+import android.aidl.tests.ITestService;
+import android.aidl.tests.IntEnum;
+import android.aidl.tests.LongEnum;
+import android.aidl.tests.SimpleParcelable;
+import android.aidl.tests.StructuredParcelable;
+import android.aidl.tests.Union;
+import android.aidl.tests.extension.ExtendableParcelable;
+import android.aidl.tests.extension.MyExt;
+import android.aidl.versioned.tests.BazUnion;
+import android.aidl.versioned.tests.Foo;
+import android.aidl.versioned.tests.IFooInterface;
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.ParcelFileDescriptor;
+import android.os.PersistableBundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.ServiceSpecificException;
+import android.util.Log;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class TestServiceServer extends ITestService.Stub {
+ public static void main(String[] args) {
+ TestServiceServer myServer = new TestServiceServer();
+ ServiceManager.addService(ITestService.class.getName(), myServer);
+
+ FooInterface foo = new FooInterface();
+ ServiceManager.addService(IFooInterface.class.getName(), foo);
+
+ Binder.joinThreadPool();
+ }
+
+ private static class FooInterface extends IFooInterface.Stub {
+ @Override
+ public void originalApi() {}
+ @Override
+ public String acceptUnionAndReturnString(BazUnion b) {
+ if (b.getTag() == BazUnion.intNum) {
+ return "" + b.getIntNum();
+ }
+ throw new IllegalArgumentException();
+ }
+ @Override
+ public int returnsLengthOfFooArray(Foo[] foos) {
+ return foos.length;
+ }
+ @Override
+ public int ignoreParcelablesAndRepeatInt(Foo inFoo, Foo inoutFoo, Foo outFoo, int value) {
+ return value;
+ }
+ @Override
+ public final int getInterfaceVersion() {
+ return IFooInterface.VERSION;
+ }
+ @Override
+ public final String getInterfaceHash() {
+ return IFooInterface.HASH;
+ }
+ }
+
+ @Override
+ public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
+ // UnimplementedMethod
+ if (code == 1)
+ return false;
+ return super.onTransact(code, data, reply, flags);
+ }
+
+ @Override
+ public int UnimplementedMethod(int arg) throws RemoteException {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public void TestOneway() throws RemoteException {
+ throw new RemoteException();
+ }
+ @Override
+ public void Deprecated() throws RemoteException {}
+ @Override
+ public boolean RepeatBoolean(boolean token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public byte RepeatByte(byte token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public char RepeatChar(char token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public int RepeatInt(int token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public long RepeatLong(long token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public float RepeatFloat(float token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public double RepeatDouble(double token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public String RepeatString(String token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public byte RepeatByteEnum(byte token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public int RepeatIntEnum(int token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public long RepeatLongEnum(long token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public boolean[] ReverseBoolean(boolean[] input, boolean[] repeated) throws RemoteException {
+ boolean[] reversed = new boolean[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public byte[] ReverseByte(byte[] input, byte[] repeated) throws RemoteException {
+ byte[] reversed = new byte[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public char[] ReverseChar(char[] input, char[] repeated) throws RemoteException {
+ char[] reversed = new char[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public int[] ReverseInt(int[] input, int[] repeated) throws RemoteException {
+ int[] reversed = new int[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public long[] ReverseLong(long[] input, long[] repeated) throws RemoteException {
+ long[] reversed = new long[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public float[] ReverseFloat(float[] input, float[] repeated) throws RemoteException {
+ float[] reversed = new float[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public double[] ReverseDouble(double[] input, double[] repeated) throws RemoteException {
+ double[] reversed = new double[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public String[] ReverseString(String[] input, String[] repeated) throws RemoteException {
+ String[] reversed = new String[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public byte[] ReverseByteEnum(byte[] input, byte[] repeated) throws RemoteException {
+ byte[] reversed = new byte[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public int[] ReverseIntEnum(int[] input, int[] repeated) throws RemoteException {
+ int[] reversed = new int[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public long[] ReverseLongEnum(long[] input, long[] repeated) throws RemoteException {
+ long[] reversed = new long[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+
+ private static class MyNamedCallback extends INamedCallback.Stub {
+ public MyNamedCallback(String name) { mName = name; }
+ @Override
+ public String GetName() {
+ return mName;
+ }
+ private String mName;
+ }
+
+ private HashMap<String, MyNamedCallback> mNamedCallbacks = new HashMap<>();
+
+ @Override
+ public INamedCallback GetOtherTestService(String name) throws RemoteException {
+ if (!mNamedCallbacks.containsKey(name)) {
+ mNamedCallbacks.put(name, new MyNamedCallback(name));
+ }
+ return mNamedCallbacks.get(name);
+ }
+ @Override
+ public boolean VerifyName(INamedCallback service, String name) throws RemoteException {
+ return name.equals(service.GetName());
+ }
+ @Override
+ public List<String> ReverseStringList(List<String> input, List<String> repeated)
+ throws RemoteException {
+ ArrayList<String> reversed = new ArrayList<String>();
+ for (String a : input) {
+ repeated.add(a);
+ reversed.add(0, a);
+ }
+ return reversed;
+ }
+ @Override
+ public ParcelFileDescriptor RepeatParcelFileDescriptor(ParcelFileDescriptor read)
+ throws RemoteException {
+ return read;
+ }
+ @Override
+ public ParcelFileDescriptor[] ReverseParcelFileDescriptorArray(
+ ParcelFileDescriptor[] input, ParcelFileDescriptor[] repeated) throws RemoteException {
+ ParcelFileDescriptor[] reversed = new ParcelFileDescriptor[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ try {
+ // extra dup, because of PARCELABLE_WRITE_RETURN_VALUE
+ reversed[i] = input[input.length - i - 1].dup();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return reversed;
+ }
+ @Override
+ public void ThrowServiceException(int code) throws RemoteException {
+ Log.i("TestServiceServer", "Throwing service specific exception " + code);
+ throw new ServiceSpecificException(code);
+ }
+ @Override
+ public int[] RepeatNullableIntArray(int[] input) throws RemoteException {
+ return input;
+ }
+ @Override
+ public byte[] RepeatNullableByteEnumArray(byte[] input) throws RemoteException {
+ return input;
+ }
+ @Override
+ public int[] RepeatNullableIntEnumArray(int[] input) throws RemoteException {
+ return input;
+ }
+ @Override
+ public long[] RepeatNullableLongEnumArray(long[] input) throws RemoteException {
+ return input;
+ }
+ @Override
+ public String RepeatNullableString(String input) throws RemoteException {
+ return input;
+ }
+ @Override
+ public List<String> RepeatNullableStringList(List<String> input) throws RemoteException {
+ return input;
+ }
+ @Override
+ public StructuredParcelable RepeatNullableParcelable(StructuredParcelable input)
+ throws RemoteException {
+ return input;
+ }
+ @Override
+ public void TakesAnIBinder(IBinder input) throws RemoteException {
+ // do nothing
+ }
+ @Override
+ public void TakesANullableIBinder(IBinder input) throws RemoteException {
+ // do nothing
+ }
+ @Override
+ public String RepeatUtf8CppString(String token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public String RepeatNullableUtf8CppString(String token) throws RemoteException {
+ return token;
+ }
+ @Override
+ public String[] ReverseUtf8CppString(String[] input, String[] repeated) throws RemoteException {
+ String[] reversed = new String[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public String[] ReverseNullableUtf8CppString(String[] input, String[] repeated)
+ throws RemoteException {
+ if (input == null)
+ return null;
+
+ String[] reversed = new String[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public List<String> ReverseUtf8CppStringList(List<String> input, List<String> repeated)
+ throws RemoteException {
+ // note - cannot clear 'repeated' here, we can only change its length
+ if (input == null)
+ return null;
+
+ ArrayList<String> reversed = new ArrayList<String>();
+ for (String a : input) {
+ repeated.add(a);
+ reversed.add(0, a);
+ }
+ return reversed;
+ }
+ @Override
+ public INamedCallback GetCallback(boolean return_null) throws RemoteException {
+ if (return_null)
+ return null;
+ return new MyNamedCallback("a callback named GetCallback");
+ }
+ @Override
+ public void FillOutStructuredParcelable(StructuredParcelable parcelable) throws RemoteException {
+ parcelable.shouldBeJerry = "Jerry";
+ parcelable.shouldContainThreeFs = new int[] {parcelable.f, parcelable.f, parcelable.f};
+ parcelable.shouldBeByteBar = ByteEnum.BAR;
+ parcelable.shouldBeIntBar = IntEnum.BAR;
+ parcelable.shouldBeLongBar = LongEnum.BAR;
+ parcelable.shouldContainTwoByteFoos = new byte[] {ByteEnum.FOO, ByteEnum.FOO};
+ parcelable.shouldContainTwoIntFoos = new int[] {IntEnum.FOO, IntEnum.FOO};
+ parcelable.shouldContainTwoLongFoos = new long[] {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 = Union.ns(new int[] {1, 2, 3});
+ parcelable.shouldBeConstS1 = Union.s(Union.S1);
+ }
+
+ private static class MyOldName extends IOldName.Stub {
+ @Override
+ public String RealName() {
+ return "OldName";
+ }
+ }
+
+ @Override
+ public IOldName GetOldNameInterface() throws RemoteException {
+ return new MyOldName();
+ }
+
+ private static class MyNewName extends INewName.Stub {
+ @Override
+ public String RealName() {
+ return "NewName";
+ }
+ }
+
+ @Override
+ public INewName GetNewNameInterface() throws RemoteException {
+ return new MyNewName();
+ }
+
+ class MyCppJavaTests extends ICppJavaTests.Stub {
+ @Override
+ public SimpleParcelable RepeatSimpleParcelable(SimpleParcelable input, SimpleParcelable repeat)
+ throws RemoteException {
+ repeat.set(input.getName(), input.getNumber());
+ return input;
+ }
+ @Override
+ public GenericStructuredParcelable<Integer, StructuredParcelable, Integer>
+ RepeatGenericParcelable(
+ GenericStructuredParcelable<Integer, StructuredParcelable, Integer> input,
+ GenericStructuredParcelable<Integer, StructuredParcelable, Integer> repeat)
+ throws RemoteException {
+ repeat.a = input.a;
+ repeat.b = input.b;
+ return input;
+ }
+ @Override
+ public PersistableBundle RepeatPersistableBundle(PersistableBundle input)
+ throws RemoteException {
+ return input;
+ }
+ @Override
+ public SimpleParcelable[] ReverseSimpleParcelables(
+ SimpleParcelable[] input, SimpleParcelable[] repeated) throws RemoteException {
+ SimpleParcelable[] reversed = new SimpleParcelable[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public PersistableBundle[] ReversePersistableBundles(
+ PersistableBundle[] input, PersistableBundle[] repeated) throws RemoteException {
+ PersistableBundle[] reversed = new PersistableBundle[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public Union ReverseUnion(Union input, Union repeated) throws RemoteException {
+ int[] repeatedArray = new int[input.getNs().length];
+ int[] reversedArray = ReverseInt(input.getNs(), repeatedArray);
+ repeated.setNs(repeatedArray);
+ return Union.ns(reversedArray);
+ }
+ @Override
+ public List<IBinder> ReverseNamedCallbackList(List<IBinder> input, List<IBinder> repeated)
+ throws RemoteException {
+ ArrayList<IBinder> reversed = new ArrayList<IBinder>();
+ for (IBinder a : input) {
+ repeated.add(a);
+ reversed.add(0, a);
+ }
+ return reversed;
+ }
+ @Override
+ public FileDescriptor RepeatFileDescriptor(FileDescriptor read) throws RemoteException {
+ return read;
+ }
+ @Override
+ public FileDescriptor[] ReverseFileDescriptorArray(
+ FileDescriptor[] input, FileDescriptor[] repeated) throws RemoteException {
+ FileDescriptor[] reversed = new FileDescriptor[input.length];
+ for (int i = 0; i < input.length; i++) {
+ repeated[i] = input[i];
+ reversed[i] = input[input.length - i - 1];
+ }
+ return reversed;
+ }
+ @Override
+ public void TakesAnIBinderList(List<IBinder> input) throws RemoteException {}
+ @Override
+ public void TakesANullableIBinderList(List<IBinder> input) throws RemoteException {}
+ @Override
+ public void RepeatExtendableParcelable(ExtendableParcelable ep, ExtendableParcelable ep2)
+ throws RemoteException {
+ ep2.a = ep.a;
+ ep2.b = ep.b;
+ // no way to copy currently w/o unparceling
+ ep2.ext.setParcelable(ep.ext.getParcelable(MyExt.class));
+ ep2.c = ep.c;
+ ep2.ext2.setParcelable(null);
+ }
+ }
+
+ @Override
+ public IBinder GetCppJavaTests() throws RemoteException {
+ return new MyCppJavaTests();
+ }
+ @Override
+ public byte getBackendType() throws RemoteException {
+ return BackendType.JAVA;
+ }
+}
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..43d9263
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/AidlJavaTests.java
@@ -0,0 +1,19 @@
+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,
+ VintfTests.class);
+
+ System.out.println(result.wasSuccessful() ? "TEST SUCCESS" : "TEST FAILURE");
+ }
+}
diff --git a/tests/java/src/android/aidl/tests/ExtensionTests.java b/tests/java/src/android/aidl/tests/ExtensionTests.java
new file mode 100644
index 0000000..e923ad2
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/ExtensionTests.java
@@ -0,0 +1,257 @@
+/*
+ * 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.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;
+import android.aidl.tests.extension.MyExt2;
+import android.aidl.tests.extension.MyExtLike;
+import android.aidl.tests.nonvintf.NonVintfExtendableParcelable;
+import android.aidl.tests.nonvintf.NonVintfParcelable;
+import android.aidl.tests.unstable.UnstableExtendableParcelable;
+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;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import java.util.Arrays;
+import java.util.HashMap;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class ExtensionTests {
+ private VintfExtendableParcelable vep;
+ private VintfParcelable vp;
+
+ private NonVintfExtendableParcelable sep;
+ private NonVintfParcelable sp;
+
+ private UnstableExtendableParcelable uep;
+ private UnstableParcelable up;
+
+ private ITestService mService;
+ private ICppJavaTests mCppJavaTests;
+
+ @Before
+ public void setUp() throws RemoteException {
+ IBinder binder = ServiceManager.waitForService(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();
+
+ sep = new NonVintfExtendableParcelable();
+ sp = new NonVintfParcelable();
+
+ uep = new UnstableExtendableParcelable();
+ up = new UnstableParcelable();
+ }
+
+ @Test
+ public void testRepeatExtendableParcelable() throws RemoteException {
+ assumeTrue(mCppJavaTests != null);
+
+ MyExt ext = new MyExt();
+ ext.a = 42;
+ ext.b = "EXT";
+
+ ExtendableParcelable ep = new ExtendableParcelable();
+ ep.a = 1;
+ ep.b = "a";
+ ep.c = 42L;
+
+ ep.ext.setParcelable(ext);
+
+ ExtendableParcelable ep2 = new ExtendableParcelable();
+ mCppJavaTests.RepeatExtendableParcelable(ep, ep2);
+ assertThat(ep2.a, is(ep.a));
+ assertThat(ep2.b, is(ep.b));
+
+ MyExt retExt = ep2.ext.getParcelable(MyExt.class);
+ assertThat(retExt.a, is(ext.a));
+ assertThat(retExt.b, is(ext.b));
+ }
+
+ @Test
+ public void testVintfParcelableHolderCanContainVintfParcelable() {
+ vep.ext.setParcelable(vp);
+ assertThat(vep.ext.getParcelable(VintfParcelable.class), is(vp));
+ }
+
+ @Test
+ public void testVintfParcelableHolderCannotContainNonVintfParcelable() {
+ assertThrows(BadParcelableException.class, () -> { vep.ext.setParcelable(sp); });
+ assertThat(vep.ext.getParcelable(VintfParcelable.class), is(nullValue()));
+ }
+
+ @Test
+ public void testVintfParcelableHolderCannotContainUnstableParcelable() {
+ assertThrows(BadParcelableException.class, () -> { vep.ext.setParcelable(up); });
+ assertThat(vep.ext.getParcelable(UnstableParcelable.class), is(nullValue()));
+ }
+
+ @Test
+ public void testStableParcelableHolderCanContainVintfParcelable() {
+ sep.ext.setParcelable(vp);
+ assertThat(sep.ext.getParcelable(VintfParcelable.class), is(vp));
+ }
+
+ @Test
+ public void testStableParcelableHolderCanContainNonVintfParcelable() {
+ sep.ext.setParcelable(sp);
+ assertThat(sep.ext.getParcelable(NonVintfParcelable.class), is(sp));
+ }
+
+ @Test
+ public void testStableParcelableHolderCanContainUnstableParcelable() {
+ sep.ext.setParcelable(up);
+ assertThat(sep.ext.getParcelable(UnstableParcelable.class), is(up));
+ }
+
+ @Test
+ public void testUnstableParcelableHolderCanContainVintfParcelable() {
+ uep.ext.setParcelable(vp);
+ assertThat(uep.ext.getParcelable(VintfParcelable.class), is(vp));
+ }
+
+ @Test
+ public void testUnstableParcelableHolderCanContainNonVintfParcelable() {
+ uep.ext.setParcelable(sp);
+ assertThat(uep.ext.getParcelable(NonVintfParcelable.class), is(sp));
+ }
+
+ @Test
+ public void testUnstableParcelableHolderCanContainUnstableParcelable() {
+ uep.ext.setParcelable(up);
+ assertThat(uep.ext.getParcelable(UnstableParcelable.class), is(up));
+ }
+
+ @Test
+ public void testReadWriteExtension() {
+ MyExt ext = new MyExt();
+ ext.a = 42;
+ ext.b = "EXT";
+
+ MyExt2 ext2 = new MyExt2();
+ ext2.a = 42;
+ ext2.b = new MyExt();
+ ext2.b.a = 24;
+ ext2.b.b = "INEXT";
+ ext2.c = "EXT2";
+
+ Parcel parcel = Parcel.obtain();
+ {
+ ExtendableParcelable ep = new ExtendableParcelable();
+ ep.a = 1;
+ ep.b = "a";
+ ep.c = 42L;
+
+ ep.ext.setParcelable(ext);
+
+ ep.ext2.setParcelable(ext2);
+ // 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);
+
+ checkContent(ep, ext, ext2);
+
+ ep.writeToParcel(parcel, 0);
+ }
+
+ parcel.setDataPosition(0);
+ {
+ ExtendableParcelable ep1 = new ExtendableParcelable();
+ ep1.readFromParcel(parcel);
+
+ parcel.setDataPosition(0);
+ ep1.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+
+ ExtendableParcelable ep2 = new ExtendableParcelable();
+
+ ep2.readFromParcel(parcel);
+
+ // 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);
+
+ MyExt2 newExt2 = new MyExt2();
+ newExt2.a = 79;
+ newExt2.b = new MyExt();
+ newExt2.b.a = 42;
+ newExt2.b.b = "INNEWEXT";
+ newExt2.c = "NEWEXT2";
+ ep2.ext2.setParcelable(newExt2);
+ checkContent(ep1, ext, ext2);
+ checkContent(ep2, ext, newExt2);
+ }
+ }
+
+ private void checkContent(ExtendableParcelable ep, MyExt ext, MyExt2 ext2) {
+ assertThat(ep.a, is(1));
+ assertThat(ep.b, is("a"));
+ assertThat(ep.c, is(42L));
+
+ MyExt actualExt = ep.ext.getParcelable(MyExt.class);
+ assertThat(dumpMyExt(actualExt), is(dumpMyExt(ext)));
+
+ MyExt2 actualExt2 = ep.ext2.getParcelable(MyExt2.class);
+ assertThat(dumpMyExt2(actualExt2), is(dumpMyExt2(ext2)));
+ }
+
+ private static String dumpMyExt(MyExt ext) {
+ if (ext == null) {
+ return null;
+ }
+ return "{a: " + ext.a + ", b: " + ext.b + "}";
+ }
+
+ private static String dumpMyExt2(MyExt2 ext2) {
+ if (ext2 == null) {
+ return null;
+ }
+ return "{a: " + ext2.a + ", b: " + dumpMyExt(ext2.b) + ", " + ext2.c + "}";
+ }
+}
diff --git a/tests/java/src/android/aidl/tests/GenericTests.java b/tests/java/src/android/aidl/tests/GenericTests.java
new file mode 100644
index 0000000..4b9b910
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/GenericTests.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019, 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.assertThat;
+
+import android.aidl.tests.IntEnum;
+import android.aidl.tests.generic.Baz;
+import android.aidl.tests.generic.IFaz;
+import android.aidl.tests.generic.Pair;
+import android.os.IBinder;
+import android.os.RemoteException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class GenericTests {
+
+ @Test
+ public void testGeneric() throws RemoteException {
+ IFaz.Stub ifaz = new IFaz.Stub() {
+ public Pair<Integer, String> getPair() {
+ Pair<Integer, String> ret = new Pair<Integer, String>();
+ ret.mFirst = 15;
+ ret.mSecond = "My";
+ return ret;
+ }
+ public Pair<Baz, Baz> getPair2() {
+ Pair<Baz, Baz> ret = new Pair<Baz, Baz>();
+ ret.mFirst = new Baz();
+ ret.mFirst.a = 15;
+ ret.mSecond = new Baz();
+ ret.mSecond.a = 16;
+ return ret;
+ }
+
+ public Pair<Integer, Integer> getPair3() {
+ Pair<Integer, Integer> ret = new Pair<Integer, Integer>();
+ ret.mFirst = 15;
+ ret.mSecond = IntEnum.BAR;
+ return ret;
+ }
+ };
+
+ IFaz service = IFaz.Stub.asInterface(ifaz);
+ assertThat(service.getPair().mFirst, is(15));
+ assertThat(service.getPair().mSecond, is("My"));
+
+ assertThat(service.getPair2().mFirst.a, is(15));
+ assertThat(service.getPair2().mSecond.a, is(16));
+
+ assertThat(service.getPair3().mFirst, is(15));
+ assertThat(service.getPair3().mSecond, is(IntEnum.BAR));
+ }
+}
diff --git a/tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java b/tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
new file mode 100644
index 0000000..a4ea0e4
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/JavaOnlyImmutableAnnotationTests.java
@@ -0,0 +1,142 @@
+/*
+ * 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.assertThat;
+import static org.junit.Assert.fail;
+
+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;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class JavaOnlyImmutableAnnotationTests {
+ @Test
+ public void testReadWriteJavaOnlyImmutableParcelable() {
+ Parcel parcel = Parcel.obtain();
+ List<Bar> list = new ArrayList<Bar>();
+ list.add(new Bar("aa"));
+ Map<String, Bar> map = new HashMap<String, Bar>();
+ map.put("key", new Bar("value"));
+ Bar[] array = new Bar[3];
+ array[0] = new Bar("zero");
+ array[1] = new Bar("one");
+ array[2] = new Bar("two");
+
+ 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);
+
+ assertThat(foo.a, is(foo2.a));
+ assertThat(foo.b.s, is(foo2.b.s));
+ assertThat(foo.c.size(), is(foo.c.size()));
+ assertThat(foo.c.get(0).s, is(foo2.c.get(0).s));
+ assertThat(foo.c.size(), is(foo.c.size()));
+ assertThat(foo.d.get("key").s, is(foo2.d.get("key").s));
+ assertThat(foo.e.length, is(foo.e.length));
+
+ 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
+ public void testEveryFieldIsFinal() {
+ for (Field f : Foo.class.getDeclaredFields()) {
+ if (!Modifier.isFinal(f.getModifiers())) {
+ fail(f.getName() + " should be final.");
+ }
+ }
+ }
+
+ @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], Union.num(42));
+ foo.c.add(new Bar("hi"));
+ // It is supposed to fail.
+ fail("A List in an immutable parcelable isn't modifiable.");
+ }
+
+ @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], 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.");
+ }
+
+ @Test
+ public void testBuilderRespectDefaultValue() {
+ assertThat(new Foo.Builder().build().a, is(10));
+ assertThat(new Bar.Builder().build().s, is("bar"));
+ }
+
+ @Test
+ public void testBuilder() {
+ Bar b = new Bar("my");
+ List<Bar> list = new ArrayList<Bar>();
+ list.add(new Bar("aa"));
+ Map<String, Bar> map = new HashMap<String, Bar>();
+ map.put("key", new Bar("value"));
+ Bar[] array = new Bar[3];
+ array[0] = new Bar("zero");
+ array[1] = new Bar("one");
+ array[2] = new Bar("two");
+
+ 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));
+ assertThat(foo.c.size(), is(foo.c.size()));
+ assertThat(foo.c.get(0).s, is(foo2.c.get(0).s));
+ assertThat(foo.c.size(), is(foo.c.size()));
+ assertThat(foo.d.get("key").s, is(foo2.d.get("key").s));
+ assertThat(foo.e.length, is(foo.e.length));
+
+ 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/src/android/aidl/tests/MapTests.java b/tests/java/src/android/aidl/tests/MapTests.java
new file mode 100644
index 0000000..1bb81cd
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/MapTests.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2019, 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.assertThat;
+
+import android.aidl.tests.map.Bar;
+import android.aidl.tests.map.Foo;
+import android.aidl.tests.map.IEmpty;
+import android.aidl.tests.map.IntEnum;
+import android.os.Parcel;
+import java.util.HashMap;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class MapTests {
+
+ @Test
+ public void testWriteAndThenReadMaps() {
+ Parcel parcel = Parcel.obtain();
+
+ // Write
+ Foo foo = new Foo();
+
+ foo.intEnumArrayMap = new HashMap<>();
+ foo.intEnumArrayMap.put("Foo", new int[] {IntEnum.FOO});
+
+ foo.intArrayMap = new HashMap<>();
+ foo.intArrayMap.put("Foo", new int[] {42});
+
+ Bar bar = new Bar();
+ bar.a = 42;
+ bar.b = "Bar";
+ foo.barMap = new HashMap<>();
+ foo.barMap.put("Foo", bar);
+
+ foo.barArrayMap = new HashMap<>();
+ foo.barArrayMap.put("Foo", new Bar[] {bar});
+
+ foo.stringMap = new HashMap<>();
+ foo.stringMap.put("Foo", "Bar");
+
+ foo.stringArrayMap = new HashMap<>();
+ foo.stringArrayMap.put("Foo", new String[] {"Bar"});
+
+ IEmpty intf = new IEmpty.Stub() {};
+ foo.interfaceMap = new HashMap<>();
+ foo.interfaceMap.put("Foo", intf);
+
+ foo.ibinderMap = new HashMap<>();
+ foo.ibinderMap.put("Foo", intf.asBinder());
+
+ foo.writeToParcel(parcel, 0);
+
+ // And then read
+ parcel.setDataPosition(0);
+
+ Foo readFoo = new Foo();
+ readFoo.readFromParcel(parcel);
+
+ assertThat(readFoo.intEnumArrayMap.size(), is(1));
+ assertThat(readFoo.intEnumArrayMap.get("Foo"), is(new int[] {IntEnum.FOO}));
+
+ assertThat(readFoo.intArrayMap.size(), is(1));
+ assertThat(readFoo.intArrayMap.get("Foo"), is(new int[] {42}));
+
+ assertThat(readFoo.barMap.containsKey("Foo"), is(true));
+ assertThat(readFoo.barMap.size(), is(1));
+
+ Bar readBar = readFoo.barMap.get("Foo");
+ assertThat(readBar.a, is(42));
+ assertThat(readBar.b, is("Bar"));
+
+ Bar[] bars = readFoo.barArrayMap.get("Foo");
+ assertThat(bars.length, is(1));
+ assertThat(bars[0].a, is(42));
+ assertThat(bars[0].b, is("Bar"));
+
+ assertThat(readFoo.stringMap.size(), is(1));
+ assertThat(readFoo.stringMap.get("Foo"), is("Bar"));
+
+ String[] strings = readFoo.stringArrayMap.get("Foo");
+ assertThat(strings.length, is(1));
+ assertThat(strings[0], is("Bar"));
+
+ assertThat(readFoo.interfaceMap.size(), is(1));
+ assertThat(readFoo.interfaceMap.get("Foo"), is(intf));
+
+ assertThat(readFoo.ibinderMap.size(), is(1));
+ assertThat(readFoo.ibinderMap.get("Foo"), is(intf.asBinder()));
+ }
+}
diff --git a/tests/java/src/android/aidl/tests/NullableTests.java b/tests/java/src/android/aidl/tests/NullableTests.java
new file mode 100644
index 0000000..392d784
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/NullableTests.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package android.aidl.tests;
+
+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;
+
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runners.JUnit4;
+import org.junit.runner.RunWith;
+
+@RunWith(JUnit4.class)
+public class NullableTests {
+ private ITestService mService;
+ private ICppJavaTests mCppJavaTests;
+
+ @Before
+ public void setUp() throws RemoteException {
+ IBinder binder = ServiceManager.waitForService(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
+ public void testExpectNpeWithNullString() throws RemoteException {
+ try {
+ String response = mService.RepeatString(null);
+ } catch (NullPointerException ex) {
+ return;
+ }
+ if (mService.getBackendType() != BackendType.JAVA) {
+ fail("NullPointerException was expected, but wasn't thrown");
+ }
+ }
+
+ @Test
+ public void testExpectNpeWithNullBinder() throws RemoteException {
+ try {
+ mService.TakesAnIBinder(null);
+ } catch (NullPointerException ex) {
+ return;
+ }
+
+ if (mService.getBackendType() != BackendType.JAVA) {
+ fail("NullPointerException was expected, but wasn't thrown");
+ }
+ }
+
+ @Test
+ public void testExpectNpeWithNullBinderList() throws RemoteException {
+ assumeTrue(mCppJavaTests != null);
+
+ List<IBinder> listWithNulls = new ArrayList<IBinder>();
+ listWithNulls.add(null);
+ try {
+ mCppJavaTests.TakesAnIBinderList(listWithNulls);
+ } catch (NullPointerException ex) {
+ return;
+ }
+ if (mService.getBackendType() != BackendType.JAVA) {
+ fail("NullPointerException was expected, but wasn't thrown");
+ }
+ }
+
+ @Test
+ public void testNullableIInterface() throws RemoteException {
+ INamedCallback callback = mService.GetCallback(false);
+ assertThat(callback, is(notNullValue()));
+
+ callback = mService.GetCallback(true);
+ assertThat(callback, is(nullValue()));
+ }
+}
diff --git a/tests/java/src/android/aidl/tests/SimpleParcelable.java b/tests/java/src/android/aidl/tests/SimpleParcelable.java
new file mode 100644
index 0000000..d3918c7
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/SimpleParcelable.java
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+package android.aidl.tests;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class SimpleParcelable implements Parcelable {
+ private String mName;
+ private int mNumber;
+
+ SimpleParcelable() {}
+ SimpleParcelable(String name, int number) { set(name, number); }
+
+ public int describeContents() { return 0; }
+
+ public void set(String name, int number) {
+ mName = name;
+ mNumber = number;
+ }
+
+ public String getName() { return mName; }
+ public int getNumber() { return mNumber; }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mName);
+ dest.writeInt(mNumber);
+ }
+
+ public void readFromParcel(Parcel source) {
+ mName = source.readString();
+ mNumber = source.readInt();
+ }
+
+ public boolean equals(Object o) {
+ if (o == null) {
+ return false;
+ }
+ if (!(o instanceof SimpleParcelable)) {
+ return false;
+ }
+ SimpleParcelable p = (SimpleParcelable)o;
+ if ((mName == null && p.mName != null) ||
+ (mName != null && !mName.equals(p.mName))) {
+ return false;
+ }
+ return mNumber == p.mNumber;
+ }
+
+ public String toString() {
+ return "SimpleParcelable(" + mName + ", " + mNumber + ")";
+ }
+
+ public static final Parcelable.Creator<SimpleParcelable> CREATOR =
+ new Parcelable.Creator<SimpleParcelable>() {
+ public SimpleParcelable createFromParcel(Parcel source) {
+ String name = source.readString();
+ int number = source.readInt();
+ return new SimpleParcelable(name, number);
+ }
+
+ public SimpleParcelable[] newArray(int size) {
+ return new SimpleParcelable[size];
+ }
+ };
+}
diff --git a/tests/java/src/android/aidl/tests/TestServiceClient.java b/tests/java/src/android/aidl/tests/TestServiceClient.java
new file mode 100644
index 0000000..e1e8e8b
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/TestServiceClient.java
@@ -0,0 +1,837 @@
+/*
+ * 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.
+ */
+
+package android.aidl.tests;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+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;
+import android.aidl.tests.INamedCallback;
+import android.aidl.tests.ITestService;
+import android.aidl.tests.IntEnum;
+import android.aidl.tests.LongEnum;
+import android.aidl.tests.SimpleParcelable;
+import android.aidl.tests.StructuredParcelable;
+import android.aidl.tests.Union;
+import android.aidl.versioned.tests.IFooInterface;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+import android.os.PersistableBundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.ServiceSpecificException;
+import android.util.Log;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class TestServiceClient {
+ private ITestService service;
+ private ICppJavaTests cpp_java_tests;
+
+ @Before
+ public void setUp() throws RemoteException {
+ IBinder binder = ServiceManager.waitForService(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
+ public void testBooleanRepeat() throws RemoteException {
+ boolean query = true;
+ assertThat(service.RepeatBoolean(query), is(query));
+ }
+
+ @Test
+ public void testCharRepeat() throws RemoteException {
+ char query = 'A';
+ assertThat(service.RepeatChar(query), is(query));
+ }
+
+ @Test
+ public void testByteRepeat() throws RemoteException {
+ byte query = -128;
+ assertThat(service.RepeatByte(query), is(query));
+ }
+
+ @Test
+ public void testIntRepeat() throws RemoteException {
+ int query = 1 << 30;
+ assertThat(service.RepeatInt(query), is(query));
+ }
+
+ @Test
+ public void testConstRepeat() throws RemoteException {
+ int query[] = {ITestService.TEST_CONSTANT,
+ ITestService.TEST_CONSTANT2,
+ ITestService.TEST_CONSTANT3,
+ ITestService.TEST_CONSTANT4,
+ ITestService.TEST_CONSTANT5,
+ ITestService.TEST_CONSTANT6,
+ ITestService.TEST_CONSTANT7,
+ ITestService.TEST_CONSTANT8};
+ for (int i = 0; i < query.length; i++) {
+ assertThat(service.RepeatInt(query[i]), is(query[i]));
+ }
+ }
+
+ @Test
+ public void testLongRepeat() throws RemoteException {
+ long query = 1L << 60;
+ assertThat(service.RepeatLong(query), is(query));
+ }
+
+ @Test
+ public void testFloatRepeat() throws RemoteException {
+ float query = 1.0f/3.0f;
+ assertThat(service.RepeatFloat(query), is(query));
+ }
+
+ @Test
+ public void testDoubleRepeat() throws RemoteException {
+ double query = 1.0/3.0;
+ assertThat(service.RepeatDouble(query), is(query));
+ }
+
+ @Test
+ public void testByteEnumRepeat() throws RemoteException {
+ byte query = ByteEnum.FOO;
+ assertThat(service.RepeatByteEnum(query), is(query));
+ }
+
+ @Test
+ public void testIntEnumRepeat() throws RemoteException {
+ int query = IntEnum.FOO;
+ assertThat(service.RepeatIntEnum(query), is(query));
+ }
+
+ @Test
+ public void testLongEnumRepeat() throws RemoteException {
+ long query = LongEnum.FOO;
+ assertThat(service.RepeatLongEnum(query), is(query));
+ }
+
+ @Test
+ public void testStringListRepeat() throws RemoteException {
+ List<String> queries = Arrays.asList(
+ "not empty", "", "\0",
+ ITestService.STRING_TEST_CONSTANT,
+ ITestService.STRING_TEST_CONSTANT2);
+ for (String query : queries) {
+ assertThat(service.RepeatString(query), is(query));
+ }
+ }
+
+ @Test
+ public void testBooleanArrayReversal() throws RemoteException {
+ boolean[] input = {true, false, false, false};
+ boolean echoed[] = new boolean[input.length];
+ boolean[] reversed = service.ReverseBoolean(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testByteArrayReversal() throws RemoteException {
+ byte[] input = {0, 1, 2};
+ byte echoed[] = new byte[input.length];
+ byte[] reversed = service.ReverseByte(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testCharArrayReversal() throws RemoteException {
+ char[] input = {'A', 'B', 'C', 'D', 'E'};
+ char echoed[] = new char[input.length];
+ char[] reversed = service.ReverseChar(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testIntArrayReversal() throws RemoteException {
+ int[] input = {-1, 0, 1, 2, 3, 4, 5, 6};
+ int echoed[] = new int[input.length];
+ int[] reversed = service.ReverseInt(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testLongArrayReversal() throws RemoteException {
+ long[] input = {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8};
+ long echoed[] = new long[input.length];
+ long[] reversed = service.ReverseLong(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testFloatArrayReversal() throws RemoteException {
+ float[] input = {0.0f, 1.0f, -0.3f};
+ float echoed[] = new float[input.length];
+ float[] reversed = service.ReverseFloat(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testDoubleArrayReversal() throws RemoteException {
+ double[] input = {-1.0, -4.0, -2.0};
+ double echoed[] = new double[input.length];
+ double[] reversed = service.ReverseDouble(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testStringArrayReversal() throws RemoteException {
+ String[] input = {"For", "relaxing", "times"};
+ String echoed[] = new String[input.length];
+ String[] reversed = service.ReverseString(input, echoed);
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testBinderExchange() throws RemoteException {
+ INamedCallback got = service.GetOtherTestService("Smythe");
+ assertThat(got.GetName(), is("Smythe"));
+
+ assertThat(service.VerifyName(got, "Smythe"), is(true));
+ }
+
+ @Test
+ public void testListReversal() throws RemoteException {
+ List<String> input = Arrays.asList("Walk", "into", "Córdoba");
+ List<String> echoed = new ArrayList<String>();
+ List<String> reversed = service.ReverseStringList(input, echoed);
+ assertThat(echoed, is(input));
+
+ Collections.reverse(input);
+ assertThat(reversed, is(input));
+ }
+
+ @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 =
+ new GenericStructuredParcelable<Integer, StructuredParcelable, Integer>();
+ input.a = 41;
+ input.b = 42;
+ GenericStructuredParcelable<Integer, StructuredParcelable, Integer> testing = input;
+ assertThat(testing, is(input));
+ GenericStructuredParcelable<Integer, StructuredParcelable, Integer> returned =
+ 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));
+ assertThat(returned.b, is(input.b));
+ }
+
+ @Test
+ public void testRepeatParcelable() throws RemoteException {
+ assumeTrue(cpp_java_tests != null);
+
+ SimpleParcelable input = new SimpleParcelable("foo", 42);
+ SimpleParcelable out_param = new SimpleParcelable();
+ 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 = 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) {
+ assertThat(reversed[k], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testRepeatEmptyPersistableBundle() throws RemoteException {
+ assumeTrue(cpp_java_tests != null);
+
+ PersistableBundle emptyBundle = new PersistableBundle();
+ 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";
+ final String testIntKey = "testInt";
+ final String testNestedIntKey = "testNestedInt";
+ final String testLongKey = "testLong";
+ final String testDoubleKey = "testDouble";
+ final String testStringKey = "testString";
+ final String testBoolArrayKey = "testBoolArray";
+ final String testIntArrayKey = "testIntArray";
+ final String testLongArrayKey = "testLongArray";
+ final String testDoubleArrayKey = "testDoubleArray";
+ final String testStringArrayKey = "testStringArray";
+ final String testPersistableBundleKey = "testPersistableBundle";
+
+ pb.putBoolean(testBoolKey, false);
+ pb.putInt(testIntKey, 33);
+ pb.putLong(testLongKey, 34359738368L);
+ pb.putDouble(testDoubleKey, 1.1);
+ pb.putString(testStringKey, new String("Woot!"));
+ pb.putBooleanArray(testBoolArrayKey, new boolean[] {true, false, true});
+ pb.putIntArray(testIntArrayKey, new int[] {33, 44, 55, 142});
+ pb.putLongArray(testLongArrayKey, new long[] {34L, 8371L, 34359738375L});
+ pb.putDoubleArray(testDoubleArrayKey, new double[] {2.2, 5.4});
+ pb.putStringArray(testStringArrayKey, new String[] {"hello", "world!"});
+ PersistableBundle testNestedPersistableBundle = new PersistableBundle();
+ testNestedPersistableBundle.putInt(testNestedIntKey, 345);
+ pb.putPersistableBundle(testPersistableBundleKey, testNestedPersistableBundle);
+
+ PersistableBundle ret = cpp_java_tests.RepeatPersistableBundle(pb);
+
+ assertThat(ret.size(), is(pb.size()));
+ assertThat(ret.getBoolean(testBoolKey), is(pb.getBoolean(testBoolKey)));
+ assertThat(ret.getInt(testIntKey), is(pb.getInt(testIntKey)));
+ assertThat(ret.getLong(testLongKey), is(pb.getLong(testLongKey)));
+ assertThat(ret.getDouble(testDoubleKey), is(pb.getDouble(testDoubleKey)));
+ assertThat(ret.getString(testStringKey), is(pb.getString(testStringKey)));
+ assertThat(ret.getBooleanArray(testBoolArrayKey), is(pb.getBooleanArray(testBoolArrayKey)));
+ assertThat(ret.getIntArray(testIntArrayKey), is(pb.getIntArray(testIntArrayKey)));
+ assertThat(ret.getLongArray(testLongArrayKey), is(pb.getLongArray(testLongArrayKey)));
+ assertThat(ret.getDoubleArray(testDoubleArrayKey), is(pb.getDoubleArray(testDoubleArrayKey)));
+ assertThat(ret.getStringArray(testStringArrayKey), is(pb.getStringArray(testStringArrayKey)));
+
+ PersistableBundle nested = ret.getPersistableBundle(testPersistableBundleKey);
+ assertThat(nested, is(notNullValue()));
+ assertThat(nested.getInt(testNestedIntKey), is(testNestedPersistableBundle.getInt(testNestedIntKey)));
+ }
+
+ @Test
+ public void testReversePersistableBundleArray() throws RemoteException {
+ assumeTrue(cpp_java_tests != null);
+
+ PersistableBundle[] input = new PersistableBundle[3];
+ PersistableBundle first = new PersistableBundle();
+ PersistableBundle second = new PersistableBundle();
+ PersistableBundle third = new PersistableBundle();
+ final String testIntKey = new String("testInt");
+ final String testLongKey = new String("testLong");
+ final String testDoubleKey = new String("testDouble");
+ first.putInt(testIntKey, 1231);
+ second.putLong(testLongKey, 222222L);
+ third.putDouble(testDoubleKey, 10.8);
+ input[0] = first;
+ input[1] = second;
+ input[2] = third;
+ final int original_input_size = input.length;
+
+ PersistableBundle[] repeated = new PersistableBundle[input.length];
+ PersistableBundle[] reversed = cpp_java_tests.ReversePersistableBundles(input, repeated);
+
+ assertThat(repeated.length, is(input.length));
+ assertThat(input.length, is(original_input_size));
+ assertThat(repeated[0].getInt(testIntKey), is(input[0].getInt(testIntKey)));
+ assertThat(repeated[1].getLong(testLongKey), is(input[1].getLong(testLongKey)));
+ assertThat(repeated[2].getDouble(testDoubleKey), is(input[2].getDouble(testDoubleKey)));
+
+ assertThat(reversed.length, is(input.length));
+ assertThat(reversed[0].getInt(testIntKey), is(input[2].getInt(testIntKey)));
+ assertThat(reversed[1].getLong(testLongKey), is(input[1].getLong(testLongKey)));
+ assertThat(reversed[2].getDouble(testDoubleKey), is(input[0].getDouble(testDoubleKey)));
+ }
+
+ @Test
+ public void testFileDescriptorPassing() throws RemoteException, IOException {
+ 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 = cpp_java_tests.RepeatFileDescriptor(descriptor);
+ fos.close();
+
+ FileOutputStream journeyedStream = new FileOutputStream(journeyed);
+
+ String testData = "FrazzleSnazzleFlimFlamFlibbityGumboChops";
+ byte[] output = testData.getBytes();
+ journeyedStream.write(output);
+ journeyedStream.close();
+
+ FileInputStream fis = new FileInputStream(file);
+ byte[] input = new byte[output.length];
+
+ assertThat(fis.read(input), is(input.length));
+ assertThat(input, is(output));
+ }
+
+ @Test
+ public void testParcelFileDescriptorPassing() throws RemoteException, IOException {
+ String file = "/data/local/tmp/aidl-test-file";
+ ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(
+ new File(file), ParcelFileDescriptor.MODE_CREATE |
+ ParcelFileDescriptor.MODE_WRITE_ONLY);
+ ParcelFileDescriptor journeyed = service.RepeatParcelFileDescriptor(descriptor);
+
+ FileOutputStream journeyedStream = new ParcelFileDescriptor.AutoCloseOutputStream(journeyed);
+
+ String testData = "FrazzleSnazzleFlimFlamFlibbityGumboChops";
+ byte[] output = testData.getBytes();
+ journeyedStream.write(output);
+ journeyedStream.close();
+
+ FileInputStream fis = new FileInputStream(file);
+ byte[] input = new byte[output.length];
+
+ assertThat(fis.read(input), is(input.length));
+ assertThat(input, is(output));
+ }
+
+ @Test
+ public void testServiceSpecificExceptions() throws RemoteException {
+ for (int i = -1; i < 2; ++i) {
+ try {
+ service.ThrowServiceException(i);
+ } catch (ServiceSpecificException ex) {
+ assertThat(ex.errorCode, is(i));
+ }
+ }
+ }
+
+ private static final List<String> utf8_queries = Arrays.asList(
+ "typical string",
+ "",
+ "\0\0\0",
+ // Java doesn't handle unicode code points above U+FFFF well.
+ new String(Character.toChars(0x1F701)) + "\u03A9");
+
+ @Test
+ public void testRepeatUtf8String() throws RemoteException {
+ for (String query : utf8_queries) {
+ String response = service.RepeatUtf8CppString(query);
+ assertThat(response, is(query));
+ }
+ }
+
+ @Test
+ public void testReverseUtf8StringArray() throws RemoteException {
+ String[] input = (String[])utf8_queries.toArray();
+ String echoed[] = new String[input.length];
+
+ String[] reversed = service.ReverseUtf8CppString(input, echoed);
+
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ @Test
+ public void testReverseNullableUtf8StringArray() throws RemoteException {
+ final List<String> utf8_queries_and_nulls = Arrays.asList(
+ "typical string",
+ null,
+ "",
+ "\0\0\0",
+ null,
+ // Java doesn't handle unicode code points above U+FFFF well.
+ new String(Character.toChars(0x1F701)) + "\u03A9");
+ String[] input = (String[])utf8_queries_and_nulls.toArray();
+ String echoed[] = new String[input.length];
+
+ String[] reversed = service.ReverseNullableUtf8CppString(input, echoed);
+
+ assertThat(echoed, is(input));
+ assertThat(reversed.length, is(input.length));
+ for (int i = 0; i < input.length; ++i) {
+ int j = reversed.length - (1 + i);
+ if (input[i] == null && reversed[j] == null) {
+ continue;
+ }
+ assertThat(reversed[j], is(input[i]));
+ }
+ }
+
+ 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;
+
+ StructuredParcelable p = new StructuredParcelable();
+ p.shouldContainThreeFs = new int[0];
+ p.f = kDesiredFValue;
+ p.shouldBeJerry = "";
+ p.shouldContainTwoByteFoos = new byte[2];
+ p.shouldContainTwoIntFoos = new int[2];
+ p.shouldContainTwoLongFoos = new long[2];
+
+ // Check the default values
+ assertThat(p.stringDefaultsToFoo, is("foo"));
+ final byte byteFour = 4;
+ assertThat(p.byteDefaultsToFour, is(byteFour));
+ assertThat(p.intDefaultsToFive, is(5));
+ assertThat(p.longDefaultsToNegativeSeven, is(-7L));
+ assertThat(p.booleanDefaultsToTrue, is(true));
+ assertThat(p.charDefaultsToC, is('C'));
+ assertThat(p.floatDefaultsToPi, is(3.14f));
+ 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);
+
+ // Check the returned values
+ assertThat(p.shouldContainThreeFs, is(new int[] {kDesiredFValue, kDesiredFValue, kDesiredFValue}));
+ assertThat(p.shouldBeJerry, is("Jerry"));
+ assertThat(p.shouldBeByteBar, is(ByteEnum.BAR));
+ assertThat(p.shouldBeIntBar, is(IntEnum.BAR));
+ assertThat(p.shouldBeLongBar, is(LongEnum.BAR));
+ assertThat(p.shouldContainTwoByteFoos, is(new byte[] {ByteEnum.FOO, ByteEnum.FOO}));
+ assertThat(p.shouldContainTwoIntFoos, is(new int[] {IntEnum.FOO, IntEnum.FOO}));
+ assertThat(p.shouldContainTwoLongFoos, is(new long[] {LongEnum.FOO, LongEnum.FOO}));
+ assertThat(p.int32_min, is(Integer.MIN_VALUE));
+ assertThat(p.int32_max, is(Integer.MAX_VALUE));
+ assertThat(p.int64_max, is(Long.MAX_VALUE));
+ assertThat(p.hexInt32_neg_1, is(-1));
+ for (int ndx = 0; ndx < p.int32_1.length; ndx++) {
+ assertThat(p.int32_1[ndx], is(1));
+ }
+ for (int ndx = 0; ndx < p.int64_1.length; ndx++) {
+ assertThat(p.int64_1[ndx], is(1L));
+ }
+ assertThat(p.hexInt32_pos_1, is(1));
+ assertThat(p.hexInt64_pos_1, is(1));
+ assertThat(p.const_exprs_1, is(1));
+ assertThat(p.const_exprs_2, is(1));
+ assertThat(p.const_exprs_3, is(1));
+ assertThat(p.const_exprs_4, is(1));
+ assertThat(p.const_exprs_5, is(1));
+ assertThat(p.const_exprs_6, is(1));
+ assertThat(p.const_exprs_7, is(1));
+ assertThat(p.const_exprs_8, is(1));
+ assertThat(p.const_exprs_9, is(1));
+ assertThat(p.const_exprs_10, is(1));
+
+ 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));
+ }
+
+ @Test
+ public void testDefaultImpl() throws RemoteException {
+ final int expectedArg = 100;
+ final int expectedReturnValue = 200;
+
+ boolean success = ITestService.Stub.setDefaultImpl(new ITestService.Default() {
+ @Override
+ public int UnimplementedMethod(int arg) throws RemoteException {
+ if (arg != expectedArg) {
+ throw new RemoteException("Argument for UnimplementedMethod is expected "
+ + " to be " + expectedArg + ", but got " + arg);
+ }
+ return expectedReturnValue;
+ }
+ });
+ assertThat(success, is(true));
+
+ int ret = service.UnimplementedMethod(expectedArg);
+ assertThat(ret, is(expectedReturnValue));
+ }
+
+ @Test
+ public void testToString() {
+ ParcelableForToString p = new ParcelableForToString();
+ p.intValue = 10;
+ p.intArray = new int[]{20, 30};
+ p.longValue = 100L;
+ p.longArray = new long[]{200L, 300L};
+ p.doubleValue = 3.14d;
+ p.doubleArray = new double[]{1.1d, 1.2d};
+ p.floatValue = 3.14f;
+ p.floatArray = new float[]{1.1f, 1.2f};
+ p.byteValue = 3;
+ p.byteArray = new byte[]{5, 6};
+ p.booleanValue = true;
+ p.booleanArray = new boolean[]{true, false};
+ p.stringValue = "this is a string";
+ p.stringArray = new String[]{"hello", "world"};
+ p.stringList = Arrays.asList(new String[]{"alice", "bob"});
+ OtherParcelableForToString op = new OtherParcelableForToString();
+ op.field = "other";
+ p.parcelableValue = op;
+ p.parcelableArray = new OtherParcelableForToString[]{op, op};
+ p.enumValue = IntEnum.FOO;
+ p.enumArray = new int[]{IntEnum.FOO, IntEnum.BAR};
+ p.nullArray = null;
+ p.nullList = null;
+ GenericStructuredParcelable<Integer, StructuredParcelable, Integer> gen =
+ new GenericStructuredParcelable<Integer, StructuredParcelable, Integer>();
+ 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, "
+ + "intArray: [20, 30], "
+ + "longValue: 100, "
+ + "longArray: [200, 300], "
+ + "doubleValue: 3.14, "
+ + "doubleArray: [1.1, 1.2], "
+ + "floatValue: 3.14, "
+ + "floatArray: [1.1, 1.2], "
+ + "byteValue: 3, "
+ + "byteArray: [5, 6], "
+ + "booleanValue: true, "
+ + "booleanArray: [true, false], "
+ + "stringValue: this is a string, "
+ + "stringArray: [hello, world], "
+ + "stringList: [alice, bob], "
+ + "parcelableValue: android.aidl.tests.OtherParcelableForToString{field: other}, "
+ + "parcelableArray: ["
+ + "android.aidl.tests.OtherParcelableForToString{field: other}, "
+ + "android.aidl.tests.OtherParcelableForToString{field: other}], "
+ + "enumValue: 1000, "
+ + "enumArray: [1000, 2000], "
+ + "nullArray: null, "
+ + "nullList: null, "
+ + "parcelableGeneric: android.aidl.tests.GenericStructuredParcelable{a: 1, b: 2}, "
+ + "unionValue: null"
+ + "}";
+
+ assertThat(p.toString(), is(expected));
+ }
+
+ @Test
+ public void testRenamedInterface() throws RemoteException {
+ IOldName oldAsOld = service.GetOldNameInterface();
+ assertNotNull(oldAsOld);
+ assertThat(oldAsOld.DESCRIPTOR, is("android.aidl.tests.IOldName"));
+ assertThat(oldAsOld.RealName(), is("OldName"));
+
+ INewName newAsNew = service.GetNewNameInterface();
+ assertNotNull(newAsNew);
+ assertThat(newAsNew.DESCRIPTOR, is("android.aidl.tests.IOldName"));
+ assertThat(oldAsOld.RealName(), is("OldName"));
+
+ IOldName newAsOld = IOldName.Stub.asInterface(service.GetNewNameInterface().asBinder());
+ assertNotNull(newAsOld);
+ assertThat(newAsOld.DESCRIPTOR, is("android.aidl.tests.IOldName"));
+ assertThat(newAsOld.RealName(), is("NewName"));
+
+ INewName oldAsNew = INewName.Stub.asInterface(service.GetOldNameInterface().asBinder());
+ assertNotNull(oldAsNew);
+ 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/src/android/aidl/tests/TestVersionedInterface.java b/tests/java/src/android/aidl/tests/TestVersionedInterface.java
new file mode 100644
index 0000000..bb96331
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/TestVersionedInterface.java
@@ -0,0 +1,99 @@
+/*
+ * 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.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import android.aidl.versioned.tests.BazUnion;
+import android.aidl.versioned.tests.Foo;
+import android.aidl.versioned.tests.IFooInterface;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class TestVersionedInterface {
+ private IFooInterface service;
+
+ @Before
+ public void setUp() {
+ IBinder binder = ServiceManager.waitForService(IFooInterface.class.getName());
+ assertNotNull(binder);
+ service = IFooInterface.Stub.asInterface(binder);
+ assertNotNull(service);
+ }
+
+ @Test
+ public void testGetInterfaceVersion() throws RemoteException {
+ assertThat(service.getInterfaceVersion(), is(1));
+ }
+
+ @Test
+ public void testGetInterfaceHash() throws RemoteException {
+ assertThat(service.getInterfaceHash(), is("9e7be1859820c59d9d55dd133e71a3687b5d2e5b"));
+ }
+
+ @Rule public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void testUnimplementedMethodTriggersException() throws RemoteException {
+ expectedException.expect(RemoteException.class);
+ expectedException.expectMessage("Method newApi is unimplemented.");
+
+ 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));
+ }
+
+ @Test
+ public void testArrayOfPacelableWithNewField() throws RemoteException {
+ Foo[] foos = new Foo[42];
+ for (int i = 0; i < foos.length; i++) {
+ foos[i] = new Foo();
+ }
+ int length = service.returnsLengthOfFooArray(foos);
+ assertThat(length, is(foos.length));
+ }
+
+ @Test
+ public void testReadDataCorrectlyAfterParcelableWithNewField() throws RemoteException {
+ Foo inFoo = new Foo();
+ Foo inoutFoo = new Foo();
+ Foo outFoo = new Foo();
+ int ret = service.ignoreParcelablesAndRepeatInt(inFoo, inoutFoo, outFoo, 43);
+ assertThat(ret, is(43));
+ }
+}
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/src/android/aidl/tests/VintfTests.java b/tests/java/src/android/aidl/tests/VintfTests.java
new file mode 100644
index 0000000..2df1b1c
--- /dev/null
+++ b/tests/java/src/android/aidl/tests/VintfTests.java
@@ -0,0 +1,67 @@
+/*
+ * 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 android.aidl.tests;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class VintfTests {
+ private static final String kInstance = "android.does.not.exist.IFoo/default";
+
+ @Test
+ public void cantAddVintfService() throws RemoteException {
+ Binder binder = new Binder();
+ binder.markVintfStability(); // <- do not do this, for test only
+
+ boolean hasException = false;
+ try {
+ ServiceManager.addService(kInstance, binder);
+ } catch (IllegalArgumentException e) {
+ hasException = true;
+ }
+
+ assertTrue(hasException);
+ }
+
+ @Test
+ public void canDowngradeVintfService() throws RemoteException {
+ Binder binder = new Binder();
+ binder.markVintfStability(); // <- do not do this, for test only
+
+ binder.forceDowngradeToSystemStability();
+
+ ServiceManager.addService(kInstance, binder);
+ }
+}
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 9093892..0000000
--- a/tests/java_app/AndroidManifest.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.aidl.tests">
-
- <application android:label="@string/application_title">
-
- <activity android:name="android.aidl.tests.TestServiceClient">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</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/java_app/src/android/aidl/tests/GenericTests.java b/tests/java_app/src/android/aidl/tests/GenericTests.java
deleted file mode 100644
index 85f09ab..0000000
--- a/tests/java_app/src/android/aidl/tests/GenericTests.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2019, 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.generic.Baz;
-import android.aidl.tests.generic.IFaz;
-import android.aidl.tests.generic.Pair;
-import android.os.IBinder;
-import android.os.RemoteException;
-
-class GenericTests {
- private TestLogger mLog;
-
- public GenericTests(TestLogger logger) { mLog = logger; }
-
- public void checkGeneric() throws TestFailException {
- mLog.log("Checking generic feature.");
- IFaz.Stub ifaz = new IFaz.Stub() {
- public Pair<Integer, String> getPair() {
- Pair<Integer, String> ret = new Pair<Integer, String>();
- ret.mFirst = 15;
- ret.mSecond = "My";
- return ret;
- }
- public Pair<Baz, Baz> getPair2() {
- Pair<Baz, Baz> ret = new Pair<Baz, Baz>();
- ret.mFirst = new Baz();
- ret.mSecond = new Baz();
- return ret;
- }
- };
- try {
- IFaz service = IFaz.Stub.asInterface(ifaz);
- if (service.getPair().mFirst != 15) {
- mLog.logAndThrow("mFirst must be 15, but it is " + service.getPair().mFirst);
- }
- if (!"My".equals(service.getPair().mSecond)) {
- mLog.logAndThrow("mSecond must be \"My\", but it is " + service.getPair().mSecond);
- }
- } catch (RemoteException e) {
- mLog.logAndThrow("This test is local, so the exception is not expected: " + e);
- }
- }
-
- public void runTests() throws TestFailException { checkGeneric(); }
-}
diff --git a/tests/java_app/src/android/aidl/tests/MapTests.java b/tests/java_app/src/android/aidl/tests/MapTests.java
deleted file mode 100644
index 46d1657..0000000
--- a/tests/java_app/src/android/aidl/tests/MapTests.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2019, 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.map.Bar;
-import android.aidl.tests.map.Foo;
-import android.aidl.tests.map.IEmpty;
-import android.os.IBinder;
-import android.os.Parcel;
-import java.util.HashMap;
-
-class MapTests {
- private TestLogger mLog;
-
- public MapTests(TestLogger logger) { mLog = logger; }
-
- public void checkMap() throws TestFailException {
- mLog.log("Checking if data in a Map object is transferred well.");
- Parcel parcel = Parcel.obtain();
- IEmpty intf = new IEmpty.Stub() {};
- {
- Foo foo = new Foo();
- Bar bar = new Bar();
- bar.a = 42;
- bar.b = "Bar";
- foo.barMap = new HashMap<>();
- foo.barMap.put("Foo", bar);
-
- foo.stringMap = new HashMap<>();
- foo.stringMap.put("Foo", "Bar");
-
- foo.interfaceMap = new HashMap<>();
- foo.interfaceMap.put("Foo", intf);
-
- foo.ibinderMap = new HashMap<>();
- foo.ibinderMap.put("Foo", intf.asBinder());
-
- foo.writeToParcel(parcel, 0);
- }
- parcel.setDataPosition(0);
- {
- Foo foo = new Foo();
- foo.readFromParcel(parcel);
- if (!foo.barMap.containsKey("Foo")) {
- mLog.logAndThrow("Map foo.a must have the element of which key is \"Foo\"");
- }
- if (foo.barMap.size() != 1) {
- mLog.logAndThrow("The size of map a is expected to be 1.");
- }
- Bar bar = foo.barMap.get("Foo");
- if (bar.a != 42 || !"Bar".equals(bar.b)) {
- mLog.logAndThrow("The content of bar is expected to be {a: 42, b: \"Bar\"}.");
- }
-
- if (foo.stringMap.size() != 1) {
- mLog.logAndThrow("The size of map a is expected to be 1.");
- }
- String string = foo.stringMap.get("Foo");
- if (!"Bar".equals(string)) {
- mLog.logAndThrow("The content of string is expected to be \"Bar\".");
- }
-
- if (foo.interfaceMap.size() != 1) {
- mLog.logAndThrow("The size of map a is expected to be 1.");
- }
-
- if (!intf.equals(foo.interfaceMap.get("Foo"))) {
- mLog.logAndThrow("The content of service is expected to be same.");
- }
-
- if (foo.ibinderMap.size() != 1) {
- mLog.logAndThrow("The size of map a is expected to be 1.");
- }
- IBinder ibinder = foo.ibinderMap.get("Foo");
- if (!intf.asBinder().equals(ibinder)) {
- mLog.logAndThrow("The content of IBinder is expected to be same.");
- }
- }
- }
-
- public void runTests() throws TestFailException { checkMap(); }
-}
diff --git a/tests/java_app/src/android/aidl/tests/NullableTests.java b/tests/java_app/src/android/aidl/tests/NullableTests.java
deleted file mode 100644
index 83a9877..0000000
--- a/tests/java_app/src/android/aidl/tests/NullableTests.java
+++ /dev/null
@@ -1,108 +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.
- */
-
-package android.aidl.tests;
-
-import android.aidl.tests.TestFailException;
-import android.os.IBinder;
-import java.util.ArrayList;
-import java.util.List;
-
-class NullableTests {
- private static final String TAG = "TestServiceClient";
- private ITestService mService;
- private TestLogger mLog;
-
- public NullableTests(ITestService service, TestLogger logger) {
- mService = service;
- mLog = logger;
- }
-
- public void checkNullHandling() throws TestFailException {
- mLog.log("Checking that sending null strings reports an error...");
- try {
- String response = mService.RepeatString(null);
- mLog.logAndThrow("Expected to fail on null string input!");
- } catch (NullPointerException ex) {
- mLog.log("Caught an exception on null string parameter (expected)");
- mLog.log("null strings behave as expected");
- return;
- } catch (Exception ex) {
- mLog.logAndThrow("Expected to receive NullPointerException on " +
- "null parameter, but got " + ex.toString());
- }
- mLog.logAndThrow("Expected to receive NullPointerException on " +
- "null parameter, but nothing was thrown??");
- }
-
- public void checkNullBinderDetection() throws TestFailException {
- mLog.log("Checking that service handles @nullable IBinder...");
- try {
- mService.TakesAnIBinder(null);
- mLog.logAndThrow("Expected to fail on null Binder!");
- } catch (NullPointerException ex) {
- mLog.log("Caught an exception on null Binder parameter (expected)");
- return;
- } catch (Exception ex) {
- mLog.logAndThrow("Expected to receive NullPointerException," +
- "but got " + ex.toString());
- }
- mLog.logAndThrow("Expected to receive NullPointerException on " +
- "null parameter, but nothing was thrown??");
- }
-
- public void checkNullBinderInListDetection() throws TestFailException {
- List<IBinder> listWithNulls = new ArrayList<IBinder>();
- listWithNulls.add(null);
- try {
- mService.TakesAnIBinderList(listWithNulls);
- mLog.logAndThrow("Expected to fail on list with null Binder!");
- } catch (NullPointerException ex) {
- mLog.log("Caught an exception on list with null Binder (expected)");
- return;
- } catch (Exception ex) {
- mLog.logAndThrow("Expected to receive NullPointerException," +
- "but got " + ex.toString());
- }
- mLog.logAndThrow("Expected to receive NullPointerException on " +
- "null parameter, but nothing was thrown??");
- }
-
- public void checkNullInterfaceHandling() throws TestFailException {
- mLog.log("Checking @nullable IInterface handling...");
- try {
- INamedCallback callback = mService.GetCallback(false);
- if (callback == null) {
- mLog.logAndThrow("Expected to get non-null INamedCallback.");
- }
- callback = mService.GetCallback(true);
- if (callback != null) {
- mLog.logAndThrow("Expected to get null INamedCallback.");
- }
- } catch (Exception ex) {
- mLog.logAndThrow("Unexpected exception during @nullable IInterface test: " +
- ex.toString());
- }
- mLog.log("@nullable IInterface handling works as expected.");
- }
-
- public void runTests() throws TestFailException {
- checkNullHandling();
- checkNullBinderDetection();
- checkNullBinderInListDetection();
- checkNullInterfaceHandling();
- }
-}
diff --git a/tests/java_app/src/android/aidl/tests/SimpleParcelable.java b/tests/java_app/src/android/aidl/tests/SimpleParcelable.java
deleted file mode 100644
index 1def98c..0000000
--- a/tests/java_app/src/android/aidl/tests/SimpleParcelable.java
+++ /dev/null
@@ -1,75 +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.
- */
-
-package android.aidl.tests;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class SimpleParcelable implements Parcelable {
- private String mName;
- private int mNumber;
-
- SimpleParcelable() {}
- SimpleParcelable(String name, int number) {
- mName = name;
- mNumber = number;
- }
-
- public int describeContents() { return 0; }
-
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(mName);
- dest.writeInt(mNumber);
- }
-
- public void readFromParcel(Parcel source) {
- mName = source.readString();
- mNumber = source.readInt();
- }
-
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (!(o instanceof SimpleParcelable)) {
- return false;
- }
- SimpleParcelable p = (SimpleParcelable)o;
- if ((mName == null && p.mName != null) ||
- (mName != null && !mName.equals(p.mName))) {
- return false;
- }
- return mNumber == p.mNumber;
- }
-
- public String toString() {
- return "SimpleParcelable(" + mName + ", " + mNumber + ")";
- }
-
- public static final Parcelable.Creator<SimpleParcelable> CREATOR =
- new Parcelable.Creator<SimpleParcelable>() {
- public SimpleParcelable createFromParcel(Parcel source) {
- String name = source.readString();
- int number = source.readInt();
- return new SimpleParcelable(name, number);
- }
-
- public SimpleParcelable[] newArray(int size) {
- return new SimpleParcelable[size];
- }
- };
-}
diff --git a/tests/java_app/src/android/aidl/tests/TestFailException.java b/tests/java_app/src/android/aidl/tests/TestFailException.java
deleted file mode 100644
index de000fa..0000000
--- a/tests/java_app/src/android/aidl/tests/TestFailException.java
+++ /dev/null
@@ -1,24 +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.
- */
-
-package android.aidl.tests;
-
-public class TestFailException extends Exception {
- public TestFailException(String message) {
- super(message);
- }
-}
-
diff --git a/tests/java_app/src/android/aidl/tests/TestLogger.java b/tests/java_app/src/android/aidl/tests/TestLogger.java
deleted file mode 100644
index b2e400b..0000000
--- a/tests/java_app/src/android/aidl/tests/TestLogger.java
+++ /dev/null
@@ -1,53 +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.
- */
-
-package android.aidl.tests;
-
-import android.util.Log;
-import java.io.PrintWriter;
-import java.io.IOException;
-import android.content.Context;
-
-public class TestLogger {
- private static final String TAG = "TestServiceClient";
- private PrintWriter mLogFile;
-
- public TestLogger(Context context) {
- try {
- mLogFile = new PrintWriter(context.openFileOutput(
- "test-client.log", Context.MODE_PRIVATE));
- } catch (IOException ex) {
- throw new RuntimeException("Failed to open log file for writing.");
- }
- }
-
- public void log(String line) {
- Log.i(TAG, line);
- mLogFile.println(line);
- }
-
- public void logAndThrow(String line) throws TestFailException {
- Log.e(TAG, line);
- mLogFile.println(line);
- throw new TestFailException(line);
- }
-
- public void close() {
- if (mLogFile != null) {
- mLogFile.close();
- }
- }
-}
diff --git a/tests/java_app/src/android/aidl/tests/TestServiceClient.java b/tests/java_app/src/android/aidl/tests/TestServiceClient.java
deleted file mode 100644
index 3415280..0000000
--- a/tests/java_app/src/android/aidl/tests/TestServiceClient.java
+++ /dev/null
@@ -1,1107 +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.
- */
-
-package android.aidl.tests;
-
-import android.aidl.tests.ByteEnum;
-import android.aidl.tests.INamedCallback;
-import android.aidl.tests.ITestService;
-import android.aidl.tests.IntEnum;
-import android.aidl.tests.LongEnum;
-import android.aidl.tests.SimpleParcelable;
-import android.aidl.tests.StructuredParcelable;
-import android.aidl.tests.TestFailException;
-import android.aidl.tests.TestLogger;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.ParcelFileDescriptor;
-import android.os.PersistableBundle;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.ServiceSpecificException;
-import android.util.Log;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class TestServiceClient extends Activity {
- private static final String TAG = "TestServiceClient";
-
- private TestLogger mLog;
- private String mSuccessSentinel;
- private String mFailureSentinel;
-
- private void init() {
- Intent intent = getIntent();
- mLog = new TestLogger(this);
- mLog.log("Reading sentinels from intent...");
- mSuccessSentinel = intent.getStringExtra("sentinel.success");
- mFailureSentinel = intent.getStringExtra("sentinel.failure");
- if (mSuccessSentinel == null || mFailureSentinel == null) {
- String message = "Failed to read intent extra input.";
- Log.e(TAG, message);
- mLog.close();
- throw new RuntimeException(message);
- }
- }
-
- private ITestService getService() throws TestFailException {
- IBinder service = ServiceManager.getService(
- ITestService.class.getName());
- if (service == null) {
- mLog.logAndThrow("Failed to obtain binder...");
- }
- ITestService ret = ITestService.Stub.asInterface(service);
- if (ret == null) {
- mLog.logAndThrow("Failed to cast IBinder instance.");
- }
- return ret;
- }
-
- private void checkPrimitiveRepeat(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can repeat primitives back...");
- try {
- {
- boolean query = true;
- boolean response = service.RepeatBoolean(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- char query = 'A';
- char response = service.RepeatChar(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- byte query = -128;
- byte response = service.RepeatByte(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- int query = 1 << 30;
- int response = service.RepeatInt(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- int query[] = {ITestService.TEST_CONSTANT,
- ITestService.TEST_CONSTANT2,
- ITestService.TEST_CONSTANT3,
- ITestService.TEST_CONSTANT4,
- ITestService.TEST_CONSTANT5,
- ITestService.TEST_CONSTANT6,
- ITestService.TEST_CONSTANT7,
- ITestService.TEST_CONSTANT8};
- for (int i = 0; i < query.length; i++) {
- int response = service.RepeatInt(query[i]);
- if (query[i] != response) {
- mLog.logAndThrow("Repeat with " + query[i] +
- " responded " + response);
- }
- }
- }
- {
- long query = 1L << 60;
- long response = service.RepeatLong(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- float query = 1.0f/3.0f;
- float response = service.RepeatFloat(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- double query = 1.0/3.0;
- double response = service.RepeatDouble(query);
- if (query != response) {
- mLog.logAndThrow("Repeat with " + query +
- " responded " + response);
- }
- }
- {
- byte query = ByteEnum.FOO;
- byte response = service.RepeatByteEnum(query);
- if (query != response) {
- mLog.logAndThrow("Repeat ByteEnum with " + query + " responded " + response);
- }
- }
- {
- int query = IntEnum.FOO;
- int response = service.RepeatIntEnum(query);
- if (query != response) {
- mLog.logAndThrow("Repeat IntEnum with " + query + " responded " + response);
- }
- }
- {
- long query = LongEnum.FOO;
- long response = service.RepeatLongEnum(query);
- if (query != response) {
- mLog.logAndThrow("Repeat LongEnum with " + query + " responded " + response);
- }
- }
-
- List<String> queries = Arrays.asList(
- "not empty", "", "\0",
- ITestService.STRING_TEST_CONSTANT,
- ITestService.STRING_TEST_CONSTANT2);
- for (String query : queries) {
- String response = service.RepeatString(query);
- if (!query.equals(response)) {
- mLog.logAndThrow("Repeat request with '" + query + "'" +
- " of length " + query.length() +
- " responded with '" + response + "'" +
- " of length " + response.length());
- }
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to repeat a primitive back.");
- }
- mLog.log("...Basic primitive repeating works.");
- }
-
- private void checkArrayReversal(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can reverse and return arrays...");
- try {
- {
- boolean[] input = {true, false, false, false};
- boolean echoed[] = new boolean[input.length];
- boolean[] reversed = service.ReverseBoolean(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- byte[] input = {0, 1, 2};
- byte echoed[] = new byte[input.length];
- byte[] reversed = service.ReverseByte(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- char[] input = {'A', 'B', 'C', 'D', 'E'};
- char echoed[] = new char[input.length];
- char[] reversed = service.ReverseChar(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- int[] input = {-1, 0, 1, 2, 3, 4, 5, 6};
- int echoed[] = new int[input.length];
- int[] reversed = service.ReverseInt(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- long[] input = {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8};
- long echoed[] = new long[input.length];
- long[] reversed = service.ReverseLong(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- float[] input = {0.0f, 1.0f, -0.3f};
- float echoed[] = new float[input.length];
- float[] reversed = service.ReverseFloat(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- double[] input = {-1.0, -4.0, -2.0};
- double echoed[] = new double[input.length];
- double[] reversed = service.ReverseDouble(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] != reversed[j]) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- String[] input = {"For", "relaxing", "times"};
- String echoed[] = new String[input.length];
- String[] reversed = service.ReverseString(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (!input[i].equals(reversed[j])) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to reverse an array.");
- }
- mLog.log("...service can reverse and return arrays.");
- }
-
- private void checkBinderExchange(
- ITestService service) throws TestFailException {
- mLog.log("Checking exchange of binders...");
- try {
- INamedCallback got = service.GetOtherTestService("Smythe");
- mLog.log("Received test service");
- String name = got.GetName();
-
- if (!name.equals("Smythe")) {
- mLog.logAndThrow("Tried to get service with name 'Smythe'" +
- " and found service with name '" + name + "'");
- }
-
- if (!service.VerifyName(got, "Smythe")) {
- mLog.logAndThrow("Test service could not verify name of 'Smythe'");
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to exchange binders.");
- }
- mLog.log("...Exchange of binders works");
- }
-
- private void checkListReversal(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can reverse and return lists...");
- try {
- {
- List<String> input = Arrays.asList("Walk", "into", "Córdoba");
- List<String> echoed = new ArrayList<String>();
- List<String> reversed = service.ReverseStringList(input, echoed);
- if (!input.equals(echoed)) {
- mLog.logAndThrow("Failed to echo input List<String> back.");
- }
- Collections.reverse(input);
- if (!input.equals(reversed)) {
- mLog.logAndThrow("Reversed list is not correct.");
- }
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to reverse an List<String>.");
- }
- mLog.log("...service can reverse and return lists.");
- }
-
- private void checkSimpleParcelables(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can repeat and reverse SimpleParcelable objects...");
- try {
- {
- SimpleParcelable input = new SimpleParcelable("foo", 42);
- SimpleParcelable out_param = new SimpleParcelable();
- SimpleParcelable returned =
- service.RepeatSimpleParcelable(input, out_param);
- if (!input.equals(out_param)) {
- mLog.log(input.toString() + " != " + out_param.toString());
- mLog.logAndThrow("out param SimpleParcelable was not equivalent");
- }
- if (!input.equals(returned)) {
- mLog.log(input.toString() + " != " + returned.toString());
- mLog.logAndThrow("returned SimpleParcelable was not equivalent");
- }
- }
- {
- 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);
- if (!Arrays.equals(input, repeated)) {
- mLog.logAndThrow(
- "Repeated list of SimpleParcelable objects did not match.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow(
- "Reversed list of SimpleParcelable objects had wrong length.");
- }
- for (int i = 0, k = input.length - 1;
- i < input.length;
- ++i, --k) {
- if (!input[i].equals(reversed[k])) {
- mLog.log(input[i].toString() + " != " +
- reversed[k].toString());
- mLog.logAndThrow("reversed SimpleParcelable was not equivalent");
- }
- }
- }
- } catch (Exception ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to handle SimpleParcelable objects.");
- }
- mLog.log("...service can manipulate SimpleParcelable objects.");
- }
-
- private void checkPersistableBundles(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can repeat and reverse PersistableBundle objects...");
- try {
- {
- PersistableBundle emptyBundle = new PersistableBundle();
- PersistableBundle returned = service.RepeatPersistableBundle(emptyBundle);
- if (emptyBundle.size() != 0 || returned.size() != 0) {
- mLog.log(emptyBundle.toString() + " != " + returned.toString());
- mLog.logAndThrow("returned empty PersistableBundle object was not equivalent");
- }
- mLog.log("...service can repeat and reverse empty PersistableBundle objects...");
- }
- {
- final String testBoolKey = new String("testBool");
- final String testIntKey = new String("testInt");
- final String testNestedIntKey = new String("testNestedInt");
- final String testLongKey = new String("testLong");
- final String testDoubleKey = new String("testDouble");
- final String testStringKey = new String("testString");
- final String testBoolArrayKey = new String("testBoolArray");
- final String testIntArrayKey = new String("testIntArray");
- final String testLongArrayKey = new String("testLongArray");
- final String testDoubleArrayKey = new String("testDoubleArray");
- final String testStringArrayKey = new String("testStringArray");
- final String testPersistableBundleKey = new String("testPersistableBundle");
- PersistableBundle nonEmptyBundle = new PersistableBundle();
- nonEmptyBundle.putBoolean(testBoolKey, false);
- nonEmptyBundle.putInt(testIntKey, 33);
- nonEmptyBundle.putLong(testLongKey, 34359738368L);
- nonEmptyBundle.putDouble(testDoubleKey, 1.1);
- nonEmptyBundle.putString(testStringKey, new String("Woot!"));
- nonEmptyBundle.putBooleanArray(testBoolArrayKey, new boolean[] {true, false, true});
- nonEmptyBundle.putIntArray(testIntArrayKey, new int[] {33, 44, 55, 142});
- nonEmptyBundle.putLongArray(
- testLongArrayKey, new long[] {34L, 8371L, 34359738375L});
- nonEmptyBundle.putDoubleArray(testDoubleArrayKey, new double[] {2.2, 5.4});
- nonEmptyBundle.putStringArray(testStringArrayKey, new String[] {"hello", "world!"});
- PersistableBundle testNestedPersistableBundle = new PersistableBundle();
- testNestedPersistableBundle.putInt(testNestedIntKey, 345);
- nonEmptyBundle.putPersistableBundle(
- testPersistableBundleKey, testNestedPersistableBundle);
- PersistableBundle returned = service.RepeatPersistableBundle(nonEmptyBundle);
- if (returned.size() != nonEmptyBundle.size()
- || returned.getBoolean(testBoolKey) != nonEmptyBundle.getBoolean(testBoolKey)
- || returned.getInt(testIntKey) != nonEmptyBundle.getInt(testIntKey)
- || returned.getLong(testLongKey) != nonEmptyBundle.getLong(testLongKey)
- || returned.getDouble(testDoubleKey) != nonEmptyBundle.getDouble(testDoubleKey)
- || !returned.getString(testStringKey)
- .equals(nonEmptyBundle.getString(testStringKey))
- || !Arrays.equals(nonEmptyBundle.getBooleanArray(testBoolArrayKey),
- returned.getBooleanArray(testBoolArrayKey))
- || !Arrays.equals(nonEmptyBundle.getIntArray(testIntArrayKey),
- returned.getIntArray(testIntArrayKey))
- || !Arrays.equals(nonEmptyBundle.getLongArray(testLongArrayKey),
- returned.getLongArray(testLongArrayKey))
- || !Arrays.equals(nonEmptyBundle.getDoubleArray(testDoubleArrayKey),
- returned.getDoubleArray(testDoubleArrayKey))
- || !Arrays.equals(nonEmptyBundle.getStringArray(testStringArrayKey),
- returned.getStringArray(testStringArrayKey))) {
- PersistableBundle temp =
- returned.getPersistableBundle(testPersistableBundleKey);
- if (temp == null
- || temp.getInt(testNestedIntKey)
- != testNestedPersistableBundle.getInt(testNestedIntKey)) {
- mLog.log(nonEmptyBundle.toString() + " != " + returned.toString());
- mLog.logAndThrow("returned non-empty PersistableBundle " +
- "object was not equivalent");
- }
- }
- mLog.log("...service can repeat and reverse non-empty " +
- "PersistableBundle objects...");
- }
- {
- PersistableBundle[] input = new PersistableBundle[3];
- PersistableBundle first = new PersistableBundle();
- PersistableBundle second = new PersistableBundle();
- PersistableBundle third = new PersistableBundle();
- final String testIntKey = new String("testInt");
- final String testLongKey = new String("testLong");
- final String testDoubleKey = new String("testDouble");
- first.putInt(testIntKey, 1231);
- second.putLong(testLongKey, 222222L);
- third.putDouble(testDoubleKey, 10.8);
- input[0] = first;
- input[1] = second;
- input[2] = third;
- final int original_input_size = input.length;
- PersistableBundle[] repeated = new PersistableBundle[input.length];
- PersistableBundle[] reversed = service.ReversePersistableBundles(input, repeated);
- if (input.length != repeated.length || input.length != original_input_size) {
- mLog.logAndThrow("Repeated list of PersistableBundle objects had " +
- "wrong length.");
- }
- if (input[0].getInt(testIntKey) != repeated[0].getInt(testIntKey)
- || input[1].getLong(testLongKey) != repeated[1].getLong(testLongKey)
- || input[2].getDouble(testDoubleKey) != repeated[2].getDouble(testDoubleKey)) {
- mLog.logAndThrow("Repeated list of PersistableBundle objects did not match.");
- }
- if (input.length != reversed.length || input.length != original_input_size) {
- mLog.logAndThrow("Reversed list of PersistableBundle objects had " +
- "wrong length.");
- }
- if (input[0].getInt(testIntKey) != reversed[2].getInt(testIntKey)
- || input[1].getLong(testLongKey) != reversed[1].getLong(testLongKey)
- || input[2].getDouble(testDoubleKey) != reversed[0].getDouble(testDoubleKey)) {
- mLog.logAndThrow("reversed PersistableBundle objects were not equivalent");
- }
- mLog.log("...service can repeat and reverse arrays of " +
- "non-empty PersistableBundle objects...");
- }
- } catch (Exception ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to handle PersistableBundle objects.");
- }
- mLog.log("...service can manipulate PersistableBundle objects.");
- }
-
- private void checkFileDescriptorPassing(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can receive and return file descriptors...");
- try {
- FileOutputStream fileOutputStream =
- openFileOutput("test-dummy", Context.MODE_PRIVATE);
-
- FileDescriptor descriptor = fileOutputStream.getFD();
- FileDescriptor journeyed = service.RepeatFileDescriptor(descriptor);
- fileOutputStream.close();
-
- FileOutputStream journeyedStream = new FileOutputStream(journeyed);
-
- String testData = "FrazzleSnazzleFlimFlamFlibbityGumboChops";
- byte[] output = testData.getBytes();
- journeyedStream.write(output);
- journeyedStream.close();
-
- FileInputStream fileInputStream = openFileInput("test-dummy");
- byte[] input = new byte[output.length];
- if (fileInputStream.read(input) != input.length) {
- mLog.logAndThrow("Read short count from file");
- }
-
- if (!Arrays.equals(input, output)) {
- mLog.logAndThrow("Read incorrect data");
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to repeat a file descriptor.");
- } catch (IOException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Exception while operating on temporary file");
- }
- mLog.log("...service can receive and return file descriptors.");
- }
-
- private void checkParcelFileDescriptorPassing(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can receive and return parcel file descriptors...");
- try {
- ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(
- getFileStreamPath("test-dummy"), ParcelFileDescriptor.MODE_CREATE |
- ParcelFileDescriptor.MODE_WRITE_ONLY);
- ParcelFileDescriptor journeyed = service.RepeatParcelFileDescriptor(descriptor);
-
- FileOutputStream journeyedStream = new ParcelFileDescriptor.AutoCloseOutputStream(journeyed);
-
- String testData = "FrazzleSnazzleFlimFlamFlibbityGumboChops";
- byte[] output = testData.getBytes();
- journeyedStream.write(output);
- journeyedStream.close();
-
- FileInputStream fileInputStream = openFileInput("test-dummy");
- byte[] input = new byte[output.length];
- if (fileInputStream.read(input) != input.length) {
- mLog.logAndThrow("Read short count from file");
- }
-
- if (!Arrays.equals(input, output)) {
- mLog.logAndThrow("Read incorrect data");
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to repeat a file descriptor.");
- } catch (IOException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Exception while operating on temporary file");
- }
- mLog.log("...service can receive and return file descriptors.");
- }
-
- private void checkServiceSpecificExceptions(
- ITestService service) throws TestFailException {
- mLog.log("Checking application exceptions...");
- for (int i = -1; i < 2; ++i) {
- try {
- service.ThrowServiceException(i);
- } catch (RemoteException ex) {
- mLog.logAndThrow("Service threw RemoteException: " +
- ex.toString());
- } catch (ServiceSpecificException ex) {
- if (ex.errorCode != i) {
- mLog.logAndThrow("Service threw wrong error code: " + i);
- }
- }
- }
- mLog.log("...application exceptions work");
- }
-
- private void checkUtf8Strings(ITestService service)
- throws TestFailException {
- mLog.log("Checking that service can work with UTF8 strings...");
- // Note that Java's underlying encoding is UTF16.
- final List<String> utf8_queries = Arrays.asList(
- "typical string",
- "",
- "\0\0\0",
- // Java doesn't handle unicode code points above U+FFFF well.
- new String(Character.toChars(0x1F701)) + "\u03A9");
- final List<String> utf8_queries_and_nulls = Arrays.asList(
- "typical string",
- null,
- "",
- "\0\0\0",
- null,
- // Java doesn't handle unicode code points above U+FFFF well.
- new String(Character.toChars(0x1F701)) + "\u03A9");
- try {
- for (String query : utf8_queries) {
- String response = service.RepeatUtf8CppString(query);
- if (!query.equals(response)) {
- mLog.logAndThrow("Repeat request with '" + query + "'" +
- " of length " + query.length() +
- " responded with '" + response + "'" +
- " of length " + response.length());
- }
- }
- {
- String[] input = (String[])utf8_queries.toArray();
- String echoed[] = new String[input.length];
- String[] reversed = service.ReverseUtf8CppString(input, echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo utf8 input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed utf8 array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (!input[i].equals(reversed[j])) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- {
- String[] input = (String[])utf8_queries_and_nulls.toArray();
- String echoed[] = new String[input.length];
- String[] reversed = service.ReverseNullableUtf8CppString(input,
- echoed);
- if (!Arrays.equals(input, echoed)) {
- mLog.logAndThrow("Failed to echo utf8 input array back.");
- }
- if (input.length != reversed.length) {
- mLog.logAndThrow("Reversed utf8 array is the wrong size.");
- }
- for (int i = 0; i < input.length; ++i) {
- int j = reversed.length - (1 + i);
- if (input[i] == null && reversed[j] == null) {
- continue;
- }
-
- if (!input[i].equals(reversed[j])) {
- mLog.logAndThrow(
- "input[" + i + "] = " + input[i] +
- " but reversed value = " + reversed[j]);
- }
- }
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to handle utf8 strings.");
- }
- mLog.log("...UTF8 annotations work.");
- }
-
- private void checkStructuredParcelable(ITestService service) throws TestFailException {
- final int kDesiredFValue = 17;
-
- StructuredParcelable parcelable = new StructuredParcelable();
- parcelable.shouldContainThreeFs = new int[0];
- parcelable.f = kDesiredFValue;
- parcelable.shouldBeJerry = "";
- parcelable.shouldContainTwoByteFoos = new byte[2];
- parcelable.shouldContainTwoIntFoos = new int[2];
- parcelable.shouldContainTwoLongFoos = new long[2];
-
- if (!parcelable.stringDefaultsToFoo.equals("foo")) {
- mLog.logAndThrow(
- "stringDefaultsToFoo should be 'foo' but is " + parcelable.stringDefaultsToFoo);
- }
- if (parcelable.byteDefaultsToFour != 4) {
- mLog.logAndThrow("byteDefaultsToFour should be 4 but is " + parcelable.byteDefaultsToFour);
- }
- if (parcelable.intDefaultsToFive != 5) {
- mLog.logAndThrow("intDefaultsToFive should be 5 but is " + parcelable.intDefaultsToFive);
- }
- if (parcelable.longDefaultsToNegativeSeven != -7) {
- mLog.logAndThrow("longDefaultsToNegativeSeven should be -7 but is "
- + parcelable.longDefaultsToNegativeSeven);
- }
- if (!parcelable.booleanDefaultsToTrue) {
- mLog.logAndThrow("booleanDefaultsToTrue should be true");
- }
- if (parcelable.charDefaultsToC != 'C') {
- mLog.logAndThrow("charDefaultsToC is " + parcelable.charDefaultsToC);
- }
- if (parcelable.floatDefaultsToPi != 3.14f) {
- mLog.logAndThrow("floatDefaultsToPi is " + parcelable.floatDefaultsToPi);
- }
- if (parcelable.doubleWithDefault != -3.14e17) {
- mLog.logAndThrow(
- "doubleWithDefault is " + parcelable.doubleWithDefault + " but should be -3.14e17");
- }
- if (!Arrays.equals(parcelable.arrayDefaultsTo123, new int[] {1, 2, 3})) {
- mLog.logAndThrow("arrayDefaultsTo123 should be [1,2,3] but is "
- + Arrays.toString(parcelable.arrayDefaultsTo123));
- }
- if (parcelable.arrayDefaultsToEmpty.length != 0) {
- mLog.logAndThrow("arrayDefaultsToEmpty should be empty but is "
- + Arrays.toString(parcelable.arrayDefaultsToEmpty));
- }
-
- try {
- service.FillOutStructuredParcelable(parcelable);
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Service failed to handle structured parcelable.");
- }
-
- if (!Arrays.equals(parcelable.shouldContainThreeFs,
- new int[] {kDesiredFValue, kDesiredFValue, kDesiredFValue})) {
- mLog.logAndThrow(
- "shouldContainThreeFs is " + Arrays.toString(parcelable.shouldContainThreeFs));
- }
-
- if (!parcelable.shouldBeJerry.equals("Jerry")) {
- mLog.logAndThrow("shouldBeJerry should be 'Jerry' but is " + parcelable.shouldBeJerry);
- }
-
- if (parcelable.shouldBeByteBar != ByteEnum.BAR) {
- mLog.logAndThrow(
- "shouldBeByteBar should be ByteEnum.BAR but is " + parcelable.shouldBeByteBar);
- }
- if (parcelable.shouldBeIntBar != IntEnum.BAR) {
- mLog.logAndThrow(
- "shouldBeIntBar should be IntEnum.BAR but is " + parcelable.shouldBeIntBar);
- }
- if (parcelable.shouldBeLongBar != LongEnum.BAR) {
- mLog.logAndThrow(
- "shouldBeLongBar should be LongEnum.BAR but is " + parcelable.shouldBeLongBar);
- }
-
- if (!Arrays.equals(
- parcelable.shouldContainTwoByteFoos, new byte[] {ByteEnum.FOO, ByteEnum.FOO})) {
- mLog.logAndThrow(
- "shouldContainTwoByteFoos is " + Arrays.toString(parcelable.shouldContainTwoByteFoos));
- }
- if (!Arrays.equals(
- parcelable.shouldContainTwoIntFoos, new int[] {IntEnum.FOO, IntEnum.FOO})) {
- mLog.logAndThrow(
- "shouldContainTwoIntFoos is " + Arrays.toString(parcelable.shouldContainTwoIntFoos));
- }
- if (!Arrays.equals(
- parcelable.shouldContainTwoLongFoos, new long[] {LongEnum.FOO, LongEnum.FOO})) {
- mLog.logAndThrow(
- "shouldContainTwoLongFoos is " + Arrays.toString(parcelable.shouldContainTwoLongFoos));
- }
-
- if (parcelable.int32_min != Integer.MIN_VALUE) {
- mLog.logAndThrow(
- "int32_min should be " + Integer.MIN_VALUE + "but is " + parcelable.int32_min);
- }
-
- if (parcelable.int32_max != Integer.MAX_VALUE) {
- mLog.logAndThrow(
- "int32_max should be " + Integer.MAX_VALUE + "but is " + parcelable.int32_max);
- }
-
- if (parcelable.int64_max != Long.MAX_VALUE) {
- mLog.logAndThrow(
- "int64_max should be " + Long.MAX_VALUE + "but is " + parcelable.int64_max);
- }
-
- if (parcelable.hexInt32_neg_1 != -1) {
- mLog.logAndThrow("hexInt32_neg_1 should be -1 but is " + parcelable.hexInt32_neg_1);
- }
-
- boolean success = true;
- for (int ndx = 0; ndx < parcelable.int32_1.length; ndx++) {
- if (parcelable.int32_1[ndx] != 1) {
- mLog.log("int32_1[" + ndx + "] should be 1 but is " + parcelable.int32_1[ndx]);
- success = false;
- }
- }
- if (!success) {
- mLog.logAndThrow("Failed to parse int32_1 array");
- }
-
- for (int ndx = 0; ndx < parcelable.int64_1.length; ndx++) {
- if (parcelable.int64_1[ndx] != 1) {
- mLog.log("int64_1[" + ndx + "] should be 1 but is " + parcelable.int64_1[ndx]);
- success = false;
- }
- }
- if (!success) {
- mLog.logAndThrow("Failed to parse int64_1 array");
- }
-
- if (parcelable.hexInt32_pos_1 != 1) {
- mLog.logAndThrow("hexInt32_pos_1 should be 1 but is " + parcelable.hexInt32_pos_1);
- }
-
- if (parcelable.hexInt64_pos_1 != 1) {
- mLog.logAndThrow("hexInt64_pos_1 should be 1 but is " + parcelable.hexInt64_pos_1);
- }
-
- if (parcelable.const_exprs_1 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_1 should be 1 but is " + parcelable.const_exprs_1);
- }
- if (parcelable.const_exprs_2 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_2 should be 1 but is " + parcelable.const_exprs_2);
- }
- if (parcelable.const_exprs_3 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_3 should be 1 but is " + parcelable.const_exprs_3);
- }
- if (parcelable.const_exprs_4 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_4 should be 1 but is " + parcelable.const_exprs_4);
- }
- if (parcelable.const_exprs_5 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_5 should be 1 but is " + parcelable.const_exprs_5);
- }
- if (parcelable.const_exprs_6 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_6 should be 1 but is " + parcelable.const_exprs_6);
- }
- if (parcelable.const_exprs_7 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_7 should be 1 but is " + parcelable.const_exprs_7);
- }
- if (parcelable.const_exprs_8 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_8 should be 1 but is " + parcelable.const_exprs_8);
- }
- if (parcelable.const_exprs_9 != 1) {
- mLog.logAndThrow("parcelable.const_exprs_9 should be 1 but is " + parcelable.const_exprs_9);
- }
- if (parcelable.const_exprs_10 != 1) {
- mLog.logAndThrow(
- "parcelable.const_exprs_10 should be 1 but is " + parcelable.const_exprs_10);
- }
-
- 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." +
- "}";
- if (!expected.equals(parcelable.toString())) {
- mLog.logAndThrow(
- "parcelable.toString() should be \"" + expected + "\" " +
- "but is \"" + parcelable.toString() + "\"");
- }
-
- mLog.log("Successfully verified the StructuredParcelable");
- }
-
- private void checkDefaultImpl(ITestService service) throws TestFailException {
- final int expectedArg = 100;
- final int expectedReturnValue = 200;
-
- boolean success = ITestService.Stub.setDefaultImpl(new ITestService.Default() {
- @Override
- public int UnimplementedMethod(int arg) throws RemoteException {
- if (arg != expectedArg) {
- throw new RemoteException("Argument for UnimplementedMethod is expected "
- + " to be " + expectedArg + ", but got " + arg);
- }
- return expectedReturnValue;
- }
- });
- if (!success) {
- mLog.logAndThrow("Failed to set default impl for ITestService");
- }
-
- try {
- int ret = service.UnimplementedMethod(expectedArg);
- if (ret != expectedReturnValue) {
- mLog.logAndThrow("Return value from UnimplementedMethod is expected "
- + " to be " + expectedReturnValue + ", but got " + ret);
- }
- } catch (RemoteException ex) {
- mLog.log(ex.toString());
- mLog.logAndThrow("Failed to call UnimplementedMethod");
- }
- }
-
- private void checkToString() throws TestFailException {
- ParcelableForToString p = new ParcelableForToString();
- p.intValue = 10;
- p.intArray = new int[]{20, 30};
- p.longValue = 100L;
- p.longArray = new long[]{200L, 300L};
- p.doubleValue = 3.14d;
- p.doubleArray = new double[]{1.1d, 1.2d};
- p.floatValue = 3.14f;
- p.floatArray = new float[]{1.1f, 1.2f};
- p.byteValue = 3;
- p.byteArray = new byte[]{5, 6};
- p.booleanValue = true;
- p.booleanArray = new boolean[]{true, false};
- p.stringValue = "this is a string";
- p.stringArray = new String[]{"hello", "world"};
- p.stringList = Arrays.asList(new String[]{"alice", "bob"});
- OtherParcelableForToString op = new OtherParcelableForToString();
- op.field = "other";
- p.parcelableValue = op;
- p.parcelableArray = new OtherParcelableForToString[]{op, op};
- p.enumValue = IntEnum.FOO;
- p.enumArray = new int[]{IntEnum.FOO, IntEnum.BAR};
- p.nullArray = null;
- p.nullList = null;
-
- final String expected = "android.aidl.tests.ParcelableForToString{" +
- "intValue: 10, " +
- "intArray: [20, 30], " +
- "longValue: 100, " +
- "longArray: [200, 300], " +
- "doubleValue: 3.14, " +
- "doubleArray: [1.1, 1.2], " +
- "floatValue: 3.14, " +
- "floatArray: [1.1, 1.2], " +
- "byteValue: 3, " +
- "byteArray: [5, 6], " +
- "booleanValue: true, " +
- "booleanArray: [true, false], " +
- "stringValue: this is a string, " +
- "stringArray: [hello, world], " +
- "stringList: [alice, bob], " +
- "parcelableValue: android.aidl.tests.OtherParcelableForToString{field: other}, " +
- "parcelableArray: [" +
- "android.aidl.tests.OtherParcelableForToString{field: other}, " +
- "android.aidl.tests.OtherParcelableForToString{field: other}], " +
- "enumValue: 1000, " +
- "enumArray: [1000, 2000], " +
- "nullArray: null, " +
- "nullList: null" +
- "}";
- if (!expected.equals(p.toString())) {
- mLog.logAndThrow(
- "parcelable.toString() should be \"" + expected + "\" " +
- "but is \"" + p.toString() + "\"");
- }
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.i(TAG, "Starting!");
- try {
- init();
- ITestService service = getService();
- checkPrimitiveRepeat(service);
- checkArrayReversal(service);
- checkBinderExchange(service);
- checkListReversal(service);
- checkSimpleParcelables(service);
- checkPersistableBundles(service);
- checkFileDescriptorPassing(service);
- checkParcelFileDescriptorPassing(service);
- checkServiceSpecificExceptions(service);
- checkUtf8Strings(service);
- checkStructuredParcelable(service);
- new NullableTests(service, mLog).runTests();
- new MapTests(mLog).runTests();
- new GenericTests(mLog).runTests();
- checkDefaultImpl(service);
- checkToString();
-
- mLog.log(mSuccessSentinel);
- } catch (TestFailException e) {
- mLog.log(mFailureSentinel);
- throw new RuntimeException(e);
- } finally {
- if (mLog != null) {
- mLog.close();
- }
- }
- }
-}
diff --git a/tests/lazy_test/Android.bp b/tests/lazy_test/Android.bp
index 4e0bcf4..fea1263 100644
--- a/tests/lazy_test/Android.bp
+++ b/tests/lazy_test/Android.bp
@@ -1,3 +1,12 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "system_tools_aidl_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
cc_test {
name: "aidl_lazy_test",
srcs: ["main.cpp"],
@@ -39,6 +48,7 @@
aidl_interface {
name: "lazy_test_service_aidl",
unstable: true,
+ flags: ["-Werror"],
srcs: [
"ILazyTestService.aidl",
],
diff --git a/tests/lazy_test/ILazyTestService.aidl b/tests/lazy_test/ILazyTestService.aidl
index 9cafdd1..46939d9 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 b31bb09..e1fa5f1 100644
--- a/tests/lazy_test/main.cpp
+++ b/tests/lazy_test/main.cpp
@@ -37,7 +37,6 @@
using ::android::String16;
std::vector<String16> gServiceNames;
-bool gUsingTestService = true;
static constexpr size_t SHUTDOWN_WAIT_TIME = 10;
sp<IBinder> waitForService(const String16& name) {
@@ -159,7 +158,12 @@
class AidlLazyRegistrarTest : public ::testing::Test {
protected:
- String16 serviceName = String16("aidl_lazy_test_1");
+ const String16 serviceName = String16("aidl_lazy_test_1");
+ void SetUp() override {
+ if (std::find(gServiceNames.begin(), gServiceNames.end(), serviceName) == gServiceNames.end()) {
+ GTEST_SKIP() << "Persistence test requires special instance: " << serviceName;
+ }
+ }
};
sp<ILazyTestService> waitForLazyTestService(String16 name) {
@@ -169,10 +173,6 @@
}
TEST_F(AidlLazyRegistrarTest, ForcedPersistenceTest) {
- if (!gUsingTestService) {
- GTEST_SKIP();
- }
-
sp<ILazyTestService> service;
for (int i = 0; i < 2; i++) {
service = waitForLazyTestService(serviceName);
@@ -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);
@@ -205,7 +219,6 @@
for (int i = 1; i < argc; i++) {
gServiceNames.push_back(String16(argv[i]));
}
- gUsingTestService = false;
}
android::ProcessState::self()->startThreadPool();
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
new file mode 100644
index 0000000..0725161
--- /dev/null
+++ b/tests/rust/test_client.rs
@@ -0,0 +1,747 @@
+/*
+ * 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::{
+ BackendType::BackendType, 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() -> binder::Strong<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;
+
+ // Java needs initial values here (can't resize arrays)
+ let mut repeated = vec![Default::default(); array.len()];
+
+ 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 backend = service.getBackendType().expect("error getting backend type");
+ if backend == BackendType::JAVA {
+ // Java needs initial values here (can't resize arrays)
+ // Other backends can't accept 'None', but we can use it in Java for convenience, rather
+ // than creating file descriptors.
+ repeated = vec![None, None];
+ }
+
+ 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();
+
+ let backend = service.getBackendType().expect("error getting backend type");
+ if backend == BackendType::JAVA {
+ // TODO(b/178861468): not correctly thrown from Java
+ return;
+ }
+
+ 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_null_array {
+ ($service:expr, $func:ident, $expect_repeated:expr) => {{
+ let mut repeated = None;
+ let result = $service.$func(None, &mut repeated);
+ assert_eq!(repeated, $expect_repeated);
+ assert_eq!(result, Ok(None));
+ }};
+}
+
+macro_rules! test_reverse_nullable_array {
+ ($service:expr, $func:ident, $array:expr) => {{
+ let mut array = $array;
+ // Java needs initial values here (can't resize arrays)
+ let mut repeated = Some(vec![Default::default(); array.len()]);
+ 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()),
+ ];
+
+ // Java can't return a null list as a parameter
+ let backend = service.getBackendType().expect("error getting backend type");
+ let null_output = if backend == BackendType::JAVA { Some(vec![]) } else { None };
+ test_reverse_null_array!(service, ReverseUtf8CppStringList, null_output);
+
+ test_reverse_null_array!(service, ReverseNullableUtf8CppString, None);
+
+ 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: binder::Strong<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: binder::Strong<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("9e7be1859820c59d9d55dd133e71a3687b5d2e5b")
+ );
+}
+
+#[test]
+fn test_versioned_known_union_field_is_ok() {
+ let service: binder::Strong<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: binder::Strong<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());
+
+ let main_service = get_test_service();
+ let backend = main_service.getBackendType().expect("error getting backend type");
+
+ // b/173458620 - for investigation of fixing difference
+ if backend == BackendType::JAVA {
+ assert_eq!(ret.unwrap_err().exception_code(), binder::ExceptionCode::ILLEGAL_ARGUMENT);
+ } else {
+ assert_eq!(ret.unwrap_err().transaction_error(), binder::StatusCode::BAD_VALUE);
+ }
+}
+
+#[test]
+fn test_array_of_parcelable_with_new_field() {
+ let service: binder::Strong<dyn IFooInterface::IFooInterface> =
+ binder::get_interface(<BpFooInterface as IFooInterface::IFooInterface>::get_descriptor())
+ .expect("did not get binder service");
+
+ let foos = [Default::default(), Default::default(), Default::default()];
+ let ret = service.returnsLengthOfFooArray(&foos);
+ assert_eq!(ret, Ok(foos.len() as i32));
+}
+
+#[test]
+fn test_read_data_correctly_after_parcelable_with_new_field() {
+ let service: binder::Strong<dyn IFooInterface::IFooInterface> =
+ binder::get_interface(<BpFooInterface as IFooInterface::IFooInterface>::get_descriptor())
+ .expect("did not get binder service");
+
+ let in_foo = Default::default();
+ let mut inout_foo = Default::default();
+ let mut out_foo = Default::default();
+ let ret = service.ignoreParcelablesAndRepeatInt(&in_foo, &mut inout_foo, &mut out_foo, 43);
+ assert_eq!(ret, Ok(43));
+}
+
+fn test_renamed_interface<F>(f: F)
+where
+ F: FnOnce(binder::Strong<dyn IOldName::IOldName>, binder::Strong<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..9019775
--- /dev/null
+++ b/tests/rust/test_service.rs
@@ -0,0 +1,350 @@
+/*
+ * 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, BinderFeatures, Interface, ParcelFileDescriptor, SpIBinder,
+};
+use aidl_test_versioned_interface::aidl::android::aidl::versioned::tests::{
+ BazUnion::BazUnion, Foo::Foo, IFooInterface, IFooInterface::BnFooInterface,
+ IFooInterface::BpFooInterface,
+};
+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, binder::Strong<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())
+ }
+
+ fn Deprecated(&self) -> binder::Result<()> {
+ Ok(())
+ }
+
+ 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<binder::Strong<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());
+ INamedCallback::BnNamedCallback::new_binder(named_callback, BinderFeatures::default())
+ });
+ Ok(other_service.to_owned())
+ }
+
+ fn VerifyName(
+ &self,
+ service: &binder::Strong<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<binder::Strong<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<binder::Strong<dyn IOldName::IOldName>> {
+ Ok(IOldName::BnOldName::new_binder(
+ OldName,
+ BinderFeatures::default(),
+ ))
+ }
+
+ fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn INewName::INewName>> {
+ Ok(INewName::BnNewName::new_binder(
+ NewName,
+ BinderFeatures::default(),
+ ))
+ }
+
+ 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 returnsLengthOfFooArray(&self, foos: &[Foo]) -> binder::Result<i32> {
+ Ok(foos.len() as i32)
+ }
+ fn ignoreParcelablesAndRepeatInt(&self, _in_foo: &Foo, _inout_foo: &mut Foo, _out_foo: &mut Foo, value: i32) -> binder::Result<i32> {
+ Ok(value)
+ }
+}
+
+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(), BinderFeatures::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, BinderFeatures::default());
+ 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/Android.bp b/tests/stability_test/Android.bp
new file mode 100644
index 0000000..a885bcb
--- /dev/null
+++ b/tests/stability_test/Android.bp
@@ -0,0 +1,94 @@
+//
+// 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "system_tools_aidl_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
+aidl_interface {
+ name: "aidl_test_nonvintf_parcelable",
+ flags: ["-Werror"],
+ srcs: [
+ "android/aidl/tests/nonvintf/*.aidl",
+ ],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ cpp: {
+ enabled: false,
+ },
+ ndk: {
+ enabled: false,
+ },
+ rust: {
+ enabled: false,
+ },
+ },
+ versions: ["1"],
+}
+
+aidl_interface {
+ name: "aidl_test_unstable_parcelable",
+ unstable: true,
+ flags: ["-Werror"],
+ srcs: [
+ "android/aidl/tests/unstable/*.aidl",
+ ],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ cpp: {
+ enabled: false,
+ },
+ ndk: {
+ enabled: false,
+ },
+ rust: {
+ enabled: false,
+ },
+ },
+}
+
+aidl_interface {
+ name: "aidl_test_vintf_parcelable",
+ stability: "vintf",
+ flags: ["-Werror"],
+ srcs: [
+ "android/aidl/tests/vintf/*.aidl",
+ ],
+ backend: {
+ java: {
+ platform_apis: true,
+ },
+ cpp: {
+ enabled: false,
+ },
+ ndk: {
+ enabled: false,
+ },
+ rust: {
+ enabled: false,
+ },
+ },
+ versions: ["1"],
+}
diff --git a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/.hash b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/.hash
new file mode 100644
index 0000000..f1295eb
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/.hash
@@ -0,0 +1 @@
+873769e09e3ac6d71f380fd36df9e15526d250e5
diff --git a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
new file mode 100644
index 0000000..6f2054e
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.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.tests.nonvintf;
+parcelable NonVintfExtendableParcelable {
+ ParcelableHolder ext;
+}
diff --git a/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/android/aidl/tests/nonvintf/NonVintfParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
new file mode 100644
index 0000000..291c472
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/1/android/aidl/tests/nonvintf/NonVintfParcelable.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.tests.nonvintf;
+parcelable NonVintfParcelable {
+ int a;
+}
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
new file mode 100644
index 0000000..55317cd
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
@@ -0,0 +1,37 @@
+/*
+ * 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 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.tests.nonvintf;
+parcelable NonVintfExtendableParcelable {
+ ParcelableHolder ext;
+}
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
new file mode 100644
index 0000000..bf17dd9
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_nonvintf_parcelable/current/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
@@ -0,0 +1,37 @@
+/*
+ * 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 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.tests.nonvintf;
+parcelable NonVintfParcelable {
+ int a;
+}
diff --git a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/.hash b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/.hash
new file mode 100644
index 0000000..8b3d144
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/.hash
@@ -0,0 +1 @@
+10def8b50cda5b371cb022d66b5f7425da9eec4f
diff --git a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/android/aidl/tests/vintf/VintfExtendableParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
new file mode 100644
index 0000000..63ceb55
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/android/aidl/tests/vintf/VintfExtendableParcelable.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.tests.vintf;
+@VintfStability
+parcelable VintfExtendableParcelable {
+ ParcelableHolder ext;
+}
diff --git a/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/android/aidl/tests/vintf/VintfParcelable.aidl b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/android/aidl/tests/vintf/VintfParcelable.aidl
new file mode 100644
index 0000000..6d00aaf
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/1/android/aidl/tests/vintf/VintfParcelable.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.tests.vintf;
+@VintfStability
+parcelable VintfParcelable {
+ int a;
+}
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
new file mode 100644
index 0000000..14c6b77
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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 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.tests.vintf;
+@VintfStability
+parcelable VintfExtendableParcelable {
+ ParcelableHolder ext;
+}
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
new file mode 100644
index 0000000..92d6f2f
--- /dev/null
+++ b/tests/stability_test/aidl_api/aidl_test_vintf_parcelable/current/android/aidl/tests/vintf/VintfParcelable.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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 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.tests.vintf;
+@VintfStability
+parcelable VintfParcelable {
+ int a;
+}
diff --git a/tests/stability_test/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl b/tests/stability_test/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
new file mode 100644
index 0000000..4dc4292
--- /dev/null
+++ b/tests/stability_test/android/aidl/tests/nonvintf/NonVintfExtendableParcelable.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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.nonvintf;
+
+parcelable NonVintfExtendableParcelable {
+ ParcelableHolder ext;
+}
diff --git a/tests/stability_test/android/aidl/tests/nonvintf/NonVintfParcelable.aidl b/tests/stability_test/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
new file mode 100644
index 0000000..485cb43
--- /dev/null
+++ b/tests/stability_test/android/aidl/tests/nonvintf/NonVintfParcelable.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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.nonvintf;
+
+parcelable NonVintfParcelable {
+ int a;
+}
diff --git a/tests/stability_test/android/aidl/tests/unstable/UnstableExtendableParcelable.aidl b/tests/stability_test/android/aidl/tests/unstable/UnstableExtendableParcelable.aidl
new file mode 100644
index 0000000..a594e3c
--- /dev/null
+++ b/tests/stability_test/android/aidl/tests/unstable/UnstableExtendableParcelable.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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.unstable;
+
+parcelable UnstableExtendableParcelable {
+ ParcelableHolder ext;
+}
diff --git a/tests/stability_test/android/aidl/tests/unstable/UnstableParcelable.aidl b/tests/stability_test/android/aidl/tests/unstable/UnstableParcelable.aidl
new file mode 100644
index 0000000..0c02c2d
--- /dev/null
+++ b/tests/stability_test/android/aidl/tests/unstable/UnstableParcelable.aidl
@@ -0,0 +1,21 @@
+/*
+ * 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.unstable;
+
+parcelable UnstableParcelable {
+ int a;
+}
diff --git a/tests/stability_test/android/aidl/tests/vintf/VintfExtendableParcelable.aidl b/tests/stability_test/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
new file mode 100644
index 0000000..398168e
--- /dev/null
+++ b/tests/stability_test/android/aidl/tests/vintf/VintfExtendableParcelable.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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.vintf;
+
+@VintfStability
+parcelable VintfExtendableParcelable {
+ ParcelableHolder ext;
+}
diff --git a/tests/stability_test/android/aidl/tests/vintf/VintfParcelable.aidl b/tests/stability_test/android/aidl/tests/vintf/VintfParcelable.aidl
new file mode 100644
index 0000000..ca794ce
--- /dev/null
+++ b/tests/stability_test/android/aidl/tests/vintf/VintfParcelable.aidl
@@ -0,0 +1,22 @@
+/*
+ * 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.vintf;
+
+@VintfStability
+parcelable VintfParcelable {
+ int a;
+}
diff --git a/tests/test_data.h b/tests/test_data.h
deleted file mode 100644
index ad428b0..0000000
--- a/tests/test_data.h
+++ /dev/null
@@ -1,96 +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[];
-
-} // 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[];
-
-} // 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[];
-
-} // 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 c9e32bf..0000000
--- a/tests/test_data_example_interface.cpp
+++ /dev/null
@@ -1,2727 +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
- {
- private static final java.lang.String DESCRIPTOR = "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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 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
- {
- private static final java.lang.String DESCRIPTOR = "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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 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
- {
- private static final java.lang.String DESCRIPTOR = "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;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::isEnabled::server");
- _result = this.isEnabled();
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- reply.writeNoException();
- reply.writeInt(((_result)?(1):(0)));
- return true;
- }
- case TRANSACTION_getState:
- {
- data.enforceInterface(descriptor);
- int _result;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::getState::server");
- _result = this.getState();
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- reply.writeNoException();
- reply.writeInt(_result);
- return true;
- }
- case TRANSACTION_getAddress:
- {
- data.enforceInterface(descriptor);
- java.lang.String _result;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::getAddress::server");
- _result = this.getAddress();
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- reply.writeNoException();
- reply.writeString(_result);
- return true;
- }
- case TRANSACTION_getParcelables:
- {
- data.enforceInterface(descriptor);
- android.foo.ExampleParcelable[] _result;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::getParcelables::server");
- _result = this.getParcelables();
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- 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;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::setScanMode::server");
- _result = this.setScanMode(_arg0, _arg1);
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- 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());
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::registerBinder::server");
- this.registerBinder(_arg0);
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- reply.writeNoException();
- return true;
- }
- case TRANSACTION_getRecursiveBinder:
- {
- data.enforceInterface(descriptor);
- android.test.IExampleInterface _result;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::getRecursiveBinder::server");
- _result = this.getRecursiveBinder();
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- 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;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::takesAnInterface::server");
- _result = this.takesAnInterface(_arg0);
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- 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;
- try {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::takesAParcelable::server");
- _result = this.takesAParcelable(_arg0, _arg1);
- }
- finally {
- android.os.Trace.traceEnd(android.os.Trace.TRACE_TAG_AIDL);
- }
- 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 {
- android.os.Trace.traceBegin(android.os.Trace.TRACE_TAG_AIDL, "IExampleInterface::isEnabled::client");
- _data.writeInterfaceToken(DESCRIPTOR);
- boolean _status = mRemote.transact(Stub.TRANSACTION_isEnabled, _data, _reply, 0);
- if (!_status && 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, "IExampleInterface::getState::client");
- _data.writeInterfaceToken(DESCRIPTOR);
- boolean _status = mRemote.transact(Stub.TRANSACTION_getState, _data, _reply, 0);
- if (!_status && 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, "IExampleInterface::getAddress::client");
- _data.writeInterfaceToken(DESCRIPTOR);
- boolean _status = mRemote.transact(Stub.TRANSACTION_getAddress, _data, _reply, 0);
- if (!_status && 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, "IExampleInterface::getParcelables::client");
- _data.writeInterfaceToken(DESCRIPTOR);
- boolean _status = mRemote.transact(Stub.TRANSACTION_getParcelables, _data, _reply, 0);
- if (!_status && 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, "IExampleInterface::setScanMode::client");
- _data.writeInterfaceToken(DESCRIPTOR);
- _data.writeInt(mode);
- _data.writeInt(duration);
- boolean _status = mRemote.transact(Stub.TRANSACTION_setScanMode, _data, _reply, 0);
- if (!_status && 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, "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 && 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, "IExampleInterface::getRecursiveBinder::client");
- _data.writeInterfaceToken(DESCRIPTOR);
- boolean _status = mRemote.transact(Stub.TRANSACTION_getRecursiveBinder, _data, _reply, 0);
- if (!_status && 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, "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 && 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, "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 && 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 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
- {
- private static final java.lang.String DESCRIPTOR = "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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 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
- {
- private static final java.lang.String DESCRIPTOR = "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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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 && 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;
- }
- @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 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;
-}
-)";
-
-} // 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 e7088fe..0000000
--- a/tests/test_data_ping_responder.cpp
+++ /dev/null
@@ -1,984 +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 {
-
-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::unique_ptr<::android::String16>& input, ::std::unique_ptr<::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::unique_ptr<::std::string>& input, ::std::unique_ptr<::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::unique_ptr<::android::String16> in_input;
- ::std::unique_ptr<::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::unique_ptr<::std::string> in_input;
- ::std::unique_ptr<::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"(#ifndef AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
-#define AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <memory>
-#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::unique_ptr<::android::String16>& input, ::std::unique_ptr<::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::unique_ptr<::std::string>& input, ::std::unique_ptr<::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::unique_ptr<::android::String16>&, ::std::unique_ptr<::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::unique_ptr<::std::string>&, ::std::unique_ptr<::std::string>*) override {
- return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
- }
-}; // class IPingResponderDefault
-
-} // namespace os
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
-)";
-
-const char kExpectedBpHeaderOutput[] =
-R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
-#define AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
-
-#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::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) override;
- ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
- ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::std::string>* _aidl_return) override;
-}; // class BpPingResponder
-
-} // namespace os
-
-} // namespace android
-
-#endif // AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
-)";
-
-const char kExpectedBnHeaderOutput[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
-#define AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
-
-#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
-
-#endif // AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
-)";
-
-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::unique_ptr<::android::String16>& input, ::std::unique_ptr<::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::unique_ptr<::std::string>& input, ::std::unique_ptr<::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::unique_ptr<::android::String16> in_input;
- ::std::unique_ptr<::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::unique_ptr<::std::string> in_input;
- ::std::unique_ptr<::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"(#ifndef AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
-#define AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/Status.h>
-#include <cstdint>
-#include <memory>
-#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::unique_ptr<::android::String16>& input, ::std::unique_ptr<::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::unique_ptr<::std::string>& input, ::std::unique_ptr<::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::unique_ptr<::android::String16>&, ::std::unique_ptr<::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::unique_ptr<::std::string>&, ::std::unique_ptr<::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
-
-#endif // AIDL_GENERATED_ANDROID_OS_I_PING_RESPONDER_H_
-)";
-
-const char kExpectedBpHeaderOutputWithVersionAndHash[] =
-R"(#ifndef AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
-#define AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
-
-#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::unique_ptr<::android::String16>& input, ::std::unique_ptr<::android::String16>* _aidl_return) override;
- ::android::binder::Status Utf8Ping(const ::std::string& input, ::std::string* _aidl_return) override;
- ::android::binder::Status NullableUtf8Ping(const ::std::unique_ptr<::std::string>& input, ::std::unique_ptr<::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
-
-#endif // AIDL_GENERATED_ANDROID_OS_BP_PING_RESPONDER_H_
-)";
-
-const char kExpectedBnHeaderOutputWithVersionAndHash[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
-#define AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
-
-#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
-
-#endif // AIDL_GENERATED_ANDROID_OS_BN_PING_RESPONDER_H_
-)";
-
-} // 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 6ea8a6c..0000000
--- a/tests/test_data_string_constants.cpp
+++ /dev/null
@@ -1,582 +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
- {
- private static final java.lang.String DESCRIPTOR = "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 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"(#ifndef AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_
-#define AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_
-
-#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
-
-#endif // AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_
-)";
-
-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
- {
- private static final java.lang.String DESCRIPTOR = "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 String EXAMPLE_CONSTANT = "foo";
- public int getInterfaceVersion() throws android.os.RemoteException;
- public String getInterfaceHash() throws android.os.RemoteException;
-}
-)";
-
-const char kExpectedIHeaderOutputWithVersionAndHash[] =
- R"(#ifndef AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_
-#define AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_
-
-#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
-
-#endif // AIDL_GENERATED_ANDROID_OS_I_STRING_CONSTANTS_H_
-)";
-
-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
-)";
-
-} // namespace string_constants
-} // namespace test_data
-} // namespace aidl
-} // namespace android
diff --git a/tests/test_helpers.h b/tests/test_helpers.h
deleted file mode 100644
index b4f0084..0000000
--- a/tests/test_helpers.h
+++ /dev/null
@@ -1,78 +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 <algorithm>
-#include <vector>
-
-#include <android-base/logging.h>
-#include <binder/Status.h>
-#include <utils/StrongPointer.h>
-
-#include "android/aidl/tests/ITestService.h"
-
-namespace android {
-namespace aidl {
-namespace tests {
-namespace client {
-
-template <typename T, typename U, typename V>
-bool RepeatPrimitive(
- const android::sp<android::aidl::tests::ITestService>& service,
- android::binder::Status(android::aidl::tests::ITestService::*func)(T, V*),
- U input) {
- V reply;
- android::binder::Status status = (*service.*func)(input, &reply);
- if (!status.isOk() || input != reply) {
- LOG(ERROR) << "Failed to repeat primitive. status=" << status.toString8()
- << ".";
- return false;
- }
- return true;
-}
-
-template <typename T>
-bool ReverseArray(
- const android::sp<android::aidl::tests::ITestService>& service,
- android::binder::Status(android::aidl::tests::ITestService::*func)(
- const std::vector<T>&, std::vector<T>*, std::vector<T>*),
- std::vector<T> input) {
- std::vector<T> actual_reversed;
- std::vector<T> actual_repeated;
- android::binder::Status status = (*service.*func)(
- input, &actual_repeated, &actual_reversed);
- if (!status.isOk()) {
- LOG(ERROR) << "Failed to repeat array. status=" << status.toString8()
- << ".";
- return false;
- }
- if (input != actual_repeated) {
- LOG(ERROR) << "Repeated version of array did not match";
- LOG(ERROR) << "input.size()=" << input.size()
- << " repeated.size()=" << actual_repeated.size();
- return false;
- }
- std::reverse(input.begin(), input.end());
- if (input != actual_reversed) {
- LOG(ERROR) << "Reversed version of array did not match";
- return false;
- }
- return true;
-}
-
-} // namespace client
-} // namespace tests
-} // 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..2cd9e25
--- /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;
+}
diff --git a/tests/versioned/android/aidl/versioned/tests/Foo.aidl b/tests/versioned/android/aidl/versioned/tests/Foo.aidl
new file mode 100644
index 0000000..acf7620
--- /dev/null
+++ b/tests/versioned/android/aidl/versioned/tests/Foo.aidl
@@ -0,0 +1,7 @@
+package android.aidl.versioned.tests;
+
+parcelable Foo {
+ // V1 is empty
+ // V2
+ int intDefault42 = 42;
+}
diff --git a/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl b/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
new file mode 100644
index 0000000..bb383b8
--- /dev/null
+++ b/tests/versioned/android/aidl/versioned/tests/IFooInterface.aidl
@@ -0,0 +1,13 @@
+package android.aidl.versioned.tests;
+import android.aidl.versioned.tests.BazUnion;
+import android.aidl.versioned.tests.Foo;
+interface IFooInterface {
+ // V1
+ void originalApi();
+ @utf8InCpp String acceptUnionAndReturnString(in BazUnion u);
+ @SuppressWarnings(value={"inout-parameter"})
+ int ignoreParcelablesAndRepeatInt(in Foo inFoo, inout Foo inoutFoo, out Foo outFoo, int value);
+ int returnsLengthOfFooArray(in Foo[] foos);
+ // V2
+ void newApi();
+}
diff --git a/trace/android/trace.h b/trace/android/trace.h
new file mode 100644
index 0000000..cd6294c
--- /dev/null
+++ b/trace/android/trace.h
@@ -0,0 +1,26 @@
+/*
+ * 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 <cutils/trace.h>
+
+inline void ATrace_beginSection(const char* sectionName) {
+ atrace_begin(ATRACE_TAG_AIDL, sectionName);
+}
+
+inline void ATrace_endSection() {
+ atrace_end(ATRACE_TAG_AIDL);
+}