summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/JavaClassGenerator.cpp
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-06-23 16:36:35 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-23 16:36:35 +0000
commit780aeb116a495b680811935aece0fe57d168bb21 (patch)
treec62c078dc4e6177b17c17176c2d0a2595268f3b9 /tools/aapt2/java/JavaClassGenerator.cpp
parenteb292b5e30b9660df3a16d39fe9a19a2ae027fa8 (diff)
parent7c72b7f45e16c822df9aaf88f0ba87b47d995d85 (diff)
Merge "Don't add API annotations in the internal R.java" into rvc-dev-plus-aosp am: 7c72b7f45e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11955280 Change-Id: Ib296aab3fdb66ed1a6c5a6a7cd9e50007c8a157b
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator.cpp')
-rw-r--r--tools/aapt2/java/JavaClassGenerator.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp
index bb541fe2490b..dffad3b99c06 100644
--- a/tools/aapt2/java/JavaClassGenerator.cpp
+++ b/tools/aapt2/java/JavaClassGenerator.cpp
@@ -604,6 +604,8 @@ bool JavaClassGenerator::Generate(const StringPiece& package_name_to_generate,
rewrite_method->AppendStatement("final int packageIdBits = p << 24;");
}
+ const bool is_public = (options_.types == JavaClassGeneratorOptions::SymbolTypes::kPublic);
+
for (const auto& package : table_->packages) {
for (const auto& type : package->types) {
if (type->type == ResourceType::kAttrPrivate) {
@@ -612,8 +614,7 @@ bool JavaClassGenerator::Generate(const StringPiece& package_name_to_generate,
}
// Stay consistent with AAPT and generate an empty type class if the R class is public.
- const bool force_creation_if_empty =
- (options_.types == JavaClassGeneratorOptions::SymbolTypes::kPublic);
+ const bool force_creation_if_empty = is_public;
std::unique_ptr<ClassDefinition> class_def;
if (out != nullptr) {
@@ -637,8 +638,7 @@ bool JavaClassGenerator::Generate(const StringPiece& package_name_to_generate,
}
}
- if (out != nullptr && type->type == ResourceType::kStyleable &&
- options_.types == JavaClassGeneratorOptions::SymbolTypes::kPublic) {
+ if (out != nullptr && type->type == ResourceType::kStyleable && is_public) {
// When generating a public R class, we don't want Styleable to be part
// of the API. It is only emitted for documentation purposes.
class_def->GetCommentBuilder()->AppendComment("@doconly");
@@ -657,7 +657,7 @@ bool JavaClassGenerator::Generate(const StringPiece& package_name_to_generate,
if (out != nullptr) {
AppendJavaDocAnnotations(options_.javadoc_annotations, r_class.GetCommentBuilder());
- ClassDefinition::WriteJavaFile(&r_class, out_package_name, options_.use_final, out);
+ ClassDefinition::WriteJavaFile(&r_class, out_package_name, options_.use_final, !is_public, out);
}
return true;
}