summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser.cpp
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2015-05-13 21:42:57 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-05-13 21:43:00 +0000
commit4ee67bc7a7bb84da1c92dc08427f9737ff8252d6 (patch)
tree1cde9191650b0264f6f4e831a563bcadbecc848c /tools/aapt2/ResourceParser.cpp
parentae8fcaf4c320dbf68db7dc032269692806150d99 (diff)
parentdfa5e0705ff82f15e228ba076bc192893bcbe118 (diff)
Merge "AAPT2: Fix issue where @null was wrongly encoded" into mnc-dev
Diffstat (limited to 'tools/aapt2/ResourceParser.cpp')
-rw-r--r--tools/aapt2/ResourceParser.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 59915a2b1a36..13f916bfc8f3 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -193,18 +193,18 @@ std::unique_ptr<Reference> ResourceParser::tryParseReference(const StringPiece16
std::unique_ptr<BinaryPrimitive> ResourceParser::tryParseNullOrEmpty(const StringPiece16& str) {
StringPiece16 trimmedStr(util::trimWhitespace(str));
- uint32_t data = 0;
+ android::Res_value value = {};
if (trimmedStr == u"@null") {
- data = android::Res_value::DATA_NULL_UNDEFINED;
+ // TYPE_NULL with data set to 0 is interpreted by the runtime as an error.
+ // Instead we set the data type to TYPE_REFERENCE with a value of 0.
+ value.dataType = android::Res_value::TYPE_REFERENCE;
} else if (trimmedStr == u"@empty") {
- data = android::Res_value::DATA_NULL_EMPTY;
+ // TYPE_NULL with value of DATA_NULL_EMPTY is handled fine by the runtime.
+ value.dataType = android::Res_value::TYPE_NULL;
+ value.data = android::Res_value::DATA_NULL_EMPTY;
} else {
return {};
}
-
- android::Res_value value = {};
- value.dataType = android::Res_value::TYPE_NULL;
- value.data = data;
return util::make_unique<BinaryPrimitive>(value);
}