Revert "Move sdkmanager's sdk level parsing to AndroidConfig"

This reverts commit 2d77922856.

Reason for revert: This causes a build error in Android tests, reverting until the a fix is ready for that to not block the repo.

Change-Id: I74961df660ebaf69caf092d53172821815f21268
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2021-09-08 12:44:11 +00:00
parent 3639d6faa7
commit 41528390b8
5 changed files with 25 additions and 29 deletions

View File

@@ -415,28 +415,6 @@ 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");

View File

@@ -90,7 +90,6 @@ public:
static QStringList apiLevelNamesFor(const SdkPlatformList &platforms);
static QString apiLevelNameFor(const SdkPlatform *platform);
static int platformNameToApiLevel(const QString &platformName);
Utils::FilePath sdkLocation() const;
void setSdkLocation(const Utils::FilePath &sdkLocation);

View File

@@ -69,6 +69,28 @@ Q_GLOBAL_STATIC_WITH_ARGS(QRegularExpression, assertionReg,
using namespace Utils;
using SdkCmdFutureInterface = QFutureInterface<AndroidSdkManager::OperationOutput>;
int platformNameToApiLevel(const QString &platformName)
{
int apiLevel = -1;
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;
}
/*!
Parses the \a line for a [spaces]key[spaces]value[spaces] pattern and returns
\c true if \a key is found, false otherwise. Result is copied into \a value.
@@ -692,7 +714,7 @@ AndroidSdkPackage *SdkManagerOutputParser::parsePlatform(const QStringList &data
SdkPlatform *platform = nullptr;
GenericPackageData packageData;
if (parseAbstractData(packageData, data, 2, "Platform")) {
const int apiLevel = AndroidConfig::platformNameToApiLevel(packageData.headerParts.at(1));
int apiLevel = platformNameToApiLevel(packageData.headerParts.at(1));
if (apiLevel == -1) {
qCDebug(sdkManagerLog) << "Platform: Cannot parse api level:"<< data;
return nullptr;
@@ -712,7 +734,7 @@ QPair<SystemImage *, int> SdkManagerOutputParser::parseSystemImage(const QString
QPair <SystemImage *, int> result(nullptr, -1);
GenericPackageData packageData;
if (parseAbstractData(packageData, data, 4, "System-image")) {
const int apiLevel = AndroidConfig::platformNameToApiLevel(packageData.headerParts.at(1));
int apiLevel = platformNameToApiLevel(packageData.headerParts.at(1));
if (apiLevel == -1) {
qCDebug(sdkManagerLog) << "System-image: Cannot parse api level:"<< data;
return result;

View File

@@ -24,7 +24,6 @@
****************************************************************************/
#include "avdmanageroutputparser.h"
#include "androidconfigurations.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/algorithm.h>
@@ -98,7 +97,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 = value.section('-', -1).toInt();
else
qCDebug(avdOutputParserLog)
<< "Avd Parsing: Cannot find sdk API:" << avdInfoFile.toString();