2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "android_global.h"
|
2021-05-06 15:19:56 +02:00
|
|
|
#include "androiddeviceinfo.h"
|
2020-07-01 23:42:34 +03:00
|
|
|
#include "androidsdkmanager.h"
|
2021-05-06 15:19:56 +02:00
|
|
|
#include "androidsdkpackage.h"
|
2020-07-01 23:42:34 +03:00
|
|
|
|
2016-10-24 15:53:37 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2019-12-23 16:13:23 +02:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2016-10-24 15:53:37 +02:00
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QString>
|
2013-05-03 15:10:21 +02:00
|
|
|
#include <QStringList>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <QVector>
|
2013-09-10 19:19:31 +02:00
|
|
|
#include <QHash>
|
|
|
|
|
#include <QMap>
|
2017-03-30 14:47:34 +02:00
|
|
|
#include <QVersionNumber>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <utils/fileutils.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2015-03-05 11:56:15 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class Abi;
|
|
|
|
|
class Project;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
namespace Android {
|
2017-08-18 08:22:34 +02:00
|
|
|
|
2018-02-09 16:16:38 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
class AndroidSdkManager;
|
|
|
|
|
class AndroidPluginPrivate;
|
|
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-08-18 08:22:34 +02:00
|
|
|
class CreateAvdInfo
|
2014-03-24 16:31:28 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2020-01-08 14:55:16 +02:00
|
|
|
bool isValid() const { return systemImage && systemImage->isValid() && !name.isEmpty(); }
|
|
|
|
|
const SystemImage *systemImage = nullptr;
|
2014-03-24 16:31:28 +01:00
|
|
|
QString name;
|
2017-08-18 08:22:34 +02:00
|
|
|
QString abi;
|
2020-01-08 14:55:16 +02:00
|
|
|
QString deviceDefinition;
|
2017-08-18 08:22:34 +02:00
|
|
|
int sdcardSize = 0;
|
|
|
|
|
QString error; // only used in the return value of createAVD
|
2020-01-08 14:55:16 +02:00
|
|
|
bool overwrite = false;
|
2014-03-24 16:31:28 +01:00
|
|
|
};
|
|
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
struct SdkForQtVersions
|
|
|
|
|
{
|
|
|
|
|
QList<QtSupport::QtVersionNumber> versions;
|
|
|
|
|
QStringList essentialPackages;
|
|
|
|
|
QString ndkPath;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool containsVersion(const QtSupport::QtVersionNumber &qtVersion) const;
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
class ANDROID_EXPORT AndroidConfig
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-08-09 01:56:51 +02:00
|
|
|
public:
|
2013-12-16 20:19:07 +01:00
|
|
|
void load(const QSettings &settings);
|
|
|
|
|
void save(QSettings &settings) const;
|
|
|
|
|
|
2017-08-18 08:22:34 +02:00
|
|
|
static QStringList apiLevelNamesFor(const SdkPlatformList &platforms);
|
|
|
|
|
static QString apiLevelNameFor(const SdkPlatform *platform);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath sdkLocation() const;
|
|
|
|
|
void setSdkLocation(const Utils::FilePath &sdkLocation);
|
2017-03-30 14:47:34 +02:00
|
|
|
QVersionNumber sdkToolsVersion() const;
|
2017-09-04 14:54:50 +02:00
|
|
|
QVersionNumber buildToolsVersion() const;
|
2017-09-27 15:26:59 +02:00
|
|
|
QStringList sdkManagerToolArgs() const;
|
|
|
|
|
void setSdkManagerToolArgs(const QStringList &args);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
Utils::FilePath ndkLocation(const QtSupport::BaseQtVersion *qtVersion) const;
|
|
|
|
|
QVersionNumber ndkVersion(const QtSupport::BaseQtVersion *qtVersion) const;
|
|
|
|
|
QVersionNumber ndkVersion(const Utils::FilePath &ndkPath) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2020-03-18 14:24:52 +01:00
|
|
|
QUrl sdkToolsUrl() const { return m_sdkToolsUrl; }
|
|
|
|
|
QByteArray getSdkToolsSha256() const { return m_sdkToolsSha256; }
|
2019-12-23 16:13:23 +02:00
|
|
|
QString ndkPathFromQtVersion(const QtSupport::BaseQtVersion &version) const;
|
|
|
|
|
|
|
|
|
|
QStringList defaultEssentials() const;
|
|
|
|
|
QStringList essentialsFromQtVersion(const QtSupport::BaseQtVersion &version) const;
|
|
|
|
|
QStringList allEssentials() const;
|
2020-07-01 23:42:34 +03:00
|
|
|
bool allEssentialsInstalled(Internal::AndroidSdkManager *sdkManager);
|
2020-05-18 18:58:32 +03:00
|
|
|
bool sdkToolsOk() const;
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath openJDKLocation() const;
|
|
|
|
|
void setOpenJDKLocation(const Utils::FilePath &openJDKLocation);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath keystoreLocation() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
QString toolchainHost(const QtSupport::BaseQtVersion *qtVersion) const;
|
|
|
|
|
QString toolchainHostFromNdk(const Utils::FilePath &ndkPath) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2020-10-06 18:49:15 +02:00
|
|
|
QStringList emulatorArgs() const;
|
|
|
|
|
void setEmulatorArgs(const QStringList &args);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
bool automaticKitCreation() const;
|
|
|
|
|
void setAutomaticKitCreation(bool b);
|
|
|
|
|
|
2020-05-18 18:58:32 +03:00
|
|
|
static Utils::FilePath defaultSdkPath();
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath adbToolPath() const;
|
|
|
|
|
Utils::FilePath emulatorToolPath() const;
|
|
|
|
|
Utils::FilePath sdkManagerToolPath() const;
|
|
|
|
|
Utils::FilePath avdManagerToolPath() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
Utils::FilePath toolchainPath(const QtSupport::BaseQtVersion *qtVersion) const;
|
2020-02-24 11:19:02 +02:00
|
|
|
Utils::FilePath toolchainPathFromNdk(const Utils::FilePath &ndkLocation) const;
|
|
|
|
|
Utils::FilePath clangPathFromNdk(const Utils::FilePath &ndkLocation) const;
|
2019-08-26 14:19:07 +03:00
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
Utils::FilePath gdbPath(const ProjectExplorer::Abi &abi, const QtSupport::BaseQtVersion *qtVersion) const;
|
2020-02-24 11:19:02 +02:00
|
|
|
Utils::FilePath gdbPathFromNdk(const ProjectExplorer::Abi &abi, const Utils::FilePath &ndkLocation) const;
|
2020-02-16 20:46:23 +02:00
|
|
|
Utils::FilePath makePathFromNdk(const Utils::FilePath &ndkLocation) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath keytoolPath() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2018-05-07 17:36:00 +02:00
|
|
|
QVector<AndroidDeviceInfo> connectedDevices(QString *error = nullptr) const;
|
2019-06-06 16:27:55 +02:00
|
|
|
static QVector<AndroidDeviceInfo> connectedDevices(const Utils::FilePath &adbToolPath, QString *error = nullptr);
|
2015-01-08 17:05:09 +01:00
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
QString bestNdkPlatformMatch(int target, const QtSupport::BaseQtVersion *qtVersion) const;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2014-11-18 18:37:05 +01:00
|
|
|
static QLatin1String toolchainPrefix(const ProjectExplorer::Abi &abi);
|
|
|
|
|
static QLatin1String toolsPrefix(const ProjectExplorer::Abi &abi);
|
|
|
|
|
static QLatin1String displayName(const ProjectExplorer::Abi &abi);
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2013-07-03 17:58:48 +02:00
|
|
|
QString getProductModel(const QString &device) const;
|
2015-04-10 16:46:30 +02:00
|
|
|
enum class OpenGl { Enabled, Disabled, Unknown };
|
|
|
|
|
OpenGl getOpenGLEnabled(const QString &emulator) const;
|
2013-11-13 16:35:29 +01:00
|
|
|
bool isConnected(const QString &serialNumber) const;
|
2013-07-03 17:58:48 +02:00
|
|
|
|
2020-04-16 16:44:06 +03:00
|
|
|
bool isCmdlineSdkToolsInstalled() const;
|
2017-07-14 19:35:48 +02:00
|
|
|
|
2020-03-18 14:24:52 +01:00
|
|
|
bool sdkFullyConfigured() const { return m_sdkFullyConfigured; }
|
|
|
|
|
void setSdkFullyConfigured(bool allEssentialsInstalled) { m_sdkFullyConfigured = allEssentialsInstalled; }
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2020-02-24 11:19:02 +02:00
|
|
|
bool isValidNdk(const QString &ndkLocation) const;
|
|
|
|
|
QStringList getCustomNdkList() const;
|
|
|
|
|
void addCustomNdk(const QString &customNdk);
|
|
|
|
|
void removeCustomNdk(const QString &customNdk);
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
Utils::FilePath openSslLocation() const;
|
|
|
|
|
void setOpenSslLocation(const Utils::FilePath &openSslLocation);
|
|
|
|
|
|
2020-06-26 00:33:43 +03:00
|
|
|
static Utils::FilePath getJdkPath();
|
2021-08-16 13:48:26 +02:00
|
|
|
static QStringList getAbis(const Utils::FilePath &adbToolPath, const QString &device);
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2021-08-22 01:51:57 +03:00
|
|
|
static QStringList getRunningAvdsFromDevices(const QVector<AndroidDeviceInfo> &devs);
|
|
|
|
|
|
2013-12-16 20:19:07 +01:00
|
|
|
private:
|
2019-06-06 16:27:55 +02:00
|
|
|
static QString getDeviceProperty(const Utils::FilePath &adbToolPath,
|
|
|
|
|
const QString &device, const QString &property);
|
2014-04-11 13:31:01 +02:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath openJDKBinPath() const;
|
2019-07-23 12:49:13 +02:00
|
|
|
static int getSDKVersion(const Utils::FilePath &adbToolPath, const QString &device);
|
2015-04-23 16:25:44 +02:00
|
|
|
static QString getAvdName(const QString &serialnumber);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
void parseDependenciesJson();
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
QVector<int> availableNdkPlatforms(const QtSupport::BaseQtVersion *qtVersion) const;
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath m_sdkLocation;
|
2017-09-27 15:26:59 +02:00
|
|
|
QStringList m_sdkManagerToolArgs;
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath m_openJDKLocation;
|
|
|
|
|
Utils::FilePath m_keystoreLocation;
|
2020-02-28 19:27:03 +02:00
|
|
|
Utils::FilePath m_openSslLocation;
|
2020-10-06 18:49:15 +02:00
|
|
|
QStringList m_emulatorArgs;
|
2016-12-05 14:04:54 +01:00
|
|
|
bool m_automaticKitCreation = true;
|
2019-12-23 16:13:23 +02:00
|
|
|
QUrl m_sdkToolsUrl;
|
|
|
|
|
QByteArray m_sdkToolsSha256;
|
|
|
|
|
QStringList m_commonEssentialPkgs;
|
|
|
|
|
SdkForQtVersions m_defaultSdkDepends;
|
|
|
|
|
QList<SdkForQtVersions> m_specificQtVersions;
|
2020-02-24 11:19:02 +02:00
|
|
|
QStringList m_customNdkList;
|
2019-12-23 16:13:23 +02:00
|
|
|
bool m_sdkFullyConfigured = false;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
//caches
|
|
|
|
|
mutable QHash<QString, QString> m_serialNumberToDeviceName;
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
class ANDROID_EXPORT AndroidConfigurations : public QObject
|
2013-12-16 20:19:07 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2014-03-07 13:44:20 +01:00
|
|
|
static const AndroidConfig ¤tConfig();
|
2017-08-18 08:22:34 +02:00
|
|
|
static Internal::AndroidSdkManager *sdkManager();
|
2013-12-16 20:19:07 +01:00
|
|
|
static void setConfig(const AndroidConfig &config);
|
|
|
|
|
static AndroidConfigurations *instance();
|
|
|
|
|
|
2015-04-22 17:42:23 +02:00
|
|
|
static void registerNewToolChains();
|
2020-02-24 11:19:02 +02:00
|
|
|
static void registerCustomToolChainsAndDebuggers();
|
2020-02-25 00:19:28 +02:00
|
|
|
static void removeUnusedDebuggers();
|
2015-04-22 17:42:23 +02:00
|
|
|
static void removeOldToolChains();
|
2013-12-16 20:19:07 +01:00
|
|
|
static void updateAutomaticKitList();
|
2014-10-31 16:09:34 +01:00
|
|
|
static bool force32bitEmulator();
|
2021-04-30 17:50:30 +02:00
|
|
|
static Utils::Environment toolsEnvironment(const AndroidConfig &config);
|
2013-09-10 19:19:31 +02:00
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
signals:
|
2019-11-18 16:57:44 +01:00
|
|
|
void aboutToUpdate();
|
2012-04-18 20:30:57 +03:00
|
|
|
void updated();
|
|
|
|
|
|
|
|
|
|
private:
|
2018-02-09 16:16:38 +01:00
|
|
|
friend class Android::Internal::AndroidPluginPrivate;
|
2018-01-26 14:57:01 +01:00
|
|
|
AndroidConfigurations();
|
2018-05-07 15:08:46 +02:00
|
|
|
~AndroidConfigurations() override;
|
2012-04-18 20:30:57 +03:00
|
|
|
void load();
|
|
|
|
|
void save();
|
|
|
|
|
|
2018-02-09 16:16:38 +01:00
|
|
|
static void updateAndroidDevice();
|
2012-04-18 20:30:57 +03:00
|
|
|
static AndroidConfigurations *m_instance;
|
|
|
|
|
AndroidConfig m_config;
|
2017-08-18 08:22:34 +02:00
|
|
|
std::unique_ptr<Internal::AndroidSdkManager> m_sdkManager;
|
2014-10-31 16:09:34 +01:00
|
|
|
bool m_force32bit;
|
2012-04-18 20:30:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Android
|