Snap for 8554636 from ace4000e4b264b7eaa3bf1cc430be849643f6df3 to sdk-release
Change-Id: I2652be5381ce033a54ec65edf5b4a215c7c9359a
diff --git a/Android.bp b/Android.bp
index 79d2590..08df261 100644
--- a/Android.bp
+++ b/Android.bp
@@ -178,8 +178,12 @@
"liblog",
],
- sanitize: {
- address: true,
+ target: {
+ host: {
+ sanitize: {
+ address: true,
+ },
+ },
},
required: ["aidl-golden-test-build-hook"],
@@ -438,6 +442,7 @@
"libbinder_ndk",
],
srcs: [
+ "tests/aidl_test_client_ndk_delegate.cpp",
"tests/aidl_test_client_ndk_loggable_interface.cpp",
"tests/aidl_test_client_ndk_nested.cpp",
"tests/aidl_test_client_ndk_nullables.cpp",
diff --git a/OWNERS b/OWNERS
index cc35b11..a1fcf5f 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,6 +2,5 @@
jiyong@google.com
jooyung@google.com
malchev@google.com
-sadmac@google.com
smoreland@google.com
vmarko@google.com
diff --git a/aidl_const_expressions.cpp b/aidl_const_expressions.cpp
index 0288a60..afab3a2 100644
--- a/aidl_const_expressions.cpp
+++ b/aidl_const_expressions.cpp
@@ -89,14 +89,14 @@
mOverflowed = true;
return 0;
}
- return mValue / o;
+ return static_cast<T>(mValue / o);
}
T operator%(T o) {
if (o == 0 || (isMin() && o == -1)) {
mOverflowed = true;
return 0;
}
- return mValue % o;
+ return static_cast<T>(mValue % o);
}
T operator|(T o) { return mValue | o; }
T operator^(T o) { return mValue ^ o; }
@@ -112,14 +112,14 @@
mOverflowed = true;
return 0;
}
- return mValue >> o;
+ return static_cast<T>(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;
+ return static_cast<T>(mValue << o);
}
T operator||(T o) { return mValue || o; }
T operator&&(T o) { return mValue && o; }
diff --git a/aidl_dumpapi.cpp b/aidl_dumpapi.cpp
index 30f65dc..1451d41 100644
--- a/aidl_dumpapi.cpp
+++ b/aidl_dumpapi.cpp
@@ -119,6 +119,7 @@
out << "enum " << t.GetName() << " {\n";
out.Indent();
for (const auto& e : t.GetEnumerators()) {
+ DumpComments(*e);
out << e->GetName() << " = ";
DumpConstantValue(t.GetBackingType(), *e->GetValue());
out << ",\n";
diff --git a/aidl_language.cpp b/aidl_language.cpp
index c835396..6e19d6e 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -143,7 +143,6 @@
"JavaOnlyStableParcelable",
CONTEXT_TYPE_UNSTRUCTURED_PARCELABLE,
{}},
- {AidlAnnotation::Type::HIDE, "Hide", CONTEXT_TYPE | CONTEXT_MEMBER, {}},
{AidlAnnotation::Type::BACKING,
"Backing",
CONTEXT_TYPE_ENUM,
@@ -155,7 +154,7 @@
/* repeatable= */ true},
{AidlAnnotation::Type::JAVA_DERIVE,
"JavaDerive",
- CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION,
+ CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION | CONTEXT_TYPE_ENUM,
{{"toString", kBooleanType}, {"equals", kBooleanType}}},
{AidlAnnotation::Type::JAVA_DEFAULT, "JavaDefault", CONTEXT_TYPE_INTERFACE, {}},
{AidlAnnotation::Type::JAVA_DELEGATOR, "JavaDelegator", CONTEXT_TYPE_INTERFACE, {}},
@@ -518,10 +517,6 @@
GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_STABLE_PARCELABLE);
}
-bool AidlAnnotatable::IsHide() const {
- return GetAnnotation(annotations_, AidlAnnotation::Type::HIDE);
-}
-
bool AidlAnnotatable::JavaDerive(const std::string& method) const {
auto annotation = GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_DERIVE);
if (annotation != nullptr) {
diff --git a/aidl_language.h b/aidl_language.h
index 1e52625..15ce4bb 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -225,7 +225,6 @@
public:
enum class Type {
BACKING = 1,
- HIDE,
JAVA_STABLE_PARCELABLE,
UNSUPPORTED_APP_USAGE,
VINTF_STABILITY,
@@ -355,7 +354,6 @@
bool IsJavaOnlyImmutable() const;
bool IsFixedSize() const;
bool IsStableApiParcelable(Options::Language lang) const;
- bool IsHide() const;
bool JavaDerive(const std::string& method) const;
bool IsJavaDefault() const;
bool IsJavaDelegator() const;
@@ -1001,10 +999,6 @@
return constants_;
}
const std::vector<std::unique_ptr<AidlMethod>>& GetMethods() const { return methods_; }
- void AddMethod(std::unique_ptr<AidlMethod> method) {
- members_.push_back(method.get());
- 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);
@@ -1013,6 +1007,17 @@
}
}
+ // Modifiers
+ void AddMethod(std::unique_ptr<AidlMethod> method) {
+ members_.push_back(method.get());
+ methods_.push_back(std::move(method));
+ }
+ void AddType(std::unique_ptr<AidlDefinedType> type) {
+ type->SetEnclosingScope(this);
+ members_.push_back(type.get());
+ types_.push_back(std::move(type));
+ }
+
protected:
// utility for subclasses with getter names
bool CheckValidForGetterNames() const;
diff --git a/aidl_language_l.ll b/aidl_language_l.ll
index 34e84f1..5b11008 100644
--- a/aidl_language_l.ll
+++ b/aidl_language_l.ll
@@ -22,6 +22,14 @@
#include "parser.h"
#include "aidl_language_y.h"
+#ifndef YYSTYPE
+#define YYSTYPE yy::parser::semantic_type
+#endif
+
+#ifndef YYLTYPE
+#define YYLTYPE yy::parser::location_type
+#endif
+
#define YY_USER_ACTION yylloc->columns(yyleng);
%}
diff --git a/aidl_to_cpp_common.cpp b/aidl_to_cpp_common.cpp
index b8e38ea..682b6c8 100644
--- a/aidl_to_cpp_common.cpp
+++ b/aidl_to_cpp_common.cpp
@@ -219,13 +219,26 @@
out << " " << enum_decl.GetName() << " : " << backing_type << " {\n";
out.Indent();
for (const auto& enumerator : enum_decl.GetEnumerators()) {
- out << enumerator->GetName() << " = "
- << enumerator->ValueString(enum_decl.GetBackingType(), decorator) << ",\n";
+ out << enumerator->GetName();
+ GenerateDeprecated(out, *enumerator);
+ out << " = " << enumerator->ValueString(enum_decl.GetBackingType(), decorator) << ",\n";
}
out.Dedent();
out << "};\n";
}
+static bool IsEnumDeprecated(const AidlEnumDeclaration& enum_decl) {
+ if (enum_decl.IsDeprecated()) {
+ return true;
+ }
+ for (const auto& e : enum_decl.GetEnumerators()) {
+ if (e->IsDeprecated()) {
+ return true;
+ }
+ }
+ return false;
+}
+
// enum_values template value is defined in its own namespace (android::internal or ndk::internal),
// so the enum_decl type should be fully qualified.
std::string GenerateEnumValues(const AidlEnumDeclaration& enum_decl,
@@ -237,9 +250,11 @@
std::ostringstream code;
code << "#pragma clang diagnostic push\n";
code << "#pragma clang diagnostic ignored \"-Wc++17-extensions\"\n";
+ if (IsEnumDeprecated(enum_decl)) {
+ code << "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n";
+ }
code << "template <>\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";
@@ -255,14 +270,12 @@
const std::string& backing_type) {
const auto q_name = GetQualifiedName(enum_decl);
std::ostringstream code;
- const std::string signature =
- "[[nodiscard]] static inline std::string toString(" + q_name + " val)";
- if (enum_decl.IsDeprecated()) {
- code << signature;
- GenerateDeprecated(code, enum_decl);
- code << ";\n";
+ bool is_enum_deprecated = IsEnumDeprecated(enum_decl);
+ if (is_enum_deprecated) {
+ code << "#pragma clang diagnostic push\n";
+ code << "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n";
}
- code << signature << " {\n";
+ code << "[[nodiscard]] static inline std::string toString(" + q_name + " val) {\n";
code << " switch(val) {\n";
std::set<std::string> unique_cases;
for (const auto& enumerator : enum_decl.GetEnumerators()) {
@@ -281,6 +294,9 @@
code << " return std::to_string(static_cast<" << backing_type << ">(val));\n";
code << " }\n";
code << "}\n";
+ if (is_enum_deprecated) {
+ code << "#pragma clang diagnostic pop\n";
+ }
return code.str();
}
@@ -409,9 +425,16 @@
out << "os << \"" + parcelable.GetName() + "{\";\n";
out << "switch (getTag()) {\n";
for (const auto& f : parcelable.GetFields()) {
+ if (f->IsDeprecated()) {
+ out << "#pragma clang diagnostic push\n";
+ out << "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n";
+ }
const string tag = f->GetName();
out << "case " << tag << ": os << \"" << tag << ": \" << "
<< "::android::internal::ToString(get<" + tag + ">()); break;\n";
+ if (f->IsDeprecated()) {
+ out << "#pragma clang diagnostic pop\n";
+ }
}
out << "}\n";
out << "os << \"}\";\n";
@@ -481,7 +504,7 @@
const auto& default_value = name_of(first_field->GetType(), typenames) + "(" +
first_field->ValueString(decorator) + ")";
- out << "Tag _tag __attribute__((aligned (1))) = " << default_name << ";\n";
+ out << "Tag _tag = " << default_name << ";\n";
out << "union _value_t {\n";
out.Indent();
out << "_value_t() {}\n";
@@ -512,23 +535,12 @@
}
void UnionWriter::PublicFields(CodeWriter& out) const {
- std::string tag_type = "int32_t";
- if (decl.IsFixedSize()) {
- // For @FixedSize union, we use a smaller type for a tag to minimize the size overhead.
- AIDL_FATAL_IF(decl.GetFields().size() > std::numeric_limits<uint8_t>::max(), decl)
- << "Too many fields for @FixedSize";
- tag_type = "uint8_t";
- }
- out << "enum Tag : " << tag_type << " {\n";
- bool is_first = true;
+ out << "// Expose tag symbols for legacy code\n";
for (const auto& f : decl.GetFields()) {
- out << " " << f->GetName();
+ out << "static const inline Tag";
GenerateDeprecated(out, *f);
- if (is_first) out << " = 0";
- out << ", // " << f->Signature() << ";\n";
- is_first = false;
+ out << " " << f->GetName() << " = Tag::" << f->GetName() << ";\n";
}
- out << "};\n";
const auto& name = decl.GetName();
@@ -646,6 +658,10 @@
read_var(tag, *tag_type);
out << fmt::format("switch (static_cast<Tag>({})) {{\n", tag);
for (const auto& variable : decl.GetFields()) {
+ if (variable->IsDeprecated()) {
+ out << "#pragma clang diagnostic push\n";
+ out << "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n";
+ }
out << fmt::format("case {}: {{\n", variable->GetName());
out.Indent();
const auto& type = variable->GetType();
@@ -665,6 +681,9 @@
out << "}\n";
out << fmt::format("return {}; }}\n", ctx.status_ok);
out.Dedent();
+ if (variable->IsDeprecated()) {
+ out << "#pragma clang diagnostic pop\n";
+ }
}
out << "}\n";
out << fmt::format("return {};\n", ctx.status_bad);
@@ -685,9 +704,16 @@
out << fmt::format("if ({} != {}) return {};\n", status, ctx.status_ok, status);
out << "switch (getTag()) {\n";
for (const auto& variable : decl.GetFields()) {
+ if (variable->IsDeprecated()) {
+ out << "#pragma clang diagnostic push\n";
+ out << "#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n";
+ }
out << fmt::format("case {}: return ", variable->GetName());
ctx.write_func(out, "get<" + variable->GetName() + ">()", variable->GetType());
out << ";\n";
+ if (variable->IsDeprecated()) {
+ out << "#pragma clang diagnostic pop\n";
+ }
}
out << "}\n";
out << "__assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, \"can't reach here\");\n";
diff --git a/aidl_to_java.cpp b/aidl_to_java.cpp
index 3cc2472..bc705df 100644
--- a/aidl_to_java.cpp
+++ b/aidl_to_java.cpp
@@ -135,14 +135,14 @@
}
namespace {
-string JavaSignatureOfInternal(
- const AidlTypeSpecifier& aidl, bool instantiable, bool omit_array,
- bool boxing = false /* boxing can be true only if it is a type parameter */) {
+string JavaSignatureOfInternal(const AidlTypeSpecifier& aidl, bool instantiable, bool omit_array,
+ bool boxing) {
string ret = JavaNameOf(aidl, instantiable, boxing && !aidl.IsArray());
if (aidl.IsGeneric()) {
vector<string> arg_names;
for (const auto& ta : aidl.GetTypeParameters()) {
- arg_names.emplace_back(JavaSignatureOfInternal(*ta, false, false, true /* boxing */));
+ arg_names.emplace_back(JavaSignatureOfInternal(*ta, /*instantiable=*/false,
+ /*omit_array=*/false, /*boxing=*/true));
}
ret += "<" + Join(arg_names, ",") + ">";
}
@@ -185,11 +185,20 @@
} // namespace
string JavaSignatureOf(const AidlTypeSpecifier& aidl) {
- return JavaSignatureOfInternal(aidl, false, false);
+ return JavaSignatureOfInternal(aidl, /*instantiable=*/false, /*omit_array=*/false,
+ /*boxing=*/false);
}
+// Used for "new" expression. Ignore arrays because "new" expression handles it.
string InstantiableJavaSignatureOf(const AidlTypeSpecifier& aidl) {
- return JavaSignatureOfInternal(aidl, true, true);
+ return JavaSignatureOfInternal(aidl, /*instantiable=*/true, /*omit_array=*/true,
+ /*boxing=*/false);
+}
+
+string JavaBoxingTypeOf(const AidlTypeSpecifier& aidl) {
+ AIDL_FATAL_IF(!AidlTypenames::IsPrimitiveTypename(aidl.GetName()), aidl);
+ return JavaSignatureOfInternal(aidl, /*instantiable=*/false, /*omit_array=*/false,
+ /*boxing=*/true);
}
string DefaultJavaValueOf(const AidlTypeSpecifier& aidl) {
@@ -209,14 +218,6 @@
}
}
-static string GetFlagFor(const CodeGeneratorContext& c) {
- if (c.is_return_value) {
- return "android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE";
- } else {
- return "0";
- }
-}
-
typedef void (*ParcelHelperGenerator)(CodeWriter&, const Options&);
static void GenerateTypedObjectHelper(CodeWriter& out, const Options&) {
@@ -408,9 +409,8 @@
c.parcel,
"v",
c.min_sdk_version,
- c.is_return_value,
+ c.write_to_parcel_flag,
c.is_classloader_created,
- c.filename,
};
WriteToParcelFor(value_context);
c.writer.Dedent();
@@ -441,15 +441,17 @@
{"ParcelFileDescriptor",
[](const CodeGeneratorContext& c) {
if (c.min_sdk_version >= 23u) {
- c.writer << c.parcel << ".writeTypedObject(" << c.var << ", " << GetFlagFor(c) << ");\n";
+ c.writer << c.parcel << ".writeTypedObject(" << c.var << ", " << c.write_to_parcel_flag
+ << ");\n";
} else {
c.writer << "_Parcel.writeTypedObject(" << c.parcel << ", " << c.var << ", "
- << GetFlagFor(c) << ");\n";
+ << c.write_to_parcel_flag << ");\n";
}
}},
{"ParcelFileDescriptor[]",
[](const CodeGeneratorContext& c) {
- c.writer << c.parcel << ".writeTypedArray(" << c.var << ", " << GetFlagFor(c) << ");\n";
+ c.writer << c.parcel << ".writeTypedArray(" << c.var << ", " << c.write_to_parcel_flag
+ << ");\n";
}},
{"CharSequence",
[](const CodeGeneratorContext& c) {
@@ -459,7 +461,7 @@
c.writer.Indent();
c.writer << c.parcel << ".writeInt(1);\n";
c.writer << "android.text.TextUtils.writeToParcel(" << c.var << ", " << c.parcel << ", "
- << GetFlagFor(c) << ");\n";
+ << c.write_to_parcel_flag << ");\n";
c.writer.Dedent();
c.writer << "}\n";
c.writer << "else {\n";
@@ -478,7 +480,7 @@
if (found != method_map.end()) {
found->second(c);
} else if (c.type.IsFixedSizeArray()) {
- std::vector<std::string> args = {c.var, GetFlagFor(c)};
+ std::vector<std::string> args = {c.var, c.write_to_parcel_flag};
for (auto dim : c.type.GetFixedSizeArrayDimensions()) {
args.push_back(std::to_string(dim));
}
@@ -494,13 +496,15 @@
}
} else if (t->AsParcelable() != nullptr) {
if (c.type.IsArray()) {
- c.writer << c.parcel << ".writeTypedArray(" << c.var << ", " << GetFlagFor(c) << ");\n";
+ c.writer << c.parcel << ".writeTypedArray(" << c.var << ", " << c.write_to_parcel_flag
+ << ");\n";
} else {
if (c.min_sdk_version >= 23u) {
- c.writer << c.parcel << ".writeTypedObject(" << c.var << ", " << GetFlagFor(c) << ");\n";
+ c.writer << c.parcel << ".writeTypedObject(" << c.var << ", " << c.write_to_parcel_flag
+ << ");\n";
} else {
c.writer << "_Parcel.writeTypedObject(" << c.parcel << ", " << c.var << ", "
- << GetFlagFor(c) << ");\n";
+ << c.write_to_parcel_flag << ");\n";
}
}
}
@@ -634,9 +638,8 @@
c.parcel,
"v",
c.min_sdk_version,
- c.is_return_value,
+ c.write_to_parcel_flag,
c.is_classloader_created,
- c.filename,
};
CreateFromParcelFor(value_context);
c.writer << c.var << ".put(k, v);\n";
@@ -822,9 +825,8 @@
c.parcel,
"v",
c.min_sdk_version,
- c.is_return_value,
+ c.write_to_parcel_flag,
c.is_classloader_created,
- c.filename,
};
CreateFromParcelFor(value_context);
c.writer << c.var << ".put(k, v);\n";
@@ -848,7 +850,9 @@
[](const CodeGeneratorContext& c) {
c.writer << "if ((0!=" << c.parcel << ".readInt())) {\n";
c.writer.Indent();
- c.writer << c.var << " = " << "android.os.ParcelFileDescriptor.CREATOR.createFromParcel(" << c.parcel << ");\n";
+ c.writer << c.var << " = "
+ << "android.os.ParcelFileDescriptor.CREATOR.createFromParcel(" << c.parcel
+ << ");\n";
c.writer.Dedent();
c.writer << "}\n";
}},
@@ -893,6 +897,17 @@
}
void ToStringFor(const CodeGeneratorContext& c) {
+ // Use derived toString() for enum type annotated with @JavaDerive(toString=true)
+ if (auto t = c.type.GetDefinedType();
+ t != nullptr && t->AsEnumDeclaration() && t->JavaDerive("toString")) {
+ if (c.type.IsArray()) {
+ c.writer << c.type.GetName() << ".$.arrayToString(" << c.var << ")";
+ } else {
+ c.writer << c.type.GetName() << ".$.toString(" << c.var << ")";
+ }
+ return;
+ }
+
if (c.type.IsArray()) {
if (c.type.IsDynamicArray() || c.type.GetFixedSizeArrayDimensions().size() == 1) {
c.writer << "java.util.Arrays.toString(" << c.var << ")";
diff --git a/aidl_to_java.h b/aidl_to_java.h
index 5a4632c..34c3239 100644
--- a/aidl_to_java.h
+++ b/aidl_to_java.h
@@ -47,6 +47,10 @@
// This includes generic type parameters with array modifiers.
string JavaSignatureOf(const AidlTypeSpecifier& aidl);
+// Returns the Java boxing type of the AIDL type spec.
+// aidl type should be a primitive type.
+string JavaBoxingTypeOf(const AidlTypeSpecifier& aidl);
+
// Returns the instantiable Jva type signature of the AIDL type spec
// This includes generic type parameters, but excludes array modifiers.
string InstantiableJavaSignatureOf(const AidlTypeSpecifier& aidl);
@@ -63,11 +67,11 @@
const string parcel;
const string var;
const uint32_t min_sdk_version;
- // Set to true when the marshalled data will be returned to the client
+ // Set PARCELABLE_WRITE_RETURN_VALUE when the marshalled data will be returned to the client.
// This is given as a hint to the Parcelable that is being marshalled
// so that the Parcelable can release its resource after the marshalling
// is done.
- const bool is_return_value;
+ const string write_to_parcel_flag;
// Most of the variables created by AIDL compiler are typed, i.e., the code
// knows exactly what type of object is in the parcel -- because the parcel
@@ -85,9 +89,6 @@
// We emit the code at most once per an AIDL method, otherwise we are wasting
// time doing the same thing multiple time.
bool* const is_classloader_created;
-
- // for error message printing
- const string filename;
};
// Writes code fragment that writes a variable to the parcel.
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 632cded..ee0de54 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -322,16 +322,6 @@
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()));
@@ -630,14 +620,6 @@
EXPECT_FALSE(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_FALSE(compile_aidl(java_options, io_delegate_));
- EXPECT_THAT(GetCapturedStderr(), HasSubstr("@JavaDerive is not available."));
- }
}
TEST_P(AidlTest, ParseDescriptorAnnotation) {
@@ -681,7 +663,8 @@
TEST_P(AidlTest, AnnotationsInMultiplePlaces) {
const string oneway_method =
- "package a; interface IFoo { @UnsupportedAppUsage oneway @Hide void f(int a); }";
+ "package a; interface IFoo { @UnsupportedAppUsage oneway @PropagateAllowBlocking void f(int "
+ "a); }";
const AidlDefinedType* defined = Parse("a/IFoo.aidl", oneway_method, typenames_, GetLanguage());
ASSERT_NE(nullptr, defined);
const AidlInterface* iface = defined->AsInterface();
@@ -694,7 +677,7 @@
// TODO(b/151102494): these annotations should be on the method
ASSERT_NE(nullptr, ret_type.UnsupportedAppUsage());
- ASSERT_TRUE(ret_type.IsHide());
+ ASSERT_TRUE(ret_type.IsPropagateAllowBlocking());
}
TEST_P(AidlTest, AnnotationValueAttribute) {
@@ -1155,6 +1138,19 @@
{Options::Language::NDK, {"out/aidl/Foo.h", "__attribute__((deprecated"}},
{Options::Language::RUST, {"out/Foo.rs", "#[deprecated"}},
});
+
+ CheckDeprecated("Foo.aidl",
+ "enum Foo {\n"
+ " /** @deprecated */\n"
+ " FOO,\n"
+ " BAR,\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"}},
+ });
}
TEST_P(AidlTest, RequireOuterClass) {
@@ -1396,9 +1392,12 @@
TEST_P(AidlTest, FailOnNoDefinedTypes) {
AidlError error;
const string expected_stderr = "ERROR: p/IFoo.aidl:1.11-11: syntax error, unexpected $end\n";
+ const string expected_stderr_newbison =
+ "ERROR: p/IFoo.aidl:1.11-11: syntax error, unexpected end of file\n";
CaptureStderr();
EXPECT_EQ(nullptr, Parse("p/IFoo.aidl", R"(package p;)", typenames_, GetLanguage(), &error));
- EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_THAT(GetCapturedStderr(),
+ testing::AnyOf(testing::Eq(expected_stderr), testing::Eq(expected_stderr_newbison)));
EXPECT_EQ(AidlError::PARSE_ERROR, error);
}
@@ -2609,9 +2608,12 @@
TEST_P(AidlTest, FailParseOnEmptyFile) {
const string contents = "";
const string expected_stderr = "ERROR: a/IFoo.aidl:1.1-1: syntax error, unexpected $end\n";
+ const string expected_stderr_newbison =
+ "ERROR: a/IFoo.aidl:1.1-1: syntax error, unexpected end of file\n";
CaptureStderr();
EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", contents, typenames_, GetLanguage()));
- EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_THAT(GetCapturedStderr(),
+ testing::AnyOf(testing::Eq(expected_stderr), testing::Eq(expected_stderr_newbison)));
}
TEST_F(AidlTest, MultipleInputFiles) {
@@ -5117,17 +5119,6 @@
}
}
-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_FALSE(compile_aidl(options, io_delegate_));
- EXPECT_THAT(GetCapturedStderr(), HasSubstr("@Hide is not available"));
-}
-
TEST_F(AidlTest, SuppressWarningsIsNotForArgs) {
io_delegate_.SetFileContents(
"IFoo.aidl",
diff --git a/build/Android.bp b/build/Android.bp
index 32c8386..24b4a93 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -104,10 +104,48 @@
"1",
"2",
"3",
+ "4",
],
}
aidl_interface {
+ name: "test-piece-ndk-sdk-29",
+ local_include_dir: "tests_1",
+ flags: ["-Werror"],
+ srcs: [
+ "tests_1/some_package/IFoo.aidl",
+ "tests_1/some_package/Thing.aidl",
+ "tests_1/some_package/sub_package/*.aidl", // testing glob w/o filegroup
+ ],
+ unstable: true,
+ backend: { ndk: { sdk_version: "29", }, },
+}
+aidl_interface {
+ name: "test-piece-ndk-sdk-30",
+ local_include_dir: "tests_1",
+ flags: ["-Werror"],
+ srcs: [
+ "tests_1/some_package/IFoo.aidl",
+ "tests_1/some_package/Thing.aidl",
+ "tests_1/some_package/sub_package/*.aidl", // testing glob w/o filegroup
+ ],
+ unstable: true,
+ backend: { ndk: { sdk_version: "30", }, },
+}
+aidl_interface {
+ name: "test-piece-ndk-sdk-31",
+ local_include_dir: "tests_1",
+ flags: ["-Werror"],
+ srcs: [
+ "tests_1/some_package/IFoo.aidl",
+ "tests_1/some_package/Thing.aidl",
+ "tests_1/some_package/sub_package/*.aidl", // testing glob w/o filegroup
+ ],
+ unstable: true,
+ backend: { ndk: { sdk_version: "31", }, },
+}
+
+aidl_interface {
name: "test-piece-2",
local_include_dir: "tests_1",
flags: ["-Werror"],
@@ -192,6 +230,7 @@
versions: [
"1",
"2",
+ "3",
],
}
diff --git a/build/aidl_api.go b/build/aidl_api.go
index 15a50d0..0f28e33 100644
--- a/build/aidl_api.go
+++ b/build/aidl_api.go
@@ -78,6 +78,9 @@
// for checking for active development on unfrozen version
hasDevelopment android.WritablePath
+
+ // for checking hash value of the unfrozen version
+ totHashFile android.WritablePath
}
func (m *aidlApi) apiDir() string {
@@ -122,7 +125,7 @@
apiFiles = append(apiFiles, outFile)
}
hashFile = android.PathForModuleOut(ctx, "dump", ".hash")
-
+ m.totHashFile = hashFile
var optionalFlags []string
if m.properties.Stability != nil {
optionalFlags = append(optionalFlags, "--stability", *m.properties.Stability)
@@ -242,7 +245,7 @@
rbc.Text("\"" + im + "-V'" + `$(if [ "$(cat `).
Input(importApis[im].hasDevelopment).
Text(`)" = "1" ]; then echo "` + importIfaces[im].nextVersion() +
- `"; else echo "` + importIfaces[im].latestVersion() + `"; fi)'"`)
+ `"; else echo "` + importIfaces[im].latestVersion() + `"; fi)'", `)
}
}
rbc.Text("]}' ").
@@ -253,10 +256,15 @@
if hasVersionSuffix(im) {
imports = append(imports, im)
} else {
- imports = append(imports, im+"-V"+importIfaces[im].latestVersion())
+ versionSuffix := importIfaces[im].latestVersion()
+ if !importIfaces[im].hasVersion() {
+ versionSuffix = importIfaces[im].nextVersion()
+ }
+ imports = append(imports, im+"-V"+versionSuffix)
}
}
- data := fmt.Sprintf(`{version: "%s", imports: %v}`, v, wrap(`"`, imports, `"`))
+ importsStr := strings.Join(wrap(`"`, imports, `"`), ", ")
+ data := fmt.Sprintf(`{version: "%s", imports: [%s]}`, v, importsStr)
// Also modify Android.bp file to add the new version to the 'versions_with_info' property.
wrapWithDiffCheckIf(m, rb, func(rbc *android.RuleBuilderCommand) {
@@ -303,8 +311,9 @@
m.migrateAndAppendVersion(ctx, rb, nil, false)
}
- timestampFile := android.PathForModuleOut(ctx, "updateapi_"+version+".timestamp")
- rb.Command().Text("touch").Output(timestampFile)
+ timestampFile := android.PathForModuleOut(ctx, "update_or_freeze_api_"+version+".timestamp")
+ // explicitly don't touch timestamp, so that the command can be run repeatedly
+ rb.Command().Text("true").ImplicitOutput(timestampFile)
rb.Build("dump_aidl_api_"+m.properties.BaseName+"_"+version, actionWord+" AIDL API dump version "+version+" for "+m.properties.BaseName+" (see "+targetDir+")")
return timestampFile
diff --git a/build/aidl_api/test-piece-1/4/.hash b/build/aidl_api/test-piece-1/4/.hash
new file mode 100644
index 0000000..8238ab4
--- /dev/null
+++ b/build/aidl_api/test-piece-1/4/.hash
@@ -0,0 +1 @@
+be5dd6bf9c9000ee053621f118b7d6a7cfd1e79e
diff --git a/build/aidl_api/test-piece-1/4/some_package/IFoo.aidl b/build/aidl_api/test-piece-1/4/some_package/IFoo.aidl
new file mode 100644
index 0000000..d8a5be9
--- /dev/null
+++ b/build/aidl_api/test-piece-1/4/some_package/IFoo.aidl
@@ -0,0 +1,39 @@
+/*
+ * 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.
+
+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/4/some_package/Thing.aidl b/build/aidl_api/test-piece-1/4/some_package/Thing.aidl
new file mode 100644
index 0000000..90c5720
--- /dev/null
+++ b/build/aidl_api/test-piece-1/4/some_package/Thing.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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.
+
+package some_package;
+parcelable Thing {
+ int a;
+ int b;
+}
diff --git a/build/aidl_api/test-piece-1/4/some_package/sub_package/IFoo.aidl b/build/aidl_api/test-piece-1/4/some_package/sub_package/IFoo.aidl
new file mode 100644
index 0000000..179f166
--- /dev/null
+++ b/build/aidl_api/test-piece-1/4/some_package/sub_package/IFoo.aidl
@@ -0,0 +1,39 @@
+/*
+ * 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.
+
+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/4/some_package/sub_package/SubThing.aidl b/build/aidl_api/test-piece-1/4/some_package/sub_package/SubThing.aidl
new file mode 100644
index 0000000..bff0008
--- /dev/null
+++ b/build/aidl_api/test-piece-1/4/some_package/sub_package/SubThing.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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.
+
+package some_package.sub_package;
+parcelable SubThing {
+ int a;
+ int b;
+}
diff --git a/build/aidl_api/test-root-package/3/.hash b/build/aidl_api/test-root-package/3/.hash
new file mode 100644
index 0000000..2dfbe74
--- /dev/null
+++ b/build/aidl_api/test-root-package/3/.hash
@@ -0,0 +1 @@
+fe1b4b56b7263d121c36b566a5d6ddf7496261cc
diff --git a/build/aidl_api/test-root-package/3/test_package/IBaz.aidl b/build/aidl_api/test-root-package/3/test_package/IBaz.aidl
new file mode 100644
index 0000000..51e0abe
--- /dev/null
+++ b/build/aidl_api/test-root-package/3/test_package/IBaz.aidl
@@ -0,0 +1,45 @@
+/*
+ * 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.
+
+package test_package;
+@SuppressWarnings(value={"mixed-oneway", "inout-parameter", "out-array"})
+interface IBaz {
+ oneway void CanYouDealWithThisBar(in some_package.IBar bar);
+ void MethodAddedInVersion2();
+ ParcelFileDescriptor readPFD();
+ void writePFD(in ParcelFileDescriptor fd);
+ void readWritePFD(inout ParcelFileDescriptor fd);
+ ParcelFileDescriptor[] readPFDArray();
+ void writePFDArray(in ParcelFileDescriptor[] fds);
+ void readWritePFDArray(inout ParcelFileDescriptor[] fds);
+}
diff --git a/build/aidl_interface.go b/build/aidl_interface.go
index 15b2588..36527e4 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -380,6 +380,11 @@
Ndk struct {
CommonNativeBackendProperties
+ // Set to the version of the sdk to compile against, for the NDK
+ // variant.
+ // Default: current
+ Sdk_version *string
+
// If set to false, the ndk backend is exclusive to platform and is not
// available to applications. Default is true (i.e. available to both
// applications and platform).
@@ -635,6 +640,12 @@
i.properties.VersionsInternal = make([]string, len(i.properties.Versions_with_info))
for idx, value := range i.properties.Versions_with_info {
i.properties.VersionsInternal[idx] = value.Version
+ for _, im := range value.Imports {
+ if !hasVersionSuffix(im) {
+ mctx.ModuleErrorf("imports in versions_with_info must specify its version, but %s. Add a version suffix(such as %s-V1).", im, im)
+ return
+ }
+ }
}
}
diff --git a/build/aidl_interface_backends.go b/build/aidl_interface_backends.go
index f522a15..62a167c 100644
--- a/build/aidl_interface_backends.go
+++ b/build/aidl_interface_backends.go
@@ -81,7 +81,7 @@
Lang: lang,
BaseName: i.ModuleBase.Name(),
GenLog: genLog,
- Version: i.versionForAidlGenRule(version),
+ Version: i.versionForInitVersionCompat(version),
GenTrace: genTrace,
Unstable: i.properties.Unstable,
NotFrozen: notFrozen,
@@ -122,7 +122,11 @@
targetProp.Product = nonAppProps
hostSupported = i.properties.Host_supported
if lang == langNdk && i.shouldGenerateAppNdkBackend() {
- sdkVersion = proptools.StringPtr("current")
+ sdkVersion = i.properties.Backend.Ndk.Sdk_version
+ if sdkVersion == nil {
+ sdkVersion = proptools.StringPtr("current")
+ }
+
// Don't worry! This maps to libc++.so for the platform variant.
stl = proptools.StringPtr("c++_shared")
}
@@ -225,7 +229,7 @@
Platform_apis: proptools.Bool(i.properties.Backend.Java.Platform_apis),
Lang: langJava,
BaseName: i.ModuleBase.Name(),
- Version: i.versionForAidlGenRule(version),
+ Version: version,
GenRpc: proptools.Bool(i.properties.Backend.Java.Gen_rpc),
GenTrace: proptools.Bool(i.properties.Gen_trace),
Unstable: i.properties.Unstable,
@@ -276,7 +280,7 @@
Min_sdk_version: i.minSdkVersion(langRust),
Lang: langRust,
BaseName: i.ModuleBase.Name(),
- Version: i.versionForAidlGenRule(version),
+ Version: i.versionForInitVersionCompat(version),
Unstable: i.properties.Unstable,
NotFrozen: notFrozen,
Flags: i.flagsForAidlGenRule(version),
@@ -339,7 +343,10 @@
}
}
-func (i *aidlInterface) versionForAidlGenRule(version string) string {
+// For certain backend, avoid a difference between the initial version of a versioned
+// interface and an unversioned interface. This ensures that prebuilts can't prevent
+// an interface from switching from unversioned to versioned.
+func (i *aidlInterface) versionForInitVersionCompat(version string) string {
if !i.hasVersion() {
return ""
}
diff --git a/build/aidl_interface_metadata_singleton.go b/build/aidl_interface_metadata_singleton.go
index 8b421a5..552114c 100644
--- a/build/aidl_interface_metadata_singleton.go
+++ b/build/aidl_interface_metadata_singleton.go
@@ -33,11 +33,12 @@
`echo "\"types\": [${types}]," && ` +
`echo "\"hashes\": [${hashes}]," && ` +
`echo "\"has_development\": ${has_development}," && ` +
+ `echo "\"development_hash\": \"${development_hash}\"," && ` +
`echo "\"versions\": [${versions}]" && ` +
`echo '}' ` +
`;} >> ${out}`,
Description: "AIDL metadata: ${out}",
- }, "name", "stability", "types", "hashes", "has_development", "versions")
+ }, "name", "stability", "types", "hashes", "has_development", "development_hash", "versions")
joinJsonObjectsToArrayRule = pctx.StaticRule("joinJsonObjectsToArrayRule", blueprint.RuleParams{
Rspfile: "$out.rsp",
@@ -56,23 +57,34 @@
)
func init() {
- android.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
+ android.InitRegistrationContext.RegisterSingletonModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
}
-func aidlInterfacesMetadataSingletonFactory() android.Module {
+func aidlInterfacesMetadataSingletonFactory() android.SingletonModule {
i := &aidlInterfacesMetadataSingleton{}
android.InitAndroidModule(i)
return i
}
type aidlInterfacesMetadataSingleton struct {
- android.ModuleBase
+ android.SingletonModuleBase
metadataPath android.WritablePath
}
var _ android.OutputFileProducer = (*aidlInterfacesMetadataSingleton)(nil)
+func (m *aidlInterfacesMetadataSingleton) GenerateSingletonBuildActions(android.SingletonContext) {
+ // Keep empty
+}
+
+func (m *aidlInterfacesMetadataSingleton) MakeVars(ctx android.MakeVarsContext) {
+ if m.metadataPath == nil {
+ return
+ }
+ ctx.DistForGoal("droidcore", m.metadataPath)
+}
+
func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if m.Name() != aidlMetadataSingletonName {
ctx.PropertyErrorf("name", "must be %s", aidlMetadataSingletonName)
@@ -80,11 +92,12 @@
}
type ModuleInfo struct {
- Stability string
- ComputedTypes []string
- HashFiles []string
- HasDevelopment android.WritablePath
- Versions []string
+ Stability string
+ ComputedTypes []string
+ HashFiles []string
+ HasDevelopment android.WritablePath
+ DevelopmentHash android.WritablePath
+ Versions []string
}
// name -> ModuleInfo
@@ -110,6 +123,7 @@
case *aidlApi:
info := moduleInfos[t.properties.BaseName]
info.HasDevelopment = t.hasDevelopment
+ info.DevelopmentHash = t.totHashFile
moduleInfos[t.properties.BaseName] = info
}
@@ -130,26 +144,34 @@
readHashes = "$$(sed 's/.*/\"&\",/' " + strings.Join(info.HashFiles, " ") +
"| tr '\\n' ' ' | sed 's/, $$//')"
}
-
+ inputs := []android.Path{}
implicits := android.PathsForSource(ctx, info.HashFiles)
hasDevelopmentValue := "true"
+ developmentHashValue := ""
+
if info.HasDevelopment != nil {
+ inputs = append(inputs, info.HasDevelopment)
hasDevelopmentValue = "$$(if [ \"$$(cat " + info.HasDevelopment.String() +
")\" = \"1\" ]; then echo true; else echo false; fi)"
+ if info.DevelopmentHash != nil {
+ inputs = append(inputs, info.DevelopmentHash)
+ developmentHashValue = "$$(if [ \"$$(cat " + info.HasDevelopment.String() +
+ ")\" = \"1\" ]; then echo $$(cat " + info.DevelopmentHash.String() + "); else echo \"\"; fi)"
+ }
}
-
ctx.Build(pctx, android.BuildParams{
Rule: aidlMetadataRule,
Implicits: implicits,
- Input: info.HasDevelopment,
+ Inputs: inputs,
Output: metadataPath,
Args: map[string]string{
- "name": name,
- "stability": info.Stability,
- "types": strings.Join(wrap(`\"`, info.ComputedTypes, `\"`), ", "),
- "hashes": readHashes,
- "has_development": hasDevelopmentValue,
- "versions": strings.Join(info.Versions, ", "),
+ "name": name,
+ "stability": info.Stability,
+ "types": strings.Join(wrap(`\"`, info.ComputedTypes, `\"`), ", "),
+ "hashes": readHashes,
+ "has_development": hasDevelopmentValue,
+ "development_hash": developmentHashValue,
+ "versions": strings.Join(info.Versions, ", "),
},
})
}
diff --git a/build/aidl_test.go b/build/aidl_test.go
index d7534d2..1bb5549 100644
--- a/build/aidl_test.go
+++ b/build/aidl_test.go
@@ -174,7 +174,7 @@
rust.PrepareForTestWithRustBuildComponents,
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("aidl_interface", aidlInterfaceFactory)
- ctx.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
+ ctx.RegisterSingletonModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory)
ctx.RegisterModuleType("rust_defaults", func() android.Module {
return rust.DefaultsFactory()
})
@@ -1720,6 +1720,37 @@
android.AssertStringListContains(t, "a/foo-v3 deps", fooV3Java.CompilerDeps(), "common-V3-java")
}
+func TestVersionsWithInfoImport(t *testing.T) {
+ testAidlError(t, "imports in versions_with_info must specify its version", ``, withFiles(map[string][]byte{
+ "common/Android.bp": []byte(`
+ aidl_interface {
+ name: "common",
+ srcs: ["ICommon.aidl"],
+ versions: ["1", "2"],
+ }
+ `),
+ "common/aidl_api/common/1/ICommon.aidl": nil,
+ "common/aidl_api/common/1/.hash": nil,
+ "common/aidl_api/common/2/ICommon.aidl": nil,
+ "common/aidl_api/common/2/.hash": nil,
+ "foo/Android.bp": []byte(`
+ aidl_interface {
+ name: "foo",
+ srcs: ["IFoo.aidl"],
+ imports: ["common"],
+ versions_with_info: [
+ {version: "1", imports: ["common"]},
+ {version: "2", imports: ["common-V2"]},
+ ]
+ }
+ `),
+ "foo/aidl_api/foo/1/IFoo.aidl": nil,
+ "foo/aidl_api/foo/1/.hash": nil,
+ "foo/aidl_api/foo/2/IFoo.aidl": nil,
+ "foo/aidl_api/foo/2/.hash": nil,
+ }))
+}
+
func TestFreezeApiDeps(t *testing.T) {
for _, transitive := range []bool{true, false} {
for _, testcase := range []struct {
@@ -1763,8 +1794,8 @@
ctx, _ := testAidl(t, ``, customizers...)
shouldHaveDep := transitive && testcase.bool
- fooFreezeApiRule := ctx.ModuleForTests("foo-api", "").Output("updateapi_3.timestamp")
- commonFreezeApiOutput := ctx.ModuleForTests("common-api", "").Output("updateapi_3.timestamp").Output.String()
+ fooFreezeApiRule := ctx.ModuleForTests("foo-api", "").Output("update_or_freeze_api_3.timestamp")
+ commonFreezeApiOutput := ctx.ModuleForTests("common-api", "").Output("update_or_freeze_api_3.timestamp").Output.String()
testMethod := android.AssertStringListDoesNotContain
if shouldHaveDep {
testMethod = android.AssertStringListContains
diff --git a/generate_java.cpp b/generate_java.cpp
index a8dd232..3420669 100644
--- a/generate_java.cpp
+++ b/generate_java.cpp
@@ -436,7 +436,7 @@
.parcel = parcel_variable->name,
.var = field->GetName(),
.min_sdk_version = options.GetMinSdkVersion(),
- .is_return_value = false,
+ .write_to_parcel_flag = "_aidl_flag",
};
WriteToParcelFor(context);
writer->Close();
@@ -603,6 +603,9 @@
}
void GenerateEnumClass(CodeWriter& out, const AidlEnumDeclaration& enum_decl) {
+ const AidlTypeSpecifier& backing_type = enum_decl.GetBackingType();
+ std::string raw_type = JavaSignatureOf(backing_type);
+ std::string boxing_type = JavaBoxingTypeOf(backing_type);
out << GenerateComments(enum_decl);
out << GenerateAnnotations(enum_decl);
out << "public ";
@@ -614,9 +617,43 @@
for (const auto& enumerator : enum_decl.GetEnumerators()) {
out << GenerateComments(*enumerator);
out << GenerateAnnotations(*enumerator);
- out << fmt::format("public static final {} {} = {};\n",
- JavaSignatureOf(enum_decl.GetBackingType()), enumerator->GetName(),
- enumerator->ValueString(enum_decl.GetBackingType(), ConstantValueDecorator));
+ out << fmt::format("public static final {} {} = {};\n", raw_type, enumerator->GetName(),
+ enumerator->ValueString(backing_type, ConstantValueDecorator));
+ }
+ if (enum_decl.JavaDerive("toString")) {
+ out << "interface $ {\n";
+ out.Indent();
+ out << "static String toString(" << raw_type << " _aidl_v) {\n";
+ out.Indent();
+ for (const auto& enumerator : enum_decl.GetEnumerators()) {
+ out << "if (_aidl_v == " << enumerator->GetName() << ") return \"" << enumerator->GetName()
+ << "\";\n";
+ }
+ out << "return " << boxing_type << ".toString(_aidl_v);\n";
+ out.Dedent();
+ out << "}\n";
+ out << fmt::format(R"(static String arrayToString(Object _aidl_v) {{
+ if (_aidl_v == null) return "null";
+ Class<?> _aidl_cls = _aidl_v.getClass();
+ if (!_aidl_cls.isArray()) throw new IllegalArgumentException("not an array: " + _aidl_v);
+ Class<?> comp = _aidl_cls.getComponentType();
+ java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(", ", "[", "]");
+ if (comp.isArray()) {{
+ for (int _aidl_i = 0; _aidl_i < java.lang.reflect.Array.getLength(_aidl_v); _aidl_i++) {{
+ _aidl_sj.add(arrayToString(java.lang.reflect.Array.get(_aidl_v, _aidl_i)));
+ }}
+ }} else {{
+ if (_aidl_cls != {raw_type}[].class) throw new IllegalArgumentException("wrong type: " + _aidl_cls);
+ for ({raw_type} e : ({raw_type}[]) _aidl_v) {{
+ _aidl_sj.add(toString(e));
+ }}
+ }}
+ return _aidl_sj.toString();
+}}
+)",
+ fmt::arg("raw_type", raw_type));
+ out.Dedent();
+ out << "}\n";
}
out.Dedent();
out << "}\n";
@@ -760,7 +797,7 @@
.parcel = parcel,
.var = name,
.min_sdk_version = options.GetMinSdkVersion(),
- .is_return_value = false,
+ .write_to_parcel_flag = "_aidl_flag",
};
WriteToParcelFor(context);
writer->Close();
@@ -904,9 +941,6 @@
std::vector<std::string> GenerateJavaAnnotations(const AidlAnnotatable& a) {
std::vector<std::string> result;
- if (a.IsHide()) {
- result.emplace_back("@android.annotation.Hide");
- }
const AidlAnnotation* unsupported_app_usage = a.UnsupportedAppUsage();
if (unsupported_app_usage != nullptr) {
@@ -945,6 +979,11 @@
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 AidlEnumerator& e) override {
+ if (e.IsDeprecated()) {
+ result.push_back("@Deprecated");
+ }
+ }
void Visit(const AidlMethod& m) override { ForMember(m); }
void Visit(const AidlConstantDeclaration& c) override { ForMember(c); }
void Visit(const AidlVariableDeclaration& v) override { ForMember(v); }
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index e94c17c..4c95180 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -392,7 +392,8 @@
.parcel = parcel,
.var = var,
.min_sdk_version = min_sdk_version,
- .is_return_value = is_return_value,
+ .write_to_parcel_flag =
+ is_return_value ? "android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE" : "0",
};
WriteToParcelFor(context);
writer->Close();
@@ -466,12 +467,13 @@
break;
}
}
- auto checkPermission = std::make_shared<MethodCall>(
- THIS_VALUE, "permissionCheckerWrapper",
- std::vector<std::shared_ptr<Expression>>{
- std::make_shared<LiteralExpression>("android.Manifest.permission." + permission),
- std::make_shared<MethodCall>(THIS_VALUE, "getCallingPid"),
- std::make_shared<LiteralExpression>(attributionSource)});
+ auto permissionName = android::aidl::perm::JavaFullName(permission);
+ auto checkPermission =
+ std::make_shared<MethodCall>(THIS_VALUE, "permissionCheckerWrapper",
+ std::vector<std::shared_ptr<Expression>>{
+ std::make_shared<LiteralExpression>(permissionName),
+ std::make_shared<MethodCall>(THIS_VALUE, "getCallingPid"),
+ std::make_shared<LiteralExpression>(attributionSource)});
return checkPermission;
}
@@ -603,7 +605,7 @@
}
// EOF check
- if (!method.GetArguments().empty() && options.GetMinSdkVersion() >= 32u) {
+ if (!method.GetArguments().empty() && options.GetMinSdkVersion() > 32u) {
statements->Add(std::make_shared<MethodCall>(transact_data, "enforceNoDataAvail"));
}
diff --git a/generate_ndk.cpp b/generate_ndk.cpp
index e3db352..4345a74 100644
--- a/generate_ndk.cpp
+++ b/generate_ndk.cpp
@@ -288,7 +288,7 @@
includes.insert("chrono");
includes.insert("sstream");
}
- // For nested interfacees client/server classes are defined in the same header.
+ // For nested interfaces client/server classes are defined in the same header.
// So we need includes for client/server class as well.
if (interface.GetParentType()) {
includes.insert("android/binder_ibinder.h");
@@ -985,6 +985,59 @@
LeaveNdkNamespace(out, defined_type);
}
+void GenerateDelegatorClassDecl(CodeWriter& out, const AidlTypenames& types,
+ const AidlInterface& defined_type, const Options& options) {
+ const std::string clazz = ClassName(defined_type, ClassNames::DELEGATOR_IMPL);
+ const std::string iface = ClassName(defined_type, ClassNames::INTERFACE);
+ const std::string bn_name = ClassName(defined_type, ClassNames::SERVER);
+ const std::string kDelegateImplVarName = "_impl";
+ const std::string kStatusType = "::ndk::ScopedAStatus";
+
+ out << "class";
+ cpp::GenerateDeprecated(out, defined_type);
+ out << " " << clazz << " : public " << bn_name << " {\n";
+ out << "public:\n";
+ out.Indent();
+ out << "explicit " << clazz << "(const std::shared_ptr<" << iface << "> &impl)"
+ << " : " << kDelegateImplVarName << "(impl) {\n";
+ if (options.Version() > 0) {
+ // TODO(b/222347502) If we need to support mismatched versions of delegator and
+ // impl, this check will be removed. The NDK backend can't override the
+ // getInterface* meta methods because they are marked "final". Removing
+ // "final" changes the ABI and breaks prebuilts.
+ out << " int32_t _impl_ver = 0;\n";
+ out << " if (!impl->" << kGetInterfaceVersion << "(&_impl_ver).isOk()) {;\n";
+ out << " __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, \"Delegator failed to get "
+ "version of the implementation.\");\n";
+ out << " }\n";
+ out << " if (_impl_ver != " << iface << "::" << kVersion << ") {\n";
+ out << " __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, \"Mismatched versions of "
+ "delegator and implementation is not allowed.\");\n";
+ out << " }\n";
+ }
+ out << "}\n\n";
+ for (const auto& method : defined_type.GetMethods()) {
+ if (method->IsUserDefined()) {
+ out << kStatusType << " " << method->GetName() << "("
+ << NdkArgList(types, *method, FormatArgForDecl) << ") override";
+ cpp::GenerateDeprecated(out, *method);
+ out << " {\n"
+ << " return " << kDelegateImplVarName << "->" << method->GetName() << "("
+ << NdkArgList(types, *method, FormatArgNameOnly) << ");\n";
+ out << "}\n";
+ }
+ }
+ out.Dedent();
+ out << "protected:\n";
+ out.Indent();
+ out.Dedent();
+ out << "private:\n";
+ out.Indent();
+ out << "std::shared_ptr<" << iface << "> " << kDelegateImplVarName << ";\n";
+ out.Dedent();
+ out << "};\n\n";
+}
+
void GenerateServerClassDecl(CodeWriter& out, const AidlTypenames& types,
const AidlInterface& defined_type, const Options& options) {
const std::string clazz = ClassName(defined_type, ClassNames::SERVER);
@@ -1033,9 +1086,18 @@
<< "\"\n";
out << "\n";
out << "#include <android/binder_ibinder.h>\n";
+ // Needed for *Delegator classes while delegator version is required to be
+ // the same as the implementation version
+ // TODO(b/222347502) If we ever need to support mismatched versions of delegator and
+ // impl, this include can be removed.
+ out << "#include <cassert>\n\n";
+ // TODO(b/31559095) bionic on host should define __assert2
+ out << "#ifndef __BIONIC__\n#ifndef __assert2\n#define __assert2(a,b,c,d) "
+ "((void)0)\n#endif\n#endif\n";
out << "\n";
EnterNdkNamespace(out, defined_type);
GenerateServerClassDecl(out, types, defined_type, options);
+ GenerateDelegatorClassDecl(out, types, defined_type, options);
LeaveNdkNamespace(out, defined_type);
}
diff --git a/generate_rust.cpp b/generate_rust.cpp
index 725cf0e..5316c45 100644
--- a/generate_rust.cpp
+++ b/generate_rust.cpp
@@ -1108,6 +1108,7 @@
code_writer->Indent();
for (const auto& enumerator : enum_decl->GetEnumerators()) {
auto value = enumerator->GetValue()->ValueString(aidl_backing_type, ConstantValueDecorator);
+ GenerateDeprecated(*code_writer, *enumerator);
*code_writer << enumerator->GetName() << " = " << value << ",\n";
}
code_writer->Dedent();
diff --git a/metadata/test.cpp b/metadata/test.cpp
index 5617415..7d7d331 100644
--- a/metadata/test.cpp
+++ b/metadata/test.cpp
@@ -39,9 +39,10 @@
"some_package.sub_package.IFoo", "some_package.sub_package.SubThing"));
EXPECT_THAT(info->hashes, ElementsAre("13e24b2fac6a979971819fba2ab0d6d7c4182122",
"dc2a9292847e43b4360bb183f7491f0e9895eaa9",
- "54f935920ab0934c242145cf00f9852ae3f5a63e"));
- EXPECT_THAT(info->versions, ElementsAre(1, 2, 3));
- EXPECT_EQ(info->has_development, true);
+ "54f935920ab0934c242145cf00f9852ae3f5a63e",
+ "be5dd6bf9c9000ee053621f118b7d6a7cfd1e79e"));
+ EXPECT_THAT(info->versions, ElementsAre(1, 2, 3, 4));
+ EXPECT_EQ(info->has_development, false);
}
TEST(AidlMetadata, HasTestInstancesNoDevelopment) {
diff --git a/parser.cpp b/parser.cpp
index 9988f56..edb110b 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -28,6 +28,29 @@
YY_BUFFER_STATE yy_scan_buffer(char*, size_t, void*);
void yy_delete_buffer(YY_BUFFER_STATE, void*);
+// For each union, generate nested "Tag" enum type so that "Tag" can be used as a valid type.
+// union Foo { int a; int b; } => union Foo { ... enum Tag { a, b }}
+struct UnionTagGenerater : AidlVisitor {
+ void Visit(const AidlUnionDecl& decl) override {
+ std::vector<std::unique_ptr<AidlEnumerator>> enumerators;
+ for (const auto& field : decl.GetFields()) {
+ enumerators.push_back(std::make_unique<AidlEnumerator>(AIDL_LOCATION_HERE, field->GetName(),
+ nullptr, field->GetComments()));
+ }
+ auto tag_enum = std::make_unique<AidlEnumDeclaration>(AIDL_LOCATION_HERE, "Tag", &enumerators,
+ decl.GetPackage(), Comments{});
+ // Tag for @FixedSize union is limited to "byte" type so that it can be passed via FMQ with
+ // with lower overhead.
+ std::shared_ptr<AidlConstantValue> backing_type{
+ AidlConstantValue::String(AIDL_LOCATION_HERE, decl.IsFixedSize() ? "\"byte\"" : "\"int\"")};
+ std::vector<std::unique_ptr<AidlAnnotation>> annotations;
+ annotations.push_back(
+ AidlAnnotation::Parse(AIDL_LOCATION_HERE, "Backing", {{"type", backing_type}}, Comments{}));
+ tag_enum->Annotate(std::move(annotations));
+ const_cast<AidlUnionDecl&>(decl).AddType(std::move(tag_enum));
+ }
+};
+
const AidlDocument* Parser::Parse(const std::string& filename,
const android::aidl::IoDelegate& io_delegate,
AidlTypenames& typenames, bool is_preprocessed) {
@@ -55,6 +78,10 @@
return nullptr;
}
+ // Preprocess parsed document before adding to typenames.
+ UnionTagGenerater v;
+ VisitTopDown(v, *parser.document_);
+
// transfer ownership to AidlTypenames and return the raw pointer
const AidlDocument* result = parser.document_.get();
if (!typenames.AddDocument(std::move(parser.document_))) {
diff --git a/permission.cpp b/permission.cpp
index 96cff20..9f730da 100644
--- a/permission.cpp
+++ b/permission.cpp
@@ -28,7 +28,7 @@
std::string AsJavaAnnotation(const Expression& expr) {
if (const auto& s = std::get_if<std::string>(&expr); s) {
- return JavaAnnotation(*s);
+ return JavaFullName(*s);
}
if (const auto& all = std::get_if<AllOf>(&expr); all) {
return all->JavaAnnotation();
@@ -39,8 +39,11 @@
return "";
}
-std::string JavaAnnotation(const std::string& permission) {
- return "android.Manifest.permission." + permission;
+std::string JavaFullName(const std::string& permission) {
+ if (permission.find('.') == std::string::npos) {
+ return "android.Manifest.permission." + permission;
+ }
+ return permission;
}
} // namespace perm
diff --git a/permission.h b/permission.h
index cd87d5c..590a00c 100644
--- a/permission.h
+++ b/permission.h
@@ -32,7 +32,7 @@
typedef std::variant<std::string, AnyOf, AllOf> Expression;
std::string AsJavaAnnotation(const Expression& expr);
-std::string JavaAnnotation(const std::string& permission);
+std::string JavaFullName(const std::string& permission);
struct AnyOf {
std::vector<std::string> operands;
@@ -40,7 +40,7 @@
std::string JavaAnnotation() const {
std::string ret("anyOf = {");
for (size_t i = 0; i < operands.size(); i++) {
- ret += android::aidl::perm::JavaAnnotation(operands[i]);
+ ret += android::aidl::perm::JavaFullName(operands[i]);
if (i != operands.size() - 1) {
ret += ", ";
}
@@ -55,7 +55,7 @@
std::string JavaAnnotation() const {
std::string ret("allOf = {");
for (size_t i = 0; i < operands.size(); i++) {
- ret += android::aidl::perm::JavaAnnotation(operands[i]);
+ ret += android::aidl::perm::JavaFullName(operands[i]);
if (i != operands.size() - 1) {
ret += ", ";
}
diff --git a/scripts/redundancy_check/Android.bp b/scripts/redundancy_check/Android.bp
new file mode 100644
index 0000000..fb6fad4
--- /dev/null
+++ b/scripts/redundancy_check/Android.bp
@@ -0,0 +1,22 @@
+
+package {
+ default_applicable_licenses: ["system_tools_aidl_license"],
+}
+
+// Example usage:
+//
+// m aidl_redundancy_check
+// aidl_redundancy_check \
+// --installed-files-json $OUT/installed-files.json \
+// --aidl-metadata-json $ANDROID_BUILD_TOP/out/soong/.intermediates/system/tools/aidl/build/aidl_metadata_json/aidl_metadata.json
+rust_binary_host {
+ name: "aidl_redundancy_check",
+ srcs: ["srcs/main.rs"],
+ rustlibs: [
+ "libanyhow",
+ "libregex",
+ "libserde",
+ "libserde_json",
+ "libstructopt",
+ ],
+}
diff --git a/scripts/redundancy_check/srcs/main.rs b/scripts/redundancy_check/srcs/main.rs
new file mode 100644
index 0000000..c45a6c0
--- /dev/null
+++ b/scripts/redundancy_check/srcs/main.rs
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2022, 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.
+ */
+
+//! Reports redundant AIDL libraries included in a partition.
+
+use anyhow::{Context, Result};
+use std::collections::BTreeMap;
+use std::fs::File;
+use std::io::BufReader;
+use std::path::{Path, PathBuf};
+use structopt::StructOpt;
+
+#[derive(StructOpt, Debug)]
+#[structopt()]
+struct Opt {
+ /// JSON file with list of files installed in a partition, e.g. "$OUT/installed-files.json".
+ #[structopt(long)]
+ installed_files_json: PathBuf,
+
+ /// JSON file with metadata for AIDL interfaces. Optional, but fewer checks are performed when
+ /// unset.
+ #[structopt(long)]
+ aidl_metadata_json: Option<PathBuf>,
+}
+
+/// "aidl_metadata.json" entry.
+#[derive(Debug, serde::Deserialize)]
+struct AidlInterfaceMetadata {
+ /// Name of module defining package.
+ name: String,
+}
+
+/// "installed-files.json" entry.
+#[derive(Debug, serde::Deserialize)]
+struct InstalledFile {
+ /// Full file path.
+ #[serde(rename = "Name")]
+ name: String,
+ /// File size.
+ #[serde(rename = "Size")]
+ size: u64,
+}
+
+#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
+enum LibDir {
+ Lib,
+ Lib64,
+}
+
+/// An instance of an AIDL interface lib.
+#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
+struct AidlInstance {
+ installed_path: String,
+ size: u64,
+ name: String,
+ variant: String, // e.g. "ndk" or "cpp"
+ version: usize,
+ lib_dir: LibDir,
+}
+
+/// Deserializes a JSON file at `path` into an object of type `T`.
+fn read_json_file<T: serde::de::DeserializeOwned>(path: &Path) -> Result<T> {
+ let file = File::open(path).with_context(|| format!("failed to open: {}", path.display()))?;
+ serde_json::from_reader(BufReader::new(file))
+ .with_context(|| format!("failed to read: {}", path.display()))
+}
+
+/// Extracts AIDL lib info an `InstalledFile`, mainly by parsing the file path. Returns `None` if
+/// it doesn't look like an AIDL lib.
+fn extract_aidl_instance(installed_file: &InstalledFile) -> Option<AidlInstance> {
+ // example: android.hardware.security.keymint-V2-ndk.so
+ let lib_regex = regex::Regex::new(r#".*/(lib|lib64)/([^-]*)-V(\d+)-([^.]+)\."#)
+ .expect("failed to parse regex");
+ let captures = lib_regex.captures(&installed_file.name)?;
+ let (dir, name, version, variant) = (&captures[1], &captures[2], &captures[3], &captures[4]);
+ Some(AidlInstance {
+ installed_path: installed_file.name.clone(),
+ size: installed_file.size,
+ name: name.to_string(),
+ variant: variant.to_string(),
+ version: version.parse().unwrap(),
+ lib_dir: if dir == "lib64" { LibDir::Lib64 } else { LibDir::Lib },
+ })
+}
+
+fn main() -> Result<()> {
+ let args = Opt::from_args();
+
+ // Read the metadata file if available.
+ let metadata_list: Option<Vec<AidlInterfaceMetadata>> = match &args.aidl_metadata_json {
+ Some(aidl_metadata_json) => read_json_file(aidl_metadata_json)?,
+ None => None,
+ };
+ let is_valid_aidl_lib = |name: &str| match &metadata_list {
+ Some(x) => x.iter().any(|metadata| metadata.name == name),
+ None => true,
+ };
+
+ // Read the "installed-files.json" and create a list of AidlInstance.
+ let installed_files: Vec<InstalledFile> = read_json_file(&args.installed_files_json)?;
+ let instances: Vec<AidlInstance> = installed_files
+ .iter()
+ .filter_map(extract_aidl_instance)
+ .filter(|instance| {
+ if !is_valid_aidl_lib(&instance.name) {
+ eprintln!(
+ "WARNING: {} looks like an AIDL lib, but has no metadata",
+ &instance.installed_path
+ );
+ return false;
+ }
+ true
+ })
+ .collect();
+
+ // Group redundant AIDL lib instances together.
+ let groups: BTreeMap<(String, LibDir), Vec<&AidlInstance>> =
+ instances.iter().fold(BTreeMap::new(), |mut acc, x| {
+ let key = (x.name.clone(), x.lib_dir);
+ acc.entry(key).or_insert(Vec::new()).push(x);
+ acc
+ });
+ let mut total_wasted_bytes = 0;
+ for (group_key, mut instances) in groups {
+ if instances.len() > 1 {
+ instances.sort();
+ // Prefer the highest version, break ties favoring ndk.
+ let preferred_instance = instances
+ .iter()
+ .max_by_key(|x| (x.version, if x.variant == "ndk" { 1 } else { 0 }))
+ .unwrap();
+ let wasted_bytes: u64 =
+ instances.iter().filter(|x| *x != preferred_instance).map(|x| x.size).sum();
+ println!("Found redundant AIDL instances for {:?}", group_key);
+ for instance in instances.iter() {
+ println!(
+ "\t{}\t({:.2} KiB){}",
+ instance.installed_path,
+ instance.size as f64 / 1024.0,
+ if instance == preferred_instance { " <- preferred" } else { "" }
+ );
+ }
+ total_wasted_bytes += wasted_bytes;
+ println!("\t(potential savings: {:.2} KiB)", wasted_bytes as f64 / 1024.0);
+ println!();
+ }
+ }
+ println!("total potential savings: {:.2} KiB", total_wasted_bytes as f64 / 1024.0);
+
+ Ok(())
+}
diff --git a/tests/aidl_parser_fuzzer.dict b/tests/aidl_parser_fuzzer.dict
index eb2d8ce..20a270a 100644
--- a/tests/aidl_parser_fuzzer.dict
+++ b/tests/aidl_parser_fuzzer.dict
@@ -49,7 +49,6 @@
" @SystemApi "
" @JavaPassthrough "
" @JavaOnlyStableParcelable "
-" @Hide "
" @Backing "
" @FixedSize "
" @Descriptor "
diff --git a/tests/aidl_test_client_ndk_delegate.cpp b/tests/aidl_test_client_ndk_delegate.cpp
new file mode 100644
index 0000000..6bec01a
--- /dev/null
+++ b/tests/aidl_test_client_ndk_delegate.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2022 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/binder_auto_utils.h>
+#include <android/binder_manager.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <aidl/android/aidl/tests/BnTestService.h>
+#include <android-base/logging.h>
+
+using aidl::android::aidl::tests::BackendType;
+using aidl::android::aidl::tests::ITestService;
+using aidl::android::aidl::tests::ITestServiceDelegator;
+
+static constexpr int8_t kCustomByte = 8;
+
+struct CustomDelegator : public ITestServiceDelegator {
+ public:
+ CustomDelegator(std::shared_ptr<ITestService>& impl) : ITestServiceDelegator(impl) {}
+
+ // Change RepeatByte to always return the same byte.
+ ndk::ScopedAStatus RepeatByte(int8_t /* token */, int8_t* _aidl_return) override {
+ *_aidl_return = kCustomByte;
+ return ndk::ScopedAStatus::ok();
+ }
+};
+
+struct AidlDelegatorTest : testing::Test {
+ template <typename T>
+ std::shared_ptr<T> getService() {
+ ndk::SpAIBinder binder = ndk::SpAIBinder(AServiceManager_getService(T::descriptor));
+ return T::fromBinder(binder);
+ }
+ void SetUp() override { service = getService<ITestService>(); }
+ std::shared_ptr<ITestService> service;
+};
+
+TEST_F(AidlDelegatorTest, SimpleDelegator) {
+ auto delegator = ndk::SharedRefBase::make<ITestServiceDelegator>(service);
+ int8_t returned_value;
+ auto status = delegator->RepeatByte(12, &returned_value);
+ ASSERT_TRUE(status.isOk()) << status.getMessage();
+ EXPECT_EQ(12, returned_value);
+}
+
+TEST_F(AidlDelegatorTest, CustomDelegator) {
+ auto delegator = ndk::SharedRefBase::make<CustomDelegator>(service);
+ int8_t returned_value;
+ auto status = delegator->RepeatByte(12, &returned_value);
+ ASSERT_TRUE(status.isOk()) << status.getMessage();
+ EXPECT_EQ(kCustomByte, returned_value);
+}
+
+TEST_F(AidlDelegatorTest, SendDelegator) {
+ auto delegator = ndk::SharedRefBase::make<ITestServiceDelegator>(service);
+ auto fromAsBinder = ITestServiceDelegator::fromBinder(delegator->asBinder());
+ // Make sure the delegator works after asBinder -> fromBinder conversions
+ int8_t returned_value = 0;
+ auto status = fromAsBinder->RepeatByte(12, &returned_value);
+ ASSERT_TRUE(status.isOk()) << status.getDescription();
+ EXPECT_EQ(12, returned_value);
+}
diff --git a/tests/aidl_test_client_ndk_parcelables.cpp b/tests/aidl_test_client_ndk_parcelables.cpp
index 72d309d..8b9cd19 100644
--- a/tests/aidl_test_client_ndk_parcelables.cpp
+++ b/tests/aidl_test_client_ndk_parcelables.cpp
@@ -25,6 +25,7 @@
#include <aidl/android/aidl/fixedsizearray/FixedSizeArrayExample.h>
#include <aidl/android/aidl/tests/ITestService.h>
#include <aidl/android/aidl/tests/RecursiveList.h>
+#include <aidl/android/aidl/tests/Union.h>
using aidl::android::aidl::fixedsizearray::FixedSizeArrayExample;
using BnRepeatFixedSizeArray =
@@ -39,6 +40,7 @@
using aidl::android::aidl::tests::BackendType;
using aidl::android::aidl::tests::ITestService;
using aidl::android::aidl::tests::RecursiveList;
+using aidl::android::aidl::tests::Union;
using android::OK;
using ndk::AParcel_readData;
using ndk::AParcel_writeData;
@@ -79,6 +81,21 @@
EXPECT_EQ(nullptr, cur);
}
+TEST_F(AidlTest, GetUnionTags) {
+ std::vector<Union> unions;
+ std::vector<Union::Tag> tags;
+ // test empty
+ auto status = getService<ITestService>()->GetUnionTags(unions, &tags);
+ ASSERT_TRUE(status.isOk());
+ EXPECT_EQ(tags, (std::vector<Union::Tag>{}));
+ // test non-empty
+ unions.push_back(Union::make<Union::n>());
+ unions.push_back(Union::make<Union::ns>());
+ status = getService<ITestService>()->GetUnionTags(unions, &tags);
+ ASSERT_TRUE(status.isOk());
+ EXPECT_EQ(tags, (std::vector<Union::Tag>{Union::n, Union::ns}));
+}
+
TEST_F(AidlTest, FixedSizeArray) {
auto parcel = AParcel_create();
diff --git a/tests/aidl_test_client_ndk_versioned_interface.cpp b/tests/aidl_test_client_ndk_versioned_interface.cpp
index 97da834..f1d0207 100644
--- a/tests/aidl_test_client_ndk_versioned_interface.cpp
+++ b/tests/aidl_test_client_ndk_versioned_interface.cpp
@@ -72,4 +72,4 @@
EXPECT_EQ(43, ret);
EXPECT_EQ(0, inoutFoo.intDefault42);
EXPECT_EQ(0, outFoo.intDefault42);
-}
\ No newline at end of file
+}
diff --git a/tests/aidl_test_client_parcelables.cpp b/tests/aidl_test_client_parcelables.cpp
index 8d4adee..119f513 100644
--- a/tests/aidl_test_client_parcelables.cpp
+++ b/tests/aidl_test_client_parcelables.cpp
@@ -575,6 +575,21 @@
EXPECT_EQ(nullptr, cur);
}
+TEST_F(AidlTest, GetUnionTags) {
+ std::vector<Union> unions;
+ std::vector<Union::Tag> tags;
+ // test empty
+ auto status = service->GetUnionTags(unions, &tags);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
+ EXPECT_EQ(tags, (std::vector<Union::Tag>{}));
+ // test non-empty
+ unions.push_back(Union::make<Union::n>());
+ unions.push_back(Union::make<Union::ns>());
+ status = service->GetUnionTags(unions, &tags);
+ ASSERT_TRUE(status.isOk()) << status.toString8();
+ EXPECT_EQ(tags, (std::vector<Union::Tag>{Union::n, Union::ns}));
+}
+
TEST_F(AidlTest, FixedSizeArray) {
android::Parcel parcel;
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index f000372..a13547f 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -742,6 +742,15 @@
return Status::ok();
}
+ Status GetUnionTags(const std::vector<Union>& input,
+ std::vector<Union::Tag>* _aidl_return) override {
+ std::vector<Union::Tag> tags;
+ std::transform(input.begin(), input.end(), std::back_inserter(tags),
+ std::mem_fn(&Union::getTag));
+ *_aidl_return = std::move(tags);
+ return Status::ok();
+ }
+
Status GetCppJavaTests(sp<IBinder>* ret) {
*ret = new CppJavaTests;
return Status::ok();
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index f8e168a..63c0c6c 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -25,6 +25,7 @@
import android.aidl.tests.LongEnum;
import android.aidl.tests.RecursiveList;
import android.aidl.tests.StructuredParcelable;
+import android.aidl.tests.Union;
import android.aidl.tests.extension.ExtendableParcelable;
/**
@@ -259,6 +260,8 @@
IOldName GetOldNameInterface();
INewName GetNewNameInterface();
+ Union.Tag[] GetUnionTags(in Union[] input);
+
// Retrieve the ICppJavaTests if the server supports it
@nullable IBinder GetCppJavaTests();
diff --git a/tests/android/aidl/tests/IntEnum.aidl b/tests/android/aidl/tests/IntEnum.aidl
index d9ae6b3..7ab63f3 100644
--- a/tests/android/aidl/tests/IntEnum.aidl
+++ b/tests/android/aidl/tests/IntEnum.aidl
@@ -16,9 +16,12 @@
package android.aidl.tests;
+@JavaDerive(toString=true)
@Backing(type="int")
enum IntEnum {
FOO = 1000,
BAR = 2000,
BAZ,
+ /** @deprecated do not use this */
+ QUX,
}
diff --git a/tests/android/aidl/tests/permission/IProtected.aidl b/tests/android/aidl/tests/permission/IProtected.aidl
index 6b46e9d..3407199 100644
--- a/tests/android/aidl/tests/permission/IProtected.aidl
+++ b/tests/android/aidl/tests/permission/IProtected.aidl
@@ -6,4 +6,7 @@
@EnforcePermission(allOf={"INTERNET", "VIBRATE"}) void MultiplePermissionsAll();
@EnforcePermission(anyOf={"INTERNET", "VIBRATE"}) void MultiplePermissionsAny();
+
+ @EnforcePermission("android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK")
+ void NonManifestPermission();
}
diff --git a/tests/android/aidl/tests/unions/EnumUnion.aidl b/tests/android/aidl/tests/unions/EnumUnion.aidl
index 5f9bb05..817ea1c 100644
--- a/tests/android/aidl/tests/unions/EnumUnion.aidl
+++ b/tests/android/aidl/tests/unions/EnumUnion.aidl
@@ -23,4 +23,6 @@
union EnumUnion {
IntEnum intEnum = IntEnum.FOO;
LongEnum longEnum;
+ /** @deprecated do not use this */
+ int deprecatedField;
}
diff --git a/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java b/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java
index f04dd40..a20ae24 100644
--- a/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java
+++ b/tests/golden_output/aidl-test-fixedsizearray-java-source/gen/android/aidl/fixedsizearray/FixedSizeArrayExample.java
@@ -84,61 +84,61 @@
{
int _aidl_start_pos = _aidl_parcel.dataPosition();
_aidl_parcel.writeInt(0);
- _aidl_parcel.writeFixedArray(int2x3, 0, 2, 3);
- _aidl_parcel.writeFixedArray(boolArray, 0, 2);
- _aidl_parcel.writeFixedArray(byteArray, 0, 2);
- _aidl_parcel.writeFixedArray(charArray, 0, 2);
- _aidl_parcel.writeFixedArray(intArray, 0, 2);
- _aidl_parcel.writeFixedArray(longArray, 0, 2);
- _aidl_parcel.writeFixedArray(floatArray, 0, 2);
- _aidl_parcel.writeFixedArray(doubleArray, 0, 2);
- _aidl_parcel.writeFixedArray(stringArray, 0, 2);
- _aidl_parcel.writeFixedArray(byteEnumArray, 0, 2);
- _aidl_parcel.writeFixedArray(intEnumArray, 0, 2);
- _aidl_parcel.writeFixedArray(longEnumArray, 0, 2);
- _aidl_parcel.writeFixedArray(parcelableArray, 0, 2);
- _aidl_parcel.writeFixedArray(boolMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(byteMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(charMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(intMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(longMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(floatMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(doubleMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(stringMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(byteEnumMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(intEnumMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(longEnumMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(parcelableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(boolNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(byteNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(charNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(intNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(longNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(floatNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(doubleNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(stringNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(byteEnumNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(intEnumNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(longEnumNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(binderNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(pfdNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(parcelableNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(interfaceNullableArray, 0, 2);
- _aidl_parcel.writeFixedArray(boolNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(byteNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(charNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(intNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(longNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(floatNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(doubleNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(stringNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(byteEnumNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(intEnumNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(longEnumNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(binderNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(pfdNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(parcelableNullableMatrix, 0, 2, 2);
- _aidl_parcel.writeFixedArray(interfaceNullableMatrix, 0, 2, 2);
+ _aidl_parcel.writeFixedArray(int2x3, _aidl_flag, 2, 3);
+ _aidl_parcel.writeFixedArray(boolArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(byteArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(charArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(intArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(longArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(floatArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(doubleArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(stringArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(byteEnumArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(intEnumArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(longEnumArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(parcelableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(boolMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(byteMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(charMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(intMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(longMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(floatMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(doubleMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(stringMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(byteEnumMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(intEnumMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(longEnumMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(parcelableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(boolNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(byteNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(charNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(intNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(longNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(floatNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(doubleNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(stringNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(byteEnumNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(intEnumNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(longEnumNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(binderNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(pfdNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(parcelableNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(interfaceNullableArray, _aidl_flag, 2);
+ _aidl_parcel.writeFixedArray(boolNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(byteNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(charNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(intNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(longNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(floatNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(doubleNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(stringNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(byteEnumNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(intEnumNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(longEnumNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(binderNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(pfdNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(parcelableNullableMatrix, _aidl_flag, 2, 2);
+ _aidl_parcel.writeFixedArray(interfaceNullableMatrix, _aidl_flag, 2, 2);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
_aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
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
index 40264c0..b7e11ae 100644
--- 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
@@ -2527,6 +2527,44 @@
return _aidl_status;
}
+::android::binder::Status BpTestService::GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _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 = remote()->transact(BnTestService::TRANSACTION_GetUnionTags, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
+ if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
+ return ITestService::getDefaultImpl()->GetUnionTags(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::GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) {
::android::Parcel _aidl_data;
_aidl_data.markSensitive();
@@ -4602,6 +4640,36 @@
}
}
break;
+ case BnTestService::TRANSACTION_GetUnionTags:
+ {
+ ::std::vector<::android::aidl::tests::Union> in_input;
+ ::std::vector<::android::aidl::tests::Union::Tag> _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;
+ }
+ if (auto st = _aidl_data.enforceNoDataAvail(); !st.isOk()) {
+ _aidl_ret_status = st.writeToParcel(_aidl_reply);
+ break;
+ }
+ ::android::binder::Status _aidl_status(GetUnionTags(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_GetCppJavaTests:
{
::android::sp<::android::IBinder> _aidl_return;
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
index f82081e..de66202 100644
--- 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
@@ -9,6 +9,6 @@
system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+ system/tools/aidl/tests/android/aidl/tests/Union.aidl \
system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
- system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
- system/tools/aidl/tests/android/aidl/tests/Union.aidl
+ system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.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
index b51ef52..0261f25 100644
--- 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
@@ -29,6 +29,19 @@
set<longEnum>(std::move(_aidl_value));
}
return ::android::OK; }
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ case deprecatedField: {
+ 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<deprecatedField>(_aidl_value);
+ } else {
+ // NOLINTNEXTLINE(performance-move-const-arg)
+ set<deprecatedField>(std::move(_aidl_value));
+ }
+ return ::android::OK; }
+ #pragma clang diagnostic pop
}
return ::android::BAD_VALUE;
}
@@ -38,6 +51,10 @@
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>()));
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ case deprecatedField: return _aidl_parcel->writeInt32(get<deprecatedField>());
+ #pragma clang diagnostic pop
}
__assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
}
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h
index 0265063..b5c0a6c 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h
@@ -2,12 +2,16 @@
#include <android/aidl/tests/ArrayOfInterfaces.h>
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/IBinder.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
+#include <cstdint>
#include <optional>
+#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
@@ -136,12 +140,17 @@
}; // class MyParcelable
class MyUnion : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- iface = 0, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface iface;
- nullable_iface, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface nullable_iface;
- iface_array, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] iface_array;
- nullable_iface_array, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] nullable_iface_array;
+ enum class Tag : int32_t {
+ iface = 0,
+ nullable_iface = 1,
+ iface_array = 2,
+ nullable_iface_array = 3,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag iface = Tag::iface;
+ static const inline Tag nullable_iface = Tag::nullable_iface;
+ static const inline Tag iface_array = Tag::iface_array;
+ static const inline Tag nullable_iface_array = Tag::nullable_iface_array;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
@@ -263,3 +272,37 @@
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(ArrayOfInterfaces::MyUnion::Tag val) {
+ switch(val) {
+ case ArrayOfInterfaces::MyUnion::Tag::iface:
+ return "iface";
+ case ArrayOfInterfaces::MyUnion::Tag::nullable_iface:
+ return "nullable_iface";
+ case ArrayOfInterfaces::MyUnion::Tag::iface_array:
+ return "iface_array";
+ case ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array:
+ return "nullable_iface_array";
+ 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::ArrayOfInterfaces::MyUnion::Tag, 4> enum_values<::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag> = {
+ ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface,
+ ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface,
+ ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface_array,
+ ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace android
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
index 2d2a864..3cb8ad0 100644
--- 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
@@ -71,8 +71,9 @@
static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 60;
static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 61;
static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 62;
- static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 63;
- static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 64;
+ static constexpr uint32_t TRANSACTION_GetUnionTags = ::android::IBinder::FIRST_CALL_TRANSACTION + 63;
+ static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 64;
+ static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 65;
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
@@ -270,6 +271,9 @@
::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override {
return _aidl_delegate->GetNewNameInterface(_aidl_return);
}
+ ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) override {
+ return _aidl_delegate->GetUnionTags(input, _aidl_return);
+ }
::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override {
return _aidl_delegate->GetCppJavaTests(_aidl_return);
}
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
index c1cbaa8..3829d9b 100644
--- 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
@@ -75,6 +75,7 @@
::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) 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 GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _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
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
index c89b38f..593eaea 100644
--- 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
@@ -19,7 +19,8 @@
namespace android {
namespace aidl {
namespace tests {
-[[nodiscard]] static inline std::string toString(DeprecatedEnum val) __attribute__((deprecated("test")));
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[nodiscard]] static inline std::string toString(DeprecatedEnum val) {
switch(val) {
case DeprecatedEnum::A:
@@ -32,6 +33,7 @@
return std::to_string(static_cast<int32_t>(val));
}
}
+#pragma clang diagnostic pop
} // namespace tests
} // namespace aidl
} // namespace android
@@ -39,8 +41,9 @@
namespace internal {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
template <>
-constexpr inline std::array<::android::aidl::tests::DeprecatedEnum, 3> __attribute__((deprecated("test"))) enum_values<::android::aidl::tests::DeprecatedEnum> = {
+constexpr inline std::array<::android::aidl::tests::DeprecatedEnum, 3> enum_values<::android::aidl::tests::DeprecatedEnum> = {
::android::aidl::tests::DeprecatedEnum::A,
::android::aidl::tests::DeprecatedEnum::B,
::android::aidl::tests::DeprecatedEnum::C,
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h
index f94a3b8..65f6711 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h
@@ -3,10 +3,13 @@
#include <android/aidl/tests/FixedSize.h>
#include <android/aidl/tests/LongEnum.h>
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
#include <cstdint>
+#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
@@ -24,16 +27,25 @@
public:
class FixedUnion : public ::android::Parcelable {
public:
- enum Tag : uint8_t {
- booleanValue = 0, // boolean booleanValue;
- byteValue, // byte byteValue;
- charValue, // char charValue;
- intValue, // int intValue;
- longValue, // long longValue;
- floatValue, // float floatValue;
- doubleValue, // double doubleValue;
- enumValue, // android.aidl.tests.LongEnum enumValue;
+ enum class Tag : int8_t {
+ booleanValue = 0,
+ byteValue = 1,
+ charValue = 2,
+ intValue = 3,
+ longValue = 4,
+ floatValue = 5,
+ doubleValue = 6,
+ enumValue = 7,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag booleanValue = Tag::booleanValue;
+ static const inline Tag byteValue = Tag::byteValue;
+ static const inline Tag charValue = Tag::charValue;
+ static const inline Tag intValue = Tag::intValue;
+ static const inline Tag longValue = Tag::longValue;
+ static const inline Tag floatValue = Tag::floatValue;
+ static const inline Tag doubleValue = Tag::doubleValue;
+ static const inline Tag enumValue = Tag::enumValue;
template <Tag _Tag>
using _at = typename std::tuple_element<static_cast<size_t>(_Tag), std::tuple<bool, int8_t, char16_t, int32_t, int64_t, float, double, ::android::aidl::tests::LongEnum>>::type;
@@ -119,7 +131,7 @@
return os.str();
}
private:
- Tag _tag __attribute__((aligned (1))) = booleanValue;
+ Tag _tag = booleanValue;
union _value_t {
_value_t() {}
~_value_t() {}
@@ -220,3 +232,49 @@
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(FixedSize::FixedUnion::Tag val) {
+ switch(val) {
+ case FixedSize::FixedUnion::Tag::booleanValue:
+ return "booleanValue";
+ case FixedSize::FixedUnion::Tag::byteValue:
+ return "byteValue";
+ case FixedSize::FixedUnion::Tag::charValue:
+ return "charValue";
+ case FixedSize::FixedUnion::Tag::intValue:
+ return "intValue";
+ case FixedSize::FixedUnion::Tag::longValue:
+ return "longValue";
+ case FixedSize::FixedUnion::Tag::floatValue:
+ return "floatValue";
+ case FixedSize::FixedUnion::Tag::doubleValue:
+ return "doubleValue";
+ case FixedSize::FixedUnion::Tag::enumValue:
+ return "enumValue";
+ 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::FixedSize::FixedUnion::Tag, 8> enum_values<::android::aidl::tests::FixedSize::FixedUnion::Tag> = {
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::booleanValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::byteValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::charValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::intValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::longValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::floatValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::doubleValue,
+ ::android::aidl::tests::FixedSize::FixedUnion::Tag::enumValue,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // 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
index dd0e7f1..9246a87 100644
--- 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
@@ -10,6 +10,7 @@
#include <android/aidl/tests/LongEnum.h>
#include <android/aidl/tests/RecursiveList.h>
#include <android/aidl/tests/StructuredParcelable.h>
+#include <android/aidl/tests/Union.h>
#include <android/aidl/tests/extension/ExtendableParcelable.h>
#include <android/binder_to_string.h>
#include <binder/IBinder.h>
@@ -272,6 +273,7 @@
virtual ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) = 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 GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _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
@@ -470,6 +472,9 @@
::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* /*_aidl_return*/) override {
return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
}
+ ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& /*input*/, ::std::vector<::android::aidl::tests::Union::Tag>* /*_aidl_return*/) override {
+ return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
+ }
::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* /*_aidl_return*/) override {
return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
}
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
index 00e8738..2e57678 100644
--- 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
@@ -12,6 +12,7 @@
FOO = 1000,
BAR = 2000,
BAZ = 2001,
+ QUX __attribute__((deprecated("do not use this"))) = 2002,
};
} // namespace tests
} // namespace aidl
@@ -19,6 +20,8 @@
namespace android {
namespace aidl {
namespace tests {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[nodiscard]] static inline std::string toString(IntEnum val) {
switch(val) {
case IntEnum::FOO:
@@ -27,10 +30,13 @@
return "BAR";
case IntEnum::BAZ:
return "BAZ";
+ case IntEnum::QUX:
+ return "QUX";
default:
return std::to_string(static_cast<int32_t>(val));
}
}
+#pragma clang diagnostic pop
} // namespace tests
} // namespace aidl
} // namespace android
@@ -38,11 +44,13 @@
namespace internal {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
template <>
-constexpr inline std::array<::android::aidl::tests::IntEnum, 3> enum_values<::android::aidl::tests::IntEnum> = {
+constexpr inline std::array<::android::aidl::tests::IntEnum, 4> enum_values<::android::aidl::tests::IntEnum> = {
::android::aidl::tests::IntEnum::FOO,
::android::aidl::tests::IntEnum::BAR,
::android::aidl::tests::IntEnum::BAZ,
+ ::android::aidl::tests::IntEnum::QUX,
};
#pragma clang diagnostic pop
} // namespace internal
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h
index e9dcb2b..455bf4b 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h
@@ -2,12 +2,16 @@
#include <android/aidl/tests/ListOfInterfaces.h>
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/IBinder.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
+#include <cstdint>
#include <optional>
+#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
@@ -136,12 +140,17 @@
}; // class MyParcelable
class MyUnion : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- iface = 0, // android.aidl.tests.ListOfInterfaces.IEmptyInterface iface;
- nullable_iface, // android.aidl.tests.ListOfInterfaces.IEmptyInterface nullable_iface;
- iface_list, // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> iface_list;
- nullable_iface_list, // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> nullable_iface_list;
+ enum class Tag : int32_t {
+ iface = 0,
+ nullable_iface = 1,
+ iface_list = 2,
+ nullable_iface_list = 3,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag iface = Tag::iface;
+ static const inline Tag nullable_iface = Tag::nullable_iface;
+ static const inline Tag iface_list = Tag::iface_list;
+ static const inline Tag nullable_iface_list = Tag::nullable_iface_list;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
@@ -263,3 +272,37 @@
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(ListOfInterfaces::MyUnion::Tag val) {
+ switch(val) {
+ case ListOfInterfaces::MyUnion::Tag::iface:
+ return "iface";
+ case ListOfInterfaces::MyUnion::Tag::nullable_iface:
+ return "nullable_iface";
+ case ListOfInterfaces::MyUnion::Tag::iface_list:
+ return "iface_list";
+ case ListOfInterfaces::MyUnion::Tag::nullable_iface_list:
+ return "nullable_iface_list";
+ 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::ListOfInterfaces::MyUnion::Tag, 4> enum_values<::android::aidl::tests::ListOfInterfaces::MyUnion::Tag> = {
+ ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface,
+ ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface,
+ ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface_list,
+ ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface_list,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // 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
index 4428401..a82300f 100644
--- 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
@@ -2,6 +2,8 @@
#include <android/aidl/tests/ByteEnum.h>
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/IBinder.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
@@ -23,15 +25,23 @@
namespace tests {
class Union : public ::android::Parcelable {
public:
- 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;
+ enum class Tag : int32_t {
+ ns = 0,
+ n = 1,
+ m = 2,
+ s = 3,
+ ibinder = 4,
+ ss = 5,
+ be = 6,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag ns = Tag::ns;
+ static const inline Tag n = Tag::n;
+ static const inline Tag m = Tag::m;
+ static const inline Tag s = Tag::s;
+ static const inline Tag ibinder = Tag::ibinder;
+ static const inline Tag ss = Tag::ss;
+ static const inline Tag be = Tag::be;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
@@ -125,3 +135,46 @@
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(Union::Tag val) {
+ switch(val) {
+ case Union::Tag::ns:
+ return "ns";
+ case Union::Tag::n:
+ return "n";
+ case Union::Tag::m:
+ return "m";
+ case Union::Tag::s:
+ return "s";
+ case Union::Tag::ibinder:
+ return "ibinder";
+ case Union::Tag::ss:
+ return "ss";
+ case Union::Tag::be:
+ return "be";
+ 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::Union::Tag, 7> enum_values<::android::aidl::tests::Union::Tag> = {
+ ::android::aidl::tests::Union::Tag::ns,
+ ::android::aidl::tests::Union::Tag::n,
+ ::android::aidl::tests::Union::Tag::m,
+ ::android::aidl::tests::Union::Tag::s,
+ ::android::aidl::tests::Union::Tag::ibinder,
+ ::android::aidl::tests::Union::Tag::ss,
+ ::android::aidl::tests::Union::Tag::be,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // 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
index 06ae2a6..c97edf1 100644
--- 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
@@ -1,11 +1,14 @@
#pragma once
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/Parcel.h>
#include <binder/ParcelFileDescriptor.h>
#include <binder/Status.h>
#include <cassert>
#include <cstdint>
+#include <string>
#include <type_traits>
#include <utility>
#include <utils/String16.h>
@@ -20,10 +23,13 @@
namespace tests {
class UnionWithFd : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- num = 0, // int num;
- pfd, // ParcelFileDescriptor pfd;
+ enum class Tag : int32_t {
+ num = 0,
+ pfd = 1,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag num = Tag::num;
+ static const inline Tag pfd = Tag::pfd;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>;
@@ -111,3 +117,31 @@
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(UnionWithFd::Tag val) {
+ switch(val) {
+ case UnionWithFd::Tag::num:
+ return "num";
+ case UnionWithFd::Tag::pfd:
+ return "pfd";
+ 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::UnionWithFd::Tag, 2> enum_values<::android::aidl::tests::UnionWithFd::Tag> = {
+ ::android::aidl::tests::UnionWithFd::Tag::num,
+ ::android::aidl::tests::UnionWithFd::Tag::pfd,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace android
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
index 3898fbc..7a41b20 100644
--- 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
@@ -3,9 +3,13 @@
#include <android/aidl/tests/IntEnum.h>
#include <android/aidl/tests/LongEnum.h>
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
+#include <cstdint>
+#include <string>
#include <type_traits>
#include <utility>
#include <utils/String16.h>
@@ -21,10 +25,15 @@
namespace unions {
class EnumUnion : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- intEnum = 0, // android.aidl.tests.IntEnum intEnum;
- longEnum, // android.aidl.tests.LongEnum longEnum;
+ enum class Tag : int32_t {
+ intEnum = 0,
+ longEnum = 1,
+ deprecatedField __attribute__((deprecated("do not use this"))) = 2,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag intEnum = Tag::intEnum;
+ static const inline Tag longEnum = Tag::longEnum;
+ static const inline Tag __attribute__((deprecated("do not use this"))) deprecatedField = Tag::deprecatedField;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>;
@@ -102,14 +111,55 @@
switch (getTag()) {
case intEnum: os << "intEnum: " << ::android::internal::ToString(get<intEnum>()); break;
case longEnum: os << "longEnum: " << ::android::internal::ToString(get<longEnum>()); break;
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ case deprecatedField: os << "deprecatedField: " << ::android::internal::ToString(get<deprecatedField>()); break;
+ #pragma clang diagnostic pop
}
os << "}";
return os.str();
}
private:
- std::variant<::android::aidl::tests::IntEnum, ::android::aidl::tests::LongEnum> _value;
+ std::variant<::android::aidl::tests::IntEnum, ::android::aidl::tests::LongEnum, int32_t> _value;
}; // class EnumUnion
} // namespace unions
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+[[nodiscard]] static inline std::string toString(EnumUnion::Tag val) {
+ switch(val) {
+ case EnumUnion::Tag::intEnum:
+ return "intEnum";
+ case EnumUnion::Tag::longEnum:
+ return "longEnum";
+ case EnumUnion::Tag::deprecatedField:
+ return "deprecatedField";
+ default:
+ return std::to_string(static_cast<int32_t>(val));
+ }
+}
+#pragma clang diagnostic pop
+} // namespace unions
+} // namespace tests
+} // namespace aidl
+} // namespace android
+namespace android {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+template <>
+constexpr inline std::array<::android::aidl::tests::unions::EnumUnion::Tag, 3> enum_values<::android::aidl::tests::unions::EnumUnion::Tag> = {
+ ::android::aidl::tests::unions::EnumUnion::Tag::intEnum,
+ ::android::aidl::tests::unions::EnumUnion::Tag::longEnum,
+ ::android::aidl::tests::unions::EnumUnion::Tag::deprecatedField,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // 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
index 9adbbe9..9badc3a 100644
--- 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
@@ -2,10 +2,13 @@
#include <android/aidl/tests/unions/EnumUnion.h>
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
#include <cstdint>
+#include <string>
#include <type_traits>
#include <utility>
#include <utils/String16.h>
@@ -21,10 +24,13 @@
namespace unions {
class UnionInUnion : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- first = 0, // android.aidl.tests.unions.EnumUnion first;
- second, // int second;
+ enum class Tag : int32_t {
+ first = 0,
+ second = 1,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag first = Tag::first;
+ static const inline Tag second = Tag::second;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>;
@@ -113,3 +119,33 @@
} // namespace tests
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+[[nodiscard]] static inline std::string toString(UnionInUnion::Tag val) {
+ switch(val) {
+ case UnionInUnion::Tag::first:
+ return "first";
+ case UnionInUnion::Tag::second:
+ return "second";
+ default:
+ return std::to_string(static_cast<int32_t>(val));
+ }
+}
+} // namespace unions
+} // 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::unions::UnionInUnion::Tag, 2> enum_values<::android::aidl::tests::unions::UnionInUnion::Tag> = {
+ ::android::aidl::tests::unions::UnionInUnion::Tag::first,
+ ::android::aidl::tests::unions::UnionInUnion::Tag::second,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
index 5c86379..ea45e08 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
@@ -565,5 +565,11 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int iface = 0;
+ public static final int nullable_iface = 1;
+ public static final int iface_array = 2;
+ public static final int nullable_iface_array = 3;
+ }
}
}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java
index 1b4ca32..4837063 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java
@@ -78,7 +78,7 @@
_aidl_parcel.writeFloat(floatValue);
_aidl_parcel.writeDouble(doubleValue);
_aidl_parcel.writeLong(enumValue);
- _aidl_parcel.writeTypedObject(parcelableValue, 0);
+ _aidl_parcel.writeTypedObject(parcelableValue, _aidl_flag);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
_aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
@@ -404,5 +404,15 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final byte booleanValue = 0;
+ public static final byte byteValue = 1;
+ public static final byte charValue = 2;
+ public static final byte intValue = 3;
+ public static final byte longValue = 4;
+ public static final byte floatValue = 5;
+ public static final byte doubleValue = 6;
+ public static final byte enumValue = 7;
+ }
}
}
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
index 50d65a6..c263576 100644
--- 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
@@ -276,6 +276,10 @@
{
return null;
}
+ @Override public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException
+ {
+ return null;
+ }
// Retrieve the ICppJavaTests if the server supports it
@Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
{
@@ -573,6 +577,10 @@
{
return mImpl.GetNewNameInterface();
}
+ @Override public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException
+ {
+ return mImpl.GetUnionTags(input);
+ }
// Retrieve the ICppJavaTests if the server supports it
@Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
{
@@ -1381,6 +1389,16 @@
reply.writeStrongInterface(_result);
break;
}
+ case TRANSACTION_GetUnionTags:
+ {
+ android.aidl.tests.Union[] _arg0;
+ _arg0 = data.createTypedArray(android.aidl.tests.Union.CREATOR);
+ data.enforceNoDataAvail();
+ int[] _result = this.GetUnionTags(_arg0);
+ reply.writeNoException();
+ reply.writeIntArray(_result);
+ break;
+ }
case TRANSACTION_GetCppJavaTests:
{
android.os.IBinder _result = this.GetCppJavaTests();
@@ -3054,6 +3072,30 @@
}
return _result;
}
+ @Override public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException
+ {
+ android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
+ _data.markSensitive();
+ android.os.Parcel _reply = android.os.Parcel.obtain();
+ int[] _result;
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeTypedArray(input, 0);
+ boolean _status = mRemote.transact(Stub.TRANSACTION_GetUnionTags, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
+ if (!_status) {
+ if (getDefaultImpl() != null) {
+ return getDefaultImpl().GetUnionTags(input);
+ }
+ }
+ _reply.readException();
+ _result = _reply.createIntArray();
+ }
+ 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
{
@@ -3166,8 +3208,9 @@
static final int TRANSACTION_ReverseNullableIBinderArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 60);
static final int TRANSACTION_GetOldNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 61);
static final int TRANSACTION_GetNewNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 62);
- static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 63);
- static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 64);
+ static final int TRANSACTION_GetUnionTags = (android.os.IBinder.FIRST_CALL_TRANSACTION + 63);
+ static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 64);
+ static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 65);
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
@@ -3357,6 +3400,7 @@
public android.os.IBinder[] ReverseNullableIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException;
public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException;
public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException;
+ public int[] GetUnionTags(android.aidl.tests.Union[] input) 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;
@@ -3461,16 +3505,16 @@
_aidl_parcel.writeBinderArray(nullable_binder_array);
_aidl_parcel.writeBinderList(binder_list);
_aidl_parcel.writeBinderList(nullable_binder_list);
- _aidl_parcel.writeTypedObject(pfd, 0);
- _aidl_parcel.writeTypedObject(nullable_pfd, 0);
- _aidl_parcel.writeTypedArray(pfd_array, 0);
- _aidl_parcel.writeTypedArray(nullable_pfd_array, 0);
+ _aidl_parcel.writeTypedObject(pfd, _aidl_flag);
+ _aidl_parcel.writeTypedObject(nullable_pfd, _aidl_flag);
+ _aidl_parcel.writeTypedArray(pfd_array, _aidl_flag);
+ _aidl_parcel.writeTypedArray(nullable_pfd_array, _aidl_flag);
_aidl_parcel.writeTypedList(pfd_list);
_aidl_parcel.writeTypedList(nullable_pfd_list);
- _aidl_parcel.writeTypedObject(parcel, 0);
- _aidl_parcel.writeTypedObject(nullable_parcel, 0);
- _aidl_parcel.writeTypedArray(parcel_array, 0);
- _aidl_parcel.writeTypedArray(nullable_parcel_array, 0);
+ _aidl_parcel.writeTypedObject(parcel, _aidl_flag);
+ _aidl_parcel.writeTypedObject(nullable_parcel, _aidl_flag);
+ _aidl_parcel.writeTypedArray(parcel_array, _aidl_flag);
+ _aidl_parcel.writeTypedArray(nullable_parcel_array, _aidl_flag);
_aidl_parcel.writeTypedList(parcel_list);
_aidl_parcel.writeTypedList(nullable_parcel_list);
int _aidl_end_pos = _aidl_parcel.dataPosition();
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
index f82b264..561c508 100644
--- 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
@@ -9,6 +9,6 @@
system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+ system/tools/aidl/tests/android/aidl/tests/Union.aidl \
system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
- system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
- system/tools/aidl/tests/android/aidl/tests/Union.aidl
+ system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.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
index 64ae00a..4114fe7 100644
--- 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
@@ -6,4 +6,34 @@
public static final int FOO = 1000;
public static final int BAR = 2000;
public static final int BAZ = 2001;
+ /** @deprecated do not use this */
+ @Deprecated
+ public static final int QUX = 2002;
+ interface $ {
+ static String toString(int _aidl_v) {
+ if (_aidl_v == FOO) return "FOO";
+ if (_aidl_v == BAR) return "BAR";
+ if (_aidl_v == BAZ) return "BAZ";
+ if (_aidl_v == QUX) return "QUX";
+ return Integer.toString(_aidl_v);
+ }
+ static String arrayToString(Object _aidl_v) {
+ if (_aidl_v == null) return "null";
+ Class<?> _aidl_cls = _aidl_v.getClass();
+ if (!_aidl_cls.isArray()) throw new IllegalArgumentException("not an array: " + _aidl_v);
+ Class<?> comp = _aidl_cls.getComponentType();
+ java.util.StringJoiner _aidl_sj = new java.util.StringJoiner(", ", "[", "]");
+ if (comp.isArray()) {
+ for (int _aidl_i = 0; _aidl_i < java.lang.reflect.Array.getLength(_aidl_v); _aidl_i++) {
+ _aidl_sj.add(arrayToString(java.lang.reflect.Array.get(_aidl_v, _aidl_i)));
+ }
+ } else {
+ if (_aidl_cls != int[].class) throw new IllegalArgumentException("wrong type: " + _aidl_cls);
+ for (int e : (int[]) _aidl_v) {
+ _aidl_sj.add(toString(e));
+ }
+ }
+ return _aidl_sj.toString();
+ }
+ }
}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
index fafba0c..6a2564d 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
@@ -545,5 +545,11 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int iface = 0;
+ public static final int nullable_iface = 1;
+ public static final int iface_list = 2;
+ public static final int nullable_iface_list = 3;
+ }
}
}
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
index c588be1..7032dc7 100644
--- 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
@@ -58,14 +58,14 @@
_aidl_parcel.writeString(stringValue);
_aidl_parcel.writeStringArray(stringArray);
_aidl_parcel.writeStringList(stringList);
- _aidl_parcel.writeTypedObject(parcelableValue, 0);
- _aidl_parcel.writeTypedArray(parcelableArray, 0);
+ _aidl_parcel.writeTypedObject(parcelableValue, _aidl_flag);
+ _aidl_parcel.writeTypedArray(parcelableArray, _aidl_flag);
_aidl_parcel.writeInt(enumValue);
_aidl_parcel.writeIntArray(enumArray);
_aidl_parcel.writeStringArray(nullArray);
_aidl_parcel.writeStringList(nullList);
- _aidl_parcel.writeTypedObject(parcelableGeneric, 0);
- _aidl_parcel.writeTypedObject(unionValue, 0);
+ _aidl_parcel.writeTypedObject(parcelableGeneric, _aidl_flag);
+ _aidl_parcel.writeTypedObject(unionValue, _aidl_flag);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
_aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
@@ -150,8 +150,8 @@
_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("enumValue: " + (android.aidl.tests.IntEnum.$.toString(enumValue)));
+ _aidl_sj.add("enumArray: " + (android.aidl.tests.IntEnum.$.arrayToString(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)));
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/RecursiveList.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/RecursiveList.java
index a0c6bb6..5efaac9 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/RecursiveList.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/RecursiveList.java
@@ -23,7 +23,7 @@
int _aidl_start_pos = _aidl_parcel.dataPosition();
_aidl_parcel.writeInt(0);
_aidl_parcel.writeInt(value);
- _aidl_parcel.writeTypedObject(next, 0);
+ _aidl_parcel.writeTypedObject(next, _aidl_flag);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
_aidl_parcel.writeInt(_aidl_end_pos - _aidl_start_pos);
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
index b90fe2c..fa34aff 100644
--- 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
@@ -112,7 +112,7 @@
_aidl_parcel.writeLong(int64_max);
_aidl_parcel.writeInt(hexInt32_neg_1);
_aidl_parcel.writeStrongBinder(ibinder);
- _aidl_parcel.writeTypedObject(empty, 0);
+ _aidl_parcel.writeTypedObject(empty, _aidl_flag);
_aidl_parcel.writeByteArray(int8_1);
_aidl_parcel.writeIntArray(int32_1);
_aidl_parcel.writeLongArray(int64_1);
@@ -131,8 +131,8 @@
_aidl_parcel.writeString(addString1);
_aidl_parcel.writeString(addString2);
_aidl_parcel.writeInt(shouldSetBit0AndBit2);
- _aidl_parcel.writeTypedObject(u, 0);
- _aidl_parcel.writeTypedObject(shouldBeConstS1, 0);
+ _aidl_parcel.writeTypedObject(u, _aidl_flag);
+ _aidl_parcel.writeTypedObject(shouldBeConstS1, _aidl_flag);
_aidl_parcel.writeInt(defaultWithFoo);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
@@ -272,10 +272,10 @@
_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("shouldBeIntBar: " + (android.aidl.tests.IntEnum.$.toString(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("shouldContainTwoIntFoos: " + (android.aidl.tests.IntEnum.$.arrayToString(shouldContainTwoIntFoos)));
_aidl_sj.add("shouldContainTwoLongFoos: " + (java.util.Arrays.toString(shouldContainTwoLongFoos)));
_aidl_sj.add("stringDefaultsToFoo: " + (java.util.Objects.toString(stringDefaultsToFoo)));
_aidl_sj.add("byteDefaultsToFour: " + (byteDefaultsToFour));
@@ -322,7 +322,7 @@
_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));
+ _aidl_sj.add("defaultWithFoo: " + (android.aidl.tests.IntEnum.$.toString(defaultWithFoo)));
return "android.aidl.tests.StructuredParcelable" + _aidl_sj.toString() ;
}
@Override
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
index 50688a6..018898a 100644
--- 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
@@ -283,4 +283,13 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int ns = 0;
+ public static final int n = 1;
+ public static final int m = 2;
+ public static final int s = 3;
+ public static final int ibinder = 4;
+ public static final int ss = 5;
+ public static final int be = 6;
+ }
}
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
index 941c947..63a5f1a 100644
--- 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
@@ -78,7 +78,7 @@
_aidl_parcel.writeInt(getNum());
break;
case pfd:
- _aidl_parcel.writeTypedObject(getPfd(), 0);
+ _aidl_parcel.writeTypedObject(getPfd(), _aidl_flag);
break;
}
}
@@ -137,4 +137,8 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int num = 0;
+ public static final int pfd = 1;
+ }
}
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/extension/MyExt2.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/extension/MyExt2.java
index 54acb1f..8d3bf56 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/extension/MyExt2.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/extension/MyExt2.java
@@ -24,7 +24,7 @@
int _aidl_start_pos = _aidl_parcel.dataPosition();
_aidl_parcel.writeInt(0);
_aidl_parcel.writeInt(a);
- _aidl_parcel.writeTypedObject(b, 0);
+ _aidl_parcel.writeTypedObject(b, _aidl_flag);
_aidl_parcel.writeString(c);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
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
index 28df6de..7519fd4 100644
--- 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
@@ -6,6 +6,7 @@
// 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;
+ public final static int deprecatedField = 2; // int deprecatedField;
private int _tag;
private Object _value;
@@ -59,6 +60,23 @@
_set(longEnum, _value);
}
+ // int deprecatedField;
+
+ /** @deprecated do not use this */
+ @Deprecated
+ public static EnumUnion deprecatedField(int _value) {
+ return new EnumUnion(deprecatedField, _value);
+ }
+
+ public int getDeprecatedField() {
+ _assertTag(deprecatedField);
+ return (int) _value;
+ }
+
+ public void setDeprecatedField(int _value) {
+ _set(deprecatedField, _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) {
@@ -80,6 +98,9 @@
case longEnum:
_aidl_parcel.writeLong(getLongEnum());
break;
+ case deprecatedField:
+ _aidl_parcel.writeInt(getDeprecatedField());
+ break;
}
}
@@ -97,6 +118,11 @@
_aidl_value = _aidl_parcel.readLong();
_set(_aidl_tag, _aidl_value);
return; }
+ case deprecatedField: {
+ int _aidl_value;
+ _aidl_value = _aidl_parcel.readInt();
+ _set(_aidl_tag, _aidl_value);
+ return; }
}
throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag);
}
@@ -112,8 +138,9 @@
@Override
public String toString() {
switch (_tag) {
- case intEnum: return "android.aidl.tests.unions.EnumUnion.intEnum(" + (getIntEnum()) + ")";
+ case intEnum: return "android.aidl.tests.unions.EnumUnion.intEnum(" + (android.aidl.tests.IntEnum.$.toString(getIntEnum())) + ")";
case longEnum: return "android.aidl.tests.unions.EnumUnion.longEnum(" + (getLongEnum()) + ")";
+ case deprecatedField: return "android.aidl.tests.unions.EnumUnion.deprecatedField(" + (getDeprecatedField()) + ")";
}
throw new IllegalStateException("unknown field: " + _tag);
}
@@ -143,6 +170,7 @@
switch (_tag) {
case intEnum: return "intEnum";
case longEnum: return "longEnum";
+ case deprecatedField: return "deprecatedField";
}
throw new IllegalStateException("unknown field: " + _tag);
}
@@ -151,4 +179,11 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int intEnum = 0;
+ public static final int longEnum = 1;
+ /** @deprecated do not use this */
+ @Deprecated
+ public static final int deprecatedField = 2;
+ }
}
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
index 241511e..4653900 100644
--- 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
@@ -75,7 +75,7 @@
_aidl_parcel.writeInt(_tag);
switch (_tag) {
case first:
- _aidl_parcel.writeTypedObject(getFirst(), 0);
+ _aidl_parcel.writeTypedObject(getFirst(), _aidl_flag);
break;
case second:
_aidl_parcel.writeInt(getSecond());
@@ -161,4 +161,8 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int first = 0;
+ public static final int second = 1;
+ }
}
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
index 0268aaa..8c9ff0a 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
@@ -1246,7 +1246,25 @@
break;
}
- case (FIRST_CALL_TRANSACTION + 63 /*GetCppJavaTests*/): {
+ case (FIRST_CALL_TRANSACTION + 63 /*GetUnionTags*/): {
+ std::vector<::aidl::android::aidl::tests::Union> in_input;
+ std::vector<::aidl::android::aidl::tests::Union::Tag> _aidl_return;
+
+ _aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_input);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetUnionTags(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_writeData(_aidl_out, _aidl_return);
+ if (_aidl_ret_status != STATUS_OK) break;
+
+ break;
+ }
+ case (FIRST_CALL_TRANSACTION + 64 /*GetCppJavaTests*/): {
::ndk::SpAIBinder _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetCppJavaTests(&_aidl_return);
@@ -1260,7 +1278,7 @@
break;
}
- case (FIRST_CALL_TRANSACTION + 64 /*getBackendType*/): {
+ case (FIRST_CALL_TRANSACTION + 65 /*getBackendType*/): {
::aidl::android::aidl::tests::BackendType _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->getBackendType(&_aidl_return);
@@ -3944,6 +3962,47 @@
_aidl_status_return:
return _aidl_status;
}
+::ndk::ScopedAStatus BpTestService::GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _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_writeData(_aidl_in.get(), in_input);
+ if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
+
+ _aidl_ret_status = AIBinder_transact(
+ asBinder().get(),
+ (FIRST_CALL_TRANSACTION + 63 /*GetUnionTags*/),
+ _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()->GetUnionTags(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_readData(_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;
@@ -3956,7 +4015,7 @@
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
- (FIRST_CALL_TRANSACTION + 63 /*GetCppJavaTests*/),
+ (FIRST_CALL_TRANSACTION + 64 /*GetCppJavaTests*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_CLEAR_BUF
@@ -3994,7 +4053,7 @@
_aidl_ret_status = AIBinder_transact(
asBinder().get(),
- (FIRST_CALL_TRANSACTION + 64 /*getBackendType*/),
+ (FIRST_CALL_TRANSACTION + 65 /*getBackendType*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_CLEAR_BUF
@@ -4388,6 +4447,11 @@
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
+::ndk::ScopedAStatus ITestServiceDefault::GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& /*in_input*/, std::vector<::aidl::android::aidl::tests::Union::Tag>* /*_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));
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d
index b46066a..19acd9f 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d
@@ -9,6 +9,6 @@
system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+ system/tools/aidl/tests/android/aidl/tests/Union.aidl \
system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
- system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
- system/tools/aidl/tests/android/aidl/tests/Union.aidl
+ system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/unions/EnumUnion.cpp b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/unions/EnumUnion.cpp
index bb47430..c3f473f 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/unions/EnumUnion.cpp
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/unions/EnumUnion.cpp
@@ -34,6 +34,19 @@
set<longEnum>(std::move(_aidl_value));
}
return STATUS_OK; }
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ case deprecatedField: {
+ int32_t _aidl_value;
+ if ((_aidl_ret_status = ::ndk::AParcel_readData(_parcel, &_aidl_value)) != STATUS_OK) return _aidl_ret_status;
+ if constexpr (std::is_trivially_copyable_v<int32_t>) {
+ set<deprecatedField>(_aidl_value);
+ } else {
+ // NOLINTNEXTLINE(performance-move-const-arg)
+ set<deprecatedField>(std::move(_aidl_value));
+ }
+ return STATUS_OK; }
+ #pragma clang diagnostic pop
}
return STATUS_BAD_VALUE;
}
@@ -43,6 +56,10 @@
switch (getTag()) {
case intEnum: return ::ndk::AParcel_writeData(_parcel, get<intEnum>());
case longEnum: return ::ndk::AParcel_writeData(_parcel, get<longEnum>());
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ case deprecatedField: return ::ndk::AParcel_writeData(_parcel, get<deprecatedField>());
+ #pragma clang diagnostic pop
}
__assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "can't reach here");
}
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h
index 40951a7..b2b9e7b 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_ibinder.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
@@ -152,13 +154,19 @@
typedef std::false_type fixed_size;
static const char* descriptor;
- enum Tag : int32_t {
- iface = 0, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface iface;
- nullable_iface, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface nullable_iface;
- iface_array, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] iface_array;
- nullable_iface_array, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] nullable_iface_array;
+ enum class Tag : int32_t {
+ iface = 0,
+ nullable_iface = 1,
+ iface_array = 2,
+ nullable_iface_array = 3,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag iface = Tag::iface;
+ static const inline Tag nullable_iface = Tag::nullable_iface;
+ static const inline Tag iface_array = Tag::iface_array;
+ static const inline Tag nullable_iface_array = Tag::nullable_iface_array;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
@@ -277,3 +285,39 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(ArrayOfInterfaces::MyUnion::Tag val) {
+ switch(val) {
+ case ArrayOfInterfaces::MyUnion::Tag::iface:
+ return "iface";
+ case ArrayOfInterfaces::MyUnion::Tag::nullable_iface:
+ return "nullable_iface";
+ case ArrayOfInterfaces::MyUnion::Tag::iface_array:
+ return "iface_array";
+ case ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array:
+ return "nullable_iface_array";
+ 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::ArrayOfInterfaces::MyUnion::Tag, 4> enum_values<aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag> = {
+ aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface,
+ aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface,
+ aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface_array,
+ aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnDeprecated.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnDeprecated.h
index 0b6f042..356e9a4 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnDeprecated.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnDeprecated.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/tests/IDeprecated.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -16,6 +23,16 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class __attribute__((deprecated("test"))) IDeprecatedDelegator : public BnDeprecated {
+public:
+ explicit IDeprecatedDelegator(const std::shared_ptr<IDeprecated> &impl) : _impl(impl) {
+ }
+
+protected:
+private:
+ std::shared_ptr<IDeprecated> _impl;
+};
+
} // namespace tests
} // namespace aidl
} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h
index 6f38a28..fa465fa 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNamedCallback.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/tests/INamedCallback.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -16,6 +23,19 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class INamedCallbackDelegator : public BnNamedCallback {
+public:
+ explicit INamedCallbackDelegator(const std::shared_ptr<INamedCallback> &impl) : _impl(impl) {
+ }
+
+ ::ndk::ScopedAStatus GetName(std::string* _aidl_return) override {
+ return _impl->GetName(_aidl_return);
+ }
+protected:
+private:
+ std::shared_ptr<INamedCallback> _impl;
+};
+
} // namespace tests
} // namespace aidl
} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNewName.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNewName.h
index 32d8a7b..78fcbaa 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNewName.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnNewName.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/tests/INewName.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -16,6 +23,19 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class INewNameDelegator : public BnNewName {
+public:
+ explicit INewNameDelegator(const std::shared_ptr<INewName> &impl) : _impl(impl) {
+ }
+
+ ::ndk::ScopedAStatus RealName(std::string* _aidl_return) override {
+ return _impl->RealName(_aidl_return);
+ }
+protected:
+private:
+ std::shared_ptr<INewName> _impl;
+};
+
} // namespace tests
} // namespace aidl
} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnOldName.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnOldName.h
index e1782d1..e08fcc1 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnOldName.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnOldName.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/tests/IOldName.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -16,6 +23,19 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class IOldNameDelegator : public BnOldName {
+public:
+ explicit IOldNameDelegator(const std::shared_ptr<IOldName> &impl) : _impl(impl) {
+ }
+
+ ::ndk::ScopedAStatus RealName(std::string* _aidl_return) override {
+ return _impl->RealName(_aidl_return);
+ }
+protected:
+private:
+ std::shared_ptr<IOldName> _impl;
+};
+
} // namespace tests
} // namespace aidl
} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnTestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnTestService.h
index a33592b..3b5a37d 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnTestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BnTestService.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/tests/ITestService.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -16,6 +23,214 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class ITestServiceDelegator : public BnTestService {
+public:
+ explicit ITestServiceDelegator(const std::shared_ptr<ITestService> &impl) : _impl(impl) {
+ }
+
+ ::ndk::ScopedAStatus UnimplementedMethod(int32_t in_arg, int32_t* _aidl_return) override {
+ return _impl->UnimplementedMethod(in_arg, _aidl_return);
+ }
+ ::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"))) {
+ return _impl->Deprecated();
+ }
+ ::ndk::ScopedAStatus TestOneway() override {
+ return _impl->TestOneway();
+ }
+ ::ndk::ScopedAStatus RepeatBoolean(bool in_token, bool* _aidl_return) override {
+ return _impl->RepeatBoolean(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatByte(int8_t in_token, int8_t* _aidl_return) override {
+ return _impl->RepeatByte(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatChar(char16_t in_token, char16_t* _aidl_return) override {
+ return _impl->RepeatChar(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatInt(int32_t in_token, int32_t* _aidl_return) override {
+ return _impl->RepeatInt(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatLong(int64_t in_token, int64_t* _aidl_return) override {
+ return _impl->RepeatLong(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatFloat(float in_token, float* _aidl_return) override {
+ return _impl->RepeatFloat(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatDouble(double in_token, double* _aidl_return) override {
+ return _impl->RepeatDouble(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatString(const std::string& in_token, std::string* _aidl_return) override {
+ return _impl->RepeatString(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatByteEnum(::aidl::android::aidl::tests::ByteEnum in_token, ::aidl::android::aidl::tests::ByteEnum* _aidl_return) override {
+ return _impl->RepeatByteEnum(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatIntEnum(::aidl::android::aidl::tests::IntEnum in_token, ::aidl::android::aidl::tests::IntEnum* _aidl_return) override {
+ return _impl->RepeatIntEnum(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatLongEnum(::aidl::android::aidl::tests::LongEnum in_token, ::aidl::android::aidl::tests::LongEnum* _aidl_return) override {
+ return _impl->RepeatLongEnum(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseBoolean(const std::vector<bool>& in_input, std::vector<bool>* out_repeated, std::vector<bool>* _aidl_return) override {
+ return _impl->ReverseBoolean(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseByte(const std::vector<uint8_t>& in_input, std::vector<uint8_t>* out_repeated, std::vector<uint8_t>* _aidl_return) override {
+ return _impl->ReverseByte(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseChar(const std::vector<char16_t>& in_input, std::vector<char16_t>* out_repeated, std::vector<char16_t>* _aidl_return) override {
+ return _impl->ReverseChar(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseInt(const std::vector<int32_t>& in_input, std::vector<int32_t>* out_repeated, std::vector<int32_t>* _aidl_return) override {
+ return _impl->ReverseInt(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseLong(const std::vector<int64_t>& in_input, std::vector<int64_t>* out_repeated, std::vector<int64_t>* _aidl_return) override {
+ return _impl->ReverseLong(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseFloat(const std::vector<float>& in_input, std::vector<float>* out_repeated, std::vector<float>* _aidl_return) override {
+ return _impl->ReverseFloat(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseDouble(const std::vector<double>& in_input, std::vector<double>* out_repeated, std::vector<double>* _aidl_return) override {
+ return _impl->ReverseDouble(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override {
+ return _impl->ReverseString(in_input, out_repeated, _aidl_return);
+ }
+ ::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 {
+ return _impl->ReverseByteEnum(in_input, out_repeated, _aidl_return);
+ }
+ ::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 {
+ return _impl->ReverseIntEnum(in_input, out_repeated, _aidl_return);
+ }
+ ::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 {
+ return _impl->ReverseLongEnum(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetOtherTestService(const std::string& in_name, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) override {
+ return _impl->GetOtherTestService(in_name, _aidl_return);
+ }
+ ::ndk::ScopedAStatus VerifyName(const std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>& in_service, const std::string& in_name, bool* _aidl_return) override {
+ return _impl->VerifyName(in_service, in_name, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetInterfaceArray(const std::vector<std::string>& in_names, std::vector<std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>>* _aidl_return) override {
+ return _impl->GetInterfaceArray(in_names, _aidl_return);
+ }
+ ::ndk::ScopedAStatus VerifyNamesWithInterfaceArray(const std::vector<std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>>& in_services, const std::vector<std::string>& in_names, bool* _aidl_return) override {
+ return _impl->VerifyNamesWithInterfaceArray(in_services, in_names, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetNullableInterfaceArray(const std::optional<std::vector<std::optional<std::string>>>& in_names, std::optional<std::vector<std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>>>* _aidl_return) override {
+ return _impl->GetNullableInterfaceArray(in_names, _aidl_return);
+ }
+ ::ndk::ScopedAStatus VerifyNamesWithNullableInterfaceArray(const std::optional<std::vector<std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>>>& in_services, const std::optional<std::vector<std::optional<std::string>>>& in_names, bool* _aidl_return) override {
+ return _impl->VerifyNamesWithNullableInterfaceArray(in_services, in_names, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetInterfaceList(const std::optional<std::vector<std::optional<std::string>>>& in_names, std::optional<std::vector<std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>>>* _aidl_return) override {
+ return _impl->GetInterfaceList(in_names, _aidl_return);
+ }
+ ::ndk::ScopedAStatus VerifyNamesWithInterfaceList(const std::optional<std::vector<std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>>>& in_services, const std::optional<std::vector<std::optional<std::string>>>& in_names, bool* _aidl_return) override {
+ return _impl->VerifyNamesWithInterfaceList(in_services, in_names, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseStringList(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override {
+ return _impl->ReverseStringList(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatParcelFileDescriptor(const ::ndk::ScopedFileDescriptor& in_read, ::ndk::ScopedFileDescriptor* _aidl_return) override {
+ return _impl->RepeatParcelFileDescriptor(in_read, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseParcelFileDescriptorArray(const std::vector<::ndk::ScopedFileDescriptor>& in_input, std::vector<::ndk::ScopedFileDescriptor>* out_repeated, std::vector<::ndk::ScopedFileDescriptor>* _aidl_return) override {
+ return _impl->ReverseParcelFileDescriptorArray(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ThrowServiceException(int32_t in_code) override {
+ return _impl->ThrowServiceException(in_code);
+ }
+ ::ndk::ScopedAStatus RepeatNullableIntArray(const std::optional<std::vector<int32_t>>& in_input, std::optional<std::vector<int32_t>>* _aidl_return) override {
+ return _impl->RepeatNullableIntArray(in_input, _aidl_return);
+ }
+ ::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 {
+ return _impl->RepeatNullableByteEnumArray(in_input, _aidl_return);
+ }
+ ::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 {
+ return _impl->RepeatNullableIntEnumArray(in_input, _aidl_return);
+ }
+ ::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 {
+ return _impl->RepeatNullableLongEnumArray(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatNullableString(const std::optional<std::string>& in_input, std::optional<std::string>* _aidl_return) override {
+ return _impl->RepeatNullableString(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatNullableStringList(const std::optional<std::vector<std::optional<std::string>>>& in_input, std::optional<std::vector<std::optional<std::string>>>* _aidl_return) override {
+ return _impl->RepeatNullableStringList(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatNullableParcelable(const std::optional<::aidl::android::aidl::tests::ITestService::Empty>& in_input, std::optional<::aidl::android::aidl::tests::ITestService::Empty>* _aidl_return) override {
+ return _impl->RepeatNullableParcelable(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatNullableParcelableArray(const std::optional<std::vector<std::optional<::aidl::android::aidl::tests::ITestService::Empty>>>& in_input, std::optional<std::vector<std::optional<::aidl::android::aidl::tests::ITestService::Empty>>>* _aidl_return) override {
+ return _impl->RepeatNullableParcelableArray(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatNullableParcelableList(const std::optional<std::vector<std::optional<::aidl::android::aidl::tests::ITestService::Empty>>>& in_input, std::optional<std::vector<std::optional<::aidl::android::aidl::tests::ITestService::Empty>>>* _aidl_return) override {
+ return _impl->RepeatNullableParcelableList(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus TakesAnIBinder(const ::ndk::SpAIBinder& in_input) override {
+ return _impl->TakesAnIBinder(in_input);
+ }
+ ::ndk::ScopedAStatus TakesANullableIBinder(const ::ndk::SpAIBinder& in_input) override {
+ return _impl->TakesANullableIBinder(in_input);
+ }
+ ::ndk::ScopedAStatus TakesAnIBinderList(const std::vector<::ndk::SpAIBinder>& in_input) override {
+ return _impl->TakesAnIBinderList(in_input);
+ }
+ ::ndk::ScopedAStatus TakesANullableIBinderList(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input) override {
+ return _impl->TakesANullableIBinderList(in_input);
+ }
+ ::ndk::ScopedAStatus RepeatUtf8CppString(const std::string& in_token, std::string* _aidl_return) override {
+ return _impl->RepeatUtf8CppString(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus RepeatNullableUtf8CppString(const std::optional<std::string>& in_token, std::optional<std::string>* _aidl_return) override {
+ return _impl->RepeatNullableUtf8CppString(in_token, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseUtf8CppString(const std::vector<std::string>& in_input, std::vector<std::string>* out_repeated, std::vector<std::string>* _aidl_return) override {
+ return _impl->ReverseUtf8CppString(in_input, out_repeated, _aidl_return);
+ }
+ ::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 {
+ return _impl->ReverseNullableUtf8CppString(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseUtf8CppStringList(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 {
+ return _impl->ReverseUtf8CppStringList(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetCallback(bool in_return_null, std::shared_ptr<::aidl::android::aidl::tests::INamedCallback>* _aidl_return) override {
+ return _impl->GetCallback(in_return_null, _aidl_return);
+ }
+ ::ndk::ScopedAStatus FillOutStructuredParcelable(::aidl::android::aidl::tests::StructuredParcelable* in_parcel) override {
+ return _impl->FillOutStructuredParcelable(in_parcel);
+ }
+ ::ndk::ScopedAStatus RepeatExtendableParcelable(const ::aidl::android::aidl::tests::extension::ExtendableParcelable& in_ep, ::aidl::android::aidl::tests::extension::ExtendableParcelable* out_ep2) override {
+ return _impl->RepeatExtendableParcelable(in_ep, out_ep2);
+ }
+ ::ndk::ScopedAStatus ReverseList(const ::aidl::android::aidl::tests::RecursiveList& in_list, ::aidl::android::aidl::tests::RecursiveList* _aidl_return) override {
+ return _impl->ReverseList(in_list, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseIBinderArray(const std::vector<::ndk::SpAIBinder>& in_input, std::vector<::ndk::SpAIBinder>* out_repeated, std::vector<::ndk::SpAIBinder>* _aidl_return) override {
+ return _impl->ReverseIBinderArray(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) override {
+ return _impl->ReverseNullableIBinderArray(in_input, out_repeated, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override {
+ return _impl->GetOldNameInterface(_aidl_return);
+ }
+ ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override {
+ return _impl->GetNewNameInterface(_aidl_return);
+ }
+ ::ndk::ScopedAStatus GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _aidl_return) override {
+ return _impl->GetUnionTags(in_input, _aidl_return);
+ }
+ ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override {
+ return _impl->GetCppJavaTests(_aidl_return);
+ }
+ ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) override {
+ return _impl->getBackendType(_aidl_return);
+ }
+protected:
+private:
+ std::shared_ptr<ITestService> _impl;
+};
+
} // namespace tests
} // namespace aidl
} // namespace android
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
index 71b75be..2cd9768 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
@@ -76,6 +76,7 @@
::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) 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 GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _aidl_return) override;
::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) override;
};
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/DeprecatedEnum.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/DeprecatedEnum.h
index 299874c..fce736b 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/DeprecatedEnum.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/DeprecatedEnum.h
@@ -29,7 +29,8 @@
namespace android {
namespace aidl {
namespace tests {
-[[nodiscard]] static inline std::string toString(DeprecatedEnum val) __attribute__((deprecated("test")));
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[nodiscard]] static inline std::string toString(DeprecatedEnum val) {
switch(val) {
case DeprecatedEnum::A:
@@ -42,6 +43,7 @@
return std::to_string(static_cast<int32_t>(val));
}
}
+#pragma clang diagnostic pop
} // namespace tests
} // namespace aidl
} // namespace android
@@ -50,8 +52,9 @@
namespace internal {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
template <>
-constexpr inline std::array<aidl::android::aidl::tests::DeprecatedEnum, 3> __attribute__((deprecated("test"))) enum_values<aidl::android::aidl::tests::DeprecatedEnum> = {
+constexpr inline std::array<aidl::android::aidl::tests::DeprecatedEnum, 3> 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,
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h
index 7c92e11..541757a 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -10,6 +11,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -37,17 +39,27 @@
typedef std::true_type fixed_size;
static const char* descriptor;
- enum Tag : uint8_t {
- booleanValue = 0, // boolean booleanValue;
- byteValue, // byte byteValue;
- charValue, // char charValue;
- intValue, // int intValue;
- longValue, // long longValue;
- floatValue, // float floatValue;
- doubleValue, // double doubleValue;
- enumValue, // android.aidl.tests.LongEnum enumValue;
+ enum class Tag : int8_t {
+ booleanValue = 0,
+ byteValue = 1,
+ charValue = 2,
+ intValue = 3,
+ longValue = 4,
+ floatValue = 5,
+ doubleValue = 6,
+ enumValue = 7,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag booleanValue = Tag::booleanValue;
+ static const inline Tag byteValue = Tag::byteValue;
+ static const inline Tag charValue = Tag::charValue;
+ static const inline Tag intValue = Tag::intValue;
+ static const inline Tag longValue = Tag::longValue;
+ static const inline Tag floatValue = Tag::floatValue;
+ static const inline Tag doubleValue = Tag::doubleValue;
+ static const inline Tag enumValue = Tag::enumValue;
+
template <Tag _Tag>
using _at = typename std::tuple_element<static_cast<size_t>(_Tag), std::tuple<bool, int8_t, char16_t, int32_t, int64_t, float, double, ::aidl::android::aidl::tests::LongEnum>>::type;
template <Tag _Tag, typename _Type>
@@ -130,7 +142,7 @@
return os.str();
}
private:
- Tag _tag __attribute__((aligned (1))) = booleanValue;
+ Tag _tag = booleanValue;
union _value_t {
_value_t() {}
~_value_t() {}
@@ -233,3 +245,51 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(FixedSize::FixedUnion::Tag val) {
+ switch(val) {
+ case FixedSize::FixedUnion::Tag::booleanValue:
+ return "booleanValue";
+ case FixedSize::FixedUnion::Tag::byteValue:
+ return "byteValue";
+ case FixedSize::FixedUnion::Tag::charValue:
+ return "charValue";
+ case FixedSize::FixedUnion::Tag::intValue:
+ return "intValue";
+ case FixedSize::FixedUnion::Tag::longValue:
+ return "longValue";
+ case FixedSize::FixedUnion::Tag::floatValue:
+ return "floatValue";
+ case FixedSize::FixedUnion::Tag::doubleValue:
+ return "doubleValue";
+ case FixedSize::FixedUnion::Tag::enumValue:
+ return "enumValue";
+ 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::FixedSize::FixedUnion::Tag, 8> enum_values<aidl::android::aidl::tests::FixedSize::FixedUnion::Tag> = {
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::booleanValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::byteValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::charValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::intValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::longValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::floatValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::doubleValue,
+ aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::enumValue,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
index dfa1692..2c396b8 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -20,6 +20,7 @@
#include <aidl/android/aidl/tests/LongEnum.h>
#include <aidl/android/aidl/tests/RecursiveList.h>
#include <aidl/android/aidl/tests/StructuredParcelable.h>
+#include <aidl/android/aidl/tests/Union.h>
#include <aidl/android/aidl/tests/extension/ExtendableParcelable.h>
#ifdef BINDER_STABILITY_SUPPORT
#include <android/binder_stability.h>
@@ -280,8 +281,9 @@
static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = FIRST_CALL_TRANSACTION + 60;
static constexpr uint32_t TRANSACTION_GetOldNameInterface = FIRST_CALL_TRANSACTION + 61;
static constexpr uint32_t TRANSACTION_GetNewNameInterface = FIRST_CALL_TRANSACTION + 62;
- static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 63;
- static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 64;
+ static constexpr uint32_t TRANSACTION_GetUnionTags = FIRST_CALL_TRANSACTION + 63;
+ static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 64;
+ static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 65;
static std::shared_ptr<ITestService> fromBinder(const ::ndk::SpAIBinder& binder);
static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<ITestService>& instance);
@@ -351,6 +353,7 @@
virtual ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) = 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 GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _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:
@@ -421,6 +424,7 @@
::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) 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 GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _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;
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/IntEnum.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/IntEnum.h
index 7d29fd4..d272eb3 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/IntEnum.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/IntEnum.h
@@ -19,6 +19,7 @@
FOO = 1000,
BAR = 2000,
BAZ = 2001,
+ QUX __attribute__((deprecated("do not use this"))) = 2002,
};
} // namespace tests
@@ -29,6 +30,8 @@
namespace android {
namespace aidl {
namespace tests {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[nodiscard]] static inline std::string toString(IntEnum val) {
switch(val) {
case IntEnum::FOO:
@@ -37,10 +40,13 @@
return "BAR";
case IntEnum::BAZ:
return "BAZ";
+ case IntEnum::QUX:
+ return "QUX";
default:
return std::to_string(static_cast<int32_t>(val));
}
}
+#pragma clang diagnostic pop
} // namespace tests
} // namespace aidl
} // namespace android
@@ -49,11 +55,13 @@
namespace internal {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
template <>
-constexpr inline std::array<aidl::android::aidl::tests::IntEnum, 3> enum_values<aidl::android::aidl::tests::IntEnum> = {
+constexpr inline std::array<aidl::android::aidl::tests::IntEnum, 4> 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,
+ aidl::android::aidl::tests::IntEnum::QUX,
};
#pragma clang diagnostic pop
} // namespace internal
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h
index 7c93f75..e0dc968 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_ibinder.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
@@ -152,13 +154,19 @@
typedef std::false_type fixed_size;
static const char* descriptor;
- enum Tag : int32_t {
- iface = 0, // android.aidl.tests.ListOfInterfaces.IEmptyInterface iface;
- nullable_iface, // android.aidl.tests.ListOfInterfaces.IEmptyInterface nullable_iface;
- iface_list, // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> iface_list;
- nullable_iface_list, // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> nullable_iface_list;
+ enum class Tag : int32_t {
+ iface = 0,
+ nullable_iface = 1,
+ iface_list = 2,
+ nullable_iface_list = 3,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag iface = Tag::iface;
+ static const inline Tag nullable_iface = Tag::nullable_iface;
+ static const inline Tag iface_list = Tag::iface_list;
+ static const inline Tag nullable_iface_list = Tag::nullable_iface_list;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
@@ -277,3 +285,39 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(ListOfInterfaces::MyUnion::Tag val) {
+ switch(val) {
+ case ListOfInterfaces::MyUnion::Tag::iface:
+ return "iface";
+ case ListOfInterfaces::MyUnion::Tag::nullable_iface:
+ return "nullable_iface";
+ case ListOfInterfaces::MyUnion::Tag::iface_list:
+ return "iface_list";
+ case ListOfInterfaces::MyUnion::Tag::nullable_iface_list:
+ return "nullable_iface_list";
+ 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::ListOfInterfaces::MyUnion::Tag, 4> enum_values<aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag> = {
+ aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface,
+ aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface,
+ aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface_list,
+ aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface_list,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h
index 27ee97c..a94d03f 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -30,16 +32,25 @@
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;
+ enum class Tag : int32_t {
+ ns = 0,
+ n = 1,
+ m = 2,
+ s = 3,
+ ibinder = 4,
+ ss = 5,
+ be = 6,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag ns = Tag::ns;
+ static const inline Tag n = Tag::n;
+ static const inline Tag m = Tag::m;
+ static const inline Tag s = Tag::s;
+ static const inline Tag ibinder = Tag::ibinder;
+ static const inline Tag ss = Tag::ss;
+ static const inline Tag be = Tag::be;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
@@ -131,3 +142,48 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(Union::Tag val) {
+ switch(val) {
+ case Union::Tag::ns:
+ return "ns";
+ case Union::Tag::n:
+ return "n";
+ case Union::Tag::m:
+ return "m";
+ case Union::Tag::s:
+ return "s";
+ case Union::Tag::ibinder:
+ return "ibinder";
+ case Union::Tag::ss:
+ return "ss";
+ case Union::Tag::be:
+ return "be";
+ 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::Union::Tag, 7> enum_values<aidl::android::aidl::tests::Union::Tag> = {
+ aidl::android::aidl::tests::Union::Tag::ns,
+ aidl::android::aidl::tests::Union::Tag::n,
+ aidl::android::aidl::tests::Union::Tag::m,
+ aidl::android::aidl::tests::Union::Tag::s,
+ aidl::android::aidl::tests::Union::Tag::ibinder,
+ aidl::android::aidl::tests::Union::Tag::ss,
+ aidl::android::aidl::tests::Union::Tag::be,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
index 818ff01..986b542 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -29,11 +31,15 @@
typedef std::false_type fixed_size;
static const char* descriptor;
- enum Tag : int32_t {
- num = 0, // int num;
- pfd, // ParcelFileDescriptor pfd;
+ enum class Tag : int32_t {
+ num = 0,
+ pfd = 1,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag num = Tag::num;
+ static const inline Tag pfd = Tag::pfd;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>;
@@ -119,3 +125,33 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+[[nodiscard]] static inline std::string toString(UnionWithFd::Tag val) {
+ switch(val) {
+ case UnionWithFd::Tag::num:
+ return "num";
+ case UnionWithFd::Tag::pfd:
+ return "pfd";
+ 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::UnionWithFd::Tag, 2> enum_values<aidl::android::aidl::tests::UnionWithFd::Tag> = {
+ aidl::android::aidl::tests::UnionWithFd::Tag::num,
+ aidl::android::aidl::tests::UnionWithFd::Tag::pfd,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/nested/BnNestedService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/nested/BnNestedService.h
index 98ec330..4fc97ab 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/nested/BnNestedService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/nested/BnNestedService.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/tests/nested/INestedService.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -17,6 +24,22 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class INestedServiceDelegator : public BnNestedService {
+public:
+ explicit INestedServiceDelegator(const std::shared_ptr<INestedService> &impl) : _impl(impl) {
+ }
+
+ ::ndk::ScopedAStatus flipStatus(const ::aidl::android::aidl::tests::nested::ParcelableWithNested& in_p, ::aidl::android::aidl::tests::nested::INestedService::Result* _aidl_return) override {
+ return _impl->flipStatus(in_p, _aidl_return);
+ }
+ ::ndk::ScopedAStatus flipStatusWithCallback(::aidl::android::aidl::tests::nested::ParcelableWithNested::Status in_status, const std::shared_ptr<::aidl::android::aidl::tests::nested::INestedService::ICallback>& in_cb) override {
+ return _impl->flipStatusWithCallback(in_status, in_cb);
+ }
+protected:
+private:
+ std::shared_ptr<INestedService> _impl;
+};
+
} // namespace nested
} // namespace tests
} // namespace aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
index dc3c3fb..2190f50 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -32,11 +34,17 @@
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;
+ enum class Tag : int32_t {
+ intEnum = 0,
+ longEnum = 1,
+ deprecatedField __attribute__((deprecated("do not use this"))) = 2,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag intEnum = Tag::intEnum;
+ static const inline Tag longEnum = Tag::longEnum;
+ static const inline Tag __attribute__((deprecated("do not use this"))) deprecatedField = Tag::deprecatedField;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>;
@@ -111,15 +119,58 @@
switch (getTag()) {
case intEnum: os << "intEnum: " << ::android::internal::ToString(get<intEnum>()); break;
case longEnum: os << "longEnum: " << ::android::internal::ToString(get<longEnum>()); break;
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ case deprecatedField: os << "deprecatedField: " << ::android::internal::ToString(get<deprecatedField>()); break;
+ #pragma clang diagnostic pop
}
os << "}";
return os.str();
}
private:
- std::variant<::aidl::android::aidl::tests::IntEnum, ::aidl::android::aidl::tests::LongEnum> _value;
+ std::variant<::aidl::android::aidl::tests::IntEnum, ::aidl::android::aidl::tests::LongEnum, int32_t> _value;
};
} // namespace unions
} // namespace tests
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+[[nodiscard]] static inline std::string toString(EnumUnion::Tag val) {
+ switch(val) {
+ case EnumUnion::Tag::intEnum:
+ return "intEnum";
+ case EnumUnion::Tag::longEnum:
+ return "longEnum";
+ case EnumUnion::Tag::deprecatedField:
+ return "deprecatedField";
+ default:
+ return std::to_string(static_cast<int32_t>(val));
+ }
+}
+#pragma clang diagnostic pop
+} // namespace unions
+} // namespace tests
+} // namespace aidl
+} // namespace android
+} // namespace aidl
+namespace ndk {
+namespace internal {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++17-extensions"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+template <>
+constexpr inline std::array<aidl::android::aidl::tests::unions::EnumUnion::Tag, 3> enum_values<aidl::android::aidl::tests::unions::EnumUnion::Tag> = {
+ aidl::android::aidl::tests::unions::EnumUnion::Tag::intEnum,
+ aidl::android::aidl::tests::unions::EnumUnion::Tag::longEnum,
+ aidl::android::aidl::tests::unions::EnumUnion::Tag::deprecatedField,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
index 147a566..a41dfbb 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -31,11 +33,15 @@
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;
+ enum class Tag : int32_t {
+ first = 0,
+ second = 1,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag first = Tag::first;
+ static const inline Tag second = Tag::second;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>;
@@ -122,3 +128,35 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace tests {
+namespace unions {
+[[nodiscard]] static inline std::string toString(UnionInUnion::Tag val) {
+ switch(val) {
+ case UnionInUnion::Tag::first:
+ return "first";
+ case UnionInUnion::Tag::second:
+ return "second";
+ default:
+ return std::to_string(static_cast<int32_t>(val));
+ }
+}
+} // namespace unions
+} // 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::unions::UnionInUnion::Tag, 2> enum_values<aidl::android::aidl::tests::unions::UnionInUnion::Tag> = {
+ aidl::android::aidl::tests::unions::UnionInUnion::Tag::first,
+ aidl::android::aidl::tests::unions::UnionInUnion::Tag::second,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java
index 9448d5d..c20acb4 100644
--- a/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java
+++ b/tests/golden_output/aidl-test-interface-permission-java-source/gen/android/aidl/tests/permission/IProtected.java
@@ -16,6 +16,9 @@
@Override public void MultiplePermissionsAny() throws android.os.RemoteException
{
}
+ @Override public void NonManifestPermission() throws android.os.RemoteException
+ {
+ }
@Override
public android.os.IBinder asBinder() {
return null;
@@ -91,6 +94,15 @@
reply.writeNoException();
break;
}
+ case TRANSACTION_NonManifestPermission:
+ {
+ if ((this.permissionCheckerWrapper(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, this.getCallingPid(), new android.content.AttributionSource(getCallingUid(), null, null))!=true)) {
+ throw new SecurityException("Access denied, requires: android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK");
+ }
+ this.NonManifestPermission();
+ reply.writeNoException();
+ break;
+ }
default:
{
return super.onTransact(code, data, reply, flags);
@@ -155,6 +167,20 @@
_data.recycle();
}
}
+ @Override public void NonManifestPermission() throws android.os.RemoteException
+ {
+ 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_NonManifestPermission, _data, _reply, 0);
+ _reply.readException();
+ }
+ finally {
+ _reply.recycle();
+ _data.recycle();
+ }
+ }
}
private boolean permissionCheckerWrapper(
String permission, int pid, android.content.AttributionSource attributionSource) {
@@ -167,6 +193,7 @@
static final int TRANSACTION_PermissionProtected = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
static final int TRANSACTION_MultiplePermissionsAll = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_MultiplePermissionsAny = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
+ static final int TRANSACTION_NonManifestPermission = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
}
public static final java.lang.String DESCRIPTOR = "android$aidl$tests$permission$IProtected".replace('$', '.');
@android.annotation.EnforcePermission(android.Manifest.permission.READ_PHONE_STATE)
@@ -175,4 +202,6 @@
public void MultiplePermissionsAll() throws android.os.RemoteException;
@android.annotation.EnforcePermission(anyOf = {android.Manifest.permission.INTERNET, android.Manifest.permission.VIBRATE})
public void MultiplePermissionsAny() throws android.os.RemoteException;
+ @android.annotation.EnforcePermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK)
+ public void NonManifestPermission() throws android.os.RemoteException;
}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
index ee4b1f1..42b05dc 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
@@ -384,6 +384,18 @@
impl binder::binder_impl::ParcelableMetadata for MyUnion {
fn get_descriptor() -> &'static str { "android.aidl.tests.ArrayOfInterfaces.MyUnion" }
}
+ pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 4] {
+ iface = 0,
+ nullable_iface = 1,
+ iface_array = 2,
+ nullable_iface_array = 3,
+ }
+ }
+ }
}
pub(crate) mod mangled {
pub use super::ArrayOfInterfaces as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces;
@@ -391,4 +403,5 @@
pub use super::IMyInterface::IMyInterface as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_12_IMyInterface;
pub use super::MyParcelable::MyParcelable as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_12_MyParcelable;
pub use super::MyUnion::MyUnion as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_7_MyUnion;
+ pub use super::MyUnion::Tag::Tag as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_7_MyUnion_3_Tag;
}
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
index ef73f72..2ea4430 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
@@ -216,9 +216,26 @@
impl binder::binder_impl::ParcelableMetadata for FixedUnion {
fn get_descriptor() -> &'static str { "android.aidl.tests.FixedSize.FixedUnion" }
}
+ pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i8; 8] {
+ booleanValue = 0,
+ byteValue = 1,
+ charValue = 2,
+ intValue = 3,
+ longValue = 4,
+ floatValue = 5,
+ doubleValue = 6,
+ enumValue = 7,
+ }
+ }
+ }
}
pub(crate) mod mangled {
pub use super::FixedSize as _7_android_4_aidl_5_tests_9_FixedSize;
pub use super::FixedParcelable::FixedParcelable as _7_android_4_aidl_5_tests_9_FixedSize_15_FixedParcelable;
pub use super::FixedUnion::FixedUnion as _7_android_4_aidl_5_tests_9_FixedSize_10_FixedUnion;
+ pub use super::FixedUnion::Tag::Tag as _7_android_4_aidl_5_tests_9_FixedSize_10_FixedUnion_3_Tag;
}
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
index 9e8fd92..36c03d4 100644
--- 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
@@ -78,6 +78,7 @@
fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::Result<Option<Vec<Option<binder::SpIBinder>>>>;
fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>;
+ fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>;
fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>>;
fn getBackendType(&self) -> binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>;
fn getDefaultImpl() -> ITestServiceDefaultRef where Self: Sized {
@@ -153,6 +154,7 @@
fn ReverseNullableIBinderArray<'a>(&'a self, _arg_input: Option<&'a [Option<binder::SpIBinder>]>, _arg_repeated: &'a mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::BoxFuture<'a, binder::Result<Option<Vec<Option<binder::SpIBinder>>>>>;
fn GetOldNameInterface<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>>;
fn GetNewNameInterface<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>>;
+ fn GetUnionTags<'a>(&'a self, _arg_input: &'a [crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::BoxFuture<'a, binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>>;
fn GetCppJavaTests<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<Option<binder::SpIBinder>>>;
fn getBackendType<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>>;
}
@@ -223,6 +225,7 @@
async fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::Result<Option<Vec<Option<binder::SpIBinder>>>>;
async fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
async fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>;
+ async fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>;
async fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>>;
async fn getBackendType(&self) -> binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>;
}
@@ -435,6 +438,9 @@
fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
self._rt.block_on(self._inner.GetNewNameInterface())
}
+ fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
+ self._rt.block_on(self._inner.GetUnionTags(_arg_input))
+ }
fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> {
self._rt.block_on(self._inner.GetCppJavaTests())
}
@@ -636,6 +642,9 @@
fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
+ fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
+ Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+ }
fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
@@ -707,8 +716,9 @@
pub const ReverseNullableIBinderArray: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 60;
pub const GetOldNameInterface: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 61;
pub const GetNewNameInterface: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 62;
- pub const GetCppJavaTests: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 63;
- pub const getBackendType: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 64;
+ pub const GetUnionTags: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 63;
+ pub const GetCppJavaTests: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 64;
+ pub const getBackendType: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 65;
}
pub type ITestServiceDefaultRef = Option<std::sync::Arc<dyn ITestServiceDefault>>;
use lazy_static::lazy_static;
@@ -1949,6 +1959,24 @@
let _aidl_return: binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName> = _aidl_reply.read()?;
Ok(_aidl_return)
}
+ fn build_parcel_GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<binder::binder_impl::Parcel> {
+ let mut aidl_data = self.binder.prepare_transact()?;
+ aidl_data.mark_sensitive();
+ aidl_data.write(_arg_input)?;
+ Ok(aidl_data)
+ }
+ fn read_response_GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union], _aidl_reply: std::result::Result<binder::binder_impl::Parcel, binder::StatusCode>) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
+ if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+ if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
+ return _aidl_default_impl.GetUnionTags(_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: Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag> = _aidl_reply.read()?;
+ Ok(_aidl_return)
+ }
fn build_parcel_GetCppJavaTests(&self) -> binder::Result<binder::binder_impl::Parcel> {
let mut aidl_data = self.binder.prepare_transact()?;
aidl_data.mark_sensitive();
@@ -2300,6 +2328,11 @@
let _aidl_reply = self.binder.submit_transact(transactions::GetNewNameInterface, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL);
self.read_response_GetNewNameInterface(_aidl_reply)
}
+ fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
+ let _aidl_data = self.build_parcel_GetUnionTags(_arg_input)?;
+ let _aidl_reply = self.binder.submit_transact(transactions::GetUnionTags, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL);
+ self.read_response_GetUnionTags(_arg_input, _aidl_reply)
+ }
fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> {
let _aidl_data = self.build_parcel_GetCppJavaTests()?;
let _aidl_reply = self.binder.submit_transact(transactions::GetCppJavaTests, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL);
@@ -3126,6 +3159,19 @@
}
)
}
+ fn GetUnionTags<'a>(&'a self, _arg_input: &'a [crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::BoxFuture<'a, binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>> {
+ let _aidl_data = match self.build_parcel_GetUnionTags(_arg_input) {
+ Ok(_aidl_data) => _aidl_data,
+ Err(err) => return Box::pin(std::future::ready(Err(err))),
+ };
+ let binder = self.binder.clone();
+ P::spawn(
+ move || binder.submit_transact(transactions::GetUnionTags, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL),
+ move |_aidl_reply| async move {
+ self.read_response_GetUnionTags(_arg_input, _aidl_reply)
+ }
+ )
+ }
fn GetCppJavaTests<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<Option<binder::SpIBinder>>> {
let _aidl_data = match self.build_parcel_GetCppJavaTests() {
Ok(_aidl_data) => _aidl_data,
@@ -3217,6 +3263,7 @@
fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::Result<Option<Vec<Option<binder::SpIBinder>>>> { self.0.ReverseNullableIBinderArray(_arg_input, _arg_repeated) }
fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> { self.0.GetOldNameInterface() }
fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> { self.0.GetNewNameInterface() }
+ fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> { self.0.GetUnionTags(_arg_input) }
fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> { self.0.GetCppJavaTests() }
fn getBackendType(&self) -> binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType> { self.0.getBackendType() }
}
@@ -4019,6 +4066,18 @@
}
Ok(())
}
+ transactions::GetUnionTags => {
+ let _arg_input: Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union> = _aidl_data.read()?;
+ let _aidl_return = _aidl_service.GetUnionTags(&_arg_input);
+ match &_aidl_return {
+ Ok(_aidl_return) => {
+ _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+ _aidl_reply.write(_aidl_return)?;
+ }
+ Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+ }
+ Ok(())
+ }
transactions::GetCppJavaTests => {
let _aidl_return = _aidl_service.GetCppJavaTests();
match &_aidl_return {
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
index 3f2111f..9786dc1 100644
--- 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
@@ -9,6 +9,6 @@
system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
+ system/tools/aidl/tests/android/aidl/tests/Union.aidl \
system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
- system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
- system/tools/aidl/tests/android/aidl/tests/Union.aidl
+ system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.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
index 5ff4d95..70e71dd 100644
--- 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
@@ -3,10 +3,12 @@
#![allow(non_upper_case_globals)]
use binder::declare_binder_enum;
declare_binder_enum! {
- IntEnum : [i32; 3] {
+ IntEnum : [i32; 4] {
FOO = 1000,
BAR = 2000,
BAZ = 2001,
+ #[deprecated = "do not use this"]
+ QUX = 2002,
}
}
pub(crate) mod mangled {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
index 274006e..4f5d5c6 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
@@ -380,6 +380,18 @@
impl binder::binder_impl::ParcelableMetadata for MyUnion {
fn get_descriptor() -> &'static str { "android.aidl.tests.ListOfInterfaces.MyUnion" }
}
+ pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 4] {
+ iface = 0,
+ nullable_iface = 1,
+ iface_list = 2,
+ nullable_iface_list = 3,
+ }
+ }
+ }
}
pub(crate) mod mangled {
pub use super::ListOfInterfaces as _7_android_4_aidl_5_tests_16_ListOfInterfaces;
@@ -387,4 +399,5 @@
pub use super::IMyInterface::IMyInterface as _7_android_4_aidl_5_tests_16_ListOfInterfaces_12_IMyInterface;
pub use super::MyParcelable::MyParcelable as _7_android_4_aidl_5_tests_16_ListOfInterfaces_12_MyParcelable;
pub use super::MyUnion::MyUnion as _7_android_4_aidl_5_tests_16_ListOfInterfaces_7_MyUnion;
+ pub use super::MyUnion::Tag::Tag as _7_android_4_aidl_5_tests_16_ListOfInterfaces_7_MyUnion_3_Tag;
}
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
index 44f1f78..a2f9295 100644
--- 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
@@ -98,6 +98,22 @@
impl binder::binder_impl::ParcelableMetadata for Union {
fn get_descriptor() -> &'static str { "android.aidl.tests.Union" }
}
+pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 7] {
+ ns = 0,
+ n = 1,
+ m = 2,
+ s = 3,
+ ibinder = 4,
+ ss = 5,
+ be = 6,
+ }
+ }
+}
pub(crate) mod mangled {
pub use super::Union as _7_android_4_aidl_5_tests_5_Union;
+ pub use super::Tag::Tag as _7_android_4_aidl_5_tests_5_Union_3_Tag;
}
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
index 29af5a3..49f9f16 100644
--- 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
@@ -48,6 +48,17 @@
impl binder::binder_impl::ParcelableMetadata for UnionWithFd {
fn get_descriptor() -> &'static str { "android.aidl.tests.UnionWithFd" }
}
+pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 2] {
+ num = 0,
+ pfd = 1,
+ }
+ }
+}
pub(crate) mod mangled {
pub use super::UnionWithFd as _7_android_4_aidl_5_tests_11_UnionWithFd;
+ pub use super::Tag::Tag as _7_android_4_aidl_5_tests_11_UnionWithFd_3_Tag;
}
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
index bf142f7..6f26dcc 100644
--- 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
@@ -4,6 +4,8 @@
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),
+ #[deprecated = "do not use this"]
+ DeprecatedField(i32),
}
impl Default for EnumUnion {
fn default() -> Self {
@@ -21,6 +23,10 @@
parcel.write(&1i32)?;
parcel.write(v)
}
+ Self::DeprecatedField(v) => {
+ parcel.write(&2i32)?;
+ parcel.write(v)
+ }
}
}
fn read_from_parcel(&mut self, parcel: &binder::binder_impl::BorrowedParcel) -> std::result::Result<(), binder::StatusCode> {
@@ -36,6 +42,11 @@
*self = Self::LongEnum(value);
Ok(())
}
+ 2 => {
+ let value: i32 = parcel.read()?;
+ *self = Self::DeprecatedField(value);
+ Ok(())
+ }
_ => {
Err(binder::StatusCode::BAD_VALUE)
}
@@ -47,6 +58,19 @@
impl binder::binder_impl::ParcelableMetadata for EnumUnion {
fn get_descriptor() -> &'static str { "android.aidl.tests.unions.EnumUnion" }
}
+pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 3] {
+ intEnum = 0,
+ longEnum = 1,
+ #[deprecated = "do not use this"]
+ deprecatedField = 2,
+ }
+ }
+}
pub(crate) mod mangled {
pub use super::EnumUnion as _7_android_4_aidl_5_tests_6_unions_9_EnumUnion;
+ pub use super::Tag::Tag as _7_android_4_aidl_5_tests_6_unions_9_EnumUnion_3_Tag;
}
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
index fd2d68d..511f44c 100644
--- 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
@@ -47,6 +47,17 @@
impl binder::binder_impl::ParcelableMetadata for UnionInUnion {
fn get_descriptor() -> &'static str { "android.aidl.tests.unions.UnionInUnion" }
}
+pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 2] {
+ first = 0,
+ second = 1,
+ }
+ }
+}
pub(crate) mod mangled {
pub use super::UnionInUnion as _7_android_4_aidl_5_tests_6_unions_12_UnionInUnion;
+ pub use super::Tag::Tag as _7_android_4_aidl_5_tests_6_unions_12_UnionInUnion_3_Tag;
}
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h b/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h
index c8ba05b..25e0d16 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h
@@ -1,10 +1,13 @@
#pragma once
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
#include <cstdint>
+#include <string>
#include <type_traits>
#include <utility>
#include <utils/String16.h>
@@ -20,9 +23,11 @@
namespace tests {
class BazUnion : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- intNum = 0, // int intNum;
+ enum class Tag : int32_t {
+ intNum = 0,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag intNum = Tag::intNum;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, BazUnion>;
@@ -110,3 +115,30 @@
} // namespace versioned
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace versioned {
+namespace tests {
+[[nodiscard]] static inline std::string toString(BazUnion::Tag val) {
+ switch(val) {
+ case BazUnion::Tag::intNum:
+ return "intNum";
+ default:
+ return std::to_string(static_cast<int32_t>(val));
+ }
+}
+} // namespace tests
+} // namespace versioned
+} // 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::versioned::tests::BazUnion::Tag, 1> enum_values<::android::aidl::versioned::tests::BazUnion::Tag> = {
+ ::android::aidl::versioned::tests::BazUnion::Tag::intNum,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace android
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java b/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java
index 29da9c2..3f0e3d7 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java
@@ -102,4 +102,7 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int intNum = 0;
+ }
}
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h b/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h
index 24a8014..9218a0b 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -30,10 +32,13 @@
typedef std::false_type fixed_size;
static const char* descriptor;
- enum Tag : int32_t {
- intNum = 0, // int intNum;
+ enum class Tag : int32_t {
+ intNum = 0,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag intNum = Tag::intNum;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, BazUnion>;
@@ -119,3 +124,32 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace versioned {
+namespace tests {
+[[nodiscard]] static inline std::string toString(BazUnion::Tag val) {
+ switch(val) {
+ case BazUnion::Tag::intNum:
+ return "intNum";
+ default:
+ return std::to_string(static_cast<int32_t>(val));
+ }
+}
+} // namespace tests
+} // namespace versioned
+} // 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::versioned::tests::BazUnion::Tag, 1> enum_values<aidl::android::aidl::versioned::tests::BazUnion::Tag> = {
+ aidl::android::aidl::versioned::tests::BazUnion::Tag::intNum,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BnFooInterface.h b/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BnFooInterface.h
index f464a1e..cdb26d7 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BnFooInterface.h
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BnFooInterface.h
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/versioned/tests/IFooInterface.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -19,6 +26,35 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class IFooInterfaceDelegator : public BnFooInterface {
+public:
+ explicit IFooInterfaceDelegator(const std::shared_ptr<IFooInterface> &impl) : _impl(impl) {
+ int32_t _impl_ver = 0;
+ if (!impl->getInterfaceVersion(&_impl_ver).isOk()) {;
+ __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Delegator failed to get version of the implementation.");
+ }
+ if (_impl_ver != IFooInterface::version) {
+ __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Mismatched versions of delegator and implementation is not allowed.");
+ }
+ }
+
+ ::ndk::ScopedAStatus originalApi() override {
+ return _impl->originalApi();
+ }
+ ::ndk::ScopedAStatus acceptUnionAndReturnString(const ::aidl::android::aidl::versioned::tests::BazUnion& in_u, std::string* _aidl_return) override {
+ return _impl->acceptUnionAndReturnString(in_u, _aidl_return);
+ }
+ ::ndk::ScopedAStatus ignoreParcelablesAndRepeatInt(const ::aidl::android::aidl::versioned::tests::Foo& in_inFoo, ::aidl::android::aidl::versioned::tests::Foo* in_inoutFoo, ::aidl::android::aidl::versioned::tests::Foo* out_outFoo, int32_t in_value, int32_t* _aidl_return) override {
+ return _impl->ignoreParcelablesAndRepeatInt(in_inFoo, in_inoutFoo, out_outFoo, in_value, _aidl_return);
+ }
+ ::ndk::ScopedAStatus returnsLengthOfFooArray(const std::vector<::aidl::android::aidl::versioned::tests::Foo>& in_foos, int32_t* _aidl_return) override {
+ return _impl->returnsLengthOfFooArray(in_foos, _aidl_return);
+ }
+protected:
+private:
+ std::shared_ptr<IFooInterface> _impl;
+};
+
} // namespace tests
} // namespace versioned
} // namespace aidl
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
index 5e30930..b60ff88 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
@@ -37,6 +37,16 @@
impl binder::binder_impl::ParcelableMetadata for BazUnion {
fn get_descriptor() -> &'static str { "android.aidl.versioned.tests.BazUnion" }
}
+pub mod Tag {
+ #![allow(non_upper_case_globals)]
+ use binder::declare_binder_enum;
+ declare_binder_enum! {
+ Tag : [i32; 1] {
+ intNum = 0,
+ }
+ }
+}
pub(crate) mod mangled {
pub use super::BazUnion as _7_android_4_aidl_9_versioned_5_tests_8_BazUnion;
+ pub use super::Tag::Tag as _7_android_4_aidl_9_versioned_5_tests_8_BazUnion_3_Tag;
}
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
index fbaf018..9b67e56 100644
--- 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
@@ -1,6 +1,8 @@
#pragma once
#include <android/binder_to_string.h>
+#include <array>
+#include <binder/Enums.h>
#include <binder/Parcel.h>
#include <binder/Status.h>
#include <cassert>
@@ -20,10 +22,13 @@
namespace loggable {
class Union : public ::android::Parcelable {
public:
- enum Tag : int32_t {
- num = 0, // int num;
- str, // String str;
+ enum class Tag : int32_t {
+ num = 0,
+ str = 1,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag num = Tag::num;
+ static const inline Tag str = Tag::str;
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
@@ -111,3 +116,31 @@
} // namespace loggable
} // namespace aidl
} // namespace android
+namespace android {
+namespace aidl {
+namespace loggable {
+[[nodiscard]] static inline std::string toString(Union::Tag val) {
+ switch(val) {
+ case Union::Tag::num:
+ return "num";
+ case Union::Tag::str:
+ return "str";
+ default:
+ return std::to_string(static_cast<int32_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::Union::Tag, 2> enum_values<::android::aidl::loggable::Union::Tag> = {
+ ::android::aidl::loggable::Union::Tag::num,
+ ::android::aidl::loggable::Union::Tag::str,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace android
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
index 5e54a99..b0072c7 100644
--- 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
@@ -26,7 +26,7 @@
_aidl_parcel.writeInt(0);
_aidl_parcel.writeInt(num);
_aidl_parcel.writeString(str);
- _aidl_parcel.writeTypedObject(nestedUnion, 0);
+ _aidl_parcel.writeTypedObject(nestedUnion, _aidl_flag);
_aidl_parcel.writeByte(nestedEnum);
int _aidl_end_pos = _aidl_parcel.dataPosition();
_aidl_parcel.setDataPosition(_aidl_start_pos);
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
index 1751db3..f85770f 100644
--- 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
@@ -127,4 +127,8 @@
this._tag = _tag;
this._value = _value;
}
+ public static @interface Tag {
+ public static final int num = 0;
+ public static final int str = 1;
+ }
}
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
index 650ca86..d6f61e1 100644
--- 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
@@ -3,6 +3,13 @@
#include "aidl/android/aidl/loggable/ILoggableInterface.h"
#include <android/binder_ibinder.h>
+#include <cassert>
+
+#ifndef __BIONIC__
+#ifndef __assert2
+#define __assert2(a,b,c,d) ((void)0)
+#endif
+#endif
namespace aidl {
namespace android {
@@ -31,6 +38,19 @@
::ndk::SpAIBinder createBinder() override;
private:
};
+class ILoggableInterfaceDelegator : public BnLoggableInterface {
+public:
+ explicit ILoggableInterfaceDelegator(const std::shared_ptr<ILoggableInterface> &impl) : _impl(impl) {
+ }
+
+ ::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 {
+ return _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);
+ }
+protected:
+private:
+ std::shared_ptr<ILoggableInterface> _impl;
+};
+
} // namespace loggable
} // namespace aidl
} // namespace android
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
index 2969134..ef0532f 100644
--- 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
@@ -1,5 +1,6 @@
#pragma once
+#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
@@ -9,6 +10,7 @@
#include <utility>
#include <variant>
#include <vector>
+#include <android/binder_enums.h>
#include <android/binder_interface_utils.h>
#include <android/binder_parcelable_utils.h>
#include <android/binder_to_string.h>
@@ -29,11 +31,15 @@
typedef std::false_type fixed_size;
static const char* descriptor;
- enum Tag : int32_t {
- num = 0, // int num;
- str, // String str;
+ enum class Tag : int32_t {
+ num = 0,
+ str = 1,
};
+ // Expose tag symbols for legacy code
+ static const inline Tag num = Tag::num;
+ static const inline Tag str = Tag::str;
+
template<typename _Tp>
static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
@@ -119,3 +125,33 @@
} // namespace aidl
} // namespace android
} // namespace aidl
+namespace aidl {
+namespace android {
+namespace aidl {
+namespace loggable {
+[[nodiscard]] static inline std::string toString(Union::Tag val) {
+ switch(val) {
+ case Union::Tag::num:
+ return "num";
+ case Union::Tag::str:
+ return "str";
+ default:
+ return std::to_string(static_cast<int32_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::Union::Tag, 2> enum_values<aidl::android::aidl::loggable::Union::Tag> = {
+ aidl::android::aidl::loggable::Union::Tag::num,
+ aidl::android::aidl::loggable::Union::Tag::str,
+};
+#pragma clang diagnostic pop
+} // namespace internal
+} // namespace ndk
diff --git a/tests/java/src/android/aidl/service/TestServiceServer.java b/tests/java/src/android/aidl/service/TestServiceServer.java
index ad98416..51a7520 100644
--- a/tests/java/src/android/aidl/service/TestServiceServer.java
+++ b/tests/java/src/android/aidl/service/TestServiceServer.java
@@ -592,6 +592,15 @@
return new MyNewName();
}
+ @Override
+ public int[] GetUnionTags(Union[] input) throws RemoteException {
+ int[] tags = new int[input.length];
+ for (int i = 0; i < input.length; i++) {
+ tags[i] = input[i].getTag();
+ }
+ return tags;
+ }
+
class MyCppJavaTests extends ICppJavaTests.Stub {
@Override
public BadParcelable RepeatBadParcelable(BadParcelable input) throws RemoteException {
diff --git a/tests/java/src/android/aidl/tests/TestServiceClient.java b/tests/java/src/android/aidl/tests/TestServiceClient.java
index e9140cc..098ad20 100644
--- a/tests/java/src/android/aidl/tests/TestServiceClient.java
+++ b/tests/java/src/android/aidl/tests/TestServiceClient.java
@@ -757,10 +757,10 @@
+ "f: 17, "
+ "shouldBeJerry: Jerry, "
+ "shouldBeByteBar: 2, "
- + "shouldBeIntBar: 2000, "
+ + "shouldBeIntBar: BAR, "
+ "shouldBeLongBar: 200000000000, "
+ "shouldContainTwoByteFoos: [1, 1], "
- + "shouldContainTwoIntFoos: [1000, 1000], "
+ + "shouldContainTwoIntFoos: [FOO, FOO], "
+ "shouldContainTwoLongFoos: [100000000000, 100000000000], "
+ "stringDefaultsToFoo: foo, "
+ "byteDefaultsToFour: 4, "
@@ -809,7 +809,7 @@
+ "shouldSetBit0AndBit2: 5, "
+ "u: android.aidl.tests.Union.ns([1, 2, 3]), "
+ "shouldBeConstS1: android.aidl.tests.Union.s(a string constant in union), "
- + "defaultWithFoo: 1000"
+ + "defaultWithFoo: FOO"
+ "}";
assertThat(p.toString(), is(expected));
}
@@ -888,8 +888,8 @@
+ "parcelableArray: ["
+ "android.aidl.tests.OtherParcelableForToString{field: other}, "
+ "android.aidl.tests.OtherParcelableForToString{field: other}], "
- + "enumValue: 1000, "
- + "enumArray: [1000, 2000], "
+ + "enumValue: FOO, "
+ + "enumArray: [FOO, BAR], "
+ "nullArray: null, "
+ "nullList: null, "
+ "parcelableGeneric: android.aidl.tests.GenericStructuredParcelable{a: 1, b: 2}, "
@@ -900,6 +900,21 @@
}
@Test
+ public void testEnumToString() {
+ assertThat(IntEnum.$.toString(IntEnum.FOO), is("FOO"));
+ assertThat(IntEnum.$.toString(0), is("0"));
+ assertThat(IntEnum.$.arrayToString(null), is("null"));
+ assertThat(IntEnum.$.arrayToString(new int[] {}), is("[]"));
+ assertThat(IntEnum.$.arrayToString(new int[] {IntEnum.FOO, IntEnum.BAR}), is("[FOO, BAR]"));
+ assertThat(IntEnum.$.arrayToString(new int[] {IntEnum.FOO, 0}), is("[FOO, 0]"));
+ assertThat(IntEnum.$.arrayToString(new int[][] {{IntEnum.FOO, IntEnum.BAR}, {IntEnum.BAZ}}),
+ is("[[FOO, BAR], [BAZ]]"));
+ assertThrows(IllegalArgumentException.class, () -> IntEnum.$.arrayToString(IntEnum.FOO));
+ assertThrows(
+ IllegalArgumentException.class, () -> IntEnum.$.arrayToString(new long[] {LongEnum.FOO}));
+ }
+
+ @Test
public void testRenamedInterface() throws RemoteException {
IOldName oldAsOld = service.GetOldNameInterface();
assertNotNull(oldAsOld);
@@ -956,6 +971,13 @@
}
@Test
+ public void testGetUnionTags() throws RemoteException {
+ assertArrayEquals(new int[] {}, service.GetUnionTags(new Union[] {}));
+ assertArrayEquals(new int[] {Union.n, Union.ns},
+ service.GetUnionTags(new Union[] {Union.n(0), Union.ns(new int[] {})}));
+ }
+
+ @Test
public void testDescribeContents() throws Exception {
CompilerChecks cc = new CompilerChecks();
cc.pfd_array = new ParcelFileDescriptor[] {null, null, null};
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
index 35c3af3..81315c9 100644
--- a/tests/rust/test_client.rs
+++ b/tests/rust/test_client.rs
@@ -822,6 +822,15 @@
}
#[test]
+fn test_get_union_tags() {
+ let service = get_test_service();
+ let result = service.GetUnionTags(&[]);
+ assert_eq!(result, Ok(vec![]));
+ let result = service.GetUnionTags(&[Union::Union::N(0), Union::Union::Ns(vec![])]);
+ assert_eq!(result, Ok(vec![Union::Tag::Tag::n, Union::Tag::Tag::ns]));
+}
+
+#[test]
fn test_unions() {
assert_eq!(Union::Union::default(), Union::Union::Ns(vec![]));
assert_eq!(EnumUnion::default(), EnumUnion::IntEnum(IntEnum::FOO));
diff --git a/tests/rust/test_service.rs b/tests/rust/test_service.rs
index 1d3c092..3a5c09c 100644
--- a/tests/rust/test_service.rs
+++ b/tests/rust/test_service.rs
@@ -441,6 +441,21 @@
Ok(INewName::BnNewName::new_binder(NewName, BinderFeatures::default()))
}
+ fn GetUnionTags(&self, input: &[Union::Union]) -> binder::Result<Vec<Union::Tag::Tag>> {
+ Ok(input
+ .iter()
+ .map(|u| match u {
+ Union::Union::Ns(_) => Union::Tag::Tag::ns,
+ Union::Union::N(_) => Union::Tag::Tag::n,
+ Union::Union::M(_) => Union::Tag::Tag::m,
+ Union::Union::S(_) => Union::Tag::Tag::s,
+ Union::Union::Ibinder(_) => Union::Tag::Tag::ibinder,
+ Union::Union::Ss(_) => Union::Tag::Tag::ss,
+ Union::Union::Be(_) => Union::Tag::Tag::be,
+ })
+ .collect::<Vec<_>>())
+ }
+
fn GetCppJavaTests(&self) -> binder::Result<Option<SpIBinder>> {
Ok(None)
}
diff --git a/tests/rust/test_service_async.rs b/tests/rust/test_service_async.rs
index f6cd039..cfc0f28 100644
--- a/tests/rust/test_service_async.rs
+++ b/tests/rust/test_service_async.rs
@@ -483,6 +483,21 @@
Ok(INewName::BnNewName::new_async_binder(NewName, rt(), BinderFeatures::default()))
}
+ async fn GetUnionTags(&self, input: &[Union::Union]) -> binder::Result<Vec<Union::Tag::Tag>> {
+ Ok(input
+ .iter()
+ .map(|u| match u {
+ Union::Union::Ns(_) => Union::Tag::Tag::ns,
+ Union::Union::N(_) => Union::Tag::Tag::n,
+ Union::Union::M(_) => Union::Tag::Tag::m,
+ Union::Union::S(_) => Union::Tag::Tag::s,
+ Union::Union::Ibinder(_) => Union::Tag::Tag::ibinder,
+ Union::Union::Ss(_) => Union::Tag::Tag::ss,
+ Union::Union::Be(_) => Union::Tag::Tag::be,
+ })
+ .collect::<Vec<_>>())
+ }
+
async fn GetCppJavaTests(&self) -> binder::Result<Option<SpIBinder>> {
Ok(None)
}