2012-04-18 20:30:57 +03:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** 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.
|
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
|
|
|
|
|
** 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
|
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
|
|
|
|
|
|
|
|
|
|
#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>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <projectexplorer/abi.h>
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <utils/fileutils.h>
|
2013-11-19 17:25:32 +01:00
|
|
|
#include <utils/environment.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2013-09-10 19:19:31 +02:00
|
|
|
namespace ProjectExplorer { class Project; }
|
|
|
|
|
|
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
|
|
|
namespace Internal {
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
2013-12-16 20:19:07 +01: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
|
|
|
AndroidConfig();
|
|
|
|
|
|
|
|
|
|
void load(const QSettings &settings);
|
|
|
|
|
void save(QSettings &settings) const;
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
QStringList 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);
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2013-04-04 01:29:47 -07:00
|
|
|
Utils::FileName gccPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
|
2013-01-25 16:49:22 +01:00
|
|
|
Utils::FileName gdbPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName keytoolPath() const;
|
|
|
|
|
Utils::FileName jarsignerPath() const;
|
2012-06-23 13:18:01 +03:00
|
|
|
Utils::FileName zipalignPath() const;
|
2013-01-25 16:49:22 +01:00
|
|
|
Utils::FileName stripPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
|
|
|
|
|
Utils::FileName readelfPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
|
2013-11-21 18:09:53 +01:00
|
|
|
QString createAVD(QWidget *parent, int minApiLevel = 0, QString targetArch = QString()) const;
|
2014-03-24 11:56:26 +01:00
|
|
|
QString createAVD(const QString &target, const QString &name, const QString &abi, int sdcardSize, QString *error) 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;
|
2012-07-03 16:57:44 +03:00
|
|
|
QVector<AndroidDeviceInfo> androidVirtualDevices() const;
|
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;
|
2013-10-17 13:12:45 +02:00
|
|
|
QString bestNdkPlatformMatch(const QString &targetAPI) const;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2013-01-25 16:49:22 +01:00
|
|
|
static ProjectExplorer::Abi::Architecture architectureForToolChainPrefix(const QString &toolchainprefix);
|
2012-04-18 20:30:57 +03:00
|
|
|
static QLatin1String toolchainPrefix(ProjectExplorer::Abi::Architecture architecture);
|
|
|
|
|
static QLatin1String toolsPrefix(ProjectExplorer::Abi::Architecture architecture);
|
|
|
|
|
|
2013-07-03 17:58:48 +02:00
|
|
|
QString getProductModel(const QString &device) 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
|
|
|
|
2013-10-17 13:23:08 +02:00
|
|
|
QString highestAndroidSdk() const;
|
2013-12-16 20:19:07 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Utils::FileName toolPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
|
|
|
|
|
Utils::FileName openJDKBinPath() const;
|
|
|
|
|
int getSDKVersion(const QString &device) const;
|
|
|
|
|
QStringList getAbis(const QString &device) const;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
//caches
|
|
|
|
|
mutable bool m_availableSdkPlatformsUpToDate;
|
|
|
|
|
mutable QVector<int> m_availableSdkPlatforms;
|
|
|
|
|
|
|
|
|
|
mutable bool m_NdkInformationUpToDate;
|
|
|
|
|
mutable QString m_toolchainHost;
|
|
|
|
|
mutable QVector<int> m_availableNdkPlatforms;
|
|
|
|
|
|
|
|
|
|
mutable QHash<QString, QString> m_serialNumberToDeviceName;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class AndroidConfigurations : public QObject
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
static AndroidDeviceInfo showDeviceDialog(ProjectExplorer::Project *project, int apiLevel, const QString &abi);
|
|
|
|
|
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);
|
2014-03-11 13:05:36 +01:00
|
|
|
static void updateToolChainList();
|
2013-12-16 20:19:07 +01:00
|
|
|
static void updateAutomaticKitList();
|
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;
|
2012-04-18 20:30:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Android
|
|
|
|
|
|
|
|
|
|
#endif // ANDROIDCONFIGURATIONS_H
|