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 "androiddeployqtwidget.h"
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "androidqtsupport.h"
|
2013-09-17 18:24:57 +02:00
|
|
|
#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>
|
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
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
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;
|
|
|
|
|
|
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");
|
2013-09-17 18:24:57 +02:00
|
|
|
const Core::Id AndroidDeployQtStep::Id("Qt4ProjectManager.AndroidDeployQtStep");
|
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
registerStep<AndroidDeployQtStep>(AndroidDeployQtStep::Id);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
|
|
|
|
setRepeatable(false);
|
|
|
|
|
setDisplayName(tr("Deploy to Android device or emulator"));
|
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
|
|
|
bool AndroidDeployQtStepFactory::canHandle(BuildStepList *parent) const
|
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
|
|
|
return BuildStepFactory::canHandle(parent)
|
|
|
|
|
&& AndroidManager::supportsAndroid(parent->target());
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AndroidDeployQtStep
|
|
|
|
|
|
|
|
|
|
AndroidDeployQtStep::AndroidDeployQtStep(ProjectExplorer::BuildStepList *parent)
|
2014-11-26 12:19:46 +01:00
|
|
|
: ProjectExplorer::BuildStep(parent, Id)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-10-03 10:18:14 +03:00
|
|
|
m_uninstallPreviousPackage = QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0);
|
2014-06-25 15:42:11 +02:00
|
|
|
m_uninstallPreviousPackageRun = false;
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2015-11-13 12:56:36 +01:00
|
|
|
static AndroidDeviceInfo earlierDeviceInfo(QList<const ProjectExplorer::BuildStep *> &earlierSteps, Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
const ProjectExplorer::BuildStep *bs
|
|
|
|
|
= Utils::findOrDefault(earlierSteps, Utils::equal(&ProjectExplorer::BuildStep::id, id));
|
|
|
|
|
return bs ? static_cast<const AndroidDeployQtStep *>(bs)->deviceInfo() : AndroidDeviceInfo();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2015-11-13 12:19:35 +01:00
|
|
|
Q_UNUSED(earlierSteps);
|
2014-09-22 16:20:51 +03:00
|
|
|
m_androiddeployqtArgs.clear();
|
|
|
|
|
|
2014-06-24 16:47:10 +02:00
|
|
|
if (AndroidManager::checkForQt51Files(project()->projectDirectory()))
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Found old folder \"android\" in source directory. Qt 5.2 does not use that folder by default."), OutputFormat::Stderr);
|
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
|
|
|
|
|
|
|
|
AndroidBuildApkStep *androidBuildApkStep
|
|
|
|
|
= AndroidGlobal::buildStep<AndroidBuildApkStep>(target()->activeBuildConfiguration());
|
|
|
|
|
if (!androidBuildApkStep) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Cannot find the android build step."), OutputFormat::Stderr);
|
2014-11-17 16:22:28 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-23 16:25:44 +02:00
|
|
|
int deviceAPILevel = AndroidManager::minimumSDK(target());
|
2015-11-13 12:56:36 +01:00
|
|
|
AndroidDeviceInfo info = earlierDeviceInfo(earlierSteps, Id);
|
|
|
|
|
if (!info.isValid()) {
|
2017-09-04 15:21:16 -07:00
|
|
|
info = AndroidConfigurations::showDeviceDialog(project(), deviceAPILevel, 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;
|
2015-09-09 17:53:37 +02:00
|
|
|
|
|
|
|
|
m_appProcessBinaries.clear();
|
2015-06-19 16:20:30 +03:00
|
|
|
m_libdir = QLatin1String("lib");
|
|
|
|
|
if (info.cpuAbi.contains(QLatin1String("arm64-v8a")) ||
|
|
|
|
|
info.cpuAbi.contains(QLatin1String("x86_64"))) {
|
2016-12-16 00:43:14 +01:00
|
|
|
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2015-06-19 16:20:30 +03:00
|
|
|
if (tc && tc->targetAbi().wordWidth() == 64) {
|
2015-09-09 17:53:37 +02:00
|
|
|
m_appProcessBinaries << QLatin1String("/system/bin/app_process64");
|
2015-06-19 16:20:30 +03:00
|
|
|
m_libdir += QLatin1String("64");
|
|
|
|
|
} else {
|
2015-09-09 17:53:37 +02:00
|
|
|
m_appProcessBinaries << QLatin1String("/system/bin/app_process32");
|
2015-06-19 16:20:30 +03:00
|
|
|
}
|
2015-09-09 17:53:37 +02:00
|
|
|
} else {
|
|
|
|
|
m_appProcessBinaries << QLatin1String("/system/bin/app_process32")
|
|
|
|
|
<< QLatin1String("/system/bin/app_process");
|
2015-05-22 21:03:01 +03:00
|
|
|
}
|
2015-04-23 16:25:44 +02:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
AndroidManager::setDeviceSerialNumber(target(), m_serialNumber);
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2014-06-25 15:42:11 +02:00
|
|
|
ProjectExplorer::BuildConfiguration *bc = target()->activeBuildConfiguration();
|
2013-09-17 18:24:57 +02:00
|
|
|
|
|
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
|
|
|
|
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
|
|
|
|
2014-08-08 20:03:47 +03:00
|
|
|
m_useAndroiddeployqt = version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0);
|
|
|
|
|
if (m_useAndroiddeployqt) {
|
|
|
|
|
Utils::FileName tmp = AndroidManager::androidQtSupport(target())->androiddeployqtPath(target());
|
|
|
|
|
if (tmp.isEmpty()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Cannot find the androiddeployqt tool."), OutputFormat::Stderr);
|
2014-08-08 20:03:47 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
m_command = tmp.toString();
|
|
|
|
|
m_workingDirectory = bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString();
|
2014-08-08 20:03:47 +03:00
|
|
|
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--verbose"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--output"));
|
2014-11-26 12:19:46 +01:00
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, m_workingDirectory);
|
2014-08-08 20:03:47 +03:00
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--no-build"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--input"));
|
|
|
|
|
tmp = AndroidManager::androidQtSupport(target())->androiddeployJsonPath(target());
|
|
|
|
|
if (tmp.isEmpty()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Cannot find the androiddeploy Json file."), OutputFormat::Stderr);
|
2014-08-08 20:03:47 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, tmp.toString());
|
2017-09-27 18:24:04 -07:00
|
|
|
if (androidBuildApkStep->useMinistro()) {
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--deployment"));
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("ministro"));
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
2017-09-08 23:36:13 +02:00
|
|
|
|
|
|
|
|
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--gradle"));
|
2014-11-18 12:08:31 +01:00
|
|
|
|
|
|
|
|
if (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-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();
|
2014-09-22 16:20:51 +03:00
|
|
|
m_apkPath = AndroidManager::androidQtSupport(target())->apkPath(target()).toString();
|
2014-11-26 12:19:46 +01:00
|
|
|
m_workingDirectory = bc->buildDirectory().toString();
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
2014-11-26 12:19:46 +01:00
|
|
|
m_environment = bc->environment();
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
m_buildDirectory = bc->buildDirectory().toString();
|
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;
|
|
|
|
|
if (avdManager.findAvd(m_avdName).isEmpty())
|
|
|
|
|
avdManager.startAvdAsync(m_avdName);
|
2013-09-17 18:24:57 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:33:10 +02:00
|
|
|
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy(QFutureInterface<bool> &fi)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-11-26 12:19:46 +01:00
|
|
|
QString args;
|
2014-08-08 20:03:47 +03:00
|
|
|
if (m_useAndroiddeployqt) {
|
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 {
|
|
|
|
|
if (m_uninstallPreviousPackageRun) {
|
2014-10-24 17:53:05 +02:00
|
|
|
const QString 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
|
|
|
}
|
|
|
|
|
|
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"));
|
|
|
|
|
Utils::QtcProcess::addArg(&args, m_apkPath);
|
|
|
|
|
}
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
m_process = new Utils::QtcProcess;
|
|
|
|
|
m_process->setCommand(m_command, args);
|
|
|
|
|
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;
|
|
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
if (fi.isCanceled()) {
|
|
|
|
|
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;
|
|
|
|
|
m_process = 0;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exitCode == 0 && exitStatus == QProcess::NormalExit) {
|
2016-07-28 17:33:10 +02:00
|
|
|
if (deployError != NoError && m_uninstallPreviousPackageRun) {
|
|
|
|
|
deployError = Failure;
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
2016-07-28 17:33:10 +02:00
|
|
|
} else {
|
|
|
|
|
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?"));
|
|
|
|
|
int button = QMessageBox::critical(0, tr("Install failed"), uninstallMsg,
|
2014-11-26 12:19:46 +01:00
|
|
|
QMessageBox::Yes, QMessageBox::No);
|
|
|
|
|
m_askForUinstall = button == QMessageBox::Yes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidDeployQtStep::slotSetSerialNumber(const QString &serialNumber)
|
|
|
|
|
{
|
|
|
|
|
AndroidManager::setDeviceSerialNumber(target(), serialNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidDeployQtStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
{
|
|
|
|
|
if (!m_avdName.isEmpty()) {
|
2017-04-03 11:11:17 +02:00
|
|
|
QString serialNumber = AndroidAvdManager().waitForAvd(m_avdName, fi);
|
2014-11-26 12:19:46 +01:00
|
|
|
if (serialNumber.isEmpty()) {
|
2016-04-20 12:49:25 +02:00
|
|
|
reportRunResult(fi, false);
|
2014-11-26 12:19:46 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_serialNumber = serialNumber;
|
|
|
|
|
emit setSerialNumber(serialNumber);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 17:33:10 +02:00
|
|
|
DeployErrorCode returnValue = runDeploy(fi);
|
|
|
|
|
if (returnValue > DeployErrorCode::NoError && returnValue < DeployErrorCode::Failure) {
|
|
|
|
|
emit askForUninstall(returnValue);
|
2014-11-26 12:19:46 +01:00
|
|
|
if (m_askForUinstall) {
|
|
|
|
|
m_uninstallPreviousPackageRun = true;
|
|
|
|
|
returnValue = runDeploy(fi);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Pulling files necessary for debugging."), OutputFormat::NormalMessage);
|
2015-03-27 11:38:34 +01:00
|
|
|
|
|
|
|
|
QString localAppProcessFile = QString::fromLatin1("%1/app_process").arg(m_buildDirectory);
|
2015-09-09 17:53:37 +02:00
|
|
|
QFile::remove(localAppProcessFile);
|
|
|
|
|
|
|
|
|
|
foreach (const QString &remoteAppProcessFile, m_appProcessBinaries) {
|
|
|
|
|
runCommand(m_adbPath,
|
|
|
|
|
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
|
|
|
|
<< QLatin1String("pull") << remoteAppProcessFile
|
|
|
|
|
<< localAppProcessFile);
|
|
|
|
|
if (QFileInfo::exists(localAppProcessFile))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-27 11:38:34 +01:00
|
|
|
if (!QFileInfo::exists(localAppProcessFile)) {
|
2015-04-22 14:10:12 +02:00
|
|
|
returnValue = Failure;
|
|
|
|
|
emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
|
2015-09-09 17:53:37 +02:00
|
|
|
.arg(m_appProcessBinaries.join(QLatin1String("\", \"")))
|
2017-01-12 10:59:12 +01:00
|
|
|
.arg(localAppProcessFile), OutputFormat::ErrorMessage);
|
2015-03-27 11:38:34 +01:00
|
|
|
}
|
2015-06-19 16:20:30 +03:00
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
runCommand(m_adbPath,
|
2013-09-17 18:24:57 +02:00
|
|
|
AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull")
|
2015-06-19 16:20:30 +03:00
|
|
|
<< QLatin1String("/system/") + m_libdir + QLatin1String("/libc.so")
|
2013-09-17 18:24:57 +02:00
|
|
|
<< QString::fromLatin1("%1/libc.so").arg(m_buildDirectory));
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2016-07-28 17:33:10 +02:00
|
|
|
reportRunResult(fi, returnValue == NoError);
|
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
|
|
|
}
|
|
|
|
|
|
2015-11-13 12:56:36 +01:00
|
|
|
AndroidDeviceInfo AndroidDeployQtStep::deviceInfo() const
|
|
|
|
|
{
|
|
|
|
|
return m_deviceInfo;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2013-11-13 16:14:27 +01:00
|
|
|
bool AndroidDeployQtStep::runInGuiThread() const
|
|
|
|
|
{
|
2014-11-26 12:19:46 +01:00
|
|
|
return false;
|
2013-11-13 16:14:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-16 14:25:34 +03:00
|
|
|
AndroidDeployQtStep::UninstallType AndroidDeployQtStep::uninstallPreviousPackage()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2014-09-16 14:25:34 +03:00
|
|
|
if (QtSupport::QtKitInformation::qtVersion(target()->kit())->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0))
|
|
|
|
|
return ForceUnintall;
|
|
|
|
|
return m_uninstallPreviousPackage ? Uninstall : Keep;
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|