androidconfigurations.cpp 46.4 KB
Newer Older
BogDan Vatra's avatar
BogDan Vatra committed
1 2
/**************************************************************************
**
3
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
BogDan Vatra's avatar
BogDan Vatra committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
BogDan Vatra's avatar
BogDan Vatra committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
BogDan Vatra's avatar
BogDan Vatra committed
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
BogDan Vatra's avatar
BogDan Vatra committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
BogDan Vatra's avatar
BogDan Vatra committed
29 30 31

#include "androidconfigurations.h"
#include "androidconstants.h"
Daniel Teske's avatar
Daniel Teske committed
32 33 34
#include "androidtoolchain.h"
#include "androiddevice.h"
#include "androidgdbserverkitinformation.h"
35
#include "androidqtversion.h"
36
#include "androiddevicedialog.h"
37
#include "avddialog.h"
BogDan Vatra's avatar
BogDan Vatra committed
38 39

#include <coreplugin/icore.h>
40
#include <coreplugin/messagemanager.h>
41
#include <utils/hostosinfo.h>
BogDan Vatra's avatar
BogDan Vatra committed
42
#include <utils/persistentsettings.h>
Daniel Teske's avatar
Daniel Teske committed
43 44 45 46
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/toolchainmanager.h>
47
#include <projectexplorer/session.h>
48
#include <debugger/debuggeritemmanager.h>
Daniel Teske's avatar
Daniel Teske committed
49 50 51 52
#include <debugger/debuggerkitinformation.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
53
#include <utils/algorithm.h>
Daniel Teske's avatar
Daniel Teske committed
54
#include <utils/environment.h>
Orgad Shaneh's avatar
Orgad Shaneh committed
55
#include <utils/sleep.h>
BogDan Vatra's avatar
BogDan Vatra committed
56 57 58 59 60 61 62 63

#include <QDateTime>
#include <QSettings>
#include <QStringList>
#include <QProcess>
#include <QFileInfo>
#include <QDirIterator>
#include <QMetaObject>
64
#include <QApplication>
65
#include <QtConcurrentRun>
BogDan Vatra's avatar
BogDan Vatra committed
66 67 68 69

#include <QStringListModel>
#include <QMessageBox>

hjk's avatar
hjk committed
70 71
#include <functional>

hjk's avatar
hjk committed
72
using namespace ProjectExplorer;
BogDan Vatra's avatar
BogDan Vatra committed
73 74 75
using namespace Utils;

namespace Android {
76
using namespace Internal;
BogDan Vatra's avatar
BogDan Vatra committed
77 78 79 80 81 82 83 84 85

namespace {
    const QLatin1String SettingsGroup("AndroidConfigurations");
    const QLatin1String SDKLocationKey("SDKLocation");
    const QLatin1String NDKLocationKey("NDKLocation");
    const QLatin1String NDKToolchainVersionKey("NDKToolchainVersion");
    const QLatin1String AntLocationKey("AntLocation");
    const QLatin1String OpenJDKLocationKey("OpenJDKLocation");
    const QLatin1String KeystoreLocationKey("KeystoreLocation");
Daniel Teske's avatar
Daniel Teske committed
86
    const QLatin1String AutomaticKitCreationKey("AutomatiKitCreation");
87
    const QLatin1String MakeExtraSearchDirectory("MakeExtraSearchDirectory");
88
    const QLatin1String DefaultDevice("DefaultDevice");
BogDan Vatra's avatar
BogDan Vatra committed
89
    const QLatin1String PartitionSizeKey("PartitionSize");
90
    const QLatin1String ToolchainHostKey("ToolchainHost");
BogDan Vatra's avatar
BogDan Vatra committed
91 92
    const QLatin1String ArmToolchainPrefix("arm-linux-androideabi");
    const QLatin1String X86ToolchainPrefix("x86");
BogDan Vatra's avatar
BogDan Vatra committed
93
    const QLatin1String MipsToolchainPrefix("mipsel-linux-android");
BogDan Vatra's avatar
BogDan Vatra committed
94
    const QLatin1String ArmToolsPrefix("arm-linux-androideabi");
BogDan Vatra's avatar
BogDan Vatra committed
95
    const QLatin1String X86ToolsPrefix("i686-linux-android");
BogDan Vatra's avatar
BogDan Vatra committed
96
    const QLatin1String MipsToolsPrefix("mipsel-linux-android");
BogDan Vatra's avatar
BogDan Vatra committed
97 98 99 100 101
    const QLatin1String Unknown("unknown");
    const QLatin1String keytoolName("keytool");
    const QLatin1String jarsignerName("jarsigner");
    const QLatin1String changeTimeStamp("ChangeTimeStamp");

102
    static QString sdkSettingsFileName()
BogDan Vatra's avatar
BogDan Vatra committed
103
    {
104 105
        return QFileInfo(Core::ICore::settings(QSettings::SystemScope)->fileName()).absolutePath()
                + QLatin1String("/qtcreator/android.xml");
BogDan Vatra's avatar
BogDan Vatra committed
106 107
    }

108
    bool androidDevicesLessThan(const AndroidDeviceInfo &dev1, const AndroidDeviceInfo &dev2)
BogDan Vatra's avatar
BogDan Vatra committed
109
    {
Daniel Teske's avatar
Compile  
Daniel Teske committed
110 111
        if (dev1.serialNumber.contains(QLatin1String("????")) == dev2.serialNumber.contains(QLatin1String("????")))
            return !dev1.serialNumber.contains(QLatin1String("????"));
112 113
        if (dev1.type != dev2.type)
            return dev1.type == AndroidDeviceInfo::Hardware;
114 115
        if (dev1.sdk != dev2.sdk)
            return dev1.sdk < dev2.sdk;
116

117
        return dev1.serialNumber < dev2.serialNumber;
BogDan Vatra's avatar
BogDan Vatra committed
118
    }
119 120 121 122 123 124 125 126 127 128 129 130 131

    static QStringList cleanAndroidABIs(const QStringList &abis)
    {
        QStringList res;
        foreach (const QString &abi, abis) {
            int index = abi.lastIndexOf(QLatin1Char('/'));
            if (index == -1)
                res << abi;
            else
                res << abi.mid(index + 1);
        }
        return res;
    }
BogDan Vatra's avatar
BogDan Vatra committed
132 133
}

Daniel Teske's avatar
Daniel Teske committed
134 135 136 137 138
//////////////////////////////////
// AndroidConfig
//////////////////////////////////

Abi::Architecture AndroidConfig::architectureForToolChainPrefix(const QString& toolchainprefix)
139 140 141 142 143
{
    if (toolchainprefix == ArmToolchainPrefix)
        return Abi::ArmArchitecture;
    if (toolchainprefix == X86ToolchainPrefix)
        return Abi::X86Architecture;
BogDan Vatra's avatar
BogDan Vatra committed
144 145
    if (toolchainprefix == MipsToolchainPrefix)
        return Abi::MipsArchitecture;
146 147 148
    return Abi::UnknownArchitecture;
}

Daniel Teske's avatar
Daniel Teske committed
149
QLatin1String AndroidConfig::toolchainPrefix(Abi::Architecture architecture)
BogDan Vatra's avatar
BogDan Vatra committed
150 151
{
    switch (architecture) {
hjk's avatar
hjk committed
152
    case Abi::ArmArchitecture:
BogDan Vatra's avatar
BogDan Vatra committed
153
        return ArmToolchainPrefix;
hjk's avatar
hjk committed
154
    case Abi::X86Architecture:
BogDan Vatra's avatar
BogDan Vatra committed
155
        return X86ToolchainPrefix;
BogDan Vatra's avatar
BogDan Vatra committed
156 157
    case Abi::MipsArchitecture:
        return MipsToolchainPrefix;
BogDan Vatra's avatar
BogDan Vatra committed
158 159 160 161 162
    default:
        return Unknown;
    }
}

Daniel Teske's avatar
Daniel Teske committed
163
QLatin1String AndroidConfig::toolsPrefix(Abi::Architecture architecture)
BogDan Vatra's avatar
BogDan Vatra committed
164 165
{
    switch (architecture) {
hjk's avatar
hjk committed
166
    case Abi::ArmArchitecture:
BogDan Vatra's avatar
BogDan Vatra committed
167
        return ArmToolsPrefix;
hjk's avatar
hjk committed
168
    case Abi::X86Architecture:
BogDan Vatra's avatar
BogDan Vatra committed
169
        return X86ToolsPrefix;
BogDan Vatra's avatar
BogDan Vatra committed
170 171
    case Abi::MipsArchitecture:
        return MipsToolsPrefix;
BogDan Vatra's avatar
BogDan Vatra committed
172 173 174 175 176
    default:
        return Unknown;
    }
}

Daniel Teske's avatar
Daniel Teske committed
177
void AndroidConfig::load(const QSettings &settings)
BogDan Vatra's avatar
BogDan Vatra committed
178 179
{
    // user settings
Daniel Teske's avatar
Daniel Teske committed
180 181 182 183 184 185 186 187
    m_partitionSize = settings.value(PartitionSizeKey, 1024).toInt();
    m_sdkLocation = FileName::fromString(settings.value(SDKLocationKey).toString());
    m_ndkLocation = FileName::fromString(settings.value(NDKLocationKey).toString());
    m_antLocation = FileName::fromString(settings.value(AntLocationKey).toString());
    m_openJDKLocation = FileName::fromString(settings.value(OpenJDKLocationKey).toString());
    m_keystoreLocation = FileName::fromString(settings.value(KeystoreLocationKey).toString());
    m_toolchainHost = settings.value(ToolchainHostKey).toString();
    m_automaticKitCreation = settings.value(AutomaticKitCreationKey, true).toBool();
188
    QString extraDirectory = settings.value(MakeExtraSearchDirectory).toString();
Daniel Teske's avatar
Daniel Teske committed
189
    m_makeExtraSearchDirectories.clear();
190
    if (!extraDirectory.isEmpty())
Daniel Teske's avatar
Daniel Teske committed
191
        m_makeExtraSearchDirectories << extraDirectory;
BogDan Vatra's avatar
BogDan Vatra committed
192 193

    PersistentSettingsReader reader;
194 195
    if (reader.load(FileName::fromString(sdkSettingsFileName()))
            && settings.value(changeTimeStamp).toInt() != QFileInfo(sdkSettingsFileName()).lastModified().toMSecsSinceEpoch() / 1000) {
BogDan Vatra's avatar
BogDan Vatra committed
196
        // persisten settings
Daniel Teske's avatar
Daniel Teske committed
197 198 199 200 201 202
        m_sdkLocation = FileName::fromString(reader.restoreValue(SDKLocationKey).toString());
        m_ndkLocation = FileName::fromString(reader.restoreValue(NDKLocationKey).toString());
        m_antLocation = FileName::fromString(reader.restoreValue(AntLocationKey).toString());
        m_openJDKLocation = FileName::fromString(reader.restoreValue(OpenJDKLocationKey).toString());
        m_keystoreLocation = FileName::fromString(reader.restoreValue(KeystoreLocationKey).toString());
        m_toolchainHost = reader.restoreValue(ToolchainHostKey).toString();
Daniel Teske's avatar
Daniel Teske committed
203 204
        QVariant v = reader.restoreValue(AutomaticKitCreationKey);
        if (v.isValid())
Daniel Teske's avatar
Daniel Teske committed
205
            m_automaticKitCreation = v.toBool();
206
        QString extraDirectory = reader.restoreValue(MakeExtraSearchDirectory).toString();
Daniel Teske's avatar
Daniel Teske committed
207
        m_makeExtraSearchDirectories.clear();
208
        if (!extraDirectory.isEmpty())
Daniel Teske's avatar
Daniel Teske committed
209
            m_makeExtraSearchDirectories << extraDirectory;
BogDan Vatra's avatar
BogDan Vatra committed
210 211
        // persistent settings
    }
Daniel Teske's avatar
Daniel Teske committed
212 213
    m_availableSdkPlatformsUpToDate = false;
    m_NdkInformationUpToDate = false;
BogDan Vatra's avatar
BogDan Vatra committed
214 215 216
}

AndroidConfig::AndroidConfig()
Daniel Teske's avatar
Daniel Teske committed
217 218
    : m_availableSdkPlatformsUpToDate(false),
      m_NdkInformationUpToDate(false)
BogDan Vatra's avatar
BogDan Vatra committed
219
{
Daniel Teske's avatar
Daniel Teske committed
220

BogDan Vatra's avatar
BogDan Vatra committed
221 222 223 224
}

void AndroidConfig::save(QSettings &settings) const
{
225
    QFileInfo fileInfo(sdkSettingsFileName());
BogDan Vatra's avatar
BogDan Vatra committed
226 227 228 229
    if (fileInfo.exists())
        settings.setValue(changeTimeStamp, fileInfo.lastModified().toMSecsSinceEpoch() / 1000);

    // user settings
Daniel Teske's avatar
Daniel Teske committed
230 231 232 233 234 235 236 237
    settings.setValue(SDKLocationKey, m_sdkLocation.toString());
    settings.setValue(NDKLocationKey, m_ndkLocation.toString());
    settings.setValue(AntLocationKey, m_antLocation.toString());
    settings.setValue(OpenJDKLocationKey, m_openJDKLocation.toString());
    settings.setValue(KeystoreLocationKey, m_keystoreLocation.toString());
    settings.setValue(PartitionSizeKey, m_partitionSize);
    settings.setValue(AutomaticKitCreationKey, m_automaticKitCreation);
    settings.setValue(ToolchainHostKey, m_toolchainHost);
238
    settings.setValue(MakeExtraSearchDirectory,
Daniel Teske's avatar
Daniel Teske committed
239 240
                      m_makeExtraSearchDirectories.isEmpty() ? QString()
                                                             : m_makeExtraSearchDirectories.at(0));
BogDan Vatra's avatar
BogDan Vatra committed
241 242
}

Daniel Teske's avatar
Daniel Teske committed
243
void AndroidConfig::updateNdkInformation() const
BogDan Vatra's avatar
BogDan Vatra committed
244
{
Daniel Teske's avatar
Daniel Teske committed
245 246
    if (m_NdkInformationUpToDate)
        return;
247
    m_availableNdkPlatforms.clear();
Daniel Teske's avatar
Daniel Teske committed
248
    FileName path = ndkLocation();
BogDan Vatra's avatar
BogDan Vatra committed
249
    QDirIterator it(path.appendPath(QLatin1String("platforms")).toString(), QStringList() << QLatin1String("android-*"), QDir::Dirs);
BogDan Vatra's avatar
BogDan Vatra committed
250 251
    while (it.hasNext()) {
        const QString &fileName = it.next();
252
        m_availableNdkPlatforms.push_back(fileName.mid(fileName.lastIndexOf(QLatin1Char('-')) + 1).toInt());
BogDan Vatra's avatar
BogDan Vatra committed
253
    }
254
    Utils::sort(m_availableNdkPlatforms, std::greater<int>());
Daniel Teske's avatar
Daniel Teske committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270

    // detect toolchain host
    QStringList hostPatterns;
    switch (HostOsInfo::hostOs()) {
    case OsTypeLinux:
        hostPatterns << QLatin1String("linux*");
        break;
    case OsTypeWindows:
        hostPatterns << QLatin1String("windows*");
        break;
    case OsTypeMac:
        hostPatterns << QLatin1String("darwin*");
        break;
    default: /* unknown host */ return;
    }

