summaryrefslogtreecommitdiff
path: root/tools/aapt2/format/binary/BinaryResourceParser.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2018-11-16 11:21:41 -0800
committerRyan Mitchell <rtmitchell@google.com>2018-12-11 13:48:45 -0800
commit1bb1fe068a7e719711963c3cf3a50209e083a17f (patch)
tree70a6d9fbaa6e7f03626b92d345f73b48fcc3fa4a /tools/aapt2/format/binary/BinaryResourceParser.cpp
parentc622083df99a87afef8348dd8e4bdfecf3050d94 (diff)
Refactor policy parsing
This change removes the ability for an overlayable resource to be defined in multiple policy blocks within the same overlayable. This change also changes aapt2 to use a bit mask to keep track of the parsed policies. Bug: 110869880 Bug: 120298168 Test: aapt2_tests Change-Id: Ie26cd913f94a16c0b312f222bccfa48f62feceaa
Diffstat (limited to 'tools/aapt2/format/binary/BinaryResourceParser.cpp')
-rw-r--r--tools/aapt2/format/binary/BinaryResourceParser.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/tools/aapt2/format/binary/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp
index df0daebe8453..61ebd4ee26ca 100644
--- a/tools/aapt2/format/binary/BinaryResourceParser.cpp
+++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp
@@ -441,25 +441,25 @@ bool BinaryResourceParser::ParseOverlayable(const ResChunk_header* chunk) {
const ResTable_overlayable_policy_header* policy_header =
ConvertTo<ResTable_overlayable_policy_header>(parser.chunk());
- std::vector<Overlayable::Policy> policies;
+ Overlayable::PolicyFlags policies = Overlayable::Policy::kNone;
if (policy_header->policy_flags & ResTable_overlayable_policy_header::POLICY_PUBLIC) {
- policies.push_back(Overlayable::Policy::kPublic);
+ policies |= Overlayable::Policy::kPublic;
}
if (policy_header->policy_flags
& ResTable_overlayable_policy_header::POLICY_SYSTEM_PARTITION) {
- policies.push_back(Overlayable::Policy::kSystem);
+ policies |= Overlayable::Policy::kSystem;
}
if (policy_header->policy_flags
& ResTable_overlayable_policy_header::POLICY_VENDOR_PARTITION) {
- policies.push_back(Overlayable::Policy::kVendor);
+ policies |= Overlayable::Policy::kVendor;
}
if (policy_header->policy_flags
& ResTable_overlayable_policy_header::POLICY_PRODUCT_PARTITION) {
- policies.push_back(Overlayable::Policy::kProduct);
+ policies |= Overlayable::Policy::kProduct;
}
if (policy_header->policy_flags
& ResTable_overlayable_policy_header::POLICY_PRODUCT_SERVICES_PARTITION) {
- policies.push_back(Overlayable::Policy::kProductServices);
+ policies |= Overlayable::Policy::kProductServices;
}
const ResTable_ref* const ref_begin = reinterpret_cast<const ResTable_ref*>(
@@ -478,13 +478,11 @@ bool BinaryResourceParser::ParseOverlayable(const ResChunk_header* chunk) {
return false;
}
- for (Overlayable::Policy policy : policies) {
- Overlayable overlayable;
- overlayable.source = source_.WithLine(0);
- overlayable.policy = policy;
- if (!table_->AddOverlayable(iter->second, overlayable, diag_)) {
- return false;
- }
+ Overlayable overlayable{};
+ overlayable.source = source_.WithLine(0);
+ overlayable.policies = policies;
+ if (!table_->SetOverlayable(iter->second, overlayable, diag_)) {
+ return false;
}
}
}