Commit 2b5f5abb authored by Vikas Pachdha's avatar Vikas Pachdha
Browse files

Android: Add system image information for each platform



Groundwork for the new sdk and avd management tool's integration

Task-number: QTCREATORBUG-17814
Change-Id: I3e46f6d3aa56c0f16dd66d0b1d731043e180e012
Reviewed-by: default avatarBogDan Vatra <bogdan@kdab.com>
parent 198c83ea
......@@ -72,13 +72,24 @@ public:
bool operator<(const AndroidDeviceInfo &other) const;
};
//! Defines an Android system image.
class SystemImage
{
public:
bool isValid() const { return (apiLevel != -1) && !abiName.isEmpty(); }
int apiLevel = -1;
QString abiName;
};
using SystemImageList = QList<SystemImage>;
class SdkPlatform
{
public:
int apiLevel = -1;
QString name;
Utils::FileName installedLocation;
QStringList abis;
SystemImageList systemImages;
};
using SdkPlatformList = QList<SdkPlatform>;
......
......@@ -293,7 +293,17 @@ void AndroidToolOutputParser::parseTargetListing(const QString &output,
if (!platformList)
return;
auto addSystemImage = [](const QStringList& abiList, SdkPlatform &platform) {
foreach (auto imageAbi, abiList) {
SystemImage image;
image.abiName = imageAbi;
image.apiLevel = platform.apiLevel;
platform.systemImages.append(image);
}
};
SdkPlatform platform;
QStringList abiList;
foreach (const QString &l, output.split('\n')) {
const QString line = l.trimmed();
if (line.startsWith(QLatin1String("id:")) && line.contains(QLatin1String("android-"))) {
......@@ -309,20 +319,26 @@ void AndroidToolOutputParser::parseTargetListing(const QString &output,
} else if (line.startsWith(QLatin1String("Name:"))) {
platform.name = line.mid(6);
} else if (line.startsWith(QLatin1String("Tag/ABIs :"))) {
platform.abis = cleanAndroidABIs(line.mid(10).trimmed().split(QLatin1String(", ")));
abiList = cleanAndroidABIs(line.mid(10).trimmed().split(QLatin1String(", ")));
} else if (line.startsWith(QLatin1String("ABIs"))) {
platform.abis = cleanAndroidABIs(line.mid(6).trimmed().split(QLatin1String(", ")));
abiList = cleanAndroidABIs(line.mid(6).trimmed().split(QLatin1String(", ")));
} else if (line.startsWith(QLatin1String("---")) || line.startsWith(QLatin1String("==="))) {
if (platform.apiLevel == -1)
continue;
addSystemImage(abiList, platform);
*platformList << platform;
platform = SdkPlatform();
abiList.clear();
}
}
// The last parsed Platform.
if (platform.apiLevel != -1)
if (platform.apiLevel != -1) {
addSystemImage(abiList, platform);
*platformList << platform;
}
}
} // namespace Internal
......
......@@ -26,6 +26,7 @@
#include "avddialog.h"
#include "androidconfigurations.h"
#include <utils/algorithm.h>
#include <utils/tooltip/tooltip.h>
#include <utils/utilsicons.h>
......@@ -94,10 +95,15 @@ void AvdDialog::updateApiLevelComboBox()
{
QList<SdkPlatform> filteredList;
QList<SdkPlatform> platforms = m_config->sdkTargets(m_minApiLevel);
foreach (const SdkPlatform &platform, platforms) {
if (platform.abis.contains(abi()))
filteredList << platform;
}
QString selectedAbi = abi();
auto hasAbi = [selectedAbi](const SystemImage &image) {
return image.isValid() && (image.abiName == selectedAbi);
};
filteredList = Utils::filtered(platforms, [hasAbi](const SdkPlatform &platform) {
return Utils::anyOf(platform.systemImages,hasAbi);
});
m_avdDialog.targetComboBox->clear();
m_avdDialog.targetComboBox->addItems(AndroidConfig::apiLevelNamesFor(filteredList));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment