From 79f039689895f620d8dee5d3a58e63f8cca1ba3e Mon Sep 17 00:00:00 2001 From: Nicholas Lativy Date: Wed, 16 Jan 2019 16:19:09 +0000 Subject: 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 --- tools/aapt2/ResourceUtils.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tools/aapt2/ResourceUtils.cpp') 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 #include #include "android-base/stringprintf.h" @@ -503,6 +504,14 @@ Maybe 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 {}; } -- cgit v1.2.3-59-g8ed1b