forked from qt-creator/qt-creator
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:
@@ -415,28 +415,6 @@ QString AndroidConfig::apiLevelNameFor(const SdkPlatform *platform)
|
|||||||
QString("android-%1").arg(platform->apiLevel()) : "";
|
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
|
bool AndroidConfig::isCmdlineSdkToolsInstalled() const
|
||||||
{
|
{
|
||||||
QString toolPath("cmdline-tools/latest/bin/sdkmanager");
|
QString toolPath("cmdline-tools/latest/bin/sdkmanager");
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ public:
|
|||||||
|
|
||||||
static QStringList apiLevelNamesFor(const SdkPlatformList &platforms);
|
static QStringList apiLevelNamesFor(const SdkPlatformList &platforms);
|
||||||
static QString apiLevelNameFor(const SdkPlatform *platform);
|
static QString apiLevelNameFor(const SdkPlatform *platform);
|
||||||
static int platformNameToApiLevel(const QString &platformName);
|
|
||||||
|
|
||||||
Utils::FilePath sdkLocation() const;
|
Utils::FilePath sdkLocation() const;
|
||||||
void setSdkLocation(const Utils::FilePath &sdkLocation);
|
void setSdkLocation(const Utils::FilePath &sdkLocation);
|
||||||
|
|||||||
@@ -69,6 +69,28 @@ Q_GLOBAL_STATIC_WITH_ARGS(QRegularExpression, assertionReg,
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using SdkCmdFutureInterface = QFutureInterface<AndroidSdkManager::OperationOutput>;
|
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
|
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.
|
\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;
|
SdkPlatform *platform = nullptr;
|
||||||
GenericPackageData packageData;
|
GenericPackageData packageData;
|
||||||
if (parseAbstractData(packageData, data, 2, "Platform")) {
|
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) {
|
if (apiLevel == -1) {
|
||||||
qCDebug(sdkManagerLog) << "Platform: Cannot parse api level:"<< data;
|
qCDebug(sdkManagerLog) << "Platform: Cannot parse api level:"<< data;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -712,7 +734,7 @@ QPair<SystemImage *, int> SdkManagerOutputParser::parseSystemImage(const QString
|
|||||||
QPair <SystemImage *, int> result(nullptr, -1);
|
QPair <SystemImage *, int> result(nullptr, -1);
|
||||||
GenericPackageData packageData;
|
GenericPackageData packageData;
|
||||||
if (parseAbstractData(packageData, data, 4, "System-image")) {
|
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) {
|
if (apiLevel == -1) {
|
||||||
qCDebug(sdkManagerLog) << "System-image: Cannot parse api level:"<< data;
|
qCDebug(sdkManagerLog) << "System-image: Cannot parse api level:"<< data;
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "avdmanageroutputparser.h"
|
#include "avdmanageroutputparser.h"
|
||||||
#include "androidconfigurations.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -98,7 +97,7 @@ static Utils::optional<AndroidDeviceInfo> parseAvd(const QStringList &deviceInfo
|
|||||||
QSettings avdInfo(avdInfoFile.toString(), QSettings::IniFormat);
|
QSettings avdInfo(avdInfoFile.toString(), QSettings::IniFormat);
|
||||||
value = avdInfo.value(avdInfoTargetKey).toString();
|
value = avdInfo.value(avdInfoTargetKey).toString();
|
||||||
if (!value.isEmpty())
|
if (!value.isEmpty())
|
||||||
avd.sdk = AndroidConfig::platformNameToApiLevel(value);
|
avd.sdk = value.section('-', -1).toInt();
|
||||||
else
|
else
|
||||||
qCDebug(avdOutputParserLog)
|
qCDebug(avdOutputParserLog)
|
||||||
<< "Avd Parsing: Cannot find sdk API:" << avdInfoFile.toString();
|
<< "Avd Parsing: Cannot find sdk API:" << avdInfoFile.toString();
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ add_qtc_test(tst_avdmanageroutputparser
|
|||||||
"${PROJECT_SOURCE_DIR}/src/plugins/android/avdmanageroutputparser.h"
|
"${PROJECT_SOURCE_DIR}/src/plugins/android/avdmanageroutputparser.h"
|
||||||
"${PROJECT_SOURCE_DIR}/src/plugins/android/androiddeviceinfo.cpp"
|
"${PROJECT_SOURCE_DIR}/src/plugins/android/androiddeviceinfo.cpp"
|
||||||
"${PROJECT_SOURCE_DIR}/src/plugins/android/androiddeviceinfo.h"
|
"${PROJECT_SOURCE_DIR}/src/plugins/android/androiddeviceinfo.h"
|
||||||
"${PROJECT_SOURCE_DIR}/src/plugins/android/androidmanager.cpp"
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/plugins/android/androidmanager.h"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
qtc_add_resources(tst_avdmanageroutputparser tst_avdmanageroutputparser_rcc
|
qtc_add_resources(tst_avdmanageroutputparser tst_avdmanageroutputparser_rcc
|
||||||
|
|||||||
Reference in New Issue
Block a user