Daniel Teske's avatar
Daniel Teske committed
271
    path = ndkLocation();
Daniel Teske's avatar
Daniel Teske committed
272 273 274 275 276 277 278
    QDirIterator jt(path.appendPath(QLatin1String("prebuilt")).toString(), hostPatterns, QDir::Dirs);
    if (jt.hasNext()) {
        jt.next();
        m_toolchainHost = jt.fileName();
    }

    m_NdkInformationUpToDate = true;
BogDan Vatra's avatar
BogDan Vatra committed
279 280
}

281 282 283 284 285 286 287 288 289
bool AndroidConfig::sortSdkPlatformByApiLevel(const SdkPlatform &a, const SdkPlatform &b)
{
    if (a.apiLevel != b.apiLevel)
        return a.apiLevel > b.apiLevel;
    if (a.name != b.name)
        return a.name < b.name;
    return false;
}

Daniel Teske's avatar
Daniel Teske committed
290
void AndroidConfig::updateAvailableSdkPlatforms() const
BogDan Vatra's avatar
BogDan Vatra committed
291
{
Daniel Teske's avatar
Daniel Teske committed
292 293
    if (m_availableSdkPlatformsUpToDate)
        return;
294 295
    m_availableSdkPlatforms.clear();

BogDan Vatra's avatar
BogDan Vatra committed
296
    QProcess proc;
297
    proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
Tobias Hunger's avatar
Tobias Hunger committed
298
    proc.start(androidToolPath().toString(), QStringList() << QLatin1String("list") << QLatin1String("target")); // list avaialbe AVDs
299
    if (!proc.waitForFinished(5000)) {
BogDan Vatra's avatar
BogDan Vatra committed
300
        proc.terminate();
301
        return;
BogDan Vatra's avatar
BogDan Vatra committed
302
    }
303 304

    SdkPlatform platform;
305
    while (proc.canReadLine()) {
306
        const QString line = QString::fromLocal8Bit(proc.readLine().trimmed());
307 308 309 310 311 312 313 314
        if (line.startsWith(QLatin1String("id:")) && line.contains(QLatin1String("android-"))) {
            int index = line.indexOf(QLatin1String("\"android-"));
            if (index == -1)
                continue;
            QString androidTarget = line.mid(index + 1, line.length() - index - 2);
            platform.apiLevel = androidTarget.mid(androidTarget.lastIndexOf(QLatin1Char('-')) + 1).toInt();
        } else if (line.startsWith(QLatin1String("Name:"))) {
            platform.name = line.mid(6);
315 316
        } else if (line.startsWith(QLatin1String("Tag/ABIs :"))) {
            platform.abis = cleanAndroidABIs(line.mid(10).trimmed().split(QLatin1String(", ")));
317
        } else if (line.startsWith(QLatin1String("ABIs"))) {
318
            platform.abis = cleanAndroidABIs(line.mid(6).trimmed().split(QLatin1String(", ")));
319 320 321 322 323 324 325 326
        } else if (line.startsWith(QLatin1String("---")) || line.startsWith(QLatin1String("==="))) {
            if (platform.apiLevel == -1)
                continue;
            auto it = qLowerBound(m_availableSdkPlatforms.begin(), m_availableSdkPlatforms.end(),
                                  platform, sortSdkPlatformByApiLevel);
            m_availableSdkPlatforms.insert(it, platform);
            platform = SdkPlatform();
        }
BogDan Vatra's avatar
BogDan Vatra committed
327
    }
328 329 330 331 332 333 334

    if (platform.apiLevel != -1) {
        auto it = qLowerBound(m_availableSdkPlatforms.begin(), m_availableSdkPlatforms.end(),
                              platform, sortSdkPlatformByApiLevel);
        m_availableSdkPlatforms.insert(it, platform);
    }

Daniel Teske's avatar
Daniel Teske committed
335
    m_availableSdkPlatformsUpToDate = true;
336 337
}

