Move sdkmanager's sdk level parsing to AndroidConfig

Both the sdkmanger and avdmanager (maybe more) need to parse the sdk
level for packages and devices which may contain letters, make them
use the same logic.

Change-Id: Iff7fef3a66e00fac11b833f73f2f334a4cf1a766
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Assam Boudjelthia
2021-09-05 19:44:16 +03:00
parent e1a69fccb1
commit 78da7e2922
5 changed files with 30 additions and 25 deletions

View File

@@ -418,6 +418,28 @@ QString AndroidConfig::apiLevelNameFor(const SdkPlatform *platform)
QString("android-%1").arg(platform->apiLevel()) : "";
}
int AndroidConfig::platformNameToApiLevel(const QString &platformName)
{
int apiLevel = -1;
static const QRegularExpression re("(android-)(?<apiLevel>[0-9A-Z]{1,})",
QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = re.match(platformName);
if (match.hasMatch()) {
QString apiLevelStr = match.captured("apiLevel");
bool isUInt;
apiLevel = apiLevelStr.toUInt(&isUInt);
if (!isUInt) {
if (apiLevelStr == 'Q')
apiLevel = 29;
else if (apiLevelStr == 'R')
apiLevel = 30;
else if (apiLevelStr == 'S')
apiLevel = 31;
}
}
return apiLevel;
}
bool AndroidConfig::isCmdlineSdkToolsInstalled() const
{
QString toolPath("cmdline-tools/latest/bin/sdkmanager");