Commit 31fe6f06 authored by Daniel Teske's avatar Daniel Teske

Android: Use minimum sdk instead of build target sdk to filter devices

Task-number: QTCREATORBUG-9662
Change-Id: I3a5b3493bc8ef48bd23d014e86eef45185f3c17e
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
parent 307aa7b3
......@@ -96,11 +96,14 @@ void AndroidDeployStep::ctor()
bool AndroidDeployStep::init()
{
m_packageName = AndroidManager::packageName(target());
const QString targetSDK = AndroidManager::buildTargetSDK(target());
m_deviceAPILevel = AndroidManager::minimumSDK(target());
m_targetArch = AndroidManager::targetArch(target());
writeOutput(tr("Please wait, searching for a suitable device for target:%1, ABI:%2").arg(targetSDK).arg(m_targetArch));
m_deviceAPILevel = targetSDK.mid(targetSDK.indexOf(QLatin1Char('-')) + 1).toInt();
if (m_deviceAPILevel == 0) // minimum api level is unset
writeOutput(tr("Please wait, searching for a suitable device for target: ABI:%2").arg(m_targetArch));
else
writeOutput(tr("Please wait, searching for a suitable device for target: API %1, ABI:%2").arg(m_deviceAPILevel).arg(m_targetArch));
QString error;
m_deviceSerialNumber = AndroidConfigurations::instance().getDeployDeviceSerialNumber(&m_deviceAPILevel, m_targetArch, &error);
if (!error.isEmpty())
......@@ -196,10 +199,8 @@ QVariantMap AndroidDeployStep::toMap() const
void AndroidDeployStep::cleanLibsOnDevice()
{
const QString targetSDK = AndroidManager::buildTargetSDK(target());
const QString targetArch = AndroidManager::targetArch(target());
int deviceAPILevel = targetSDK.mid(targetSDK.indexOf(QLatin1Char('-')) + 1).toInt();
int deviceAPILevel = AndroidManager::minimumSDK(target());
QString deviceSerialNumber = AndroidConfigurations::instance().getDeployDeviceSerialNumber(&deviceAPILevel, targetArch);
if (deviceSerialNumber.isEmpty()) {
QString avdName = AndroidConfigurations::instance().findAvd(&deviceAPILevel, targetArch);
......@@ -258,8 +259,7 @@ void AndroidDeployStep::kitUpdated(Kit *kit)
void AndroidDeployStep::installQASIPackage(const QString &packagePath)
{
const QString targetArch = AndroidManager::targetArch(target());
const QString targetSDK = AndroidManager::buildTargetSDK(target());
int deviceAPILevel = targetSDK.mid(targetSDK.indexOf(QLatin1Char('-')) + 1).toInt();
int deviceAPILevel = AndroidManager::minimumSDK(target());
QString deviceSerialNumber = AndroidConfigurations::instance().getDeployDeviceSerialNumber(&deviceAPILevel, targetArch);
if (deviceSerialNumber.isEmpty()) {
QString avdName = AndroidConfigurations::instance().findAvd(&deviceAPILevel, targetArch);
......
......@@ -196,6 +196,24 @@ QString AndroidManager::activityName(ProjectExplorer::Target *target)
return activityElem.attribute(QLatin1String("android:name"));
}
int AndroidManager::minimumSDK(ProjectExplorer::Target *target)
{
QDomDocument doc;
if (!openManifest(target, doc))
return 0;
QDomElement manifestElem = doc.documentElement();
QDomElement usesSdk = manifestElem.firstChildElement(QLatin1String("uses-sdk"));
if (usesSdk.isNull())
return 0;
if (usesSdk.hasAttribute(QLatin1String("android:minSdkVersion"))) {
bool ok;
int tmp = usesSdk.attribute(QLatin1String("android:minSdkVersion")).toInt(&ok);
if (ok)
return tmp;
}
return 0;
}
QString AndroidManager::buildTargetSDK(ProjectExplorer::Target *target)
{
QVariant v = target->namedSettings(QLatin1String("AndroidManager.TargetSdk"));
......
......@@ -74,6 +74,7 @@ public:
static QString buildTargetSDK(ProjectExplorer::Target *target);
static bool setBuildTargetSDK(ProjectExplorer::Target *target, const QString &sdk);
static int minimumSDK(ProjectExplorer::Target *target);
static QString targetArch(ProjectExplorer::Target *target);
......
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