summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils.cpp
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-01-16 23:24:10 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-16 23:24:10 +0000
commit54938a0534b2dfdc98a3113eadacb5196929577c (patch)
tree9ae0b075c5f8209ccf7527f2f232d7320e6b464f /tools/aapt2/ResourceUtils.cpp
parent46c2a56f6d21bed16a75f378de6756b3e4952ef4 (diff)
parent79f039689895f620d8dee5d3a58e63f8cca1ba3e (diff)
Merge "AAPT2: Add support for parsing codeNames with fingerprints."
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 {};
}