diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-09-17 17:52:13 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-17 17:52:13 +0000 |
commit | e0f44eb6e772e9a5c5d21c14c758f06295f6413b (patch) | |
tree | 065c6d5ec067accaea5857a6e65321ac329adcf6 /tools | |
parent | bf6a120aaaef4b9589db75278961ddcd8846fc57 (diff) | |
parent | 701a7fe39d30509a9a6bc4e612fe93166a5cdbd3 (diff) |
Merge "Ignore resources from unknown types"
Diffstat (limited to 'tools')
-rw-r--r-- | tools/aapt2/Resource.cpp | 2 | ||||
-rw-r--r-- | tools/aapt2/Resource.h | 5 | ||||
-rw-r--r-- | tools/aapt2/format/binary/BinaryResourceParser.cpp | 21 |
3 files changed, 10 insertions, 18 deletions
diff --git a/tools/aapt2/Resource.cpp b/tools/aapt2/Resource.cpp index ae01170a6894..b78f48ce7f17 100644 --- a/tools/aapt2/Resource.cpp +++ b/tools/aapt2/Resource.cpp @@ -96,8 +96,6 @@ StringPiece to_string(ResourceType type) { return "styleable"; case ResourceType::kTransition: return "transition"; - case ResourceType::kUnknown: - return "unknown"; case ResourceType::kXml: return "xml"; } diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h index c49c370bcc44..4e051a37f3ed 100644 --- a/tools/aapt2/Resource.h +++ b/tools/aapt2/Resource.h @@ -66,11 +66,6 @@ enum class ResourceType { kStyle, kStyleable, kTransition, - - // Not a parsed type. It is only used when loading resource tables that may have modified type - // names - kUnknown, - kXml, }; diff --git a/tools/aapt2/format/binary/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp index f362744c0942..cccd9faa9b39 100644 --- a/tools/aapt2/format/binary/BinaryResourceParser.cpp +++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp @@ -352,15 +352,15 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, config.copyFromDtoH(type->config); const std::string type_str = util::GetString(type_pool_, type->id - 1); - - // Be lenient on the name of the type if the table is lenient on resource validation. - auto parsed_type = ResourceType::kUnknown; - if (const ResourceType* parsed = ParseResourceType(type_str)) { - parsed_type = *parsed; - } else if (table_->GetValidateResources()) { - diag_->Error(DiagMessage(source_) << "invalid type name '" << type_str << "' for type with ID " - << (int) type->id); - return false; + const ResourceType* parsed_type = ParseResourceType(type_str); + if (!parsed_type) { + // Be lenient on the name of the type if the table is lenient on resource validation. + bool log_error = table_->GetValidateResources(); + if (log_error) { + diag_->Error(DiagMessage(source_) << "invalid type name '" << type_str + << "' for type with ID " << type->id); + } + return !log_error; } TypeVariant tv(type); @@ -370,9 +370,8 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, continue; } - const ResourceName name(package->name, parsed_type, + const ResourceName name(package->name, *parsed_type, util::GetString(key_pool_, util::DeviceToHost32(entry->key.index))); - const ResourceId res_id(package->id.value(), type->id, static_cast<uint16_t>(it.index())); std::unique_ptr<Value> resource_value; |