2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2014-06-25 15:42:11 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-06-25 15:42:11 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2014-06-25 15:42:11 +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.
|
2014-06-25 15:42:11 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "androidbuildapkstep.h"
|
2018-07-02 18:40:29 +02:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "androidbuildapkwidget.h"
|
|
|
|
|
#include "androidconfigurations.h"
|
|
|
|
|
#include "androidconstants.h"
|
|
|
|
|
#include "androidmanager.h"
|
2017-08-18 08:22:34 +02:00
|
|
|
#include "androidsdkmanager.h"
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "certificatesmodel.h"
|
|
|
|
|
|
|
|
|
|
#include "javaparser.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/fileutils.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2019-01-18 18:07:54 +01:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <projectexplorer/processparameters.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2018-07-02 18:40:29 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2018-12-05 10:29:48 +01:00
|
|
|
#include <projectexplorer/projectnodes.h>
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
|
2017-12-06 10:27:27 +01:00
|
|
|
#include <utils/algorithm.h>
|
2019-12-13 00:06:34 +01:00
|
|
|
#include <utils/infolabel.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2016-04-29 16:52:58 +02:00
|
|
|
#include <utils/synchronousprocess.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
#include <QDateTime>
|
2016-12-22 17:55:17 +01:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QHBoxLayout>
|
2019-03-06 14:17:17 +02:00
|
|
|
#include <QJsonDocument>
|
|
|
|
|
#include <QJsonObject>
|
2016-12-22 17:55:17 +01:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
2018-06-18 11:49:14 +02:00
|
|
|
#include <QLoggingCategory>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <QMessageBox>
|
2016-04-29 16:52:58 +02:00
|
|
|
#include <QProcess>
|
2016-12-22 17:55:17 +01:00
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2018-06-13 13:51:41 +02:00
|
|
|
using namespace ProjectExplorer;
|
2019-05-15 13:59:43 +02:00
|
|
|
using namespace Utils;
|
2018-07-02 18:40:29 +02:00
|
|
|
using namespace Android::Internal;
|
|
|
|
|
|
2018-06-18 11:49:14 +02:00
|
|
|
namespace {
|
2020-01-15 14:39:23 +01:00
|
|
|
static Q_LOGGING_CATEGORY(buildapkstepLog, "qtc.android.build.androidbuildapkstep", QtWarningMsg)
|
2018-06-18 11:49:14 +02:00
|
|
|
}
|
2018-06-13 13:51:41 +02:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
namespace Android {
|
2018-07-02 18:40:29 +02:00
|
|
|
|
2017-04-12 14:08:17 +02:00
|
|
|
const QVersionNumber gradleScriptRevokedSdkVersion(25, 3, 0);
|
2017-06-12 14:23:06 +02:00
|
|
|
const char KeystoreLocationKey[] = "KeystoreLocation";
|
|
|
|
|
const char BuildTargetSdkKey[] = "BuildTargetSdk";
|
|
|
|
|
const char VerboseOutputKey[] = "VerboseOutput";
|
2017-09-27 18:24:04 -07:00
|
|
|
const char UseMinistroKey[] = "UseMinistro";
|
2016-12-22 17:55:17 +01:00
|
|
|
|
2018-06-13 13:51:41 +02:00
|
|
|
static void setupProcessParameters(ProcessParameters *pp,
|
|
|
|
|
BuildConfiguration *bc,
|
|
|
|
|
const QStringList &arguments,
|
|
|
|
|
const QString &command)
|
|
|
|
|
{
|
|
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
2019-05-15 13:59:43 +02:00
|
|
|
pp->setWorkingDirectory(bc->buildDirectory());
|
2018-06-13 13:51:41 +02:00
|
|
|
Utils::Environment env = bc->environment();
|
|
|
|
|
pp->setEnvironment(env);
|
2019-07-23 10:17:57 +02:00
|
|
|
pp->setCommandLine({command, arguments});
|
2018-06-13 13:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-23 13:42:07 +02:00
|
|
|
class PasswordInputDialog : public QDialog
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2016-12-22 17:55:17 +01:00
|
|
|
public:
|
|
|
|
|
enum Context{
|
|
|
|
|
KeystorePassword = 1,
|
|
|
|
|
CertificatePassword
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PasswordInputDialog(Context context, std::function<bool (const QString &)> callback,
|
|
|
|
|
const QString &extraContextStr, QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
static QString getPassword(Context context, std::function<bool (const QString &)> callback,
|
|
|
|
|
const QString &extraContextStr, bool *ok = nullptr,
|
|
|
|
|
QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::function<bool (const QString &)> verifyCallback = [](const QString &) { return true; };
|
|
|
|
|
QLabel *inputContextlabel = new QLabel(this);
|
|
|
|
|
QLineEdit *inputEdit = new QLineEdit(this);
|
2019-12-13 00:06:34 +01:00
|
|
|
Utils::InfoLabel *warningLabel = new Utils::InfoLabel(tr("Incorrect password."),
|
|
|
|
|
Utils::InfoLabel::Warning, this);
|
2016-12-22 17:55:17 +01:00
|
|
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
|
|
|
|
|
this);
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-20 13:48:45 +01:00
|
|
|
static FilePath aabPath(const BuildConfiguration *bc)
|
|
|
|
|
{
|
|
|
|
|
if (!bc)
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
QString buildType;
|
|
|
|
|
if (bc->buildType() == BuildConfiguration::Release)
|
|
|
|
|
buildType = "release";
|
|
|
|
|
else
|
|
|
|
|
buildType = "debug";
|
|
|
|
|
|
|
|
|
|
return bc->buildDirectory()
|
|
|
|
|
.pathAppended(Constants::ANDROID_BUILDDIRECTORY)
|
|
|
|
|
.pathAppended(QString("build/outputs/bundle/%1/android-build-%1.aab").arg(buildType));
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 17:05:30 +01:00
|
|
|
AndroidBuildApkStep::AndroidBuildApkStep(BuildStepList *parent, Core::Id id)
|
|
|
|
|
: AbstractProcessStep(parent, id),
|
2017-08-18 08:22:34 +02:00
|
|
|
m_buildTargetSdk(AndroidConfig::apiLevelNameFor(AndroidConfigurations::
|
|
|
|
|
sdkManager()->latestAndroidSdkPlatform()))
|
2014-06-25 15:42:11 +02:00
|
|
|
{
|
|
|
|
|
//: AndroidBuildApkStep default display name
|
|
|
|
|
setDefaultDisplayName(tr("Build Android APK"));
|
2018-10-22 17:56:04 +02:00
|
|
|
setImmutable(true);
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool AndroidBuildApkStep::init()
|
2014-06-25 15:42:11 +02:00
|
|
|
{
|
|
|
|
|
ProjectExplorer::BuildConfiguration *bc = buildConfiguration();
|
|
|
|
|
|
|
|
|
|
if (m_signPackage) {
|
2018-06-18 11:49:14 +02:00
|
|
|
qCDebug(buildapkstepLog) << "Signing enabled";
|
2014-06-25 15:42:11 +02:00
|
|
|
// check keystore and certificate passwords
|
2018-06-18 11:49:14 +02:00
|
|
|
if (!verifyKeystorePassword() || !verifyCertificatePassword()) {
|
|
|
|
|
qCDebug(buildapkstepLog) << "Init failed. Keystore/Certificate password verification failed.";
|
2016-12-22 17:55:17 +01:00
|
|
|
return false;
|
2018-06-18 11:49:14 +02:00
|
|
|
}
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2015-02-20 15:10:56 +01:00
|
|
|
if (bc->buildType() != ProjectExplorer::BuildConfiguration::Release)
|
|
|
|
|
emit addOutput(tr("Warning: Signing a debug or profile package."),
|
2017-01-12 10:59:12 +01:00
|
|
|
OutputFormat::ErrorMessage);
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit());
|
2014-06-25 15:42:11 +02:00
|
|
|
if (!version)
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-07-31 13:36:18 +02:00
|
|
|
const QVersionNumber sdkToolsVersion = AndroidConfigurations::currentConfig().sdkToolsVersion();
|
2017-09-08 23:36:13 +02:00
|
|
|
if (sdkToolsVersion >= gradleScriptRevokedSdkVersion) {
|
2019-05-17 13:20:41 +02:00
|
|
|
if (!version->sourcePath().pathAppended("src/3rdparty/gradle").exists()) {
|
2017-09-08 23:36:13 +02:00
|
|
|
emit addOutput(tr("The installed SDK tools version (%1) does not include Gradle "
|
|
|
|
|
"scripts. The minimum Qt version required for Gradle build to work "
|
|
|
|
|
"is %2").arg(sdkToolsVersion.toString()).arg("5.9.0/5.6.3"),
|
|
|
|
|
OutputFormat::Stderr);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) {
|
2017-12-27 13:56:54 +01:00
|
|
|
emit addOutput(tr("The minimum Qt version required for Gradle build to work is %1. "
|
2017-09-08 23:36:13 +02:00
|
|
|
"It is recommended to install the latest Qt version.")
|
|
|
|
|
.arg("5.4.0"), OutputFormat::Stderr);
|
2017-04-12 14:08:17 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-17 18:46:12 +02:00
|
|
|
int minSDKForKit = AndroidManager::minimumSDK(target()->kit());
|
|
|
|
|
if (AndroidManager::minimumSDK(target()) < minSDKForKit) {
|
|
|
|
|
emit addOutput(tr("The API level set for the APK is less than the minimum required by the kit."
|
2017-01-12 10:59:12 +01:00
|
|
|
"\nThe minimum API level required by the kit is %1.").arg(minSDKForKit), OutputFormat::Stderr);
|
2016-08-17 18:46:12 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-25 12:19:15 +02:00
|
|
|
auto parser = new JavaParser;
|
2017-12-06 10:27:27 +01:00
|
|
|
parser->setProjectFileList(Utils::transform(target()->project()->files(ProjectExplorer::Project::AllFiles),
|
2019-05-28 13:49:26 +02:00
|
|
|
&Utils::FilePath::toString));
|
2018-05-09 09:55:37 +02:00
|
|
|
|
2018-12-05 10:29:48 +01:00
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
2019-03-06 14:17:17 +02:00
|
|
|
const QString buildKey = rc ? rc->buildKey() : QString();
|
|
|
|
|
const ProjectNode *node = rc ? target()->project()->findNodeForBuildKey(buildKey) : nullptr;
|
|
|
|
|
|
|
|
|
|
QString sourceDirName;
|
|
|
|
|
if (node)
|
|
|
|
|
sourceDirName = node->data(Constants::AndroidPackageSourceDir).toString();
|
2018-12-05 10:29:48 +01:00
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
QFileInfo sourceDirInfo(sourceDirName);
|
2019-05-28 13:49:26 +02:00
|
|
|
parser->setSourceDirectory(Utils::FilePath::fromString(sourceDirInfo.canonicalFilePath()));
|
2019-05-17 13:20:41 +02:00
|
|
|
parser->setBuildDirectory(bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY));
|
2014-06-25 15:42:11 +02:00
|
|
|
setOutputParser(parser);
|
|
|
|
|
|
|
|
|
|
m_openPackageLocationForRun = m_openPackageLocation;
|
2019-12-20 13:48:45 +01:00
|
|
|
m_packagePath = m_buildAAB ? aabPath(buildConfiguration()).toString()
|
|
|
|
|
: AndroidManager::apkPath(target()).toString();
|
2019-08-26 14:19:07 +03:00
|
|
|
qCDebug(buildapkstepLog) << "Package path:" << m_packagePath;
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
if (!AbstractProcessStep::init())
|
2014-06-25 15:42:11 +02:00
|
|
|
return false;
|
|
|
|
|
|
2019-09-30 14:34:31 +02:00
|
|
|
QString command = version->hostBinPath().toString();
|
2018-06-13 13:51:41 +02:00
|
|
|
if (!command.endsWith('/'))
|
|
|
|
|
command += '/';
|
2019-11-14 16:07:55 +01:00
|
|
|
command += Utils::HostOsInfo::withExecutableSuffix("androiddeployqt");
|
2018-06-13 13:51:41 +02:00
|
|
|
|
2019-05-17 13:20:41 +02:00
|
|
|
QString outputDir = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
2018-06-13 13:51:41 +02:00
|
|
|
|
2018-12-05 10:29:48 +01:00
|
|
|
if (node)
|
2020-01-20 11:20:09 +02:00
|
|
|
m_inputFile = node->data(Constants::AndroidDeploySettingsFile).toString();
|
2018-12-05 10:29:48 +01:00
|
|
|
|
2020-01-20 11:20:09 +02:00
|
|
|
if (m_inputFile.isEmpty()) {
|
2018-06-13 13:51:41 +02:00
|
|
|
m_skipBuilding = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 18:25:11 +01:00
|
|
|
if (m_buildTargetSdk.isEmpty()) {
|
2018-06-13 13:51:41 +02:00
|
|
|
emit addOutput(tr("Android build SDK not defined. Check Android settings."),
|
|
|
|
|
OutputFormat::Stderr);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-20 11:20:09 +02:00
|
|
|
QStringList arguments = {"--input", m_inputFile,
|
2018-06-13 13:51:41 +02:00
|
|
|
"--output", outputDir,
|
2020-02-12 18:25:11 +01:00
|
|
|
"--android-platform", m_buildTargetSdk,
|
2018-06-13 13:51:41 +02:00
|
|
|
"--jdk", AndroidConfigurations::currentConfig().openJDKLocation().toString()};
|
|
|
|
|
|
|
|
|
|
if (m_verbose)
|
|
|
|
|
arguments << "--verbose";
|
|
|
|
|
|
|
|
|
|
arguments << "--gradle";
|
|
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
if (m_buildAAB)
|
|
|
|
|
arguments << "--aab" << "--jarsigner";
|
|
|
|
|
|
2018-06-13 13:51:41 +02:00
|
|
|
if (m_useMinistro)
|
|
|
|
|
arguments << "--deployment" << "ministro";
|
|
|
|
|
|
|
|
|
|
QStringList argumentsPasswordConcealed = arguments;
|
|
|
|
|
|
|
|
|
|
if (m_signPackage) {
|
|
|
|
|
arguments << "--sign" << m_keystorePath.toString() << m_certificateAlias
|
|
|
|
|
<< "--storepass" << m_keystorePasswd;
|
|
|
|
|
argumentsPasswordConcealed << "--sign" << "******"
|
|
|
|
|
<< "--storepass" << "******";
|
|
|
|
|
if (!m_certificatePasswd.isEmpty()) {
|
|
|
|
|
arguments << "--keypass" << m_certificatePasswd;
|
|
|
|
|
argumentsPasswordConcealed << "--keypass" << "******";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Must be the last option, otherwise androiddeployqt might use the other
|
|
|
|
|
// params (e.g. --sign) to choose not to add gdbserver
|
|
|
|
|
if (version->qtVersion() >= QtSupport::QtVersionNumber(5, 6, 0)) {
|
|
|
|
|
if (m_addDebugger || bc->buildType() == ProjectExplorer::BuildConfiguration::Debug)
|
|
|
|
|
arguments << "--gdbserver";
|
|
|
|
|
else
|
|
|
|
|
arguments << "--no-gdbserver";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ProcessParameters *pp = processParameters();
|
|
|
|
|
setupProcessParameters(pp, bc, arguments, command);
|
|
|
|
|
|
|
|
|
|
// Generate arguments with keystore password concealed
|
|
|
|
|
ProjectExplorer::ProcessParameters pp2;
|
|
|
|
|
setupProcessParameters(&pp2, bc, argumentsPasswordConcealed, command);
|
2019-05-15 13:59:43 +02:00
|
|
|
m_command = pp2.effectiveCommand().toString();
|
2018-06-13 13:51:41 +02:00
|
|
|
m_argumentsPasswordConcealed = pp2.prettyArguments();
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::showInGraphicalShell()
|
|
|
|
|
{
|
2019-08-26 14:19:07 +03:00
|
|
|
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), m_packagePath);
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildStepConfigWidget *AndroidBuildApkStep::createConfigWidget()
|
|
|
|
|
{
|
2018-07-02 18:40:29 +02:00
|
|
|
return new AndroidBuildApkWidget(this);
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
|
|
|
|
{
|
|
|
|
|
AbstractProcessStep::processFinished(exitCode, status);
|
|
|
|
|
if (m_openPackageLocationForRun && status == QProcess::NormalExit && exitCode == 0)
|
|
|
|
|
QMetaObject::invokeMethod(this, "showInGraphicalShell", Qt::QueuedConnection);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-22 17:55:17 +01:00
|
|
|
bool AndroidBuildApkStep::verifyKeystorePassword()
|
|
|
|
|
{
|
2017-01-10 16:33:56 +01:00
|
|
|
if (!m_keystorePath.exists()) {
|
2019-01-16 18:06:21 +01:00
|
|
|
emit addOutput(tr("Cannot sign the package. Invalid keystore path (%1).")
|
|
|
|
|
.arg(m_keystorePath.toString()), OutputFormat::ErrorMessage);
|
2017-01-10 16:33:56 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-22 17:55:17 +01:00
|
|
|
if (AndroidManager::checkKeystorePassword(m_keystorePath.toString(), m_keystorePasswd))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
auto verifyCallback = std::bind(&AndroidManager::checkKeystorePassword,
|
|
|
|
|
m_keystorePath.toString(), std::placeholders::_1);
|
|
|
|
|
m_keystorePasswd = PasswordInputDialog::getPassword(PasswordInputDialog::KeystorePassword,
|
|
|
|
|
verifyCallback, "", &success);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AndroidBuildApkStep::verifyCertificatePassword()
|
|
|
|
|
{
|
2017-01-10 16:33:56 +01:00
|
|
|
if (!AndroidManager::checkCertificateExists(m_keystorePath.toString(), m_keystorePasswd,
|
|
|
|
|
m_certificateAlias)) {
|
2019-01-16 18:06:21 +01:00
|
|
|
emit addOutput(tr("Cannot sign the package. Certificate alias %1 does not exist.")
|
|
|
|
|
.arg(m_certificateAlias), OutputFormat::ErrorMessage);
|
2017-01-10 16:33:56 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-22 17:55:17 +01:00
|
|
|
if (AndroidManager::checkCertificatePassword(m_keystorePath.toString(), m_keystorePasswd,
|
|
|
|
|
m_certificateAlias, m_certificatePasswd)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
auto verifyCallback = std::bind(&AndroidManager::checkCertificatePassword,
|
|
|
|
|
m_keystorePath.toString(), m_keystorePasswd,
|
|
|
|
|
m_certificateAlias, std::placeholders::_1);
|
|
|
|
|
|
|
|
|
|
m_certificatePasswd = PasswordInputDialog::getPassword(PasswordInputDialog::CertificatePassword,
|
|
|
|
|
verifyCallback, m_certificateAlias,
|
|
|
|
|
&success);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
|
|
|
|
|
static bool copyFileIfNewer(const QString &sourceFileName,
|
|
|
|
|
const QString &destinationFileName)
|
|
|
|
|
{
|
2020-01-20 11:20:09 +02:00
|
|
|
if (sourceFileName == destinationFileName)
|
|
|
|
|
return true;
|
2019-03-06 14:17:17 +02:00
|
|
|
if (QFile::exists(destinationFileName)) {
|
|
|
|
|
QFileInfo destinationFileInfo(destinationFileName);
|
|
|
|
|
QFileInfo sourceFileInfo(sourceFileName);
|
|
|
|
|
if (sourceFileInfo.lastModified() <= destinationFileInfo.lastModified())
|
|
|
|
|
return true;
|
|
|
|
|
if (!QFile(destinationFileName).remove())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!QDir().mkpath(QFileInfo(destinationFileName).path()))
|
|
|
|
|
return false;
|
|
|
|
|
return QFile::copy(sourceFileName, destinationFileName);
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void AndroidBuildApkStep::doRun()
|
2018-06-13 13:51:41 +02:00
|
|
|
{
|
|
|
|
|
if (m_skipBuilding) {
|
2019-03-06 14:17:17 +02:00
|
|
|
emit addOutput(tr("Android deploy settings file not found, not building an APK."), BuildStep::OutputFormat::ErrorMessage);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(true);
|
2018-06-13 13:51:41 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2019-03-06 14:17:17 +02:00
|
|
|
|
|
|
|
|
auto setup = [this] {
|
2020-02-10 16:27:58 +01:00
|
|
|
auto bc = buildConfiguration();
|
2019-08-26 14:19:07 +03:00
|
|
|
const auto androidAbis = AndroidManager::applicationAbis(target());
|
|
|
|
|
for (const auto &abi : androidAbis) {
|
|
|
|
|
Utils::FilePath androidLibsDir = bc->buildDirectory()
|
|
|
|
|
.pathAppended("android-build/libs")
|
|
|
|
|
.pathAppended(abi);
|
|
|
|
|
if (!androidLibsDir.exists() && !QDir{bc->buildDirectory().toString()}.mkpath(androidLibsDir.toString()))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-03-06 14:17:17 +02:00
|
|
|
|
|
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
|
|
|
|
const QString buildKey = rc ? rc->buildKey() : QString();
|
|
|
|
|
const ProjectNode *node = rc ? target()->project()->findNodeForBuildKey(buildKey) : nullptr;
|
|
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
|
return false;
|
|
|
|
|
|
2020-01-20 11:20:09 +02:00
|
|
|
bool inputExists = QFile::exists(m_inputFile);
|
|
|
|
|
if (inputExists && !AndroidManager::isQtCreatorGenerated(FilePath::fromString(m_inputFile)))
|
|
|
|
|
return true; // use the generated file if it was not generated by qtcreator
|
2019-10-18 09:25:14 +03:00
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
auto targets = node->data(Android::Constants::AndroidTargets).toStringList();
|
|
|
|
|
if (targets.isEmpty())
|
2020-01-20 11:20:09 +02:00
|
|
|
return inputExists; // qmake does this job for us
|
2019-03-06 14:17:17 +02:00
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
|
2020-01-20 11:20:09 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit());
|
|
|
|
|
if (!version)
|
|
|
|
|
return false;
|
2019-08-26 14:19:07 +03:00
|
|
|
|
2020-01-20 11:20:09 +02:00
|
|
|
QJsonObject deploySettings = Android::AndroidManager::deploymentSettings(target());
|
|
|
|
|
QString applicationBinary;
|
|
|
|
|
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 14, 0)) {
|
|
|
|
|
QTC_ASSERT(androidAbis.size() == 1, return false);
|
|
|
|
|
applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toString();
|
|
|
|
|
Utils::FilePath androidLibsDir = bc->buildDirectory().pathAppended("android-build/libs").pathAppended(androidAbis.first());
|
2019-08-26 14:19:07 +03:00
|
|
|
for (const auto &target : targets) {
|
2020-01-20 11:20:09 +02:00
|
|
|
if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString()))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
deploySettings["target-architecture"] = androidAbis.first();
|
|
|
|
|
} else {
|
|
|
|
|
applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toFileInfo().fileName();
|
|
|
|
|
QJsonObject architectures;
|
|
|
|
|
|
|
|
|
|
// Copy targets to android build folder
|
|
|
|
|
for (const auto &abi : androidAbis) {
|
|
|
|
|
QString targetSuffix = QString{"_%1.so"}.arg(abi);
|
|
|
|
|
if (applicationBinary.endsWith(targetSuffix)) {
|
|
|
|
|
// Keep only TargetName from "lib[TargetName]_abi.so"
|
|
|
|
|
applicationBinary.remove(0, 3).chop(targetSuffix.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::FilePath androidLibsDir = bc->buildDirectory()
|
|
|
|
|
.pathAppended("android-build/libs")
|
|
|
|
|
.pathAppended(abi);
|
|
|
|
|
for (const auto &target : targets) {
|
|
|
|
|
if (target.endsWith(targetSuffix)) {
|
|
|
|
|
if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString()))
|
|
|
|
|
return false;
|
|
|
|
|
architectures[abi] = AndroidManager::archTriplet(abi);
|
2019-08-26 14:19:07 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-20 11:20:09 +02:00
|
|
|
deploySettings["architectures"] = architectures;
|
2019-03-06 14:17:17 +02:00
|
|
|
}
|
2019-08-26 14:19:07 +03:00
|
|
|
deploySettings["application-binary"] = applicationBinary;
|
|
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
QString extraLibs = node->data(Android::Constants::AndroidExtraLibs).toString();
|
|
|
|
|
if (!extraLibs.isEmpty())
|
|
|
|
|
deploySettings["android-extra-libs"] = extraLibs;
|
|
|
|
|
|
|
|
|
|
QString androidSrcs = node->data(Android::Constants::AndroidPackageSourceDir).toString();
|
|
|
|
|
if (!androidSrcs.isEmpty())
|
|
|
|
|
deploySettings["android-package-source-directory"] = androidSrcs;
|
|
|
|
|
|
|
|
|
|
QString qmlImportPath = node->data("QML_IMPORT_PATH").toString();
|
|
|
|
|
if (!qmlImportPath.isEmpty())
|
|
|
|
|
deploySettings["qml-import-paths"] = qmlImportPath;
|
|
|
|
|
|
|
|
|
|
QString qmlRootPath = node->data("QML_ROOT_PATH").toString();
|
|
|
|
|
if (qmlRootPath.isEmpty())
|
|
|
|
|
qmlRootPath = target()->project()->rootProjectDirectory().toString();
|
2019-05-30 15:16:07 +02:00
|
|
|
deploySettings["qml-root-path"] = qmlRootPath;
|
2019-03-06 14:17:17 +02:00
|
|
|
|
2020-01-20 11:20:09 +02:00
|
|
|
QFile f{m_inputFile};
|
2019-03-06 14:17:17 +02:00
|
|
|
if (!f.open(QIODevice::WriteOnly))
|
|
|
|
|
return false;
|
|
|
|
|
f.write(QJsonDocument{deploySettings}.toJson());
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!setup()) {
|
|
|
|
|
emit addOutput(tr("Cannot set up Android, not building an APK."), BuildStep::OutputFormat::ErrorMessage);
|
|
|
|
|
emit finished(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
AbstractProcessStep::doRun();
|
2018-06-13 13:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::processStarted()
|
|
|
|
|
{
|
|
|
|
|
emit addOutput(tr("Starting: \"%1\" %2")
|
|
|
|
|
.arg(QDir::toNativeSeparators(m_command),
|
|
|
|
|
m_argumentsPasswordConcealed),
|
|
|
|
|
BuildStep::OutputFormat::NormalMessage);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
bool AndroidBuildApkStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2019-05-28 13:49:26 +02:00
|
|
|
m_keystorePath = Utils::FilePath::fromString(map.value(KeystoreLocationKey).toString());
|
2014-06-25 15:42:11 +02:00
|
|
|
m_signPackage = false; // don't restore this
|
|
|
|
|
m_buildTargetSdk = map.value(BuildTargetSdkKey).toString();
|
2017-08-18 08:22:34 +02:00
|
|
|
if (m_buildTargetSdk.isEmpty()) {
|
|
|
|
|
m_buildTargetSdk = AndroidConfig::apiLevelNameFor(AndroidConfigurations::
|
|
|
|
|
sdkManager()->latestAndroidSdkPlatform());
|
|
|
|
|
}
|
2014-06-25 15:42:11 +02:00
|
|
|
m_verbose = map.value(VerboseOutputKey).toBool();
|
2017-09-27 18:24:04 -07:00
|
|
|
m_useMinistro = map.value(UseMinistroKey).toBool();
|
2014-06-25 15:42:11 +02:00
|
|
|
return ProjectExplorer::BuildStep::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AndroidBuildApkStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = ProjectExplorer::AbstractProcessStep::toMap();
|
|
|
|
|
map.insert(KeystoreLocationKey, m_keystorePath.toString());
|
|
|
|
|
map.insert(BuildTargetSdkKey, m_buildTargetSdk);
|
|
|
|
|
map.insert(VerboseOutputKey, m_verbose);
|
2017-09-27 18:24:04 -07:00
|
|
|
map.insert(UseMinistroKey, m_useMinistro);
|
2014-06-25 15:42:11 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath AndroidBuildApkStep::keystorePath()
|
2014-06-25 15:42:11 +02:00
|
|
|
{
|
|
|
|
|
return m_keystorePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AndroidBuildApkStep::buildTargetSdk() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildTargetSdk;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setBuildTargetSdk(const QString &sdk)
|
|
|
|
|
{
|
|
|
|
|
m_buildTargetSdk = sdk;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
QVariant AndroidBuildApkStep::data(Core::Id id) const
|
|
|
|
|
{
|
2020-02-16 20:46:23 +02:00
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(target()->kit());
|
|
|
|
|
|
|
|
|
|
if (id == Constants::AndroidNdkPlatform) {
|
|
|
|
|
return AndroidConfigurations::currentConfig()
|
|
|
|
|
.bestNdkPlatformMatch(AndroidManager::minimumSDK(target()), qtVersion).mid(8);
|
|
|
|
|
}
|
2019-03-06 14:17:17 +02:00
|
|
|
if (id == Constants::NdkLocation)
|
2020-02-16 20:46:23 +02:00
|
|
|
return QVariant::fromValue(AndroidConfigurations::currentConfig().ndkLocation(qtVersion));
|
2019-10-18 09:25:14 +03:00
|
|
|
if (id == Constants::SdkLocation)
|
|
|
|
|
return QVariant::fromValue(AndroidConfigurations::currentConfig().sdkLocation());
|
2019-08-26 14:19:07 +03:00
|
|
|
if (id == Constants::AndroidABIs)
|
|
|
|
|
return AndroidManager::applicationAbis(target());
|
2019-03-06 14:17:17 +02:00
|
|
|
|
|
|
|
|
return AbstractProcessStep::data(id);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
void AndroidBuildApkStep::setKeystorePath(const Utils::FilePath &path)
|
2014-06-25 15:42:11 +02:00
|
|
|
{
|
|
|
|
|
m_keystorePath = path;
|
|
|
|
|
m_certificatePasswd.clear();
|
|
|
|
|
m_keystorePasswd.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setKeystorePassword(const QString &pwd)
|
|
|
|
|
{
|
|
|
|
|
m_keystorePasswd = pwd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setCertificateAlias(const QString &alias)
|
|
|
|
|
{
|
|
|
|
|
m_certificateAlias = alias;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setCertificatePassword(const QString &pwd)
|
|
|
|
|
{
|
|
|
|
|
m_certificatePasswd = pwd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AndroidBuildApkStep::signPackage() const
|
|
|
|
|
{
|
|
|
|
|
return m_signPackage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setSignPackage(bool b)
|
|
|
|
|
{
|
|
|
|
|
m_signPackage = b;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
bool AndroidBuildApkStep::buildAAB() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildAAB;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setBuildAAB(bool aab)
|
|
|
|
|
{
|
|
|
|
|
m_buildAAB = aab;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
bool AndroidBuildApkStep::openPackageLocation() const
|
|
|
|
|
{
|
|
|
|
|
return m_openPackageLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setOpenPackageLocation(bool open)
|
|
|
|
|
{
|
|
|
|
|
m_openPackageLocation = open;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setVerboseOutput(bool verbose)
|
|
|
|
|
{
|
|
|
|
|
m_verbose = verbose;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-27 18:24:04 -07:00
|
|
|
bool AndroidBuildApkStep::useMinistro() const
|
|
|
|
|
{
|
|
|
|
|
return m_useMinistro;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setUseMinistro(bool useMinistro)
|
|
|
|
|
{
|
|
|
|
|
m_useMinistro = useMinistro;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 14:03:20 +02:00
|
|
|
bool AndroidBuildApkStep::addDebugger() const
|
|
|
|
|
{
|
|
|
|
|
return m_addDebugger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidBuildApkStep::setAddDebugger(bool debug)
|
|
|
|
|
{
|
|
|
|
|
m_addDebugger = debug;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
bool AndroidBuildApkStep::verboseOutput() const
|
|
|
|
|
{
|
|
|
|
|
return m_verbose;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
|
|
|
|
{
|
2016-12-22 17:55:17 +01:00
|
|
|
// check keystore passwords
|
|
|
|
|
if (!verifyKeystorePassword())
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
CertificatesModel *model = nullptr;
|
2017-06-12 18:23:05 +02:00
|
|
|
const QStringList params = {"-list", "-v", "-keystore", m_keystorePath.toUserOutput(),
|
|
|
|
|
"-storepass", m_keystorePasswd, "-J-Duser.language=en"};
|
2016-12-22 17:55:17 +01:00
|
|
|
|
|
|
|
|
Utils::SynchronousProcess keytoolProc;
|
|
|
|
|
keytoolProc.setTimeoutS(30);
|
2019-06-06 16:27:55 +02:00
|
|
|
const SynchronousProcessResponse response
|
|
|
|
|
= keytoolProc.run({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
2017-01-11 09:29:37 +01:00
|
|
|
if (response.result > Utils::SynchronousProcessResponse::FinishedError)
|
2018-07-25 12:19:15 +02:00
|
|
|
QMessageBox::critical(nullptr, tr("Error"), tr("Failed to run keytool."));
|
2016-12-22 17:55:17 +01:00
|
|
|
else
|
|
|
|
|
model = new CertificatesModel(response.stdOut(), this);
|
|
|
|
|
|
|
|
|
|
return model;
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-22 17:55:17 +01:00
|
|
|
PasswordInputDialog::PasswordInputDialog(PasswordInputDialog::Context context,
|
|
|
|
|
std::function<bool (const QString &)> callback,
|
|
|
|
|
const QString &extraContextStr,
|
|
|
|
|
QWidget *parent) :
|
|
|
|
|
QDialog(parent, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint),
|
|
|
|
|
verifyCallback(callback)
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
{
|
2016-12-22 17:55:17 +01:00
|
|
|
inputEdit->setEchoMode(QLineEdit::Password);
|
|
|
|
|
|
|
|
|
|
warningLabel->hide();
|
|
|
|
|
|
|
|
|
|
auto mainLayout = new QVBoxLayout(this);
|
|
|
|
|
mainLayout->addWidget(inputContextlabel);
|
|
|
|
|
mainLayout->addWidget(inputEdit);
|
2019-12-13 00:06:34 +01:00
|
|
|
mainLayout->addWidget(warningLabel);
|
2016-12-22 17:55:17 +01:00
|
|
|
mainLayout->addWidget(buttonBox);
|
|
|
|
|
|
|
|
|
|
connect(inputEdit, &QLineEdit::textChanged,[this](const QString &text) {
|
|
|
|
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, [this]() {
|
|
|
|
|
if (verifyCallback(inputEdit->text())) {
|
|
|
|
|
accept(); // Dialog accepted.
|
|
|
|
|
} else {
|
|
|
|
|
warningLabel->show();
|
|
|
|
|
inputEdit->clear();
|
|
|
|
|
adjustSize();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
|
|
|
|
|
setWindowTitle(context == KeystorePassword ? tr("Keystore") : tr("Certificate"));
|
|
|
|
|
|
|
|
|
|
QString contextStr;
|
|
|
|
|
if (context == KeystorePassword)
|
|
|
|
|
contextStr = tr("Enter keystore password");
|
|
|
|
|
else
|
|
|
|
|
contextStr = tr("Enter certificate password");
|
|
|
|
|
|
|
|
|
|
contextStr += extraContextStr.isEmpty() ? QStringLiteral(":") :
|
|
|
|
|
QStringLiteral(" (%1):").arg(extraContextStr);
|
|
|
|
|
inputContextlabel->setText(contextStr);
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-22 17:55:17 +01:00
|
|
|
QString PasswordInputDialog::getPassword(Context context, std::function<bool (const QString &)> callback,
|
|
|
|
|
const QString &extraContextStr, bool *ok, QWidget *parent)
|
2014-06-25 15:42:11 +02:00
|
|
|
{
|
2016-12-22 17:55:17 +01:00
|
|
|
std::unique_ptr<PasswordInputDialog> dlg(new PasswordInputDialog(context, callback,
|
|
|
|
|
extraContextStr, parent));
|
|
|
|
|
bool isAccepted = dlg->exec() == QDialog::Accepted;
|
|
|
|
|
if (ok)
|
|
|
|
|
*ok = isAccepted;
|
|
|
|
|
return isAccepted ? dlg->inputEdit->text() : "";
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-02 18:40:29 +02:00
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// AndroidBuildApkStepFactory
|
|
|
|
|
|
|
|
|
|
AndroidBuildApkStepFactory::AndroidBuildApkStepFactory()
|
|
|
|
|
{
|
2018-12-05 13:00:36 +01:00
|
|
|
registerStep<AndroidBuildApkStep>(Constants::ANDROID_BUILD_APK_ID);
|
2018-07-02 18:40:29 +02:00
|
|
|
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
|
|
|
|
setDisplayName(AndroidBuildApkStep::tr("Build Android APK"));
|
|
|
|
|
setRepeatable(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2014-06-25 15:42:11 +02:00
|
|
|
} // namespace Android
|
2017-10-23 13:42:07 +02:00
|
|
|
|
|
|
|
|
#include "androidbuildapkstep.moc"
|