summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceTable.h
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-03-29 13:52:38 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-03-29 20:56:32 +0000
commitb1afa07745280c7a36077beda6293b69c6ba4ea2 (patch)
tree77483b34ca63be514c3ee1caa562c7fd503cd3da /tools/aapt2/ResourceTable.h
parent22ea35187f7d8a55ad7ede0d0e97be65b83801be (diff)
AAPT2: Allow arbitrary entry names with aapt2 optimize
Presumably, the apps build fine for the developers, so just feed the existing names through without validation. Validation still exists when building an app from source. Bug: 36051854 Change-Id: Idc64ee91b08dce67d3c28f3c5284a7afa1312df1 Test: run aapt2 optimize on the apks from b/36051854 and build aapt2_tests
Diffstat (limited to 'tools/aapt2/ResourceTable.h')
-rw-r--r--tools/aapt2/ResourceTable.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 6b69aaf02cbe..b0321214c6cc 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -113,8 +113,7 @@ class ResourceEntry {
const android::StringPiece& product);
ResourceConfigValue* FindOrCreateValue(const ConfigDescription& config,
const android::StringPiece& product);
- std::vector<ResourceConfigValue*> findAllValues(
- const ConfigDescription& config);
+ std::vector<ResourceConfigValue*> FindAllValues(const ConfigDescription& config);
std::vector<ResourceConfigValue*> FindValuesIf(
const std::function<bool(ResourceConfigValue*)>& f);
@@ -189,8 +188,7 @@ class ResourceTable {
* When a collision of resources occurs, this method decides which value to
* keep.
*/
- static CollisionResult ResolveValueCollision(Value* existing,
- Value* incoming);
+ static CollisionResult ResolveValueCollision(Value* existing, Value* incoming);
bool AddResource(const ResourceNameRef& name, const ConfigDescription& config,
const android::StringPiece& product, std::unique_ptr<Value> value,
@@ -274,20 +272,24 @@ class ResourceTable {
std::map<size_t, std::string> included_packages_;
private:
+ // The function type that validates a symbol name. Returns a non-empty StringPiece representing
+ // the offending character (which may be more than one byte in UTF-8). Returns an empty string
+ // if the name was valid.
+ using NameValidator = android::StringPiece(const android::StringPiece&);
+
ResourceTablePackage* FindOrCreatePackage(const android::StringPiece& name);
bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id,
const ConfigDescription& config, const android::StringPiece& product,
- std::unique_ptr<Value> value, const char* valid_chars,
+ std::unique_ptr<Value> value, NameValidator name_validator,
const CollisionResolverFunc& conflict_resolver, IDiagnostics* diag);
bool AddFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config,
const Source& source, const android::StringPiece& path, io::IFile* file,
- const char* valid_chars, IDiagnostics* diag);
+ NameValidator name_validator, IDiagnostics* diag);
bool SetSymbolStateImpl(const ResourceNameRef& name, const ResourceId& res_id,
- const Symbol& symbol, const char* valid_chars,
- IDiagnostics* diag);
+ const Symbol& symbol, NameValidator name_validator, IDiagnostics* diag);
DISALLOW_COPY_AND_ASSIGN(ResourceTable);
};