338 339 340 341 342 343 344 345
QStringList AndroidConfig::apiLevelNamesFor(const QList<SdkPlatform> &platforms)
{
    QStringList results;
    foreach (const SdkPlatform &platform, platforms)
        results << QLatin1String("android-") + QString::number(platform.apiLevel);
    return results;
}

346 347 348 349 350
QString AndroidConfig::apiLevelNameFor(const SdkPlatform &platform)
{
    return QLatin1String("android-") + QString::number(platform.apiLevel);
}

351
QList<SdkPlatform> AndroidConfig::sdkTargets(int minApiLevel) const
352
{
Daniel Teske's avatar
Daniel Teske committed
353
    updateAvailableSdkPlatforms();
354
    QList<SdkPlatform> result;
355
    for (int i = 0; i < m_availableSdkPlatforms.size(); ++i) {
356 357
        if (m_availableSdkPlatforms.at(i).apiLevel >= minApiLevel)
            result << m_availableSdkPlatforms.at(i);
358 359 360 361
        else
            break;
    }
    return result;
BogDan Vatra's avatar
BogDan Vatra committed
362 363
}

Daniel Teske's avatar
Daniel Teske committed
364
FileName AndroidConfig::adbToolPath() const
BogDan Vatra's avatar
BogDan Vatra committed
365
{
Daniel Teske's avatar
Daniel Teske committed
366
    Utils::FileName path = m_sdkLocation;
367
    return path.appendPath(QLatin1String("platform-tools/adb" QTC_HOST_EXE_SUFFIX));
BogDan Vatra's avatar
BogDan Vatra committed
368 369
}

