Refactor overlayable policy
To make it easier to add the actor policy in a follow up CL,
move most of the policy handling to a central location.
The strings and transformation between strings and flags is
now handled in libidmap2policies, with libandroidfw
containing the single source of policy flags.
This also extracts all the test resource IDs into an R.h
so they can be swapped without having to edit a dozen files
each time.
Bug: 130563563
Test: m aapt2_tests idmapt2_tests and run from host test output
Test: atest libandroidfw_tests
Change-Id: Ie533c9cebf938215df7586f00c38763ae467e606
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 30ba1ae..93a7a31 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -36,6 +36,8 @@
#include <unordered_map>
#include <vector>
+using PolicyFlags = android::ResTable_overlayable_policy_header::PolicyFlags;
+
namespace aapt {
// The Public status of a resource.
@@ -75,36 +77,8 @@
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 = 0x00000000,
-
- // The resource can be overlaid by any overlay.
- kPublic = 0x00000001,
-
- // The resource can be overlaid by any overlay on the system partition.
- kSystem = 0x00000002,
-
- // The resource can be overlaid by any overlay on the vendor partition.
- kVendor = 0x00000004,
-
- // The resource can be overlaid by any overlay on the product partition.
- kProduct = 0x00000008,
-
- // The resource can be overlaid by any overlay signed with the same signature as its actor.
- kSignature = 0x00000010,
-
- // The resource can be overlaid by any overlay on the odm partition.
- kOdm = 0x00000020,
-
- // The resource can be overlaid by any overlay on the oem partition.
- kOem = 0x00000040,
- };
-
std::shared_ptr<Overlayable> overlayable;
- PolicyFlags policies = Policy::kNone;
+ PolicyFlags policies = PolicyFlags::NONE;
std::string comment;
Source source;
};