blob: 30ba1aed25f891fe0e8123a31b49048e27ad9121 [file] [log] [blame]
Adam Lesinski6f6ceb72014-11-14 14:48:12 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef AAPT_RESOURCE_TABLE_H
18#define AAPT_RESOURCE_TABLE_H
19
Adam Lesinski1ab598f2015-08-14 14:26:04 -070020#include "Diagnostics.h"
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080021#include "Resource.h"
22#include "ResourceValues.h"
23#include "Source.h"
24#include "StringPool.h"
Adam Lesinski355f2852016-02-13 20:26:45 -080025#include "io/File.h"
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080026
Adam Lesinskid5083f62017-01-16 15:07:21 -080027#include "android-base/macros.h"
Mårten Kongstad24c9aa62018-06-20 08:46:41 +020028#include "androidfw/ConfigDescription.h"
Adam Lesinskid5083f62017-01-16 15:07:21 -080029#include "androidfw/StringPiece.h"
30
Adam Lesinski458b8772016-04-25 14:20:21 -070031#include <functional>
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -080032#include <map>
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080033#include <memory>
34#include <string>
35#include <tuple>
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -080036#include <unordered_map>
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080037#include <vector>
38
39namespace aapt {
40
Adam Lesinski71be7052017-12-12 16:48:07 -080041// The Public status of a resource.
42struct Visibility {
43 enum class Level {
44 kUndefined,
45 kPrivate,
46 kPublic,
47 };
48
49 Level level = Level::kUndefined;
50 Source source;
51 std::string comment;
Adam Lesinski9e10ac72015-10-16 14:37:48 -070052};
53
Adam Lesinski71be7052017-12-12 16:48:07 -080054// Represents <add-resource> in an overlay.
55struct AllowNew {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070056 Source source;
Adam Lesinski71be7052017-12-12 16:48:07 -080057 std::string comment;
58};
Adam Lesinski4488f1c2017-05-26 17:33:38 -070059
Adam Lesinski71be7052017-12-12 16:48:07 -080060struct Overlayable {
Ryan Mitchell54237ff2018-12-13 15:44:29 -080061 Overlayable() = default;
62 Overlayable(const android::StringPiece& name, const android::StringPiece& actor)
63 : name(name.to_string()), actor(actor.to_string()) {}
64 Overlayable(const android::StringPiece& name, const android::StringPiece& actor,
65 const Source& source)
66 : name(name.to_string()), actor(actor.to_string()), source(source ){}
67
68 static const char* kActorScheme;
69 std::string name;
70 std::string actor;
71 Source source;
72};
73
74// Represents a declaration that a resource is overlayable at runtime.
75struct OverlayableItem {
76 explicit OverlayableItem(const std::shared_ptr<Overlayable>& overlayable)
77 : overlayable(overlayable) {}
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080078
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070079 // Represents the types overlays that are allowed to overlay the resource.
Ryan Mitchell54237ff2018-12-13 15:44:29 -080080 typedef uint32_t PolicyFlags;
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080081 enum Policy : uint32_t {
Ryan Mitchell939df092019-04-09 17:13:50 -070082 kNone = 0x00000000,
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080083
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070084 // The resource can be overlaid by any overlay.
Ryan Mitchell939df092019-04-09 17:13:50 -070085 kPublic = 0x00000001,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070086
87 // The resource can be overlaid by any overlay on the system partition.
Ryan Mitchell939df092019-04-09 17:13:50 -070088 kSystem = 0x00000002,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070089
90 // The resource can be overlaid by any overlay on the vendor partition.
Ryan Mitchell939df092019-04-09 17:13:50 -070091 kVendor = 0x00000004,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070092
93 // The resource can be overlaid by any overlay on the product partition.
Ryan Mitchell939df092019-04-09 17:13:50 -070094 kProduct = 0x00000008,
Winsonb2d7f532019-02-04 16:32:43 -080095
96 // The resource can be overlaid by any overlay signed with the same signature as its actor.
Ryan Mitchell939df092019-04-09 17:13:50 -070097 kSignature = 0x00000010,
98
99 // The resource can be overlaid by any overlay on the odm partition.
100 kOdm = 0x00000020,
101
102 // The resource can be overlaid by any overlay on the oem partition.
103 kOem = 0x00000040,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700104 };
105
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800106 std::shared_ptr<Overlayable> overlayable;
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800107 PolicyFlags policies = Policy::kNone;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700108 std::string comment;
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800109 Source source;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800110};
111
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800112class ResourceConfigValue {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700113 public:
Adam Lesinski71be7052017-12-12 16:48:07 -0800114 // The configuration for which this value is defined.
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200115 const android::ConfigDescription config;
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800116
Adam Lesinski71be7052017-12-12 16:48:07 -0800117 // The product for which this value is defined.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700118 const std::string product;
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800119
Adam Lesinski71be7052017-12-12 16:48:07 -0800120 // The actual Value.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700121 std::unique_ptr<Value> value;
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800122
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200123 ResourceConfigValue(const android::ConfigDescription& config, const android::StringPiece& product)
Adam Lesinskid5083f62017-01-16 15:07:21 -0800124 : config(config), product(product.to_string()) {}
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800125
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700126 private:
127 DISALLOW_COPY_AND_ASSIGN(ResourceConfigValue);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800128};
129
Adam Lesinski73bff1e2017-12-08 16:06:10 -0800130// Represents a resource entry, which may have varying values for each defined configuration.
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800131class ResourceEntry {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700132 public:
Adam Lesinski71be7052017-12-12 16:48:07 -0800133 // The name of the resource. Immutable, as this determines the order of this resource
134 // when doing lookups.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700135 const std::string name;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800136
Adam Lesinski71be7052017-12-12 16:48:07 -0800137 // The entry ID for this resource (the EEEE in 0xPPTTEEEE).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700138 Maybe<uint16_t> id;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800139
Adam Lesinski71be7052017-12-12 16:48:07 -0800140 // Whether this resource is public (and must maintain the same entry ID across builds).
141 Visibility visibility;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800142
Adam Lesinski71be7052017-12-12 16:48:07 -0800143 Maybe<AllowNew> allow_new;
144
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700145 // The declarations of this resource as overlayable for RROs
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800146 Maybe<OverlayableItem> overlayable_item;
Adam Lesinski71be7052017-12-12 16:48:07 -0800147
148 // The resource's values for each configuration.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700149 std::vector<std::unique_ptr<ResourceConfigValue>> values;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800150
Adam Lesinskid5083f62017-01-16 15:07:21 -0800151 explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {}
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800152
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200153 ResourceConfigValue* FindValue(const android::ConfigDescription& config);
Adam Lesinski34a16872018-02-23 16:18:10 -0800154
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200155 ResourceConfigValue* FindValue(const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800156 const android::StringPiece& product);
Adam Lesinski34a16872018-02-23 16:18:10 -0800157
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200158 ResourceConfigValue* FindOrCreateValue(const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800159 const android::StringPiece& product);
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200160 std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config);
Adam Lesinski34a16872018-02-23 16:18:10 -0800161
162 template <typename Func>
163 std::vector<ResourceConfigValue*> FindValuesIf(Func f) {
164 std::vector<ResourceConfigValue*> results;
165 for (auto& config_value : values) {
166 if (f(config_value.get())) {
167 results.push_back(config_value.get());
168 }
169 }
170 return results;
171 }
172
173 bool HasDefaultValue() const;
Adam Lesinski458b8772016-04-25 14:20:21 -0700174
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700175 private:
176 DISALLOW_COPY_AND_ASSIGN(ResourceEntry);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800177};
178
Adam Lesinski71be7052017-12-12 16:48:07 -0800179// Represents a resource type (eg. string, drawable, layout, etc.) containing resource entries.
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800180class ResourceTableType {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700181 public:
Adam Lesinski71be7052017-12-12 16:48:07 -0800182 // The logical type of resource (string, drawable, layout, etc.).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700183 const ResourceType type;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800184
Adam Lesinski71be7052017-12-12 16:48:07 -0800185 // The type ID for this resource (the TT in 0xPPTTEEEE).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700186 Maybe<uint8_t> id;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800187
Adam Lesinski71be7052017-12-12 16:48:07 -0800188 // Whether this type is public (and must maintain the same type ID across builds).
189 Visibility::Level visibility_level = Visibility::Level::kUndefined;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800190
Adam Lesinski71be7052017-12-12 16:48:07 -0800191 // List of resources for this type.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700192 std::vector<std::unique_ptr<ResourceEntry>> entries;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800193
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700194 explicit ResourceTableType(const ResourceType type) : type(type) {}
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700195
Ryan Mitchell8d4ee972018-08-27 11:24:04 -0700196 ResourceEntry* FindEntry(const android::StringPiece& name,
197 Maybe<uint16_t> id = Maybe<uint16_t>());
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700198 ResourceEntry* FindOrCreateEntry(const android::StringPiece& name,
Ryan Mitchell8d4ee972018-08-27 11:24:04 -0700199 Maybe<uint16_t> id = Maybe<uint16_t>());
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800200
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700201 private:
202 DISALLOW_COPY_AND_ASSIGN(ResourceTableType);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700203};
204
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800205class ResourceTablePackage {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700206 public:
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700207 std::string name;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700208
Adam Lesinski71be7052017-12-12 16:48:07 -0800209 // The package ID (the PP in 0xPPTTEEEE).
210 Maybe<uint8_t> id;
211
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700212 std::vector<std::unique_ptr<ResourceTableType>> types;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700213
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700214 ResourceTablePackage() = default;
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700215 ResourceTableType* FindType(ResourceType type, Maybe<uint8_t> id = Maybe<uint8_t>());
216 ResourceTableType* FindOrCreateType(const ResourceType type,
217 Maybe<uint8_t> id = Maybe<uint8_t>());
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800218
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700219 private:
220 DISALLOW_COPY_AND_ASSIGN(ResourceTablePackage);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800221};
222
Adam Lesinski71be7052017-12-12 16:48:07 -0800223// The container and index for all resources defined for an app.
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800224class ResourceTable {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700225 public:
226 ResourceTable() = default;
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700227 explicit ResourceTable(bool validate_resources) : validate_resources_(validate_resources) {}
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800228
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700229 enum class CollisionResult { kKeepBoth, kKeepOriginal, kConflict, kTakeNew };
Adam Lesinski5c3464c2016-08-24 16:03:48 -0700230
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700231 using CollisionResolverFunc = std::function<CollisionResult(Value*, Value*)>;
Adam Lesinski5c3464c2016-08-24 16:03:48 -0700232
Adam Lesinski71be7052017-12-12 16:48:07 -0800233 // When a collision of resources occurs, this method decides which value to keep.
Adam Lesinskib1afa072017-03-29 13:52:38 -0700234 static CollisionResult ResolveValueCollision(Value* existing, Value* incoming);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800235
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700236 // When a collision of resources occurs, this method keeps both values
237 static CollisionResult IgnoreCollision(Value* existing, Value* incoming);
238
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200239 bool AddResource(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800240 const android::StringPiece& product, std::unique_ptr<Value> value,
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700241 IDiagnostics* diag);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700242
Adam Lesinski71be7052017-12-12 16:48:07 -0800243 bool AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id,
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200244 const android::ConfigDescription& config,
245 const android::StringPiece& product, std::unique_ptr<Value> value,
246 IDiagnostics* diag);
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800247
Adam Lesinski71be7052017-12-12 16:48:07 -0800248 // Same as AddResource, but doesn't verify the validity of the name. This is used
249 // when loading resources from an existing binary resource table that may have mangled names.
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200250 bool AddResourceMangled(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinski71be7052017-12-12 16:48:07 -0800251 const android::StringPiece& product, std::unique_ptr<Value> value,
252 IDiagnostics* diag);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800253
Adam Lesinski71be7052017-12-12 16:48:07 -0800254 bool AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id,
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200255 const android::ConfigDescription& config,
Adam Lesinski71be7052017-12-12 16:48:07 -0800256 const android::StringPiece& product, std::unique_ptr<Value> value,
257 IDiagnostics* diag);
Adam Lesinski769de982015-04-10 19:43:55 -0700258
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700259 bool GetValidateResources();
260
Adam Lesinski71be7052017-12-12 16:48:07 -0800261 bool SetVisibility(const ResourceNameRef& name, const Visibility& visibility, IDiagnostics* diag);
Adam Lesinski71be7052017-12-12 16:48:07 -0800262 bool SetVisibilityWithId(const ResourceNameRef& name, const Visibility& visibility,
263 const ResourceId& res_id, IDiagnostics* diag);
264 bool SetVisibilityWithIdMangled(const ResourceNameRef& name, const Visibility& visibility,
265 const ResourceId& res_id, IDiagnostics* diag);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800266
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800267 bool SetOverlayable(const ResourceNameRef& name, const OverlayableItem& overlayable,
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800268 IDiagnostics *diag);
Adam Lesinski71be7052017-12-12 16:48:07 -0800269
270 bool SetAllowNew(const ResourceNameRef& name, const AllowNew& allow_new, IDiagnostics* diag);
271 bool SetAllowNewMangled(const ResourceNameRef& name, const AllowNew& allow_new,
272 IDiagnostics* diag);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800273
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700274 struct SearchResult {
275 ResourceTablePackage* package;
276 ResourceTableType* type;
277 ResourceEntry* entry;
278 };
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700279
Adam Lesinski71be7052017-12-12 16:48:07 -0800280 Maybe<SearchResult> FindResource(const ResourceNameRef& name) const;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700281
Adam Lesinski71be7052017-12-12 16:48:07 -0800282 // Returns the package struct with the given name, or nullptr if such a package does not
283 // exist. The empty string is a valid package and typically is used to represent the
284 // 'current' package before it is known to the ResourceTable.
285 ResourceTablePackage* FindPackage(const android::StringPiece& name) const;
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800286
Adam Lesinski71be7052017-12-12 16:48:07 -0800287 ResourceTablePackage* FindPackageById(uint8_t id) const;
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800288
289 ResourceTablePackage* CreatePackage(const android::StringPiece& name, Maybe<uint8_t> id = {});
290
David Chaloupkae3c1a4a2018-01-18 13:44:36 +0000291 // Attempts to find a package having the specified name and ID. If not found, a new package
292 // of the specified parameters is created and returned.
293 ResourceTablePackage* CreatePackageAllowingDuplicateNames(const android::StringPiece& name,
294 const Maybe<uint8_t> id);
295
Shane Farmer0a5b2012017-06-22 12:24:12 -0700296 std::unique_ptr<ResourceTable> Clone() const;
297
Adam Lesinski71be7052017-12-12 16:48:07 -0800298 // The string pool used by this resource table. Values that reference strings must use
299 // this pool to create their strings.
300 // NOTE: `string_pool` must come before `packages` so that it is destroyed after.
301 // When `string_pool` references are destroyed (as they will be when `packages` is destroyed),
302 // they decrement a refCount, which would cause invalid memory access if the pool was already
303 // destroyed.
Adam Lesinskice5e56e2016-10-21 17:56:45 -0700304 StringPool string_pool;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800305
David Chaloupkae3c1a4a2018-01-18 13:44:36 +0000306 // The list of packages in this table, sorted alphabetically by package name and increasing
307 // package ID (missing ID being the lowest).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700308 std::vector<std::unique_ptr<ResourceTablePackage>> packages;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800309
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800310 // Set of dynamic packages that this table may reference. Their package names get encoded
311 // into the resources.arsc along with their compile-time assigned IDs.
312 std::map<size_t, std::string> included_packages_;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700313
314 private:
Adam Lesinskib1afa072017-03-29 13:52:38 -0700315 // The function type that validates a symbol name. Returns a non-empty StringPiece representing
316 // the offending character (which may be more than one byte in UTF-8). Returns an empty string
317 // if the name was valid.
318 using NameValidator = android::StringPiece(const android::StringPiece&);
319
Adam Lesinskid5083f62017-01-16 15:07:21 -0800320 ResourceTablePackage* FindOrCreatePackage(const android::StringPiece& name);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700321
Adam Lesinski71be7052017-12-12 16:48:07 -0800322 bool ValidateName(NameValidator validator, const ResourceNameRef& name, const Source& source,
323 IDiagnostics* diag);
324
Adam Lesinskice5e56e2016-10-21 17:56:45 -0700325 bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id,
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200326 const android::ConfigDescription& config,
327 const android::StringPiece& product, std::unique_ptr<Value> value,
328 NameValidator name_validator, const CollisionResolverFunc& conflict_resolver,
329 IDiagnostics* diag);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700330
Adam Lesinski71be7052017-12-12 16:48:07 -0800331 bool SetVisibilityImpl(const ResourceNameRef& name, const Visibility& visibility,
332 const ResourceId& res_id, NameValidator name_validator,
333 IDiagnostics* diag);
334
335 bool SetAllowNewImpl(const ResourceNameRef& name, const AllowNew& allow_new,
336 NameValidator name_validator, IDiagnostics* diag);
337
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800338 bool SetOverlayableImpl(const ResourceNameRef &name, const OverlayableItem& overlayable,
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800339 NameValidator name_validator, IDiagnostics *diag);
Adam Lesinski71be7052017-12-12 16:48:07 -0800340
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700341 // Controls whether the table validates resource names and prevents duplicate resource names
342 bool validate_resources_ = true;
343
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700344 DISALLOW_COPY_AND_ASSIGN(ResourceTable);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800345};
346
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700347} // namespace aapt
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800348
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700349#endif // AAPT_RESOURCE_TABLE_H