Daniel Teske's avatar
Daniel Teske committed
370
Utils::Environment AndroidConfig::androidToolEnvironment() const
371 372
{
    Utils::Environment env = Utils::Environment::systemEnvironment();
Daniel Teske's avatar
Daniel Teske committed
373 374
    if (!m_openJDKLocation.isEmpty())
        env.set(QLatin1String("JAVA_HOME"), m_openJDKLocation.toUserOutput());
375 376 377
    return env;
}

Daniel Teske's avatar
Daniel Teske committed
378
FileName AndroidConfig::androidToolPath() const
BogDan Vatra's avatar
BogDan Vatra committed
379
{
380 381 382
    if (HostOsInfo::isWindowsHost()) {
        // I want to switch from using android.bat to using an executable. All it really does is call
        // Java and I've made some progress on it. So if android.exe exists, return that instead.
Daniel Teske's avatar
Daniel Teske committed
383
        FileName path = m_sdkLocation;
384
        path.appendPath(QLatin1String("tools/android" QTC_HOST_EXE_SUFFIX));
385 386
        if (path.toFileInfo().exists())
            return path;
Daniel Teske's avatar
Daniel Teske committed
387
        path = m_sdkLocation;
388
        return path.appendPath(QLatin1String("tools/android" ANDROID_BAT_SUFFIX));
389
    } else {
Daniel Teske's avatar
Daniel Teske committed
390
        FileName path = m_sdkLocation;
391 392
        return path.appendPath(QLatin1String("tools/android"));
    }
BogDan Vatra's avatar
BogDan Vatra committed
393 394
}

Daniel Teske's avatar
Daniel Teske committed
395
FileName AndroidConfig::antToolPath() const
BogDan Vatra's avatar
BogDan Vatra committed
396
{
Daniel Teske's avatar
Daniel Teske committed
397 398
    if (!m_antLocation.isEmpty())
        return m_antLocation;
BogDan Vatra's avatar
BogDan Vatra committed
399
    else
400
        return FileName::fromLatin1("ant");
BogDan Vatra's avatar
BogDan Vatra committed
401 402
}

Daniel Teske's avatar
Daniel Teske committed
403
FileName AndroidConfig::emulatorToolPath() const
BogDan Vatra's avatar
BogDan Vatra committed
404
{
Daniel Teske's avatar
Daniel Teske committed
405
    FileName path = m_sdkLocation;
406
    return path.appendPath(QLatin1String("tools/emulator" QTC_HOST_EXE_SUFFIX));
BogDan Vatra's avatar
BogDan Vatra committed
407 408
}

Daniel Teske's avatar
Daniel Teske committed
409
FileName AndroidConfig::toolPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
BogDan Vatra's avatar
BogDan Vatra committed
410
{
Daniel Teske's avatar
Daniel Teske committed
411
    FileName path = m_ndkLocation;
Tobias Hunger's avatar
Tobias Hunger committed
412
    return path.appendPath(QString::fromLatin1("toolchains/%1-%2/prebuilt/%3/bin/%4")
BogDan Vatra's avatar
BogDan Vatra committed
413
            .arg(toolchainPrefix(architecture))
414
            .arg(ndkToolChainVersion)
Daniel Teske's avatar
Daniel Teske committed
415
            .arg(toolchainHost())
Tobias Hunger's avatar
Tobias Hunger committed
416
            .arg(toolsPrefix(architecture)));
BogDan Vatra's avatar
BogDan Vatra committed
417 418
}

