Fix avdmanageroutputparser test

- There is no PLUGIN_DEPENDS for tests, and it wouldn't work anyhow
  because of duplicated symbols. It was interpreted as a dependency and
  the test disabled because no such target exists.
- Move the platformNameToApiLevel(...) function to
  avdmanageroutputparser.h to break the dependency to a lot of Android
  support code.

Amends 78da7e2922

Change-Id: I6933684a76e5291d415c72388caa3df2bee7cbfb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2022-02-02 16:32:24 +01:00
committed by Alessandro Portale
parent 1e34d6ee22
commit 9bc9fb5a0d
6 changed files with 28 additions and 29 deletions

View File

@@ -34,6 +34,7 @@
#include <utils/variant.h>
#include <QLoggingCategory>
#include <QRegularExpression>
#include <QSettings>
namespace {
@@ -98,7 +99,7 @@ static Utils::optional<AndroidDeviceInfo> parseAvd(const QStringList &deviceInfo
QSettings avdInfo(avdInfoFile.toString(), QSettings::IniFormat);
value = avdInfo.value(avdInfoTargetKey).toString();
if (!value.isEmpty())
avd.sdk = AndroidConfig::platformNameToApiLevel(value);
avd.sdk = platformNameToApiLevel(value);
else
qCDebug(avdOutputParserLog)
<< "Avd Parsing: Cannot find sdk API:" << avdInfoFile.toString();
@@ -164,5 +165,27 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
return avdList;
}
int 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;
}
} // namespace Internal
} // namespace Android