master designated for R. Update MAX_PLATFORM_VERSION, etc.

Test: aapt2_tests
Bug: 128934651
Change-Id: I179f7b92dcf65e77f039e6cd42d91bf5b1461e35
Merged-In: I179f7b92dcf65e77f039e6cd42d91bf5b1461e35
This commit is contained in:
Ryan Mitchell
2019-04-11 14:29:25 -07:00
committed by Dan Willemsen
parent ad5b4ba2a2
commit 3a60b9c4d2
3 changed files with 11 additions and 8 deletions

View File

@@ -497,9 +497,9 @@ Maybe<int> ParseSdkVersion(const StringPiece& str) {
}
// Try parsing the code name.
std::pair<StringPiece, int> entry = GetDevelopmentSdkCodeNameAndVersion();
if (entry.first == trimmed_str) {
return entry.second;
Maybe<int> entry = GetDevelopmentSdkCodeNameVersion(trimmed_str);
if (entry) {
return entry.value();
}
return {};
}

View File

@@ -18,15 +18,17 @@
#include <algorithm>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using android::StringPiece;
namespace aapt {
static const char* sDevelopmentSdkCodeName = "Q";
static ApiVersion sDevelopmentSdkLevel = 10000;
static const auto sDevelopmentSdkCodeNames = std::unordered_set<StringPiece>({
"Q", "R"
});
static const std::vector<std::pair<uint16_t, ApiVersion>> sAttrIdMap = {
{0x021c, 1},
@@ -72,8 +74,9 @@ ApiVersion FindAttributeSdkLevel(const ResourceId& id) {
return iter->second;
}
std::pair<StringPiece, ApiVersion> GetDevelopmentSdkCodeNameAndVersion() {
return std::make_pair(StringPiece(sDevelopmentSdkCodeName), sDevelopmentSdkLevel);
Maybe<ApiVersion> GetDevelopmentSdkCodeNameVersion(const StringPiece& code_name) {
return (sDevelopmentSdkCodeNames.find(code_name) == sDevelopmentSdkCodeNames.end())
? Maybe<ApiVersion>() : sDevelopmentSdkLevel;
}
} // namespace aapt

View File

@@ -57,7 +57,7 @@ enum : ApiVersion {
};
ApiVersion FindAttributeSdkLevel(const ResourceId& id);
std::pair<android::StringPiece, ApiVersion> GetDevelopmentSdkCodeNameAndVersion();
Maybe<ApiVersion> GetDevelopmentSdkCodeNameVersion(const android::StringPiece& code_name);
} // namespace aapt