Daniel Teske's avatar
Daniel Teske committed
419
FileName AndroidConfig::stripPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
BogDan Vatra's avatar
BogDan Vatra committed
420
{
421
    return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-strip" QTC_HOST_EXE_SUFFIX));
BogDan Vatra's avatar
BogDan Vatra committed
422 423
}

Daniel Teske's avatar
Daniel Teske committed
424
FileName AndroidConfig::readelfPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
BogDan Vatra's avatar
BogDan Vatra committed
425
{
426
    return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-readelf" QTC_HOST_EXE_SUFFIX));
BogDan Vatra's avatar
BogDan Vatra committed
427 428
}

Daniel Teske's avatar
Daniel Teske committed
429
FileName AndroidConfig::gccPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
430
{
431
    return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-gcc" QTC_HOST_EXE_SUFFIX));
432 433
}

Daniel Teske's avatar
Daniel Teske committed
434
FileName AndroidConfig::gdbPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
BogDan Vatra's avatar
BogDan Vatra committed
435
{
436
    return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-gdb" QTC_HOST_EXE_SUFFIX));
BogDan Vatra's avatar
BogDan Vatra committed
437 438
}

Daniel Teske's avatar
Daniel Teske committed
439
FileName AndroidConfig::openJDKBinPath() const
BogDan Vatra's avatar
BogDan Vatra committed
440
{
Daniel Teske's avatar
Daniel Teske committed
441
    FileName path = m_openJDKLocation;
Tobias Hunger's avatar
Tobias Hunger committed
442 443 444
    if (!path.isEmpty())
        return path.appendPath(QLatin1String("bin"));
    return path;
BogDan Vatra's avatar
BogDan Vatra committed
445 446
}

Daniel Teske's avatar
Daniel Teske committed
447
FileName AndroidConfig::keytoolPath() const
BogDan Vatra's avatar
BogDan Vatra committed
448
{
Tobias Hunger's avatar
Tobias Hunger committed
449
    return openJDKBinPath().appendPath(keytoolName);
BogDan Vatra's avatar
BogDan Vatra committed
450 451
}

Daniel Teske's avatar
Daniel Teske committed
452
FileName AndroidConfig::jarsignerPath() const
BogDan Vatra's avatar
BogDan Vatra committed
453
{
Tobias Hunger's avatar
Tobias Hunger committed
454
    return openJDKBinPath().appendPath(jarsignerName);
BogDan Vatra's avatar
BogDan Vatra committed
455 456
}

Daniel Teske's avatar
Daniel Teske committed
457
FileName AndroidConfig::zipalignPath() const
458
{
Daniel Teske's avatar
Daniel Teske committed
459
    FileName path = m_sdkLocation;
460
    return path.appendPath(QLatin1String("tools/zipalign" QTC_HOST_EXE_SUFFIX));
461 462
}

Daniel Teske's avatar
Daniel Teske committed
463
QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const
BogDan Vatra's avatar
BogDan Vatra committed
464
{
465
    QVector<AndroidDeviceInfo> devices;
BogDan Vatra's avatar
BogDan Vatra committed
466
    QProcess adbProc;
Tobias Hunger's avatar
Tobias Hunger committed
467
    adbProc.start(adbToolPath().toString(), QStringList() << QLatin1String("devices"));
468
    if (!adbProc.waitForFinished(10000)) {
469
        adbProc.kill();
470
        if (error)
Daniel Teske's avatar
Daniel Teske committed
471 472 473
            *error = QApplication::translate("AndroidConfiguration",
                                             "Could not run: %1")
                .arg(adbToolPath().toString() + QLatin1String(" devices"));
BogDan Vatra's avatar
BogDan Vatra committed
474 475 476
        return devices;
    }
    QList<QByteArray> adbDevs = adbProc.readAll().trimmed().split('\n');
BogDan Vatra's avatar
BogDan Vatra committed
477 478 479 480 481 482
    if (adbDevs.empty())
        return devices;

    while (adbDevs.first().startsWith("* daemon"))
        adbDevs.removeFirst(); // remove the daemon logs
    adbDevs.removeFirst(); // remove "List of devices attached" header line
483 484 485

    // workaround for '????????????' serial numbers:
    // can use "adb -d" when only one usb device attached
BogDan Vatra's avatar
BogDan Vatra committed
486
    foreach (const QByteArray &device, adbDevs) {
487 488
        const QString serialNo = QString::fromLatin1(device.left(device.indexOf('\t')).trimmed());
        const QString deviceType = QString::fromLatin1(device.mid(device.indexOf('\t'))).trimmed();
489 490
        if (isBootToQt(serialNo))
            continue;
491
        AndroidDeviceInfo dev;
492
        dev.serialNumber = serialNo;
493
        dev.type = serialNo.startsWith(QLatin1String("emulator")) ? AndroidDeviceInfo::Emulator : AndroidDeviceInfo::Hardware;
BogDan Vatra's avatar
BogDan Vatra committed
494
        dev.sdk = getSDKVersion(dev.serialNumber);
495
        dev.cpuAbi = getAbis(dev.serialNumber);
Daniel Teske's avatar
Daniel Teske committed
496 497 498 499 500 501
        if (deviceType == QLatin1String("unauthorized"))
            dev.state = AndroidDeviceInfo::UnAuthorizedState;
        else if (deviceType == QLatin1String("offline"))
            dev.state = AndroidDeviceInfo::OfflineState;
        else
            dev.state = AndroidDeviceInfo::OkState;
BogDan Vatra's avatar
BogDan Vatra committed
502 503
        devices.push_back(dev);
    }
504

505
    Utils::sort(devices, androidDevicesLessThan);
506
    if (devices.isEmpty() && error)
Daniel Teske's avatar
Daniel Teske committed
507 508 509
        *error = QApplication::translate("AndroidConfiguration",
                                         "No devices found in output of: %1")
            .arg(adbToolPath().toString() + QLatin1String(" devices"));
BogDan Vatra's avatar
BogDan Vatra committed
510 511 512
    return devices;
}

