qt-dev-plus-aosp designated for R. Update MAX_PLATFORM_VERSION, etc.
Test: aapt2_tests Bug: 128934651 Change-Id: I179f7b92dcf65e77f039e6cd42d91bf5b1461e35
This commit is contained in:
@@ -534,17 +534,18 @@ Maybe<int> ParseSdkVersion(const StringPiece& str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try parsing the code name.
|
// Try parsing the code name.
|
||||||
std::pair<StringPiece, int> entry = GetDevelopmentSdkCodeNameAndVersion();
|
Maybe<int> entry = GetDevelopmentSdkCodeNameVersion(trimmed_str);
|
||||||
if (entry.first == trimmed_str) {
|
if (entry) {
|
||||||
return entry.second;
|
return entry.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try parsing codename from "[codename].[preview_sdk_fingerprint]" value.
|
// Try parsing codename from "[codename].[preview_sdk_fingerprint]" value.
|
||||||
const StringPiece::const_iterator begin = std::begin(trimmed_str);
|
const StringPiece::const_iterator begin = std::begin(trimmed_str);
|
||||||
const StringPiece::const_iterator end = std::end(trimmed_str);
|
const StringPiece::const_iterator end = std::end(trimmed_str);
|
||||||
const StringPiece::const_iterator codename_end = std::find(begin, end, '.');
|
const StringPiece::const_iterator codename_end = std::find(begin, end, '.');
|
||||||
if (codename_end != end && entry.first == trimmed_str.substr(begin, codename_end)) {
|
entry = GetDevelopmentSdkCodeNameVersion(trimmed_str.substr(begin, codename_end));
|
||||||
return entry.second;
|
if (entry) {
|
||||||
|
return entry.value();
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,14 +214,15 @@ TEST(ResourceUtilsTest, ItemsWithWhitespaceAreParsedCorrectly) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ResourceUtilsTest, ParseSdkVersionWithCodename) {
|
TEST(ResourceUtilsTest, ParseSdkVersionWithCodename) {
|
||||||
const android::StringPiece codename =
|
EXPECT_THAT(ResourceUtils::ParseSdkVersion("Q"), Eq(Maybe<int>(10000)));
|
||||||
GetDevelopmentSdkCodeNameAndVersion().first;
|
|
||||||
const int version = GetDevelopmentSdkCodeNameAndVersion().second;
|
|
||||||
|
|
||||||
EXPECT_THAT(ResourceUtils::ParseSdkVersion(codename), Eq(Maybe<int>(version)));
|
|
||||||
EXPECT_THAT(
|
EXPECT_THAT(
|
||||||
ResourceUtils::ParseSdkVersion(codename.to_string() + ".fingerprint"),
|
ResourceUtils::ParseSdkVersion("Q.fingerprint"),
|
||||||
Eq(Maybe<int>(version)));
|
Eq(Maybe<int>(10000)));
|
||||||
|
|
||||||
|
EXPECT_THAT(ResourceUtils::ParseSdkVersion("R"), Eq(Maybe<int>(10000)));
|
||||||
|
EXPECT_THAT(
|
||||||
|
ResourceUtils::ParseSdkVersion("R.fingerprint"),
|
||||||
|
Eq(Maybe<int>(10000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ResourceUtilsTest, StringBuilderWhitespaceRemoval) {
|
TEST(ResourceUtilsTest, StringBuilderWhitespaceRemoval) {
|
||||||
|
|||||||
@@ -18,15 +18,17 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using android::StringPiece;
|
using android::StringPiece;
|
||||||
|
|
||||||
namespace aapt {
|
namespace aapt {
|
||||||
|
|
||||||
static const char* sDevelopmentSdkCodeName = "Q";
|
|
||||||
static ApiVersion sDevelopmentSdkLevel = 10000;
|
static ApiVersion sDevelopmentSdkLevel = 10000;
|
||||||
|
static const auto sDevelopmentSdkCodeNames = std::unordered_set<StringPiece>({
|
||||||
|
"Q", "R"
|
||||||
|
});
|
||||||
|
|
||||||
static const std::vector<std::pair<uint16_t, ApiVersion>> sAttrIdMap = {
|
static const std::vector<std::pair<uint16_t, ApiVersion>> sAttrIdMap = {
|
||||||
{0x021c, 1},
|
{0x021c, 1},
|
||||||
@@ -72,8 +74,9 @@ ApiVersion FindAttributeSdkLevel(const ResourceId& id) {
|
|||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<StringPiece, ApiVersion> GetDevelopmentSdkCodeNameAndVersion() {
|
Maybe<ApiVersion> GetDevelopmentSdkCodeNameVersion(const StringPiece& code_name) {
|
||||||
return std::make_pair(StringPiece(sDevelopmentSdkCodeName), sDevelopmentSdkLevel);
|
return (sDevelopmentSdkCodeNames.find(code_name) == sDevelopmentSdkCodeNames.end())
|
||||||
|
? Maybe<ApiVersion>() : sDevelopmentSdkLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace aapt
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ enum : ApiVersion {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ApiVersion FindAttributeSdkLevel(const ResourceId& id);
|
ApiVersion FindAttributeSdkLevel(const ResourceId& id);
|
||||||
std::pair<android::StringPiece, ApiVersion> GetDevelopmentSdkCodeNameAndVersion();
|
Maybe<ApiVersion> GetDevelopmentSdkCodeNameVersion(const android::StringPiece& code_name);
|
||||||
|
|
||||||
} // namespace aapt
|
} // namespace aapt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user