2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02: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-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-24 15:49:09 +02: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-24 15:49:09 +02: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-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "android_global.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-08-28 15:48:02 +02:00
|
|
|
#include <QPair>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <QObject>
|
2018-07-03 11:53:25 +02:00
|
|
|
#include <QVersionNumber>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
#include <projectexplorer/abi.h>
|
|
|
|
|
|
2018-08-07 11:12:45 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QProcess;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class Kit;
|
|
|
|
|
class Target;
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-06-06 16:27:55 +02:00
|
|
|
namespace Utils {
|
|
|
|
|
class CommandLine;
|
|
|
|
|
class FilePath;
|
|
|
|
|
}
|
2015-03-05 11:56:15 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
namespace Android {
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2018-08-07 11:12:45 +02:00
|
|
|
class SdkToolResult {
|
|
|
|
|
public:
|
|
|
|
|
SdkToolResult() = default;
|
|
|
|
|
bool success() const { return m_success; }
|
|
|
|
|
const QString &stdOut() { return m_stdOut; }
|
|
|
|
|
const QString &stdErr() { return m_stdErr; }
|
|
|
|
|
const QString &exitMessage() { return m_exitMessage; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool m_success = false;
|
|
|
|
|
QString m_stdOut;
|
|
|
|
|
QString m_stdErr;
|
|
|
|
|
QString m_exitMessage;
|
|
|
|
|
friend class AndroidManager;
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
class ANDROID_EXPORT AndroidManager : public QObject
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static QString packageName(ProjectExplorer::Target *target);
|
2019-05-28 13:49:26 +02:00
|
|
|
static QString packageName(const Utils::FilePath &manifestFile);
|
2018-08-07 14:47:08 +02:00
|
|
|
static bool packageInstalled(const QString &deviceSerial, const QString &packageName);
|
|
|
|
|
static int packageVersionCode(const QString &deviceSerial, const QString &packageName);
|
2019-05-28 13:49:26 +02:00
|
|
|
static void apkInfo(const Utils::FilePath &apkPath,
|
2018-07-03 11:53:25 +02:00
|
|
|
QString *packageName = nullptr,
|
2018-08-07 14:47:08 +02:00
|
|
|
int *version = nullptr,
|
2018-07-03 11:53:25 +02:00
|
|
|
QString *activityPath = nullptr);
|
2012-04-24 15:49:09 +02:00
|
|
|
static QString activityName(ProjectExplorer::Target *target);
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
static QString deviceSerialNumber(ProjectExplorer::Target *target);
|
2014-06-25 15:42:11 +02:00
|
|
|
static void setDeviceSerialNumber(ProjectExplorer::Target *target, const QString &deviceSerialNumber);
|
2013-03-07 13:22:21 +01:00
|
|
|
|
2020-05-18 16:20:21 +02:00
|
|
|
static QString apkDevicePreferredAbi(const ProjectExplorer::Target *target);
|
2019-08-26 14:19:07 +03:00
|
|
|
static void setDeviceAbis(ProjectExplorer::Target *target, const QStringList &deviceAbis);
|
|
|
|
|
|
2018-03-17 09:31:56 +02:00
|
|
|
static int deviceApiLevel(ProjectExplorer::Target *target);
|
|
|
|
|
static void setDeviceApiLevel(ProjectExplorer::Target *target, int level);
|
|
|
|
|
|
2013-08-28 15:20:54 +02:00
|
|
|
static QString buildTargetSDK(ProjectExplorer::Target *target);
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2013-08-28 15:23:04 +02:00
|
|
|
static int minimumSDK(ProjectExplorer::Target *target);
|
2016-08-17 18:46:12 +02:00
|
|
|
static int minimumSDK(const ProjectExplorer::Kit *kit);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
static QStringList applicationAbis(const ProjectExplorer::Target *target);
|
2020-01-20 11:20:09 +02:00
|
|
|
static QString archTriplet(const QString &abi);
|
2013-05-03 15:10:21 +02:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
static Utils::FilePath dirPath(const ProjectExplorer::Target *target);
|
|
|
|
|
static Utils::FilePath manifestPath(ProjectExplorer::Target *target);
|
|
|
|
|
static void setManifestPath(ProjectExplorer::Target *target, const Utils::FilePath &path);
|
|
|
|
|
static Utils::FilePath manifestSourcePath(ProjectExplorer::Target *target);
|
|
|
|
|
static Utils::FilePath defaultPropertiesPath(ProjectExplorer::Target *target);
|
|
|
|
|
static Utils::FilePath apkPath(const ProjectExplorer::Target *target);
|
2019-08-26 14:19:07 +03:00
|
|
|
static bool matchedAbis(const QStringList &deviceAbis, const QStringList &appAbis);
|
|
|
|
|
static QString devicePreferredAbi(const QStringList &deviceAbis, const QStringList &appAbis);
|
|
|
|
|
static ProjectExplorer::Abi androidAbi2Abi(const QString &androidAbi);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2014-05-07 15:03:43 +03:00
|
|
|
static QPair<int, int> apiLevelRange();
|
2013-08-14 13:39:45 +02:00
|
|
|
static QString androidNameForApiLevel(int x);
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
static void installQASIPackage(ProjectExplorer::Target *target, const QString &packagePath);
|
|
|
|
|
|
|
|
|
|
static bool checkKeystorePassword(const QString &keystorePath, const QString &keystorePasswd);
|
|
|
|
|
static bool checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd);
|
2017-01-10 16:33:56 +01:00
|
|
|
static bool checkCertificateExists(const QString &keystorePath, const QString &keystorePasswd,
|
|
|
|
|
const QString &alias);
|
2019-08-01 10:12:34 +02:00
|
|
|
static bool updateGradleProperties(ProjectExplorer::Target *target, const QString &buildKey);
|
2019-05-28 13:49:26 +02:00
|
|
|
static int findApiLevel(const Utils::FilePath &platformPath);
|
2018-07-03 11:51:28 +02:00
|
|
|
|
2018-08-07 11:12:45 +02:00
|
|
|
static QProcess *runAdbCommandDetached(const QStringList &args, QString *err = nullptr,
|
|
|
|
|
bool deleteOnFinish = false);
|
|
|
|
|
static SdkToolResult runAdbCommand(const QStringList &args, const QByteArray &writeData = {},
|
|
|
|
|
int timeoutS = 30);
|
|
|
|
|
static SdkToolResult runAaptCommand(const QStringList &args, int timeoutS = 30);
|
|
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
static QJsonObject deploymentSettings(const ProjectExplorer::Target *target);
|
2020-01-20 11:20:09 +02:00
|
|
|
static bool isQtCreatorGenerated(const Utils::FilePath &deploymentFile);
|
2019-03-06 14:17:17 +02:00
|
|
|
|
2018-08-07 11:12:45 +02:00
|
|
|
private:
|
2019-06-06 16:27:55 +02:00
|
|
|
static SdkToolResult runCommand(const Utils::CommandLine &command,
|
2018-08-07 11:12:45 +02:00
|
|
|
const QByteArray &writeData = {}, int timeoutS = 30);
|
2012-04-24 15:49:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Android
|