513
AndroidConfig::CreateAvdInfo AndroidConfig::gatherCreateAVDInfo(QWidget *parent, int minApiLevel, QString targetArch) const
BogDan Vatra's avatar
BogDan Vatra committed
514
{
515
    CreateAvdInfo result;
516 517
    AvdDialog d(minApiLevel, targetArch, this, parent);
    if (d.exec() != QDialog::Accepted || !d.isValid())
518
        return result;
519

520 521 522 523 524 525
    result.target = d.target();
    result.name = d.name();
    result.abi = d.abi();
    result.sdcardSize = d.sdcardSize();
    return result;
}
526

527 528 529
QFuture<AndroidConfig::CreateAvdInfo> AndroidConfig::createAVD(CreateAvdInfo info) const
{
    return QtConcurrent::run(&AndroidConfig::createAVDImpl, info, androidToolPath(), androidToolEnvironment());
BogDan Vatra's avatar
BogDan Vatra committed
530 531
}

532
AndroidConfig::CreateAvdInfo AndroidConfig::createAVDImpl(CreateAvdInfo info, Utils::FileName androidToolPath, Utils::Environment env)
BogDan Vatra's avatar
BogDan Vatra committed
533 534
{
    QProcess proc;
535 536 537 538 539 540 541 542 543 544 545 546 547
    proc.setProcessEnvironment(env.toProcessEnvironment());
    QStringList arguments;
    arguments << QLatin1String("create") << QLatin1String("avd")
              << QLatin1String("-t") << info.target
              << QLatin1String("-n") << info.name
              << QLatin1String("-b") << info.abi
              << QLatin1String("-c") << QString::fromLatin1("%1M").arg(info.sdcardSize);
    proc.start(androidToolPath.toString(), arguments);
    if (!proc.waitForStarted()) {
        info.error = QApplication::translate("AndroidConfig", "Could not start process \"%1 %2\"")
                .arg(androidToolPath.toString(), arguments.join(QLatin1String(" ")));
        return info;
    }
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568

    proc.write(QByteArray("yes\n")); // yes to "Do you wish to create a custom hardware profile"

    QByteArray question;
    while (true) {
        proc.waitForReadyRead(500);
        question += proc.readAllStandardOutput();
        if (question.endsWith(QByteArray("]:"))) {
            // truncate to last line
            int index = question.lastIndexOf(QByteArray("\n"));
            if (index != -1)
                question = question.mid(index);
            if (question.contains("hw.gpu.enabled"))
                proc.write(QByteArray("yes\n"));
            else
                proc.write(QByteArray("\n"));
            question.clear();
        }

        if (proc.state() != QProcess::Running)
            break;
BogDan Vatra's avatar
BogDan Vatra committed
569
    }
570 571 572

    proc.waitForFinished();

573 574 575 576
    QString errorOutput = QString::fromLocal8Bit(proc.readAllStandardError());
    // The exit code is always 0, so we need to check stderr
    // For now assume that any output at all indicates a error
    if (!errorOutput.isEmpty()) {
577
        info.error = errorOutput;
578 579
    }

580
    return info;
BogDan Vatra's avatar
BogDan Vatra committed
581 582
}

Daniel Teske's avatar
Daniel Teske committed
583
bool AndroidConfig::removeAVD(const QString &name) const
BogDan Vatra's avatar
BogDan Vatra committed
584 585
{
    QProcess proc;
586
    proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
Tobias Hunger's avatar
Tobias Hunger committed
587
    proc.start(androidToolPath().toString(),
BogDan Vatra's avatar
BogDan Vatra committed
588 589
               QStringList() << QLatin1String("delete") << QLatin1String("avd")
               << QLatin1String("-n") << name);
590
    if (!proc.waitForFinished(5000)) {
BogDan Vatra's avatar
BogDan Vatra committed
591 592 593 594 595 596
        proc.terminate();
        return false;
    }
    return !proc.exitCode();
}

Daniel Teske's avatar
Daniel Teske committed
597
QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevices() const
BogDan Vatra's avatar
BogDan Vatra committed
598
{
599
    QVector<AndroidDeviceInfo> devices;
BogDan Vatra's avatar
BogDan Vatra committed
600
    QProcess proc;
601
    proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
Tobias Hunger's avatar
Tobias Hunger committed
602
    proc.start(androidToolPath().toString(),
BogDan Vatra's avatar
BogDan Vatra committed
603
               QStringList() << QLatin1String("list") << QLatin1String("avd")); // list available AVDs
604
    if (!proc.waitForFinished(5000)) {
BogDan Vatra's avatar
BogDan Vatra committed
605 606 607 608
        proc.terminate();
        return devices;
    }
    QList<QByteArray> avds = proc.readAll().trimmed().split('\n');
BogDan Vatra's avatar
BogDan Vatra committed
609 610 611 612 613 614 615
    if (avds.empty())
        return devices;

    while (avds.first().startsWith("* daemon"))
        avds.removeFirst(); // remove the daemon logs
    avds.removeFirst(); // remove "List of devices attached" header line

616
    AndroidDeviceInfo dev;
BogDan Vatra's avatar
BogDan Vatra committed
617 618 619 620 621 622 623 624 625 626 627
    for (int i = 0; i < avds.size(); i++) {
        QString line = QLatin1String(avds[i]);
        if (!line.contains(QLatin1String("Name:")))
            continue;

        dev.serialNumber = line.mid(line.indexOf(QLatin1Char(':')) + 2).trimmed();
        ++i;
        for (; i < avds.size(); ++i) {
            line = QLatin1String(avds[i]);
            if (line.contains(QLatin1String("---------")))
                break;
628 629 630 631 632 633 634
            if (line.contains(QLatin1String("Target:"))) {
                QString tmp = line.mid(line.lastIndexOf(QLatin1Char(' '))).remove(QLatin1Char(')')).trimmed();
                if (tmp == QLatin1String("L")) // HACK for android-L preview
                    dev.sdk = 20;
                else
                    dev.sdk = tmp.toInt();
            }
635 636 637
            if (line.contains(QLatin1String("Tag/ABI:")))
                dev.cpuAbi = QStringList() << line.mid(line.lastIndexOf(QLatin1Char('/')) +1);
            else if (line.contains(QLatin1String("ABI:")))
638
                dev.cpuAbi = QStringList() << line.mid(line.lastIndexOf(QLatin1Char(' '))).trimmed();
BogDan Vatra's avatar
BogDan Vatra committed
639
        }
640 641 642
        // armeabi-v7a devices can also run armeabi code
        if (dev.cpuAbi == QStringList(QLatin1String("armeabi-v7a")))
            dev.cpuAbi << QLatin1String("armeabi");
Daniel Teske's avatar
Daniel Teske committed
643
        dev.state = AndroidDeviceInfo::OkState;
644
        dev.type = AndroidDeviceInfo::Emulator;
BogDan Vatra's avatar
BogDan Vatra committed
645 646
        devices.push_back(dev);
    }
647
    Utils::sort(devices, androidDevicesLessThan);
BogDan Vatra's avatar
BogDan Vatra committed
648 649 650 651

    return devices;
}

