2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
|
|
|
|
// Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2022-07-22 10:32:08 +02:00
|
|
|
#include <utils/filepath.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2022-07-22 10:32:08 +02:00
|
|
|
namespace ProjectExplorer { class Abi; }
|
2015-03-05 11:56:15 +01:00
|
|
|
|
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;
|
2021-09-11 18:38:13 +03:00
|
|
|
bool cancelled = false;
|
2014-03-24 16:31:28 +01:00
|
|
|
};
|
|
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
struct SdkForQtVersions
|
|
|
|
|
{
|
2022-07-04 18:36:40 +02:00
|
|
|
QList<QVersionNumber> versions;
|
2019-12-23 16:13:23 +02:00
|
|
|
QStringList essentialPackages;
|
|
|
|
|
|
|
|
|
|
public:
|
2022-07-04 18:36:40 +02:00
|
|
|
bool containsVersion(const QVersionNumber &qtVersion) const;
|
2019-12-23 16:13:23 +02:00
|
|
|
};
|
|
|
|
|
|
2023-08-18 09:55:43 +02:00
|
|
|
class 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;
|
2020-11-28 15:44:37 +02:00
|
|
|
Utils::FilePath sdkToolsVersionPath() 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
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
Utils::FilePath ndkLocation(const QtSupport::QtVersion *qtVersion) const;
|
|
|
|
|
QVersionNumber ndkVersion(const QtSupport::QtVersion *qtVersion) const;
|
2022-01-25 07:59:21 +01:00
|
|
|
static QVersionNumber ndkVersion(const Utils::FilePath &ndkPath);
|
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; }
|
2023-01-06 15:39:05 +01:00
|
|
|
Utils::FilePath ndkSubPathFromQtVersion(const QtSupport::QtVersion &version) const; // relative!
|
2019-12-23 16:13:23 +02:00
|
|
|
|
|
|
|
|
QStringList defaultEssentials() const;
|
2022-01-21 16:06:36 +01:00
|
|
|
QStringList essentialsFromQtVersion(const QtSupport::QtVersion &version) const;
|
2019-12-23 16:13:23 +02:00
|
|
|
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
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
QString toolchainHost(const QtSupport::QtVersion *qtVersion) const;
|
2022-01-25 07:59:21 +01:00
|
|
|
static QString toolchainHostFromNdk(const Utils::FilePath &ndkPath);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2022-04-14 16:52:51 +02:00
|
|
|
QString emulatorArgs() const;
|
|
|
|
|
void setEmulatorArgs(const QString &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-11-28 15:44:37 +02:00
|
|
|
void setTemporarySdkToolsPath(const Utils::FilePath &path);
|
|
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
Utils::FilePath toolchainPath(const QtSupport::QtVersion *qtVersion) const;
|
2022-01-25 09:28:43 +01:00
|
|
|
static Utils::FilePath toolchainPathFromNdk(const Utils::FilePath &ndkLocation,
|
|
|
|
|
Utils::OsType hostOs = Utils::HostOsInfo::hostOs());
|
2022-01-25 07:59:21 +01:00
|
|
|
static Utils::FilePath clangPathFromNdk(const Utils::FilePath &ndkLocation);
|
2019-08-26 14:19:07 +03:00
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
Utils::FilePath gdbPath(const ProjectExplorer::Abi &abi, const QtSupport::QtVersion *qtVersion) const;
|
2022-01-25 07:59:21 +01:00
|
|
|
static Utils::FilePath gdbPathFromNdk(const ProjectExplorer::Abi &abi,
|
|
|
|
|
const Utils::FilePath &ndkLocation);
|
|
|
|
|
static Utils::FilePath lldbPathFromNdk(const Utils::FilePath &ndkLocation);
|
|
|
|
|
static Utils::FilePath makePathFromNdk(const Utils::FilePath &ndkLocation);
|
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;
|
2015-01-08 17:05:09 +01:00
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
QString bestNdkPlatformMatch(int target, const QtSupport::QtVersion *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;
|
2013-11-13 16:35:29 +01:00
|
|
|
bool isConnected(const QString &serialNumber) const;
|
2013-07-03 17:58: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);
|
2021-12-07 21:04:51 +01:00
|
|
|
void setDefaultNdk(const Utils::FilePath &defaultNdk);
|
|
|
|
|
Utils::FilePath defaultNdk() const;
|
2020-02-24 11:19:02 +02:00
|
|
|
|
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-10-06 22:24:52 +03:00
|
|
|
static QStringList getAbis(const QString &device);
|
2021-10-29 18:19:54 +03:00
|
|
|
static int getSDKVersion(const QString &device);
|
2021-08-22 01:51:57 +03:00
|
|
|
|
2023-07-27 14:44:44 +02:00
|
|
|
Utils::Environment toolsEnvironment() const;
|
|
|
|
|
|
2013-12-16 20:19:07 +01:00
|
|
|
private:
|
2021-10-06 22:24:52 +03:00
|
|
|
static QString getDeviceProperty(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;
|
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
|
|
|
|
2022-01-31 08:03:37 +01:00
|
|
|
QList<int> availableNdkPlatforms(const QtSupport::QtVersion *qtVersion) const;
|
2020-02-16 20:46:23 +02:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath m_sdkLocation;
|
2020-11-28 15:44:37 +02:00
|
|
|
Utils::FilePath m_temporarySdkToolsPath;
|
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;
|
2022-04-14 16:52:51 +02:00
|
|
|
QString 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;
|
2021-12-07 21:04:51 +01:00
|
|
|
Utils::FilePath m_defaultNdk;
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-18 09:55:43 +02:00
|
|
|
class AndroidConfigurations : public QObject
|
2013-12-16 20:19:07 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2021-10-25 15:58:02 +03:00
|
|
|
static 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();
|
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;
|
2012-04-18 20:30:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Android
|
2022-01-31 08:03:37 +01:00
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(ProjectExplorer::Abis)
|
|
|
|
|
Q_DECLARE_METATYPE(Utils::OsType)
|