blob: e646f5be43c7a5f0b3888890356fe486c1ab6733 [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
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080060// Represents a declaration that a resource is overlayable at runtime.
Adam Lesinski71be7052017-12-12 16:48:07 -080061struct Overlayable {
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080062
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070063 // Represents the types overlays that are allowed to overlay the resource.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080064 enum Policy : uint32_t {
65 kNone = 0x00,
66
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070067 // The resource can be overlaid by any overlay.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080068 kPublic = 0x01,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070069
70 // The resource can be overlaid by any overlay on the system partition.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080071 kSystem = 0x02,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070072
73 // The resource can be overlaid by any overlay on the vendor partition.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080074 kVendor = 0x04,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070075
76 // The resource can be overlaid by any overlay on the product partition.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080077 kProduct = 0x08,
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070078
79 // The resource can be overlaid by any overlay on the product services partition.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080080 kProductServices = 0x10
Ryan Mitchelle4e989c2018-10-29 02:21:50 -070081 };
82
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -080083 typedef uint32_t PolicyFlags;
84 PolicyFlags policies = Policy::kNone;
85
Adam Lesinski71be7052017-12-12 16:48:07 -080086 Source source;
Adam Lesinskicacb28f2016-10-19 12:18:14 -070087 std::string comment;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080088};
89
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -080090class ResourceConfigValue {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070091 public:
Adam Lesinski71be7052017-12-12 16:48:07 -080092 // The configuration for which this value is defined.
Mårten Kongstad24c9aa62018-06-20 08:46:41 +020093 const android::ConfigDescription config;
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -080094
Adam Lesinski71be7052017-12-12 16:48:07 -080095 // The product for which this value is defined.
Adam Lesinskicacb28f2016-10-19 12:18:14 -070096 const std::string product;
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -080097
Adam Lesinski71be7052017-12-12 16:48:07 -080098 // The actual Value.
Adam Lesinskicacb28f2016-10-19 12:18:14 -070099 std::unique_ptr<Value> value;
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800100
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200101 ResourceConfigValue(const android::ConfigDescription& config, const android::StringPiece& product)
Adam Lesinskid5083f62017-01-16 15:07:21 -0800102 : config(config), product(product.to_string()) {}
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800103
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700104 private:
105 DISALLOW_COPY_AND_ASSIGN(ResourceConfigValue);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800106};
107
Adam Lesinski73bff1e2017-12-08 16:06:10 -0800108// Represents a resource entry, which may have varying values for each defined configuration.
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800109class ResourceEntry {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700110 public:
Adam Lesinski71be7052017-12-12 16:48:07 -0800111 // The name of the resource. Immutable, as this determines the order of this resource
112 // when doing lookups.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700113 const std::string name;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800114
Adam Lesinski71be7052017-12-12 16:48:07 -0800115 // The entry ID for this resource (the EEEE in 0xPPTTEEEE).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700116 Maybe<uint16_t> id;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800117
Adam Lesinski71be7052017-12-12 16:48:07 -0800118 // Whether this resource is public (and must maintain the same entry ID across builds).
119 Visibility visibility;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800120
Adam Lesinski71be7052017-12-12 16:48:07 -0800121 Maybe<AllowNew> allow_new;
122
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700123 // The declarations of this resource as overlayable for RROs
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800124 Maybe<Overlayable> overlayable;
Adam Lesinski71be7052017-12-12 16:48:07 -0800125
126 // The resource's values for each configuration.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700127 std::vector<std::unique_ptr<ResourceConfigValue>> values;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800128
Adam Lesinskid5083f62017-01-16 15:07:21 -0800129 explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {}
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800130
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200131 ResourceConfigValue* FindValue(const android::ConfigDescription& config);
Adam Lesinski34a16872018-02-23 16:18:10 -0800132
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200133 ResourceConfigValue* FindValue(const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800134 const android::StringPiece& product);
Adam Lesinski34a16872018-02-23 16:18:10 -0800135
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200136 ResourceConfigValue* FindOrCreateValue(const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800137 const android::StringPiece& product);
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200138 std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config);
Adam Lesinski34a16872018-02-23 16:18:10 -0800139
140 template <typename Func>
141 std::vector<ResourceConfigValue*> FindValuesIf(Func f) {
142 std::vector<ResourceConfigValue*> results;
143 for (auto& config_value : values) {
144 if (f(config_value.get())) {
145 results.push_back(config_value.get());
146 }
147 }
148 return results;
149 }
150
151 bool HasDefaultValue() const;
Adam Lesinski458b8772016-04-25 14:20:21 -0700152
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700153 private:
154 DISALLOW_COPY_AND_ASSIGN(ResourceEntry);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800155};
156
Adam Lesinski71be7052017-12-12 16:48:07 -0800157// Represents a resource type (eg. string, drawable, layout, etc.) containing resource entries.
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800158class ResourceTableType {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700159 public:
Adam Lesinski71be7052017-12-12 16:48:07 -0800160 // The logical type of resource (string, drawable, layout, etc.).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700161 const ResourceType type;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800162
Adam Lesinski71be7052017-12-12 16:48:07 -0800163 // The type ID for this resource (the TT in 0xPPTTEEEE).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700164 Maybe<uint8_t> id;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800165
Adam Lesinski71be7052017-12-12 16:48:07 -0800166 // Whether this type is public (and must maintain the same type ID across builds).
167 Visibility::Level visibility_level = Visibility::Level::kUndefined;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800168
Adam Lesinski71be7052017-12-12 16:48:07 -0800169 // List of resources for this type.
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700170 std::vector<std::unique_ptr<ResourceEntry>> entries;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800171
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700172 explicit ResourceTableType(const ResourceType type) : type(type) {}
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700173
Ryan Mitchell8d4ee972018-08-27 11:24:04 -0700174 ResourceEntry* FindEntry(const android::StringPiece& name,
175 Maybe<uint16_t> id = Maybe<uint16_t>());
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700176 ResourceEntry* FindOrCreateEntry(const android::StringPiece& name,
Ryan Mitchell8d4ee972018-08-27 11:24:04 -0700177 Maybe<uint16_t> id = Maybe<uint16_t>());
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800178
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700179 private:
180 DISALLOW_COPY_AND_ASSIGN(ResourceTableType);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700181};
182
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800183class ResourceTablePackage {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700184 public:
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700185 std::string name;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700186
Adam Lesinski71be7052017-12-12 16:48:07 -0800187 // The package ID (the PP in 0xPPTTEEEE).
188 Maybe<uint8_t> id;
189
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700190 std::vector<std::unique_ptr<ResourceTableType>> types;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700191
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700192 ResourceTablePackage() = default;
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700193 ResourceTableType* FindType(ResourceType type, Maybe<uint8_t> id = Maybe<uint8_t>());
194 ResourceTableType* FindOrCreateType(const ResourceType type,
195 Maybe<uint8_t> id = Maybe<uint8_t>());
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800196
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700197 private:
198 DISALLOW_COPY_AND_ASSIGN(ResourceTablePackage);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800199};
200
Adam Lesinski71be7052017-12-12 16:48:07 -0800201// The container and index for all resources defined for an app.
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800202class ResourceTable {
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700203 public:
204 ResourceTable() = default;
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700205 explicit ResourceTable(bool validate_resources) : validate_resources_(validate_resources) {}
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800206
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700207 enum class CollisionResult { kKeepBoth, kKeepOriginal, kConflict, kTakeNew };
Adam Lesinski5c3464c2016-08-24 16:03:48 -0700208
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700209 using CollisionResolverFunc = std::function<CollisionResult(Value*, Value*)>;
Adam Lesinski5c3464c2016-08-24 16:03:48 -0700210
Adam Lesinski71be7052017-12-12 16:48:07 -0800211 // When a collision of resources occurs, this method decides which value to keep.
Adam Lesinskib1afa072017-03-29 13:52:38 -0700212 static CollisionResult ResolveValueCollision(Value* existing, Value* incoming);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800213
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700214 // When a collision of resources occurs, this method keeps both values
215 static CollisionResult IgnoreCollision(Value* existing, Value* incoming);
216
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200217 bool AddResource(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800218 const android::StringPiece& product, std::unique_ptr<Value> value,
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700219 IDiagnostics* diag);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700220
Adam Lesinski71be7052017-12-12 16:48:07 -0800221 bool AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id,
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200222 const android::ConfigDescription& config,
223 const android::StringPiece& product, std::unique_ptr<Value> value,
224 IDiagnostics* diag);
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800225
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200226 bool AddFileReference(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800227 const Source& source, const android::StringPiece& path, IDiagnostics* diag);
Adam Lesinskifb48d292015-11-07 15:52:13 -0800228
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200229 bool AddFileReferenceMangled(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinski71be7052017-12-12 16:48:07 -0800230 const Source& source, const android::StringPiece& path,
231 io::IFile* file, IDiagnostics* diag);
Adam Lesinskie78fd612015-10-22 12:48:43 -0700232
Adam Lesinski71be7052017-12-12 16:48:07 -0800233 // Same as AddResource, but doesn't verify the validity of the name. This is used
234 // when loading resources from an existing binary resource table that may have mangled names.
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200235 bool AddResourceMangled(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinski71be7052017-12-12 16:48:07 -0800236 const android::StringPiece& product, std::unique_ptr<Value> value,
237 IDiagnostics* diag);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800238
Adam Lesinski71be7052017-12-12 16:48:07 -0800239 bool AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id,
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200240 const android::ConfigDescription& config,
Adam Lesinski71be7052017-12-12 16:48:07 -0800241 const android::StringPiece& product, std::unique_ptr<Value> value,
242 IDiagnostics* diag);
Adam Lesinski769de982015-04-10 19:43:55 -0700243
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700244 bool GetValidateResources();
245
Adam Lesinski71be7052017-12-12 16:48:07 -0800246 bool SetVisibility(const ResourceNameRef& name, const Visibility& visibility, IDiagnostics* diag);
247 bool SetVisibilityMangled(const ResourceNameRef& name, const Visibility& visibility,
248 IDiagnostics* diag);
249 bool SetVisibilityWithId(const ResourceNameRef& name, const Visibility& visibility,
250 const ResourceId& res_id, IDiagnostics* diag);
251 bool SetVisibilityWithIdMangled(const ResourceNameRef& name, const Visibility& visibility,
252 const ResourceId& res_id, IDiagnostics* diag);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800253
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800254 bool SetOverlayable(const ResourceNameRef& name, const Overlayable& overlayable,
255 IDiagnostics *diag);
256 bool SetOverlayableMangled(const ResourceNameRef& name, const Overlayable& overlayable,
Adam Lesinski71be7052017-12-12 16:48:07 -0800257 IDiagnostics* diag);
258
259 bool SetAllowNew(const ResourceNameRef& name, const AllowNew& allow_new, IDiagnostics* diag);
260 bool SetAllowNewMangled(const ResourceNameRef& name, const AllowNew& allow_new,
261 IDiagnostics* diag);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800262
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700263 struct SearchResult {
264 ResourceTablePackage* package;
265 ResourceTableType* type;
266 ResourceEntry* entry;
267 };
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700268
Adam Lesinski71be7052017-12-12 16:48:07 -0800269 Maybe<SearchResult> FindResource(const ResourceNameRef& name) const;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700270
Adam Lesinski71be7052017-12-12 16:48:07 -0800271 // Returns the package struct with the given name, or nullptr if such a package does not
272 // exist. The empty string is a valid package and typically is used to represent the
273 // 'current' package before it is known to the ResourceTable.
274 ResourceTablePackage* FindPackage(const android::StringPiece& name) const;
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800275
Adam Lesinski71be7052017-12-12 16:48:07 -0800276 ResourceTablePackage* FindPackageById(uint8_t id) const;
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800277
278 ResourceTablePackage* CreatePackage(const android::StringPiece& name, Maybe<uint8_t> id = {});
279
David Chaloupkae3c1a4a2018-01-18 13:44:36 +0000280 // Attempts to find a package having the specified name and ID. If not found, a new package
281 // of the specified parameters is created and returned.
282 ResourceTablePackage* CreatePackageAllowingDuplicateNames(const android::StringPiece& name,
283 const Maybe<uint8_t> id);
284
Shane Farmer0a5b2012017-06-22 12:24:12 -0700285 std::unique_ptr<ResourceTable> Clone() const;
286
Adam Lesinski71be7052017-12-12 16:48:07 -0800287 // The string pool used by this resource table. Values that reference strings must use
288 // this pool to create their strings.
289 // NOTE: `string_pool` must come before `packages` so that it is destroyed after.
290 // When `string_pool` references are destroyed (as they will be when `packages` is destroyed),
291 // they decrement a refCount, which would cause invalid memory access if the pool was already
292 // destroyed.
Adam Lesinskice5e56e2016-10-21 17:56:45 -0700293 StringPool string_pool;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800294
David Chaloupkae3c1a4a2018-01-18 13:44:36 +0000295 // The list of packages in this table, sorted alphabetically by package name and increasing
296 // package ID (missing ID being the lowest).
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700297 std::vector<std::unique_ptr<ResourceTablePackage>> packages;
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800298
Adam Lesinskiceb9b2f2017-02-16 12:05:42 -0800299 // Set of dynamic packages that this table may reference. Their package names get encoded
300 // into the resources.arsc along with their compile-time assigned IDs.
301 std::map<size_t, std::string> included_packages_;
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700302
303 private:
Adam Lesinskib1afa072017-03-29 13:52:38 -0700304 // The function type that validates a symbol name. Returns a non-empty StringPiece representing
305 // the offending character (which may be more than one byte in UTF-8). Returns an empty string
306 // if the name was valid.
307 using NameValidator = android::StringPiece(const android::StringPiece&);
308
Adam Lesinskid5083f62017-01-16 15:07:21 -0800309 ResourceTablePackage* FindOrCreatePackage(const android::StringPiece& name);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700310
Adam Lesinski71be7052017-12-12 16:48:07 -0800311 bool ValidateName(NameValidator validator, const ResourceNameRef& name, const Source& source,
312 IDiagnostics* diag);
313
Adam Lesinskice5e56e2016-10-21 17:56:45 -0700314 bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id,
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200315 const android::ConfigDescription& config,
316 const android::StringPiece& product, std::unique_ptr<Value> value,
317 NameValidator name_validator, const CollisionResolverFunc& conflict_resolver,
318 IDiagnostics* diag);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700319
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200320 bool AddFileReferenceImpl(const ResourceNameRef& name, const android::ConfigDescription& config,
Adam Lesinskid5083f62017-01-16 15:07:21 -0800321 const Source& source, const android::StringPiece& path, io::IFile* file,
Adam Lesinskib1afa072017-03-29 13:52:38 -0700322 NameValidator name_validator, IDiagnostics* diag);
Adam Lesinskie4bb9eb2016-02-12 22:18:51 -0800323
Adam Lesinski71be7052017-12-12 16:48:07 -0800324 bool SetVisibilityImpl(const ResourceNameRef& name, const Visibility& visibility,
325 const ResourceId& res_id, NameValidator name_validator,
326 IDiagnostics* diag);
327
328 bool SetAllowNewImpl(const ResourceNameRef& name, const AllowNew& allow_new,
329 NameValidator name_validator, IDiagnostics* diag);
330
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800331 bool SetOverlayableImpl(const ResourceNameRef &name, const Overlayable &overlayable,
332 NameValidator name_validator, IDiagnostics *diag);
Adam Lesinski71be7052017-12-12 16:48:07 -0800333
Adam Lesinskice5e56e2016-10-21 17:56:45 -0700334 bool SetSymbolStateImpl(const ResourceNameRef& name, const ResourceId& res_id,
Adam Lesinski71be7052017-12-12 16:48:07 -0800335 const Visibility& symbol, NameValidator name_validator,
336 IDiagnostics* diag);
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700337
Ryan Mitchell83a37ad2018-08-06 16:32:24 -0700338 // Controls whether the table validates resource names and prevents duplicate resource names
339 bool validate_resources_ = true;
340
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700341 DISALLOW_COPY_AND_ASSIGN(ResourceTable);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800342};
343
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700344} // namespace aapt
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800345
Adam Lesinskicacb28f2016-10-19 12:18:14 -0700346#endif // AAPT_RESOURCE_TABLE_H