Add actor and name parsing for overlayable
Add parsing of two overlayable attributes:
name : The unnique identifying name of the overlayable set of resources
actor: The component responsible for enabling and disabling overlays
targeting the specified set of resources
Bug: 110869880
Bug: 119390855
Test: m -j aapt2_tests
Change-Id: Id42463e2b92b69034fb39cd29bc8606affb61ba7
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index e646f5b..eaf6a47 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -57,10 +57,27 @@
std::string comment;
};
-// Represents a declaration that a resource is overlayable at runtime.
struct Overlayable {
+ Overlayable() = default;
+ Overlayable(const android::StringPiece& name, const android::StringPiece& actor)
+ : name(name.to_string()), actor(actor.to_string()) {}
+ Overlayable(const android::StringPiece& name, const android::StringPiece& actor,
+ const Source& source)
+ : name(name.to_string()), actor(actor.to_string()), source(source ){}
+
+ static const char* kActorScheme;
+ std::string name;
+ std::string actor;
+ Source source;
+};
+
+// Represents a declaration that a resource is overlayable at runtime.
+struct OverlayableItem {
+ explicit OverlayableItem(const std::shared_ptr<Overlayable>& overlayable)
+ : overlayable(overlayable) {}
// Represents the types overlays that are allowed to overlay the resource.
+ typedef uint32_t PolicyFlags;
enum Policy : uint32_t {
kNone = 0x00,
@@ -80,11 +97,10 @@
kProductServices = 0x10
};
- typedef uint32_t PolicyFlags;
+ std::shared_ptr<Overlayable> overlayable;
PolicyFlags policies = Policy::kNone;
-
- Source source;
std::string comment;
+ Source source;
};
class ResourceConfigValue {
@@ -121,7 +137,7 @@
Maybe<AllowNew> allow_new;
// The declarations of this resource as overlayable for RROs
- Maybe<Overlayable> overlayable;
+ Maybe<OverlayableItem> overlayable_item;
// The resource's values for each configuration.
std::vector<std::unique_ptr<ResourceConfigValue>> values;
@@ -251,9 +267,9 @@
bool SetVisibilityWithIdMangled(const ResourceNameRef& name, const Visibility& visibility,
const ResourceId& res_id, IDiagnostics* diag);
- bool SetOverlayable(const ResourceNameRef& name, const Overlayable& overlayable,
+ bool SetOverlayable(const ResourceNameRef& name, const OverlayableItem& overlayable,
IDiagnostics *diag);
- bool SetOverlayableMangled(const ResourceNameRef& name, const Overlayable& overlayable,
+ bool SetOverlayableMangled(const ResourceNameRef& name, const OverlayableItem& overlayable,
IDiagnostics* diag);
bool SetAllowNew(const ResourceNameRef& name, const AllowNew& allow_new, IDiagnostics* diag);
@@ -328,7 +344,7 @@
bool SetAllowNewImpl(const ResourceNameRef& name, const AllowNew& allow_new,
NameValidator name_validator, IDiagnostics* diag);
- bool SetOverlayableImpl(const ResourceNameRef &name, const Overlayable &overlayable,
+ bool SetOverlayableImpl(const ResourceNameRef &name, const OverlayableItem& overlayable,
NameValidator name_validator, IDiagnostics *diag);
bool SetSymbolStateImpl(const ResourceNameRef& name, const ResourceId& res_id,