From cd78febeac2956525931b1f0f15ad507bec6a24c Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 18 Dec 2019 15:20:48 -0800 Subject: Recognize dynamic res ids as valid Shared libraries are assigned package id 0. Resource ids that start with 0x00 are not invalid. This change changes is_valid to accept dynamic resource ids and adds an is_valid_static method for when an id must have a non-zero package id. This also fixes an issue that made layouts in shared libraries that use internal attributes exclude compiled resource ids from the binay xml output. Bug: 146491000 Test: Build a shared library with a layout that uses app attributes as well as android attribute and verify that all attributes have assigned resource ids using `aapt2 dump xmltree` Change-Id: Ibc0407c610ffc98d7aaf233c37c065912ab0d516 --- tools/aapt2/ResourceValues.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/aapt2/ResourceValues.cpp') diff --git a/tools/aapt2/ResourceValues.cpp b/tools/aapt2/ResourceValues.cpp index 34b46c552e0c..4f0fa8ae29ba 100644 --- a/tools/aapt2/ResourceValues.cpp +++ b/tools/aapt2/ResourceValues.cpp @@ -117,7 +117,7 @@ bool Reference::Equals(const Value* value) const { bool Reference::Flatten(android::Res_value* out_value) const { const ResourceId resid = id.value_or_default(ResourceId(0)); - const bool dynamic = resid.is_valid_dynamic() && is_dynamic; + const bool dynamic = resid.is_valid() && is_dynamic; if (reference_type == Reference::Type::kResource) { if (dynamic) { @@ -159,7 +159,7 @@ void Reference::Print(std::ostream* out) const { *out << name.value(); } - if (id && id.value().is_valid_dynamic()) { + if (id && id.value().is_valid()) { if (name) { *out << " "; } @@ -196,7 +196,7 @@ static void PrettyPrintReferenceImpl(const Reference& ref, bool print_package, P printer->Print("/"); printer->Print(name.entry); } - } else if (ref.id && ref.id.value().is_valid_dynamic()) { + } else if (ref.id && ref.id.value().is_valid()) { printer->Print(ref.id.value().to_string()); } } -- cgit v1.2.3-59-g8ed1b