2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2013-09-17 18:24:57 +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/
|
2013-09-17 18:24:57 +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.
|
2013-09-17 18:24:57 +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.
|
2013-09-17 18:24:57 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "androiddeployqtstep.h"
|
|
|
|
|
#include "certificatesmodel.h"
|
|
|
|
|
|
|
|
|
|
#include "javaparser.h"
|
|
|
|
|
#include "androidmanager.h"
|
2013-11-06 13:06:10 +01:00
|
|
|
#include "androidconstants.h"
|
2014-08-08 20:03:47 +03:00
|
|
|
#include "androidglobal.h"
|
2017-04-03 11:11:17 +02:00
|
|
|
#include "androidavdmanager.h"
|
2013-09-17 18:24:57 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/fileutils.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/messagemanager.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2013-09-17 18:24:57 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2018-12-05 10:29:48 +01:00
|
|
|
#include <projectexplorer/projectnodes.h>
|
2018-06-18 13:40:02 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2015-05-22 21:03:01 +03:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2015-11-13 12:56:36 +01:00
|
|
|
#include <utils/algorithm.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#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-01-25 14:33:57 +01:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QGroupBox>
|
2013-09-17 18:24:57 +02:00
|
|
|
#include <QInputDialog>
|
2018-06-18 11:49:14 +02:00
|
|
|
#include <QLoggingCategory>
|
2019-01-25 14:33:57 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QVBoxLayout>
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
using namespace ProjectExplorer;
|
2013-09-17 18:24:57 +02:00
|
|
|
using namespace Android;
|
|
|
|
|
using namespace Android::Internal;
|
|
|
|
|
|
2018-06-18 11:49:14 +02:00
|
|
|
namespace {
|
2018-10-12 09:33:30 +03:00
|
|
|
Q_LOGGING_CATEGORY(deployStepLog, "qtc.android.build.androiddeployqtstep", QtWarningMsg)
|
2018-06-18 11:49:14 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
const QLatin1String UninstallPreviousPackageKey("UninstallPreviousPackage");
|
|
|
|
|
const QLatin1String InstallFailedInconsistentCertificatesString("INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES");
|
2016-07-28 17:33:10 +02:00
|
|
|
const QLatin1String InstallFailedUpdateIncompatible("INSTALL_FAILED_UPDATE_INCOMPATIBLE");
|
|
|
|
|
const QLatin1String InstallFailedPermissionModelDowngrade("INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE");
|
2017-02-24 11:20:05 +01:00
|
|
|
const QLatin1String InstallFailedVersionDowngrade("INSTALL_FAILED_VERSION_DOWNGRADE");
|
2018-06-18 13:40:02 +02:00
|
|
|
static const char *qmlProjectRunConfigIdName = "QmlProjectManager.QmlRunConfiguration";
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2016-07-28 17:32:08 +02:00
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
// AndroidDeployQtStepFactory
|
2013-09-17 18:24:57 +02:00
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
AndroidDeployQtStepFactory::AndroidDeployQtStepFactory()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2019-01-18 11:32:53 +01:00
|
|
|
registerStep<AndroidDeployQtStep>(AndroidDeployQtStep::stepId());
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
2017-12-19 10:32:39 +01:00
|
|
|
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
setRepeatable(false);
|
2018-05-14 17:50:56 +02:00
|
|
|
setDisplayName(AndroidDeployQtStep::tr("Deploy to Android device or emulator"));
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-25 14:33:57 +01:00
|
|
|
// AndroidDeployQtWidget
|
|
|
|
|
|
|
|
|
|
class AndroidDeployQtWidget : public BuildStepConfigWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AndroidDeployQtWidget(AndroidDeployQtStep *step)
|
|
|
|
|
: ProjectExplorer::BuildStepConfigWidget(step)
|
|
|
|
|
{
|
|
|
|
|
setDisplayName(QString("<b>%1</b>").arg(step->displayName()));
|
|
|
|
|
setSummaryText(displayName());
|
|
|
|
|
|
|
|
|
|
auto uninstallPreviousPackage = new QCheckBox(this);
|
2019-03-12 17:23:55 +01:00
|
|
|
uninstallPreviousPackage->setText(AndroidDeployQtStep::tr("Uninstall previous package"));
|
2019-01-25 14:33:57 +01:00
|
|
|
uninstallPreviousPackage->setChecked(step->uninstallPreviousPackage() > AndroidDeployQtStep::Keep);
|
|
|
|
|
uninstallPreviousPackage->setEnabled(step->uninstallPreviousPackage() != AndroidDeployQtStep::ForceUnintall);
|
|
|
|
|
|
|
|
|
|
auto resetDefaultDevices = new QPushButton(this);
|
|
|
|
|
resetDefaultDevices->setText(AndroidDeployQtStep::tr("Reset Default Devices"));
|
|
|
|
|
|
|
|
|
|
auto cleanLibsPushButton = new QPushButton(this);
|
|
|
|
|
cleanLibsPushButton->setText(AndroidDeployQtStep::tr("Clean Temporary Libraries Directory on Device"));
|
|
|
|
|
|
|
|
|
|
auto installMinistroButton = new QPushButton(this);
|
|
|
|
|
installMinistroButton->setText(AndroidDeployQtStep::tr("Install Ministro from APK"));
|
|
|
|
|
|
|
|
|
|
connect(installMinistroButton, &QAbstractButton::clicked, this, [this, step] {
|
|
|
|
|
QString packagePath =
|
|
|
|
|
QFileDialog::getOpenFileName(this,
|
|
|
|
|
AndroidDeployQtStep::tr("Qt Android Smart Installer"),
|
|
|
|
|
QDir::homePath(),
|
|
|
|
|
AndroidDeployQtStep::tr("Android package (*.apk)"));
|
|
|
|
|
if (!packagePath.isEmpty())
|
|
|
|
|
AndroidManager::installQASIPackage(step->target(), packagePath);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(cleanLibsPushButton, &QAbstractButton::clicked, this, [step] {
|
|
|
|
|
AndroidManager::cleanLibsOnDevice(step->target());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(resetDefaultDevices, &QAbstractButton::clicked, this, [step] {
|
|
|
|
|
AndroidConfigurations::clearDefaultDevices(step->project());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(uninstallPreviousPackage, &QAbstractButton::toggled,
|
|
|
|
|
step, &AndroidDeployQtStep::setUninstallPreviousPackage);
|
|
|
|
|
|
|
|
|
|
auto layout = new QVBoxLayout(this);
|
|
|
|
|
layout->addWidget(uninstallPreviousPackage);
|
|
|
|
|
layout->addWidget(resetDefaultDevices);
|
|
|
|
|
layout->addWidget(cleanLibsPushButton);
|
|
|
|
|
layout->addWidget(installMinistroButton);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
// AndroidDeployQtStep
|
|
|
|
|
|
|
|
|
|
AndroidDeployQtStep::AndroidDeployQtStep(ProjectExplorer::BuildStepList *parent)
|
2019-01-18 11:32:53 +01:00
|
|
|
: ProjectExplorer::BuildStep(parent, stepId())
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2018-10-22 17:56:04 +02:00
|
|
|
setImmutable(true);
|
2019-02-06 12:50:51 +01:00
|
|
|
m_uninstallPreviousPackage = QtSupport::QtKitAspect::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0);
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
//: AndroidDeployQtStep default display name
|
|
|
|
|
setDefaultDisplayName(tr("Deploy to Android device"));
|
2014-11-26 12:19:46 +01:00
|
|
|
|
|
|
|
|
connect(this, &AndroidDeployQtStep::askForUninstall,
|
|
|
|
|
this, &AndroidDeployQtStep::slotAskForUninstall,
|
|
|
|
|
Qt::BlockingQueuedConnection);
|
|
|
|
|
|
|
|
|
|
connect(this, &AndroidDeployQtStep::setSerialNumber,
|
|
|
|
|
this, &AndroidDeployQtStep::slotSetSerialNumber);
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-18 11:32:53 +01:00
|
|
|
Core::Id AndroidDeployQtStep::stepId()
|
|
|
|
|
{
|
|
|
|
|
return "Qt4ProjectManager.AndroidDeployQtStep";
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool AndroidDeployQtStep::init()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-09-22 16:20:51 +03:00
|
|
|
m_androiddeployqtArgs.clear();
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
m_targetArch = AndroidManager::targetArch(target());
|
2013-10-09 16:24:25 +02:00
|
|
|
if (m_targetArch.isEmpty()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("No Android arch set by the .pro file."), OutputFormat::Stderr);
|
2013-10-09 16:24:25 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-11-17 16:22:28 +01:00
|
|
|
|
2018-10-26 15:22:35 +02:00
|
|
|
emit addOutput(tr("Initializing deployment to Android device/simulator"), OutputFormat::Stdout);
|
2018-07-17 13:58:50 +02:00
|
|
|
|
2018-06-18 13:40:02 +02:00
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
|
|
|
|
QTC_ASSERT(rc, return false);
|
|
|
|
|
const bool deployQtLive = rc->id().name().startsWith(qmlProjectRunConfigIdName);
|
|
|
|
|
ProjectExplorer::BuildConfiguration *bc = buildConfiguration();
|
|
|
|
|
QTC_ASSERT(deployQtLive || bc, return false);
|
|
|
|
|
|
2019-01-18 18:07:54 +01:00
|
|
|
auto androidBuildApkStep = AndroidBuildApkStep::findInBuild(bc);
|
2018-07-17 13:58:50 +02:00
|
|
|
int minTargetApi = AndroidManager::minimumSDK(target());
|
|
|
|
|
qCDebug(deployStepLog) << "Target architecture:" << m_targetArch
|
|
|
|
|
<< "Min target API" << minTargetApi;
|
2019-01-10 16:23:05 +01:00
|
|
|
|
|
|
|
|
// Try to re-use user-provided information from an earlier step of the same type.
|
|
|
|
|
auto bsl = qobject_cast<BuildStepList *>(parent());
|
|
|
|
|
QTC_ASSERT(bsl, return false);
|
|
|
|
|
auto androidDeployQtStep = bsl->firstOfType<AndroidDeployQtStep>();
|
|
|
|
|
QTC_ASSERT(androidDeployQtStep, return false);
|
|
|
|
|
AndroidDeviceInfo info;
|
|
|
|
|
if (androidDeployQtStep != this)
|
|
|
|
|
info = androidDeployQtStep->m_deviceInfo;
|
|
|
|
|
|
2015-11-13 12:56:36 +01:00
|
|
|
if (!info.isValid()) {
|
2018-07-17 13:58:50 +02:00
|
|
|
info = AndroidConfigurations::showDeviceDialog(project(), minTargetApi, m_targetArch);
|
2015-11-13 12:56:36 +01:00
|
|
|
m_deviceInfo = info; // Keep around for later steps
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!info.isValid()) // aborted
|
2013-09-17 18:24:57 +02:00
|
|
|
return false;
|
|
|
|
|
|
2015-04-23 16:25:44 +02:00
|
|
|
m_avdName = info.avdname;
|
|
|
|
|
m_serialNumber = info.serialNumber;
|
2018-07-17 13:58:50 +02:00
|
|
|
qCDebug(deployStepLog) << "Selected Device:" << info;
|
2015-09-09 17:53:37 +02:00
|
|
|
|
2018-06-18 13:40:02 +02:00
|
|
|
if (!deployQtLive)
|
|
|
|
|
gatherFilesToPull();
|
2018-03-12 18:03:42 +01:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
AndroidManager::setDeviceSerialNumber(target(), m_serialNumber);
|
2018-03-17 09:31:56 +02:00
|
|
|
AndroidManager::setDeviceApiLevel(target(), info.sdk);
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2018-07-17 13:58:50 +02:00
|
|
|
emit addOutput(tr("Deploying to %1").arg(m_serialNumber), OutputFormat::Stdout);
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit());
|
2013-09-17 18:24:57 +02:00
|
|
|
if (!version)
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
m_uninstallPreviousPackageRun = m_uninstallPreviousPackage;
|
|
|
|
|
if (m_uninstallPreviousPackageRun)
|
2014-10-24 17:53:05 +02:00
|
|
|
m_manifestName = AndroidManager::manifestPath(target());
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2018-12-05 10:29:48 +01:00
|
|
|
m_useAndroiddeployqt = !deployQtLive &&
|
2018-06-18 13:40:02 +02:00
|
|
|
version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0);
|
2018-01-30 18:19:46 +01:00
|
|
|
|
2014-08-08 20:03:47 +03:00
|
|
|
if (m_useAndroiddeployqt) {
|
2019-04-03 18:10:35 +02:00
|
|
|
const ProjectNode *node = target()->project()->findNodeForBuildKey(rc->buildKey());
|
2019-05-28 13:49:26 +02:00
|
|
|
m_apkPath = Utils::FilePath::fromString(node->data(Constants::AndroidApk).toString());
|
2019-04-03 18:10:35 +02:00
|
|
|
if (!m_apkPath.isEmpty()) {
|
2019-05-28 13:49:26 +02:00
|
|
|
m_manifestName = Utils::FilePath::fromString(node->data(Constants::AndroidManifest).toString());
|
2019-04-03 18:10:35 +02:00
|
|
|
m_command = AndroidConfigurations::currentConfig().adbToolPath().toString();
|
|
|
|
|
AndroidManager::setManifestPath(target(), m_manifestName);
|
|
|
|
|
} else {
|
|
|
|
|
QString jsonFile;
|
|
|
|
|
if (node)
|
|
|
|
|
jsonFile = node->data(Constants::AndroidDeploySettingsFile).toString();
|
|
|
|
|
if (jsonFile.isEmpty()) {
|
|
|
|
|
emit addOutput(tr("Cannot find the androiddeploy Json file."), OutputFormat::Stderr);
|
|
|
|
|
return false;
|
|
|
|
|
} m_command = version->qmakeProperty("QT_HOST_BINS");
|
|
|
|
|
if (m_command.isEmpty()) {
|
|
|
|
|
emit addOutput(tr("Cannot find the androiddeployqt tool."), OutputFormat::Stderr);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
qCDebug(deployStepLog) << "Using androiddeployqt";
|
|
|
|
|
if (!m_command.endsWith(QLatin1Char('/')))
|
|
|
|
|
m_command += QLatin1Char('/');
|
|
|
|
|
m_command += Utils::HostOsInfo::withExecutableSuffix(QLatin1String("androiddeployqt"));
|
|
|
|
|
|
2019-05-17 13:20:41 +02:00
|
|
|
m_workingDirectory = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
2019-04-03 18:10:35 +02:00
|
|
|
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--verbose"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--output"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, m_workingDirectory);
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--no-build"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--input"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, jsonFile);
|
|
|
|
|
if (androidBuildApkStep && androidBuildApkStep->useMinistro()) {
|
|
|
|
|
qCDebug(deployStepLog) << "Using ministro";
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--deployment"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("ministro"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--gradle"));
|
|
|
|
|
|
|
|
|
|
if (androidBuildApkStep && androidBuildApkStep->signPackage()) {
|
|
|
|
|
// The androiddeployqt tool is not really written to do stand-alone installations.
|
|
|
|
|
// This hack forces it to use the correct filename for the apk file when installing
|
|
|
|
|
// as a temporary fix until androiddeployqt gets the support. Since the --sign is
|
|
|
|
|
// only used to get the correct file name of the apk, its parameters are ignored.
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--sign"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("foo"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("bar"));
|
|
|
|
|
}
|
2014-11-18 12:08:31 +01:00
|
|
|
}
|
2014-08-08 20:03:47 +03:00
|
|
|
} else {
|
2014-09-16 14:25:34 +03:00
|
|
|
m_uninstallPreviousPackageRun = true;
|
2014-11-26 12:19:46 +01:00
|
|
|
m_command = AndroidConfigurations::currentConfig().adbToolPath().toString();
|
2018-06-18 13:40:02 +02:00
|
|
|
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
2018-07-27 11:18:06 +02:00
|
|
|
m_apkPath = deployQtLive ? config.qtLiveApkPath() : AndroidManager::apkPath(target());
|
2018-01-30 18:19:46 +01:00
|
|
|
m_workingDirectory = bc ? bc->buildDirectory().toString() : QString();
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
2018-01-30 18:19:46 +01:00
|
|
|
m_environment = bc ? bc->environment() : Utils::Environment();
|
2014-11-26 12:19:46 +01:00
|
|
|
|
|
|
|
|
m_adbPath = AndroidConfigurations::currentConfig().adbToolPath().toString();
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2017-04-03 11:11:17 +02:00
|
|
|
AndroidAvdManager avdManager;
|
2018-05-03 08:05:04 +02:00
|
|
|
// Start the AVD if not running.
|
|
|
|
|
if (!m_avdName.isEmpty() && avdManager.findAvd(m_avdName).isEmpty())
|
2017-04-03 11:11:17 +02:00
|
|
|
avdManager.startAvdAsync(m_avdName);
|
2013-09-17 18:24:57 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-11-26 12:19:46 +01:00
|
|
|
QString args;
|
2019-04-03 18:10:35 +02:00
|
|
|
if (m_useAndroiddeployqt && m_apkPath.isEmpty()) {
|
2014-11-26 12:19:46 +01:00
|
|
|
args = m_androiddeployqtArgs;
|
|
|
|
|
if (m_uninstallPreviousPackageRun)
|
|
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("--install"));
|
|
|
|
|
else
|
|
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("--reinstall"));
|
|
|
|
|
|
2014-08-08 20:03:47 +03:00
|
|
|
if (!m_serialNumber.isEmpty() && !m_serialNumber.startsWith(QLatin1String("????"))) {
|
2014-11-26 12:19:46 +01:00
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("--device"));
|
|
|
|
|
Utils::QtcProcess::addArg(&args, m_serialNumber);
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
|
|
|
|
} else {
|
2018-06-18 13:40:02 +02:00
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
|
|
|
|
QTC_ASSERT(rc, return DeployErrorCode::Failure);
|
|
|
|
|
const bool deployQtLive = rc->id().name().startsWith(qmlProjectRunConfigIdName);
|
|
|
|
|
QString packageName;
|
2018-08-07 14:47:08 +02:00
|
|
|
int packageVersion = -1;
|
2018-06-18 13:40:02 +02:00
|
|
|
if (deployQtLive) {
|
2018-08-07 14:47:08 +02:00
|
|
|
// Do not install Qt live if apk is already installed or the same version is
|
|
|
|
|
// being installed.
|
|
|
|
|
AndroidManager::apkInfo(m_apkPath, &packageName, &packageVersion);
|
|
|
|
|
if (AndroidManager::packageInstalled(m_serialNumber, packageName)) {
|
|
|
|
|
int installedVersion = AndroidManager::packageVersionCode(m_serialNumber,
|
|
|
|
|
packageName);
|
|
|
|
|
if (installedVersion == packageVersion) {
|
|
|
|
|
qCDebug(deployStepLog) << "Qt live APK already installed. APK version:"
|
|
|
|
|
<< packageVersion << "Installed version:"
|
|
|
|
|
<< installedVersion;
|
|
|
|
|
return DeployErrorCode::NoError;
|
|
|
|
|
} else {
|
|
|
|
|
qCDebug(deployStepLog) << "Re-installing Qt live APK. Version mismatch."
|
|
|
|
|
<< "APK version:" << packageVersion
|
|
|
|
|
<< "Installed version:" << installedVersion;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
qCDebug(deployStepLog) << "Installing Qt live APK. APK version:" << packageVersion;
|
|
|
|
|
}
|
2018-06-18 13:40:02 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-08 20:03:47 +03:00
|
|
|
if (m_uninstallPreviousPackageRun) {
|
2018-06-18 13:40:02 +02:00
|
|
|
if (!deployQtLive)
|
|
|
|
|
packageName = AndroidManager::packageName(m_manifestName);
|
2014-11-26 12:19:46 +01:00
|
|
|
if (packageName.isEmpty()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Cannot find the package name."), OutputFormat::Stderr);
|
2014-11-26 12:19:46 +01:00
|
|
|
return Failure;
|
2014-10-24 17:53:05 +02:00
|
|
|
}
|
2018-06-18 13:40:02 +02:00
|
|
|
qCDebug(deployStepLog) << "Uninstalling previous package";
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Uninstall previous package %1.").arg(packageName), OutputFormat::NormalMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
runCommand(m_adbPath,
|
2014-08-08 20:03:47 +03:00
|
|
|
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
2014-10-24 17:53:05 +02:00
|
|
|
<< QLatin1String("uninstall") << packageName);
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (const QString &arg, AndroidDeviceInfo::adbSelector(m_serialNumber))
|
|
|
|
|
Utils::QtcProcess::addArg(&args, arg);
|
|
|
|
|
|
|
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("install"));
|
|
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("-r"));
|
2018-06-18 13:40:02 +02:00
|
|
|
Utils::QtcProcess::addArg(&args, m_apkPath.toString());
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
m_process = new Utils::QtcProcess;
|
2019-05-28 18:59:45 +02:00
|
|
|
m_process->setCommand(Utils::CommandLine(Utils::FilePath::fromString(m_command), args));
|
2014-11-26 12:19:46 +01:00
|
|
|
m_process->setWorkingDirectory(m_workingDirectory);
|
|
|
|
|
m_process->setEnvironment(m_environment);
|
|
|
|
|
|
|
|
|
|
if (Utils::HostOsInfo::isWindowsHost())
|
|
|
|
|
m_process->setUseCtrlCStub(true);
|
|
|
|
|
|
2016-07-28 17:32:08 +02:00
|
|
|
DeployErrorCode deployError = NoError;
|
2014-11-26 12:19:46 +01:00
|
|
|
connect(m_process, &Utils::QtcProcess::readyReadStandardOutput,
|
2016-07-28 17:32:08 +02:00
|
|
|
std::bind(&AndroidDeployQtStep::processReadyReadStdOutput, this, std::ref(deployError)));
|
2014-11-26 12:19:46 +01:00
|
|
|
connect(m_process, &Utils::QtcProcess::readyReadStandardError,
|
2016-07-28 17:32:08 +02:00
|
|
|
std::bind(&AndroidDeployQtStep::processReadyReadStdError, this, std::ref(deployError)));
|
2014-11-26 12:19:46 +01:00
|
|
|
|
|
|
|
|
m_process->start();
|
|
|
|
|
|
|
|
|
|
emit addOutput(tr("Starting: \"%1\" %2")
|
|
|
|
|
.arg(QDir::toNativeSeparators(m_command), args),
|
2017-01-12 10:59:12 +01:00
|
|
|
BuildStep::OutputFormat::NormalMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2016-04-29 16:52:58 +02:00
|
|
|
while (!m_process->waitForFinished(200)) {
|
|
|
|
|
if (m_process->state() == QProcess::NotRunning)
|
|
|
|
|
break;
|
|
|
|
|
|
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
|
|
|
if (isCanceled()) {
|
2014-11-26 12:19:46 +01:00
|
|
|
m_process->kill();
|
|
|
|
|
m_process->waitForFinished();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString line = QString::fromLocal8Bit(m_process->readAllStandardError());
|
2016-07-28 17:32:08 +02:00
|
|
|
if (!line.isEmpty()) {
|
|
|
|
|
deployError |= parseDeployErrors(line);
|
2014-11-26 12:19:46 +01:00
|
|
|
stdError(line);
|
2016-07-28 17:32:08 +02:00
|
|
|
}
|
2014-11-26 12:19:46 +01:00
|
|
|
|
|
|
|
|
line = QString::fromLocal8Bit(m_process->readAllStandardOutput());
|
2016-07-28 17:32:08 +02:00
|
|
|
if (!line.isEmpty()) {
|
|
|
|
|
deployError |= parseDeployErrors(line);
|
2014-11-26 12:19:46 +01:00
|
|
|
stdOutput(line);
|
2016-07-28 17:32:08 +02:00
|
|
|
}
|
2014-11-26 12:19:46 +01:00
|
|
|
|
|
|
|
|
QProcess::ExitStatus exitStatus = m_process->exitStatus();
|
|
|
|
|
int exitCode = m_process->exitCode();
|
|
|
|
|
delete m_process;
|
2018-06-18 11:49:14 +02:00
|
|
|
m_process = nullptr;
|
2014-11-26 12:19:46 +01:00
|
|
|
|
|
|
|
|
if (exitStatus == QProcess::NormalExit && exitCode == 0) {
|
|
|
|
|
emit addOutput(tr("The process \"%1\" exited normally.").arg(m_command),
|
2017-01-12 10:59:12 +01:00
|
|
|
BuildStep::OutputFormat::NormalMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
} else if (exitStatus == QProcess::NormalExit) {
|
|
|
|
|
emit addOutput(tr("The process \"%1\" exited with code %2.")
|
|
|
|
|
.arg(m_command, QString::number(exitCode)),
|
2017-01-12 10:59:12 +01:00
|
|
|
BuildStep::OutputFormat::ErrorMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
} else {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("The process \"%1\" crashed.").arg(m_command), BuildStep::OutputFormat::ErrorMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 13:59:13 +02:00
|
|
|
if (deployError != NoError) {
|
|
|
|
|
if (m_uninstallPreviousPackageRun)
|
|
|
|
|
deployError = Failure; // Even re-install failed. Set to Failure.
|
|
|
|
|
} else if (exitCode != 0 || exitStatus != QProcess::NormalExit) {
|
|
|
|
|
// Set the deployError to Failure when no deployError code was detected
|
|
|
|
|
// but the adb tool failed otherwise relay the detected deployError.
|
2016-07-28 17:33:10 +02:00
|
|
|
deployError = Failure;
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
2016-07-28 17:33:10 +02:00
|
|
|
|
|
|
|
|
return deployError;
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:33:10 +02:00
|
|
|
void AndroidDeployQtStep::slotAskForUninstall(DeployErrorCode errorCode)
|
2014-11-26 12:19:46 +01:00
|
|
|
{
|
2016-07-28 17:33:10 +02:00
|
|
|
Q_ASSERT(errorCode > 0);
|
|
|
|
|
|
|
|
|
|
QString uninstallMsg = tr("Deployment failed with the following errors:\n\n");
|
|
|
|
|
uint errorCodeFlags = errorCode;
|
|
|
|
|
uint mask = 1;
|
|
|
|
|
while (errorCodeFlags) {
|
|
|
|
|
switch (errorCodeFlags & mask) {
|
|
|
|
|
case DeployErrorCode::PermissionModelDowngrade:
|
|
|
|
|
uninstallMsg += InstallFailedPermissionModelDowngrade+"\n";
|
|
|
|
|
break;
|
|
|
|
|
case InconsistentCertificates:
|
|
|
|
|
uninstallMsg += InstallFailedInconsistentCertificatesString+"\n";
|
|
|
|
|
break;
|
|
|
|
|
case UpdateIncompatible:
|
|
|
|
|
uninstallMsg += InstallFailedUpdateIncompatible+"\n";
|
|
|
|
|
break;
|
2017-02-24 11:20:05 +01:00
|
|
|
case VersionDowngrade:
|
|
|
|
|
uninstallMsg += InstallFailedVersionDowngrade+"\n";
|
|
|
|
|
break;
|
2016-07-28 17:33:10 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
errorCodeFlags &= ~mask;
|
|
|
|
|
mask <<= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uninstallMsg.append(tr("\nUninstalling the installed package may solve the issue.\nDo you want to uninstall the existing package?"));
|
2018-07-25 12:19:15 +02:00
|
|
|
int button = QMessageBox::critical(nullptr, tr("Install failed"), uninstallMsg,
|
2014-11-26 12:19:46 +01:00
|
|
|
QMessageBox::Yes, QMessageBox::No);
|
2018-01-05 17:52:10 +01:00
|
|
|
m_askForUninstall = button == QMessageBox::Yes;
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidDeployQtStep::slotSetSerialNumber(const QString &serialNumber)
|
|
|
|
|
{
|
2018-06-18 11:49:14 +02:00
|
|
|
qCDebug(deployStepLog) << "Target device serial number change:" << serialNumber;
|
2014-11-26 12:19:46 +01:00
|
|
|
AndroidManager::setDeviceSerialNumber(target(), serialNumber);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
bool AndroidDeployQtStep::runImpl()
|
2014-11-26 12:19:46 +01:00
|
|
|
{
|
|
|
|
|
if (!m_avdName.isEmpty()) {
|
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
|
|
|
QString serialNumber = AndroidAvdManager().waitForAvd(m_avdName, cancelChecker());
|
2018-06-18 11:49:14 +02:00
|
|
|
qCDebug(deployStepLog) << "Deploying to AVD:" << m_avdName << serialNumber;
|
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
|
|
|
if (serialNumber.isEmpty())
|
|
|
|
|
return false;
|
2014-11-26 12:19:46 +01:00
|
|
|
m_serialNumber = serialNumber;
|
|
|
|
|
emit setSerialNumber(serialNumber);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
DeployErrorCode returnValue = runDeploy();
|
2016-07-28 17:33:10 +02:00
|
|
|
if (returnValue > DeployErrorCode::NoError && returnValue < DeployErrorCode::Failure) {
|
|
|
|
|
emit askForUninstall(returnValue);
|
2018-01-05 17:52:10 +01:00
|
|
|
if (m_askForUninstall) {
|
2014-11-26 12:19:46 +01:00
|
|
|
m_uninstallPreviousPackageRun = true;
|
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
|
|
|
returnValue = runDeploy();
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2018-06-18 13:40:02 +02:00
|
|
|
if (!m_filesToPull.isEmpty())
|
|
|
|
|
emit addOutput(tr("Pulling files necessary for debugging."), OutputFormat::NormalMessage);
|
|
|
|
|
|
2018-03-12 18:03:42 +01:00
|
|
|
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
|
|
|
|
|
QFile::remove(itr.value());
|
2015-09-09 17:53:37 +02:00
|
|
|
runCommand(m_adbPath,
|
|
|
|
|
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
2018-03-12 18:03:42 +01:00
|
|
|
<< "pull" << itr.key() << itr.value());
|
|
|
|
|
if (!QFileInfo::exists(itr.value())) {
|
|
|
|
|
emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
|
|
|
|
|
.arg(itr.key())
|
|
|
|
|
.arg(itr.value()), OutputFormat::ErrorMessage);
|
|
|
|
|
}
|
2015-03-27 11:38:34 +01:00
|
|
|
}
|
2015-06-19 16:20:30 +03:00
|
|
|
|
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
|
|
|
return returnValue == NoError;
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-18 13:40:02 +02:00
|
|
|
void AndroidDeployQtStep::gatherFilesToPull()
|
|
|
|
|
{
|
|
|
|
|
m_filesToPull.clear();
|
|
|
|
|
ProjectExplorer::BuildConfiguration *bc = buildConfiguration();
|
|
|
|
|
QString buildDir = bc ? bc->buildDirectory().toString() : QString();
|
|
|
|
|
if (bc && !buildDir.endsWith("/")) {
|
|
|
|
|
buildDir += "/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_deviceInfo.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString linkerName("linker");
|
|
|
|
|
QString libDirName("lib");
|
|
|
|
|
if (m_deviceInfo.cpuAbi.contains(QLatin1String("arm64-v8a")) ||
|
|
|
|
|
m_deviceInfo.cpuAbi.contains(QLatin1String("x86_64"))) {
|
|
|
|
|
const Core::Id cxxLanguageId = ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
2019-02-06 12:50:51 +01:00
|
|
|
ToolChain *tc = ToolChainKitAspect::toolChain(target()->kit(), cxxLanguageId);
|
2018-06-18 13:40:02 +02:00
|
|
|
if (tc && tc->targetAbi().wordWidth() == 64) {
|
|
|
|
|
m_filesToPull["/system/bin/app_process64"] = buildDir + "app_process";
|
|
|
|
|
libDirName = "lib64";
|
|
|
|
|
linkerName = "linker64";
|
|
|
|
|
} else {
|
|
|
|
|
m_filesToPull["/system/bin/app_process32"] = buildDir + "app_process";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
m_filesToPull["/system/bin/app_process32"] = buildDir + "app_process";
|
|
|
|
|
m_filesToPull["/system/bin/app_process"] = buildDir + "app_process";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_filesToPull["/system/bin/" + linkerName] = buildDir + linkerName;
|
|
|
|
|
m_filesToPull["/system/" + libDirName + "/libc.so"] = buildDir + "libc.so";
|
|
|
|
|
|
|
|
|
|
qCDebug(deployStepLog) << "Files to pull from device:";
|
|
|
|
|
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr)
|
|
|
|
|
qCDebug(deployStepLog) << itr.key() << "to" << itr.value();
|
|
|
|
|
}
|
|
|
|
|
|
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 AndroidDeployQtStep::doRun()
|
|
|
|
|
{
|
|
|
|
|
runInThread([this] { return runImpl(); });
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
void AndroidDeployQtStep::runCommand(const QString &program, const QStringList &arguments)
|
|
|
|
|
{
|
2016-04-29 16:52:58 +02:00
|
|
|
Utils::SynchronousProcess buildProc;
|
|
|
|
|
buildProc.setTimeoutS(2 * 60);
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Package deploy: Running command \"%1 %2\".").arg(program).arg(arguments.join(QLatin1Char(' '))), BuildStep::OutputFormat::NormalMessage);
|
2016-04-29 16:52:58 +02:00
|
|
|
Utils::SynchronousProcessResponse response = buildProc.run(program, arguments);
|
|
|
|
|
if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0)
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(response.exitMessage(program, 2 * 60), BuildStep::OutputFormat::ErrorMessage);
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
ProjectExplorer::BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-06-25 15:42:11 +02:00
|
|
|
return new AndroidDeployQtWidget(this);
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:32:08 +02:00
|
|
|
void AndroidDeployQtStep::processReadyReadStdOutput(DeployErrorCode &errorCode)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-11-26 12:19:46 +01:00
|
|
|
m_process->setReadChannel(QProcess::StandardOutput);
|
|
|
|
|
while (m_process->canReadLine()) {
|
|
|
|
|
QString line = QString::fromLocal8Bit(m_process->readLine());
|
2016-07-28 17:32:08 +02:00
|
|
|
errorCode |= parseDeployErrors(line);
|
2014-11-26 12:19:46 +01:00
|
|
|
stdOutput(line);
|
|
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
void AndroidDeployQtStep::stdOutput(const QString &line)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(line, BuildStep::OutputFormat::Stdout, BuildStep::DontAppendNewline);
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:32:08 +02:00
|
|
|
void AndroidDeployQtStep::processReadyReadStdError(DeployErrorCode &errorCode)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-11-26 12:19:46 +01:00
|
|
|
m_process->setReadChannel(QProcess::StandardError);
|
|
|
|
|
while (m_process->canReadLine()) {
|
|
|
|
|
QString line = QString::fromLocal8Bit(m_process->readLine());
|
2016-07-28 17:32:08 +02:00
|
|
|
errorCode |= parseDeployErrors(line);
|
2014-11-26 12:19:46 +01:00
|
|
|
stdError(line);
|
2014-06-25 15:42:11 +02:00
|
|
|
}
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidDeployQtStep::stdError(const QString &line)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(line, BuildStep::OutputFormat::Stderr, BuildStep::DontAppendNewline);
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:32:08 +02:00
|
|
|
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::parseDeployErrors(QString &deployOutputLine) const
|
|
|
|
|
{
|
|
|
|
|
DeployErrorCode errorCode = NoError;
|
|
|
|
|
|
|
|
|
|
if (deployOutputLine.contains(InstallFailedInconsistentCertificatesString))
|
|
|
|
|
errorCode |= InconsistentCertificates;
|
2016-07-28 17:33:10 +02:00
|
|
|
if (deployOutputLine.contains(InstallFailedUpdateIncompatible))
|
2016-07-28 17:32:08 +02:00
|
|
|
errorCode |= UpdateIncompatible;
|
2016-07-28 17:33:10 +02:00
|
|
|
if (deployOutputLine.contains(InstallFailedPermissionModelDowngrade))
|
|
|
|
|
errorCode |= PermissionModelDowngrade;
|
2017-02-24 11:20:05 +01:00
|
|
|
if (deployOutputLine.contains(InstallFailedVersionDowngrade))
|
|
|
|
|
errorCode |= VersionDowngrade;
|
2016-07-28 17:32:08 +02:00
|
|
|
|
|
|
|
|
return errorCode;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
bool AndroidDeployQtStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2014-10-03 10:18:14 +03:00
|
|
|
m_uninstallPreviousPackage = map.value(UninstallPreviousPackageKey, m_uninstallPreviousPackage).toBool();
|
2013-09-17 18:24:57 +02:00
|
|
|
return ProjectExplorer::BuildStep::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AndroidDeployQtStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = ProjectExplorer::BuildStep::toMap();
|
2014-06-25 15:42:11 +02:00
|
|
|
map.insert(UninstallPreviousPackageKey, m_uninstallPreviousPackage);
|
2013-09-17 18:24:57 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
void AndroidDeployQtStep::setUninstallPreviousPackage(bool uninstall)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-06-25 15:42:11 +02:00
|
|
|
m_uninstallPreviousPackage = uninstall;
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-16 14:25:34 +03:00
|
|
|
AndroidDeployQtStep::UninstallType AndroidDeployQtStep::uninstallPreviousPackage()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
if (QtSupport::QtKitAspect::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0))
|
2014-09-16 14:25:34 +03:00
|
|
|
return ForceUnintall;
|
|
|
|
|
return m_uninstallPreviousPackage ? Uninstall : Keep;
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|