diff options
author | Daniel Norman <danielnorman@google.com> | 2020-08-31 12:05:49 -0700 |
---|---|---|
committer | Bill Peckham <bpeckham@google.com> | 2020-09-09 10:21:03 -0700 |
commit | 8abdf0e95a5d15a310b6df69d33a4510a0b44b4a (patch) | |
tree | f0c990be5370711e157b2e9e5ae746cb1af915b9 /tools/aapt2/java/JavaClassGenerator.cpp | |
parent | 93e6c963c3228074d0e0dd5f3f8d057d9bd11e05 (diff) | |
parent | 6997558ebbaa0c3e5708246807239f11e70ad35d (diff) |
Merge SP1A.200727.001
Change-Id: Ibb86a528ed692cde325705779c7fa57e4b4de682
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator.cpp')
-rw-r--r-- | tools/aapt2/java/JavaClassGenerator.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp index bb541fe2490b..f0f839d968d5 100644 --- a/tools/aapt2/java/JavaClassGenerator.cpp +++ b/tools/aapt2/java/JavaClassGenerator.cpp @@ -218,13 +218,10 @@ struct StyleableAttr { static bool operator<(const StyleableAttr& lhs, const StyleableAttr& rhs) { const ResourceId lhs_id = lhs.attr_ref->id.value_or_default(ResourceId(0)); const ResourceId rhs_id = rhs.attr_ref->id.value_or_default(ResourceId(0)); - if (lhs_id < rhs_id) { - return true; - } else if (lhs_id > rhs_id) { - return false; - } else { + if (lhs_id == rhs_id) { return lhs.attr_ref->name.value() < rhs.attr_ref->name.value(); } + return cmp_ids_dynamic_after_framework(lhs_id, rhs_id); } void JavaClassGenerator::ProcessStyleable(const ResourceNameRef& name, const ResourceId& id, @@ -604,6 +601,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 +611,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 +635,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 +654,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; } |