Merge changes from topic "R"

am: 39a77f1951

Change-Id: I32a27fb346e236a6836d4c139cac2fb4cfdb733d
This commit is contained in:
Dan Willemsen
2019-04-19 19:17:46 -07:00
committed by android-build-merger
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