summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils.cpp
diff options
context:
space:
mode:
authorNicholas Lativy <nlativy@google.com>2019-01-16 16:19:09 +0000
committerNicholas Lativy <nlativy@google.com>2019-01-16 16:49:31 +0000
commit79f039689895f620d8dee5d3a58e63f8cca1ba3e (patch)
treeb32eea286726171e5cc9bcff40bc9b7355942120 /tools/aapt2/ResourceUtils.cpp
parentf8e7ff917512017baf1fff7b2a9efd533fec78a5 (diff)
AAPT2: Add support for parsing codeNames with fingerprints.
In addition to supporting manifest declared codenames of the form "[codename]", also support codenames of the form "[codename].[fingerprint]". Matches the behaviour of PackageParser as of ag/6056697. Test: ResourceUtils_test Change-Id: I814330eba9d383e4549e35da791fcfa9bd0cdf57
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r--tools/aapt2/ResourceUtils.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp
index c6f91527c91c..ab4805f626a5 100644
--- a/tools/aapt2/ResourceUtils.cpp
+++ b/tools/aapt2/ResourceUtils.cpp
@@ -16,6 +16,7 @@
#include "ResourceUtils.h"
+#include <algorithm>
#include <sstream>
#include "android-base/stringprintf.h"
@@ -503,6 +504,14 @@ Maybe<int> ParseSdkVersion(const StringPiece& str) {
if (entry.first == trimmed_str) {
return entry.second;
}
+
+ // Try parsing codename from "[codename].[preview_sdk_fingerprint]" value.
+ const StringPiece::const_iterator begin = std::begin(trimmed_str);
+ const StringPiece::const_iterator end = std::end(trimmed_str);
+ const StringPiece::const_iterator codename_end = std::find(begin, end, '.');
+ if (codename_end != end && entry.first == trimmed_str.substr(begin, codename_end)) {
+ return entry.second;
+ }
return {};
}