diff options
author | Scott Lobdell <slobdell@google.com> | 2021-04-08 03:01:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-04-08 03:01:43 +0000 |
commit | 702f04add003ce3e490a2f0bdff083a7e6f5979e (patch) | |
tree | dc1073e6063a647d0f20623ec9cc1c5f8a3d68af /tools/aapt2/format/binary/BinaryResourceParser.cpp | |
parent | a7b4f0495b55a4a61f2e7d47830805e9f143392f (diff) | |
parent | 70939ecb75ca298cc1212f614e2f7f2ceacc3488 (diff) |
Merge changes from topic "SP1A.210331.003" into s-keystone-qcom-dev
* changes:
Revert "Fixed an issue where the user would have no notifications on lockscreen"
Calling linkToDeath on binder in NRI constructor
Update framework from jetpack.
Improve permission enforcement in SoundTriggerService
Merge SP1A.210331.003
Diffstat (limited to 'tools/aapt2/format/binary/BinaryResourceParser.cpp')
-rw-r--r-- | tools/aapt2/format/binary/BinaryResourceParser.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/tools/aapt2/format/binary/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp index cccd9faa9b39..bfb8d5854d6d 100644 --- a/tools/aapt2/format/binary/BinaryResourceParser.cpp +++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp @@ -192,8 +192,7 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { std::u16string package_name = strcpy16_dtoh((const char16_t*)package_header->name, arraysize(package_header->name)); - ResourceTablePackage* package = - table_->CreatePackage(util::Utf16ToUtf8(package_name), static_cast<uint8_t>(package_id)); + ResourceTablePackage* package = table_->FindOrCreatePackage(util::Utf16ToUtf8(package_name)); if (!package) { diag_->Error(DiagMessage(source_) << "incompatible package '" << package_name << "' with ID " << package_id); @@ -232,13 +231,13 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { break; case android::RES_TABLE_TYPE_SPEC_TYPE: - if (!ParseTypeSpec(package, parser.chunk())) { + if (!ParseTypeSpec(package, parser.chunk(), package_id)) { return false; } break; case android::RES_TABLE_TYPE_TYPE: - if (!ParseType(package, parser.chunk())) { + if (!ParseType(package, parser.chunk(), package_id)) { return false; } break; @@ -276,7 +275,7 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { } bool BinaryResourceParser::ParseTypeSpec(const ResourceTablePackage* package, - const ResChunk_header* chunk) { + const ResChunk_header* chunk, uint8_t package_id) { if (type_pool_.getError() != NO_ERROR) { diag_->Error(DiagMessage(source_) << "missing type string pool"); return false; @@ -317,14 +316,14 @@ bool BinaryResourceParser::ParseTypeSpec(const ResourceTablePackage* package, const uint32_t* type_spec_flags = reinterpret_cast<const uint32_t*>( reinterpret_cast<uintptr_t>(type_spec) + util::DeviceToHost16(type_spec->header.headerSize)); for (size_t i = 0; i < entry_count; i++) { - ResourceId id(package->id.value_or_default(0x0), type_spec->id, static_cast<size_t>(i)); + ResourceId id(package_id, type_spec->id, static_cast<size_t>(i)); entry_type_spec_flags_[id] = util::DeviceToHost32(type_spec_flags[i]); } return true; } bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, - const ResChunk_header* chunk) { + const ResChunk_header* chunk, uint8_t package_id) { if (type_pool_.getError() != NO_ERROR) { diag_->Error(DiagMessage(source_) << "missing type string pool"); return false; @@ -354,13 +353,9 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, const std::string type_str = util::GetString(type_pool_, type->id - 1); 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; + diag_->Warn(DiagMessage(source_) + << "invalid type name '" << type_str << "' for type with ID " << type->id); + return true; } TypeVariant tv(type); @@ -372,7 +367,7 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, 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())); + const ResourceId res_id(package_id, type->id, static_cast<uint16_t>(it.index())); std::unique_ptr<Value> resource_value; if (entry->flags & ResTable_entry::FLAG_COMPLEX) { @@ -392,17 +387,13 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, return false; } - if (!table_->AddResourceWithIdMangled(name, res_id, config, {}, std::move(resource_value), - diag_)) { - return false; - } + NewResourceBuilder res_builder(name); + res_builder.SetValue(std::move(resource_value), config) + .SetId(res_id, OnIdConflict::CREATE_ENTRY) + .SetAllowMangled(true); if (entry->flags & ResTable_entry::FLAG_PUBLIC) { - Visibility visibility; - visibility.level = Visibility::Level::kPublic; - if (!table_->SetVisibilityWithIdMangled(name, visibility, res_id, diag_)) { - return false; - } + res_builder.SetVisibility(Visibility{Visibility::Level::kPublic}); // Erase the ID from the map once processed, so that we don't mark the same symbol more than // once. @@ -415,6 +406,10 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, if (cache_iter == id_index_.end()) { id_index_.insert({res_id, name}); } + + if (!table_->AddResource(res_builder.Build(), diag_)) { + return false; + } } return true; } @@ -472,7 +467,12 @@ bool BinaryResourceParser::ParseOverlayable(const ResChunk_header* chunk) { OverlayableItem overlayable_item(overlayable); overlayable_item.policies = policy_header->policy_flags; - if (!table_->SetOverlayable(iter->second, overlayable_item, diag_)) { + if (!table_->AddResource(NewResourceBuilder(iter->second) + .SetId(res_id, OnIdConflict::CREATE_ENTRY) + .SetOverlayable(std::move(overlayable_item)) + .SetAllowMangled(true) + .Build(), + diag_)) { return false; } } |