aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-10-17 15:01:14 +0900
committerJiyong Park <jiyong@google.com>2019-11-30 05:18:34 +0000
commit56e61e0c6ed30095f0fb760ae72e6381629c3f9a (patch)
treec9df4a54ab15bb9215047a6842814e832ae61ea3
parent795ec97fef1399ad3a10b56d13845c8e088cf8ed (diff)
downloadaidl-56e61e0c6ed30095f0fb760ae72e6381629c3f9a.tar.gz
No java output for parcelable declaration
The AIDL compiler no longer generates an empty Java file for parcelable declaration, which was the behavior before the AIDL compiler refactoring happend for Android10. The platform build system now is okay with no output because the generated Java files are zipped to a srcjar. Bug: 143993752 Test: run aidl_unittests Merged-In: Iaa9c78c5df06afee165462db05c6dc6e11a1ba8a (cherry picked from commit 9ca5c7ed13e29295a2d597e2a823cd979f33b289) Change-Id: Iaa9c78c5df06afee165462db05c6dc6e11a1ba8a
-rw-r--r--aidl.cpp9
-rw-r--r--aidl_unittest.cpp13
-rw-r--r--generate_java.cpp13
3 files changed, 20 insertions, 15 deletions
diff --git a/aidl.cpp b/aidl.cpp
index 6c7bdf9b..25609c07 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -776,8 +776,13 @@ int compile_aidl(const Options& options, const IoDelegate& io_delegate) {
io_delegate);
success = true;
} else if (lang == Options::Language::JAVA) {
- success =
- java::generate_java(output_file_name, defined_type, &java_types, io_delegate, options);
+ if (defined_type->AsUnstructuredParcelable() != nullptr) {
+ // Legacy behavior. For parcelable declarations in Java, don't generate output file.
+ success = true;
+ } else {
+ success =
+ java::generate_java(output_file_name, defined_type, &java_types, io_delegate, options);
+ }
} else {
LOG(FATAL) << "Should not reach here" << endl;
return 1;
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 721bc89c..7cf81722 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -612,6 +612,19 @@ TEST_F(AidlTest, WritesDependencyFileForStructuredParcelable) {
EXPECT_EQ(actual_dep_file_contents, kExpectedStructuredParcelableDepFileContents);
}
+TEST_F(AidlTest, NoJavaOutputForParcelableDeclaration) {
+ vector<string> args = {
+ "aidl",
+ "--lang=java",
+ "-o place/for/output",
+ "p/Foo.aidl"};
+ Options options = Options::From(args);
+ io_delegate_.SetFileContents(options.InputFiles().front(), "package p; parcelable Foo;");
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ string output_file_contents;
+ EXPECT_FALSE(io_delegate_.GetWrittenContents(options.OutputFile(), &output_file_contents));
+}
+
/* not working until type_namespace.h is fixed
TEST_F(AidlTest, AcceptsNestedContainerType) {
string nested_in_iface = "package a; interface IFoo {\n"
diff --git a/generate_java.cpp b/generate_java.cpp
index 777d530a..0d962035 100644
--- a/generate_java.cpp
+++ b/generate_java.cpp
@@ -63,14 +63,6 @@ bool generate_java_parcel(const std::string& filename, const AidlStructuredParce
return true;
}
-bool generate_java_parcel_declaration(const std::string& filename, const IoDelegate& io_delegate) {
- CodeWriterPtr code_writer = io_delegate.GetCodeWriter(filename);
- *code_writer
- << "// This file is intentionally left blank as placeholder for parcel declaration.\n";
-
- return true;
-}
-
bool generate_java(const std::string& filename, const AidlDefinedType* defined_type,
JavaTypeNamespace* types, const IoDelegate& io_delegate,
const Options& options) {
@@ -79,11 +71,6 @@ bool generate_java(const std::string& filename, const AidlDefinedType* defined_t
return generate_java_parcel(filename, parcelable, types->typenames_, io_delegate);
}
- const AidlParcelable* parcelable_decl = defined_type->AsParcelable();
- if (parcelable_decl != nullptr) {
- return generate_java_parcel_declaration(filename, io_delegate);
- }
-
const AidlInterface* interface = defined_type->AsInterface();
if (interface != nullptr) {
return generate_java_interface(filename, interface, types, io_delegate, options);