Daniel Teske's avatar
Daniel Teske committed
652
QString AndroidConfig::startAVD(const QString &name, int apiLevel, QString cpuAbi) const
653
{
654
    if (!findAvd(apiLevel, cpuAbi).isEmpty() || startAVDAsync(name))
655 656 657
        return waitForAvd(apiLevel, cpuAbi);
    return QString();
}
BogDan Vatra's avatar
BogDan Vatra committed
658

Daniel Teske's avatar
Daniel Teske committed
659
bool AndroidConfig::startAVDAsync(const QString &avdName) const
660 661
{
    QProcess *avdProcess = new QProcess();
Daniel Teske's avatar
Daniel Teske committed
662
    avdProcess->connect(avdProcess, SIGNAL(finished(int)), avdProcess, SLOT(deleteLater()));
BogDan Vatra's avatar
BogDan Vatra committed
663 664

    // start the emulator
Orgad Shaneh's avatar
Orgad Shaneh committed
665
    avdProcess->start(emulatorToolPath().toString(),
Daniel Teske's avatar
Daniel Teske committed
666
                        QStringList() << QLatin1String("-partition-size") << QString::number(partitionSize())
BogDan Vatra's avatar
BogDan Vatra committed
667
                        << QLatin1String("-avd") << avdName);
Orgad Shaneh's avatar
Orgad Shaneh committed
668 669
    if (!avdProcess->waitForStarted(-1)) {
        delete avdProcess;
670
        return false;
BogDan Vatra's avatar
BogDan Vatra committed
671
    }
672 673 674
    return true;
}

Daniel Teske's avatar
Daniel Teske committed
675
QString AndroidConfig::findAvd(int apiLevel, const QString &cpuAbi) const
676 677 678 679 680 681 682 683 684
{
    QVector<AndroidDeviceInfo> devices = connectedDevices();
    foreach (AndroidDeviceInfo device, devices) {
        if (!device.serialNumber.startsWith(QLatin1String("emulator")))
            continue;
        if (!device.cpuAbi.contains(cpuAbi))
            continue;
        if (device.sdk != apiLevel)
            continue;
685
        return device.serialNumber;
686
    }
687
    return QString();
688 689
}

Daniel Teske's avatar
Daniel Teske committed
690
bool AndroidConfig::isConnected(const QString &serialNumber) const
691
{
Daniel Teske's avatar
Daniel Teske committed
692 693 694 695 696 697 698
    QVector<AndroidDeviceInfo> devices = connectedDevices();
    foreach (AndroidDeviceInfo device, devices) {
        if (device.serialNumber == serialNumber)
            return true;
    }
    return false;
}
699

Daniel Teske's avatar
Daniel Teske committed
700
bool AndroidConfig::waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const
Daniel Teske's avatar
Daniel Teske committed
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
{
    // found a serial number, now wait until it's done booting...
    for (int i = 0; i < 60; ++i) {
        if (fi.isCanceled())
            return false;
        if (hasFinishedBooting(serialNumber)) {
            return true;
        } else {
            Utils::sleep(2000);
            if (!isConnected(serialNumber)) // device was disconnected
                return false;
        }
    }
    return false;
}

Daniel Teske's avatar
Daniel Teske committed
717
QString AndroidConfig::waitForAvd(int apiLevel, const QString &cpuAbi, const QFutureInterface<bool> &fi) const
Daniel Teske's avatar
Daniel Teske committed
718 719 720
{
    // we cannot use adb -e wait-for-device, since that doesn't work if a emulator is already running
    // 60 rounds of 2s sleeping, two minutes for the avd to start
721
    QString serialNumber;
Daniel Teske's avatar
Daniel Teske committed
722 723
    for (int i = 0; i < 60; ++i) {
        if (fi.isCanceled())
Orgad Shaneh's avatar
Orgad Shaneh committed
724
            return QString();
Daniel Teske's avatar
Daniel Teske committed
725 726 727 728
        serialNumber = findAvd(apiLevel, cpuAbi);
        if (!serialNumber.isEmpty())
            return waitForBooted(serialNumber, fi) ?  serialNumber : QString();
        Utils::sleep(2000);
BogDan Vatra's avatar
BogDan Vatra committed
729 730 731 732
    }
    return QString();
}

Daniel Teske's avatar
Daniel Teske committed
733
bool AndroidConfig::isBootToQt(const QString &device) const
734 735 736 737 738 739 740 741
{
    // workaround for '????????????' serial numbers
    QStringList arguments = AndroidDeviceInfo::adbSelector(device);
    arguments << QLatin1String("shell")
              << QLatin1String("ls -l /system/bin/appcontroller || ls -l /usr/bin/appcontroller && echo Boot2Qt");

    QProcess adbProc;
    adbProc.start(adbToolPath().toString(), arguments);
742
    if (!adbProc.waitForFinished(10000)) {
743
        adbProc.kill();
744
        return false;
745 746 747 748
    }
    return adbProc.readAll().contains("Boot2Qt");
}

