Merge changes from topic "R"

* changes:
  master designated for R. Update MAX_PLATFORM_VERSION, etc.
  AAPT2: Update SDK development codename to Q
This commit is contained in:
Dan Willemsen
2019-04-20 01:06:00 +00:00
committed by Gerrit Code Review
4 changed files with 23 additions and 30 deletions

View File

@@ -497,9 +497,9 @@ 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();
} }
return {}; return {};
} }

View File

@@ -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 = "P"; static ApiVersion sDevelopmentSdkLevel = 10000;
static ApiVersion sDevelopmentSdkLevel = 28; 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},
@@ -54,6 +56,7 @@ static const std::vector<std::pair<uint16_t, ApiVersion>> sAttrIdMap = {
{0x0530, SDK_NOUGAT_MR1}, {0x0530, SDK_NOUGAT_MR1},
{0x0568, SDK_O}, {0x0568, SDK_O},
{0x056d, SDK_O_MR1}, {0x056d, SDK_O_MR1},
{0x0586, SDK_P},
}; };
static bool less_entry_id(const std::pair<uint16_t, ApiVersion>& p, uint16_t entryId) { static bool less_entry_id(const std::pair<uint16_t, ApiVersion>& p, uint16_t entryId) {
@@ -71,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

View File

@@ -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

View File

@@ -705,35 +705,24 @@ TEST_F(ConfigurationParserTest, AndroidSdkGroupAction_InvalidVersion) {
} }
TEST_F(ConfigurationParserTest, AndroidSdkGroupAction_NonNumeric) { TEST_F(ConfigurationParserTest, AndroidSdkGroupAction_NonNumeric) {
static constexpr const char* xml = R"xml( auto doc = test::BuildXmlDom(R"xml(
<android-sdk <android-sdk
label="P" label="Q"
minSdkVersion="25" minSdkVersion="25"
targetSdkVersion="%s" targetSdkVersion="Q"
maxSdkVersion="%s"> maxSdkVersion="Q">
</android-sdk>)xml"; </android-sdk>)xml");
const auto& dev_sdk = GetDevelopmentSdkCodeNameAndVersion();
const char* codename = dev_sdk.first.data();
const ApiVersion& version = dev_sdk.second;
auto doc = test::BuildXmlDom(StringPrintf(xml, codename, codename));
PostProcessingConfiguration config; PostProcessingConfiguration config;
bool ok = AndroidSdkTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_); ASSERT_TRUE(AndroidSdkTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_));
ASSERT_TRUE(ok);
ASSERT_EQ(1ul, config.android_sdks.size()); ASSERT_EQ(1ul, config.android_sdks.size());
ASSERT_EQ(1u, config.android_sdks.count("P")); ASSERT_EQ(1u, config.android_sdks.count("Q"));
auto& out = config.android_sdks["P"];
AndroidSdk sdk; AndroidSdk sdk;
sdk.min_sdk_version = 25; sdk.min_sdk_version = 25;
sdk.target_sdk_version = version; sdk.target_sdk_version = 10000;
sdk.max_sdk_version = version; sdk.max_sdk_version = 10000;
ASSERT_EQ(sdk, config.android_sdks["Q"]);
ASSERT_EQ(sdk, out);
} }
TEST_F(ConfigurationParserTest, GlTextureGroupAction) { TEST_F(ConfigurationParserTest, GlTextureGroupAction) {