summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceTable.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-05-26 17:33:38 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-05-26 17:38:34 -0700
commit4488f1c74a0f7df09f2b201f7caa228d729e8389 (patch)
tree84b28ff7c770f906f0a58cf280ec28ecc3a58f68 /tools/aapt2/ResourceTable.cpp
parent2354b568379fe31ba4e774f7a92d4c685a60a2ab (diff)
AAPT2: Fix <add-resource> tag for overlays
Bug: 38355988 Test: make aapt2_tests Change-Id: Iea8887f55f8ceb2c15bd963405fd132916173c0c
Diffstat (limited to 'tools/aapt2/ResourceTable.cpp')
-rw-r--r--tools/aapt2/ResourceTable.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp
index 1947628e9267..168004f0b721 100644
--- a/tools/aapt2/ResourceTable.cpp
+++ b/tools/aapt2/ResourceTable.cpp
@@ -440,8 +440,7 @@ bool ResourceTable::AddResourceImpl(const ResourceNameRef& name, const ResourceI
return true;
}
-bool ResourceTable::SetSymbolState(const ResourceNameRef& name,
- const ResourceId& res_id,
+bool ResourceTable::SetSymbolState(const ResourceNameRef& name, const ResourceId& res_id,
const Symbol& symbol, IDiagnostics* diag) {
return SetSymbolStateImpl(name, res_id, symbol, ValidateName, diag);
}
@@ -489,8 +488,7 @@ bool ResourceTable::SetSymbolStateImpl(const ResourceNameRef& name, const Resour
diag->Error(DiagMessage(symbol.source)
<< "trying to add resource '" << name << "' with ID " << res_id
<< " but resource already has ID "
- << ResourceId(package->id.value(), type->id.value(),
- entry->id.value()));
+ << ResourceId(package->id.value(), type->id.value(), entry->id.value()));
return false;
}
@@ -505,6 +503,11 @@ bool ResourceTable::SetSymbolStateImpl(const ResourceNameRef& name, const Resour
type->symbol_status.state = SymbolState::kPublic;
}
+ if (symbol.allow_new) {
+ // This symbol can be added as a new resource when merging (if it belongs to an overlay).
+ entry->symbol_status.allow_new = true;
+ }
+
if (symbol.state == SymbolState::kUndefined &&
entry->symbol_status.state != SymbolState::kUndefined) {
// We can't undefine a symbol (remove its visibility). Ignore.
@@ -517,7 +520,10 @@ bool ResourceTable::SetSymbolStateImpl(const ResourceNameRef& name, const Resour
return true;
}
- entry->symbol_status = std::move(symbol);
+ // This symbol definition takes precedence, replace.
+ entry->symbol_status.state = symbol.state;
+ entry->symbol_status.source = symbol.source;
+ entry->symbol_status.comment = symbol.comment;
return true;
}