summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceTable.h
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/ResourceTable.h
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/ResourceTable.h')
-rw-r--r--tools/aapt2/ResourceTable.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 3dd0a769d944..e646f5be43c7 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -57,27 +57,32 @@ struct AllowNew {
std::string comment;
};
-// Represents a declaration that a resource is overayable at runtime.
+// Represents a declaration that a resource is overlayable at runtime.
struct Overlayable {
+
// Represents the types overlays that are allowed to overlay the resource.
- enum class Policy {
+ enum Policy : uint32_t {
+ kNone = 0x00,
+
// The resource can be overlaid by any overlay.
- kPublic,
+ kPublic = 0x01,
// The resource can be overlaid by any overlay on the system partition.
- kSystem,
+ kSystem = 0x02,
// The resource can be overlaid by any overlay on the vendor partition.
- kVendor,
+ kVendor = 0x04,
// The resource can be overlaid by any overlay on the product partition.
- kProduct,
+ kProduct = 0x08,
// The resource can be overlaid by any overlay on the product services partition.
- kProductServices,
+ kProductServices = 0x10
};
- Maybe<Policy> policy;
+ typedef uint32_t PolicyFlags;
+ PolicyFlags policies = Policy::kNone;
+
Source source;
std::string comment;
};
@@ -116,7 +121,7 @@ class ResourceEntry {
Maybe<AllowNew> allow_new;
// The declarations of this resource as overlayable for RROs
- std::vector<Overlayable> overlayable_declarations;
+ Maybe<Overlayable> overlayable;
// The resource's values for each configuration.
std::vector<std::unique_ptr<ResourceConfigValue>> values;
@@ -246,9 +251,9 @@ class ResourceTable {
bool SetVisibilityWithIdMangled(const ResourceNameRef& name, const Visibility& visibility,
const ResourceId& res_id, IDiagnostics* diag);
- bool AddOverlayable(const ResourceNameRef& name, const Overlayable& overlayable,
- IDiagnostics* diag);
- bool AddOverlayableMangled(const ResourceNameRef& name, const Overlayable& overlayable,
+ bool SetOverlayable(const ResourceNameRef& name, const Overlayable& overlayable,
+ IDiagnostics *diag);
+ bool SetOverlayableMangled(const ResourceNameRef& name, const Overlayable& overlayable,
IDiagnostics* diag);
bool SetAllowNew(const ResourceNameRef& name, const AllowNew& allow_new, IDiagnostics* diag);
@@ -323,8 +328,8 @@ class ResourceTable {
bool SetAllowNewImpl(const ResourceNameRef& name, const AllowNew& allow_new,
NameValidator name_validator, IDiagnostics* diag);
- bool AddOverlayableImpl(const ResourceNameRef& name, const Overlayable& overlayable,
- NameValidator name_validator, IDiagnostics* diag);
+ bool SetOverlayableImpl(const ResourceNameRef &name, const Overlayable &overlayable,
+ NameValidator name_validator, IDiagnostics *diag);
bool SetSymbolStateImpl(const ResourceNameRef& name, const ResourceId& res_id,
const Visibility& symbol, NameValidator name_validator,