Daniel Teske's avatar
Daniel Teske committed
749
int AndroidConfig::getSDKVersion(const QString &device) const
BogDan Vatra's avatar
BogDan Vatra committed
750
{
751 752 753 754
    // workaround for '????????????' serial numbers
    QStringList arguments = AndroidDeviceInfo::adbSelector(device);
    arguments << QLatin1String("shell") << QLatin1String("getprop")
              << QLatin1String("ro.build.version.sdk");
BogDan Vatra's avatar
BogDan Vatra committed
755 756

    QProcess adbProc;
757
    adbProc.start(adbToolPath().toString(), arguments);
758
    if (!adbProc.waitForFinished(10000)) {
759
        adbProc.kill();
BogDan Vatra's avatar
BogDan Vatra committed
760 761 762 763 764
        return -1;
    }
    return adbProc.readAll().trimmed().toInt();
}

765 766 767 768 769
//!
//! \brief AndroidConfigurations::getProductModel
//! \param device serial number
//! \return the produce model of the device or if that cannot be read the serial number
//!
Daniel Teske's avatar
Daniel Teske committed
770
QString AndroidConfig::getProductModel(const QString &device) const
771
{
772 773
    if (m_serialNumberToDeviceName.contains(device))
        return m_serialNumberToDeviceName.value(device);
774 775 776 777 778 779 780
    // workaround for '????????????' serial numbers
    QStringList arguments = AndroidDeviceInfo::adbSelector(device);
    arguments << QLatin1String("shell") << QLatin1String("getprop")
              << QLatin1String("ro.product.model");

    QProcess adbProc;
    adbProc.start(adbToolPath().toString(), arguments);
781
    if (!adbProc.waitForFinished(10000)) {
782 783 784 785 786 787
        adbProc.kill();
        return device;
    }
    QString model = QString::fromLocal8Bit(adbProc.readAll().trimmed());
    if (model.isEmpty())
        return device;
788 789
    if (!device.startsWith(QLatin1String("????")))
        m_serialNumberToDeviceName.insert(device, model);
790 791 792
    return model;
}

Daniel Teske's avatar
Daniel Teske committed
793
bool AndroidConfig::hasFinishedBooting(const QString &device) const
794 795 796 797 798 799 800
{
    QStringList arguments = AndroidDeviceInfo::adbSelector(device);
    arguments << QLatin1String("shell") << QLatin1String("getprop")
              << QLatin1String("init.svc.bootanim");

    QProcess adbProc;
    adbProc.start(adbToolPath().toString(), arguments);
801
    if (!adbProc.waitForFinished(10000)) {
802 803 804 805 806 807 808 809 810
        adbProc.kill();
        return false;
    }
    QString value = QString::fromLocal8Bit(adbProc.readAll().trimmed());
    if (value == QLatin1String("stopped"))
        return true;
    return false;
}

Daniel Teske's avatar
Daniel Teske committed
811
QStringList AndroidConfig::getAbis(const QString &device) const
812 813
{
    QStringList result;
814
    for (int i = 1; i < 6; ++i) {
815 816 817 818 819 820 821 822 823
        QStringList arguments = AndroidDeviceInfo::adbSelector(device);
        arguments << QLatin1String("shell") << QLatin1String("getprop");
        if (i == 1)
            arguments << QLatin1String("ro.product.cpu.abi");
        else
            arguments << QString::fromLatin1("ro.product.cpu.abi%1").arg(i);

        QProcess adbProc;
        adbProc.start(adbToolPath().toString(), arguments);
824
        if (!adbProc.waitForFinished(10000)) {
825 826 827 828 829 830 831 832 833 834 835
            adbProc.kill();
            return result;
        }
        QString abi = QString::fromLocal8Bit(adbProc.readAll().trimmed());
        if (abi.isEmpty())
            break;
        result << abi;
    }
    return result;
}

836
SdkPlatform AndroidConfig::highestAndroidSdk() const
837
{
Daniel Teske's avatar
Daniel Teske committed
838
    updateAvailableSdkPlatforms();
839
    if (m_availableSdkPlatforms.isEmpty())
840 841
        return SdkPlatform();
    return m_availableSdkPlatforms.first();
842 843
}

844
QString AndroidConfig::bestNdkPlatformMatch(int target) const
BogDan Vatra's avatar
BogDan Vatra committed
845
{
846
    target = std::max(9, target);
847
    updateNdkInformation();
848
    foreach (int apiLevel, m_availableNdkPlatforms) {
BogDan Vatra's avatar
BogDan Vatra committed
849 850 851
        if (apiLevel <= target)
            return QString::fromLatin1("android-%1").arg(apiLevel);
    }
852
    return QLatin1String("android-9");
BogDan Vatra's avatar
BogDan Vatra committed
853 854
}

Daniel Teske's avatar
Daniel Teske committed
855
FileName AndroidConfig::sdkLocation() const
856
{
Daniel Teske's avatar
Daniel Teske committed
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
    return m_sdkLocation;
}

void AndroidConfig::setSdkLocation(const FileName &sdkLocation)
{
    m_sdkLocation = sdkLocation;
    m_availableSdkPlatformsUpToDate = false;
}

FileName AndroidConfig::ndkLocation() const
{
    return m_ndkLocation;
}

void AndroidConfig::setNdkLocation(const FileName &ndkLocation)
{
    m_ndkLocation = ndkLocation;
    m_NdkInformationUpToDate = false;
}

FileName AndroidConfig::antLocation() const
{
    return m_antLocation;
}

void AndroidConfig::setAntLocation(const FileName &antLocation)
{
    m_antLocation = antLocation;
}

FileName AndroidConfig::openJDKLocation() const
{
    return m_openJDKLocation;
}

void AndroidConfig::