2012-04-18 20:30:57 +03:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-04-18 20:30:57 +03:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#ifndef ANDROIDCONFIGURATIONS_H
|
|
|
|
|
#define ANDROIDCONFIGURATIONS_H
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "android_global.h"
|
|
|
|
|
|
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>
|
2013-11-13 16:35:29 +01:00
|
|
|
#include <QFutureInterface>
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Utils { class Environment; }
|
2013-09-10 19:19:31 +02:00
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
namespace Android {
|
2013-12-16 20:19:07 +01:00
|
|
|
class AndroidPlugin;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
struct AndroidDeviceInfo
|
|
|
|
|
{
|
2012-04-18 20:30:57 +03:00
|
|
|
QString serialNumber;
|
2013-07-04 12:43:26 +02:00
|
|
|
QStringList cpuAbi;
|
2012-04-18 20:30:57 +03:00
|
|
|
int sdk;
|
2014-03-10 15:18:46 +01:00
|
|
|
enum State { OkState, UnAuthorizedState, OfflineState };
|
|
|
|
|
State state;
|
2013-08-28 12:50:32 +02:00
|
|
|
bool unauthorized;
|
2013-09-10 19:19:31 +02:00
|
|
|
enum AndroidDeviceType { Hardware, Emulator };
|
|
|
|
|
AndroidDeviceType type;
|
2013-02-24 18:04:36 +04:00
|
|
|
|
|
|
|
|
static QStringList adbSelector(const QString &serialNumber);
|
2012-04-18 20:30:57 +03:00
|
|
|
};
|
|
|
|
|
|
2014-03-24 16:31:28 +01:00
|
|
|
class SdkPlatform
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SdkPlatform()
|
|
|
|
|
: apiLevel(-1)
|
|
|
|
|
{}
|
|
|
|
|
int apiLevel;
|
|
|
|
|
QString name;
|
|
|
|
|
QStringList abis;
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
AndroidConfig();
|
|
|
|
|
|
|
|
|
|
void load(const QSettings &settings);
|
|
|
|
|
void save(QSettings &settings) const;
|
|
|
|
|
|
2014-03-24 16:31:28 +01:00
|
|
|
static QStringList apiLevelNamesFor(const QList<SdkPlatform> &platforms);
|
2014-06-25 15:42:11 +02:00
|
|
|
static QString apiLevelNameFor(const SdkPlatform &platform);
|
2014-03-24 16:31:28 +01:00
|
|
|
QList<SdkPlatform> sdkTargets(int minApiLevel = 0) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
Utils::FileName sdkLocation() const;
|
|
|
|
|
void setSdkLocation(const Utils::FileName &sdkLocation);
|
|
|
|
|
|
|
|
|
|
Utils::FileName ndkLocation() const;
|
|
|
|
|
void setNdkLocation(const Utils::FileName &ndkLocation);
|
|
|
|
|
|
|
|
|
|
Utils::FileName antLocation() const;
|
|
|
|
|
void setAntLocation(const Utils::FileName &antLocation);
|
|
|
|
|
|
|
|
|
|
Utils::FileName openJDKLocation() const;
|
|
|
|
|
void setOpenJDKLocation(const Utils::FileName &openJDKLocation);
|
|
|
|
|
|
|
|
|
|
Utils::FileName keystoreLocation() const;
|
|
|
|
|
void setKeystoreLocation(const Utils::FileName &keystoreLocation);
|
|
|
|
|
|
|
|
|
|
QString toolchainHost() const;
|
|
|
|
|
QStringList makeExtraSearchDirectories() const;
|
|
|
|
|
|
|
|
|
|
unsigned partitionSize() const;
|
|
|
|
|
void setPartitionSize(unsigned partitionSize);
|
|
|
|
|
|
|
|
|
|
bool automaticKitCreation() const;
|
|
|
|
|
void setAutomaticKitCreation(bool b);
|
|
|
|
|
|
2014-09-22 16:20:51 +03:00
|
|
|
bool useGrandle() const;
|
|
|
|
|
void setUseGradle(bool b);
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName adbToolPath() const;
|
|
|
|
|
Utils::FileName androidToolPath() const;
|
2013-11-19 17:25:32 +01:00
|
|
|
Utils::Environment androidToolEnvironment() const;
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName antToolPath() const;
|
|
|
|
|
Utils::FileName emulatorToolPath() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
|
2014-11-18 18:37:05 +01:00
|
|
|
Utils::FileName gccPath(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion) const;
|
|
|
|
|
Utils::FileName gdbPath(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName keytoolPath() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2014-04-11 13:31:01 +02:00
|
|
|
class CreateAvdInfo
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QString target;
|
|
|
|
|
QString name;
|
|
|
|
|
QString abi;
|
|
|
|
|
int sdcardSize;
|
|
|
|
|
QString error; // only used in the return value of createAVD
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CreateAvdInfo gatherCreateAVDInfo(QWidget *parent, int minApiLevel = 0, QString targetArch = QString()) const;
|
|
|
|
|
QFuture<CreateAvdInfo> createAVD(CreateAvdInfo info) const;
|
2012-04-18 20:30:57 +03:00
|
|
|
bool removeAVD(const QString &name) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2013-07-03 17:58:48 +02:00
|
|
|
QVector<AndroidDeviceInfo> connectedDevices(QString *error = 0) const;
|
2015-04-10 18:08:51 +02:00
|
|
|
static QVector<AndroidDeviceInfo> connectedDevices(const QString &adbToolPath, QString *error = 0);
|
2015-01-08 17:05:09 +01:00
|
|
|
|
|
|
|
|
QFuture<QVector<AndroidDeviceInfo> > androidVirtualDevicesFuture();
|
2012-07-03 16:57:44 +03:00
|
|
|
QVector<AndroidDeviceInfo> androidVirtualDevices() const;
|
2015-04-10 18:08:51 +02:00
|
|
|
static QVector<AndroidDeviceInfo> androidVirtualDevices(const QString &androidTool, const Utils::Environment &environment);
|
2015-01-08 17:05:09 +01:00
|
|
|
|
2013-07-05 18:54:42 +02:00
|
|
|
QString startAVD(const QString &name, int apiLevel, QString cpuAbi) const;
|
|
|
|
|
bool startAVDAsync(const QString &avdName) const;
|
2013-11-13 16:32:38 +01:00
|
|
|
QString findAvd(int apiLevel, const QString &cpuAbi) const;
|
2013-11-13 16:35:29 +01:00
|
|
|
QString waitForAvd(int apiLevel, const QString &cpuAbi, const QFutureInterface<bool> &fi = QFutureInterface<bool>()) const;
|
2014-06-25 15:41:32 +02:00
|
|
|
QString bestNdkPlatformMatch(int target) const;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2014-11-18 18:37:05 +01:00
|
|
|
static ProjectExplorer::Abi abiForToolChainPrefix(const QString &toolchainPrefix);
|
|
|
|
|
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-07-05 18:54:42 +02:00
|
|
|
bool hasFinishedBooting(const QString &device) const;
|
2013-11-13 16:35:29 +01:00
|
|
|
bool waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const;
|
|
|
|
|
bool isConnected(const QString &serialNumber) const;
|
2013-07-03 17:58:48 +02:00
|
|
|
|
2014-03-24 16:31:28 +01:00
|
|
|
SdkPlatform highestAndroidSdk() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
private:
|
2014-04-11 13:31:01 +02:00
|
|
|
static CreateAvdInfo createAVDImpl(CreateAvdInfo info, Utils::FileName androidToolPath, Utils::Environment env);
|
2015-04-10 18:08:51 +02:00
|
|
|
static QString getDeviceProperty(const QString &adbToolPath, const QString &device, const QString &property);
|
2014-04-11 13:31:01 +02:00
|
|
|
|
2014-11-18 18:37:05 +01:00
|
|
|
Utils::FileName toolPath(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
Utils::FileName openJDKBinPath() const;
|
|
|
|
|
int getSDKVersion(const QString &device) const;
|
2015-04-10 18:08:51 +02:00
|
|
|
static int getSDKVersion(const QString &adbToolPath, const QString &device);
|
2013-12-16 20:19:07 +01:00
|
|
|
QStringList getAbis(const QString &device) const;
|
2015-04-10 18:08:51 +02:00
|
|
|
static QStringList getAbis(const QString &adbToolPath, const QString &device);
|
|
|
|
|
static bool isBootToQt(const QString &adbToolPath, const QString &device);
|
2013-12-16 20:19:07 +01:00
|
|
|
bool isBootToQt(const QString &device) const;
|
|
|
|
|
|
|
|
|
|
void updateAvailableSdkPlatforms() const;
|
|
|
|
|
void updateNdkInformation() const;
|
|
|
|
|
|
|
|
|
|
Utils::FileName m_sdkLocation;
|
|
|
|
|
Utils::FileName m_ndkLocation;
|
|
|
|
|
Utils::FileName m_antLocation;
|
|
|
|
|
Utils::FileName m_openJDKLocation;
|
|
|
|
|
Utils::FileName m_keystoreLocation;
|
|
|
|
|
QStringList m_makeExtraSearchDirectories;
|
|
|
|
|
unsigned m_partitionSize;
|
|
|
|
|
bool m_automaticKitCreation;
|
2014-09-22 16:20:51 +03:00
|
|
|
bool m_useGradle;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
//caches
|
|
|
|
|
mutable bool m_availableSdkPlatformsUpToDate;
|
2014-03-24 16:31:28 +01:00
|
|
|
mutable QVector<SdkPlatform> m_availableSdkPlatforms;
|
|
|
|
|
static bool sortSdkPlatformByApiLevel(const SdkPlatform &a, const SdkPlatform &b);
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
mutable bool m_NdkInformationUpToDate;
|
|
|
|
|
mutable QString m_toolchainHost;
|
|
|
|
|
mutable QVector<int> m_availableNdkPlatforms;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
friend class Android::AndroidPlugin;
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2014-03-07 13:44:20 +01:00
|
|
|
static const AndroidConfig ¤tConfig();
|
2013-12-16 20:19:07 +01:00
|
|
|
static void setConfig(const AndroidConfig &config);
|
|
|
|
|
static AndroidConfigurations *instance();
|
|
|
|
|
|
|
|
|
|
static void updateAndroidDevice();
|
2014-11-17 16:22:28 +01:00
|
|
|
enum Options { None, FilterAndroid5 };
|
|
|
|
|
static AndroidDeviceInfo showDeviceDialog(ProjectExplorer::Project *project, int apiLevel, const QString &abi, Options options);
|
2013-12-16 20:19:07 +01:00
|
|
|
static void setDefaultDevice(ProjectExplorer::Project *project, const QString &abi, const QString &serialNumber); // serial number or avd name
|
|
|
|
|
static QString defaultDevice(ProjectExplorer::Project *project, const QString &abi); // serial number or avd name
|
2013-09-10 19:19:31 +02:00
|
|
|
public slots:
|
2013-12-16 20:19:07 +01:00
|
|
|
static void clearDefaultDevices(ProjectExplorer::Project *project);
|
2015-04-22 17:42:23 +02:00
|
|
|
static void registerNewToolChains();
|
|
|
|
|
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:
|
|
|
|
|
void updated();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
AndroidConfigurations(QObject *parent);
|
|
|
|
|
void load();
|
|
|
|
|
void save();
|
|
|
|
|
|
|
|
|
|
static AndroidConfigurations *m_instance;
|
|
|
|
|
AndroidConfig m_config;
|
2013-09-10 19:19:31 +02:00
|
|
|
|
|
|
|
|
QMap<ProjectExplorer::Project *, QMap<QString, QString> > m_defaultDeviceForAbi;
|
2014-10-31 16:09:34 +01:00
|
|
|
bool m_force32bit;
|
2012-04-18 20:30:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Android
|
|
|
|
|
|
|
|
|
|
#endif // ANDROIDCONFIGURATIONS_H
|