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"
|
2021-02-12 20:57:18 +01:00
|
|
|
#include "androidqtversion.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>
|
2020-07-14 15:23:26 +03:00
|
|
|
#include <projectexplorer/buildsystem.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>
|
2020-08-11 17:53:44 +03:00
|
|
|
#include <projectexplorer/taskhub.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>
|
2020-10-09 15:24:33 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
|
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;
|
2019-05-29 18:11:38 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2018-06-18 11:49:14 +02:00
|
|
|
namespace {
|
2020-01-15 14:39:23 +01:00
|
|
|
static 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");
|
2016-07-28 17:32:08 +02:00
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
// AndroidDeployQtStep
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
AndroidDeployQtStep::AndroidDeployQtStep(BuildStepList *parent, Utils::Id id)
|
2019-12-20 17:05:30 +01:00
|
|
|
: BuildStep(parent, id)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2018-10-22 17:56:04 +02:00
|
|
|
setImmutable(true);
|
2020-10-09 15:24:33 +02:00
|
|
|
|
|
|
|
|
m_uninstallPreviousPackage = addAspect<BoolAspect>();
|
|
|
|
|
m_uninstallPreviousPackage->setSettingsKey(UninstallPreviousPackageKey);
|
2020-10-24 19:41:09 +03:00
|
|
|
m_uninstallPreviousPackage->setLabel(tr("Uninstall the existing app first"),
|
|
|
|
|
BoolAspect::LabelPlacement::AtCheckBox);
|
2020-10-09 15:24:33 +02:00
|
|
|
m_uninstallPreviousPackage->setValue(false);
|
|
|
|
|
|
2020-09-07 15:56:18 +02:00
|
|
|
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(kit());
|
2020-10-09 15:24:33 +02:00
|
|
|
const bool forced = qt && qt->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0);
|
|
|
|
|
if (forced) {
|
|
|
|
|
m_uninstallPreviousPackage->setValue(true);
|
|
|
|
|
m_uninstallPreviousPackage->setEnabled(false);
|
|
|
|
|
}
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2014-11-26 12:19:46 +01:00
|
|
|
connect(this, &AndroidDeployQtStep::askForUninstall,
|
|
|
|
|
this, &AndroidDeployQtStep::slotAskForUninstall,
|
|
|
|
|
Qt::BlockingQueuedConnection);
|
2019-01-18 11:32:53 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool AndroidDeployQtStep::init()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
|
2020-06-30 16:07:09 +03:00
|
|
|
if (!version) {
|
|
|
|
|
qCDebug(deployStepLog,
|
|
|
|
|
"The Qt version for kit %s is not valid.",
|
2020-09-07 15:56:18 +02:00
|
|
|
qPrintable(kit()->displayName()));
|
2020-01-17 13:00:13 +01:00
|
|
|
return false;
|
2020-06-30 16:07:09 +03:00
|
|
|
}
|
2020-01-17 13:00:13 +01:00
|
|
|
|
2019-05-29 18:11:38 +02:00
|
|
|
m_androiddeployqtArgs = CommandLine();
|
2014-09-22 16:20:51 +03:00
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
m_androidABIs = AndroidManager::applicationAbis(target());
|
|
|
|
|
if (m_androidABIs.isEmpty()) {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("No Android arch set by the .pro file.");
|
|
|
|
|
emit addOutput(error, OutputFormat::Stderr);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
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);
|
2020-04-14 15:40:07 +02:00
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
2020-01-20 09:50:53 +01:00
|
|
|
QTC_ASSERT(bc, return false);
|
2018-06-18 13:40:02 +02:00
|
|
|
|
2019-12-20 10:54:54 +01:00
|
|
|
auto androidBuildApkStep = bc->buildSteps()->firstOfType<AndroidBuildApkStep>();
|
2018-07-17 13:58:50 +02:00
|
|
|
int minTargetApi = AndroidManager::minimumSDK(target());
|
2019-08-26 14:19:07 +03:00
|
|
|
qCDebug(deployStepLog) << "Target architecture:" << m_androidABIs
|
2018-07-17 13:58:50 +02:00
|
|
|
<< "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.
|
2019-08-16 12:16:17 +02:00
|
|
|
BuildStepList *bsl = stepList();
|
2019-01-10 16:23:05 +01:00
|
|
|
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()) {
|
2019-08-26 14:19:07 +03:00
|
|
|
info = AndroidConfigurations::showDeviceDialog(project(), minTargetApi, m_androidABIs);
|
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;
|
|
|
|
|
|
2020-07-14 15:23:26 +03:00
|
|
|
const QString buildKey = target()->activeBuildKey();
|
2020-11-05 01:55:58 +02:00
|
|
|
auto selectedAbis = buildSystem()->property(Constants::ANDROID_ABIS).toStringList();
|
2020-07-14 15:23:26 +03:00
|
|
|
|
2020-11-05 01:55:58 +02:00
|
|
|
if (selectedAbis.isEmpty())
|
|
|
|
|
selectedAbis = buildSystem()->extraData(buildKey, Constants::ANDROID_ABIS).toStringList();
|
|
|
|
|
|
|
|
|
|
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(kit());
|
|
|
|
|
if (qt && qt->supportsMultipleQtAbis() && !selectedAbis.contains(info.cpuAbi.first())) {
|
2020-08-11 17:53:44 +03:00
|
|
|
TaskHub::addTask(DeploymentTask(
|
|
|
|
|
Task::Warning,
|
2020-08-10 19:56:45 +02:00
|
|
|
tr("Android: The main ABI of the deployment device (%1) is not selected. The app "
|
2020-07-28 11:40:16 +02:00
|
|
|
"execution or debugging might not work properly. Add it from Projects > Build > "
|
|
|
|
|
"Build Steps > qmake > ABIs.")
|
2020-08-11 17:53:44 +03:00
|
|
|
.arg(info.cpuAbi.first())));
|
2020-07-14 15:23:26 +03:00
|
|
|
}
|
|
|
|
|
|
2015-04-23 16:25:44 +02:00
|
|
|
m_avdName = info.avdname;
|
|
|
|
|
m_serialNumber = info.serialNumber;
|
2020-07-01 18:10:02 +03:00
|
|
|
qCDebug(deployStepLog) << "Selected device info:" << info;
|
2015-09-09 17:53:37 +02:00
|
|
|
|
2019-12-15 18:52:57 +01:00
|
|
|
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);
|
2019-08-26 14:19:07 +03:00
|
|
|
AndroidManager::setDeviceAbis(target(), info.cpuAbi);
|
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);
|
|
|
|
|
|
2020-10-09 15:24:33 +02:00
|
|
|
m_uninstallPreviousPackageRun = m_uninstallPreviousPackage->value();
|
2014-11-26 12:19:46 +01:00
|
|
|
if (m_uninstallPreviousPackageRun)
|
2014-10-24 17:53:05 +02:00
|
|
|
m_manifestName = AndroidManager::manifestPath(target());
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2019-12-15 18:52:57 +01:00
|
|
|
m_useAndroiddeployqt = 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) {
|
2020-03-31 20:25:54 +02:00
|
|
|
const QString buildKey = target()->activeBuildKey();
|
|
|
|
|
const ProjectNode *node = target()->project()->findNodeForBuildKey(buildKey);
|
2019-06-15 10:12:31 +03:00
|
|
|
if (!node)
|
|
|
|
|
return false;
|
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-06-05 10:47:30 +02:00
|
|
|
m_command = AndroidConfigurations::currentConfig().adbToolPath();
|
2019-04-03 18:10:35 +02:00
|
|
|
AndroidManager::setManifestPath(target(), m_manifestName);
|
|
|
|
|
} else {
|
2021-02-12 20:57:18 +01:00
|
|
|
QString jsonFile = AndroidQtVersion::androidDeploymentSettings(target()).toString();
|
2019-04-03 18:10:35 +02:00
|
|
|
if (jsonFile.isEmpty()) {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("Cannot find the androiddeploy Json file.");
|
|
|
|
|
emit addOutput(error, OutputFormat::Stderr);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
2019-04-03 18:10:35 +02:00
|
|
|
return false;
|
2019-06-05 10:47:30 +02:00
|
|
|
}
|
2019-09-30 14:34:31 +02:00
|
|
|
m_command = version->hostBinPath();
|
2019-04-03 18:10:35 +02:00
|
|
|
if (m_command.isEmpty()) {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("Cannot find the androiddeployqt tool.");
|
|
|
|
|
emit addOutput(error, OutputFormat::Stderr);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
2019-04-03 18:10:35 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-06-05 10:47:30 +02:00
|
|
|
m_command = m_command.pathAppended(HostOsInfo::withExecutableSuffix("androiddeployqt"));
|
2019-04-03 18:10:35 +02:00
|
|
|
|
2019-06-05 10:47:30 +02:00
|
|
|
m_workingDirectory = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY);
|
2019-04-03 18:10:35 +02:00
|
|
|
|
2019-05-29 18:11:38 +02:00
|
|
|
m_androiddeployqtArgs.addArgs({"--verbose",
|
2019-06-05 10:47:30 +02:00
|
|
|
"--output", m_workingDirectory.toString(),
|
2019-05-29 18:11:38 +02:00
|
|
|
"--no-build",
|
|
|
|
|
"--input", jsonFile});
|
2019-04-03 18:10:35 +02:00
|
|
|
|
2019-05-29 18:11:38 +02:00
|
|
|
m_androiddeployqtArgs.addArg("--gradle");
|
2019-04-03 18:10:35 +02:00
|
|
|
|
|
|
|
|
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.
|
2019-05-29 18:11:38 +02:00
|
|
|
m_androiddeployqtArgs.addArgs({"--sign", "foo", "bar"});
|
2019-04-03 18:10:35 +02:00
|
|
|
}
|
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;
|
2019-06-05 10:47:30 +02:00
|
|
|
m_command = AndroidConfigurations::currentConfig().adbToolPath();
|
2019-12-15 18:52:57 +01:00
|
|
|
m_apkPath = AndroidManager::apkPath(target());
|
2019-06-05 10:47:30 +02:00
|
|
|
m_workingDirectory = bc ? bc->buildDirectory() : FilePath();
|
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
|
|
|
|
2019-06-05 10:47:30 +02:00
|
|
|
m_adbPath = AndroidConfigurations::currentConfig().adbToolPath();
|
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
|
|
|
{
|
2019-06-05 15:35:15 +02:00
|
|
|
CommandLine cmd(m_command);
|
2019-04-03 18:10:35 +02:00
|
|
|
if (m_useAndroiddeployqt && m_apkPath.isEmpty()) {
|
2019-06-05 15:35:15 +02:00
|
|
|
cmd.addArgs(m_androiddeployqtArgs.arguments(), CommandLine::Raw);
|
2014-11-26 12:19:46 +01:00
|
|
|
if (m_uninstallPreviousPackageRun)
|
2019-05-29 18:11:38 +02:00
|
|
|
cmd.addArg("--install");
|
2014-11-26 12:19:46 +01:00
|
|
|
else
|
2019-05-29 18:11:38 +02:00
|
|
|
cmd.addArg("--reinstall");
|
|
|
|
|
|
|
|
|
|
if (!m_serialNumber.isEmpty() && !m_serialNumber.startsWith("????"))
|
|
|
|
|
cmd.addArgs({"--device", m_serialNumber});
|
2014-11-26 12:19:46 +01:00
|
|
|
|
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);
|
|
|
|
|
QString packageName;
|
|
|
|
|
|
2014-08-08 20:03:47 +03:00
|
|
|
if (m_uninstallPreviousPackageRun) {
|
2019-12-15 18:52:57 +01:00
|
|
|
packageName = AndroidManager::packageName(m_manifestName);
|
2014-11-26 12:19:46 +01:00
|
|
|
if (packageName.isEmpty()) {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("Cannot find the package name.");
|
|
|
|
|
emit addOutput(error, OutputFormat::Stderr);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
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);
|
2019-06-06 16:27:55 +02:00
|
|
|
runCommand({m_adbPath,
|
2014-08-08 20:03:47 +03:00
|
|
|
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
2019-06-06 16:27:55 +02:00
|
|
|
<< "uninstall" << packageName});
|
2014-08-08 20:03:47 +03:00
|
|
|
}
|
|
|
|
|
|
2019-05-29 18:11:38 +02:00
|
|
|
cmd.addArgs(AndroidDeviceInfo::adbSelector(m_serialNumber));
|
|
|
|
|
cmd.addArgs({"install", "-r", 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-29 18:11:38 +02:00
|
|
|
m_process->setCommand(cmd);
|
2019-06-05 10:47:30 +02:00
|
|
|
m_process->setWorkingDirectory(m_workingDirectory.toString());
|
2014-11-26 12:19:46 +01:00
|
|
|
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();
|
|
|
|
|
|
2019-05-29 18:11:38 +02:00
|
|
|
emit addOutput(tr("Starting: \"%1\"").arg(cmd.toUserOutput()),
|
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) {
|
2019-06-05 10:47:30 +02:00
|
|
|
emit addOutput(tr("The process \"%1\" exited normally.").arg(m_command.toUserOutput()),
|
2017-01-12 10:59:12 +01:00
|
|
|
BuildStep::OutputFormat::NormalMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
} else if (exitStatus == QProcess::NormalExit) {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("The process \"%1\" exited with code %2.")
|
|
|
|
|
.arg(m_command.toUserOutput(), QString::number(exitCode));
|
|
|
|
|
emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
2014-11-26 12:19:46 +01:00
|
|
|
} else {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("The process \"%1\" crashed.").arg(m_command.toUserOutput());
|
|
|
|
|
emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
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
|
|
|
}
|
|
|
|
|
|
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;
|
2020-08-25 11:47:09 +02:00
|
|
|
qCDebug(deployStepLog) << "Target device serial number change:" << serialNumber;
|
|
|
|
|
AndroidManager::setDeviceSerialNumber(target(), serialNumber);
|
2014-11-26 12:19:46 +01: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
|
|
|
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);
|
|
|
|
|
|
2020-06-16 15:46:36 +03:00
|
|
|
// Note that values are not necessarily unique, e.g. app_process is looked up in several directories
|
2018-03-12 18:03:42 +01:00
|
|
|
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
|
|
|
|
|
QFile::remove(itr.value());
|
2020-06-16 15:46:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
|
2019-06-06 16:27:55 +02:00
|
|
|
runCommand({m_adbPath,
|
2015-09-09 17:53:37 +02:00
|
|
|
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
2019-06-06 16:27:55 +02:00
|
|
|
<< "pull" << itr.key() << itr.value()});
|
2018-03-12 18:03:42 +01:00
|
|
|
if (!QFileInfo::exists(itr.value())) {
|
2020-09-01 13:28:50 +03:00
|
|
|
const QString error = tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
|
|
|
|
|
.arg(itr.key())
|
|
|
|
|
.arg(itr.value());
|
|
|
|
|
emit addOutput(error, OutputFormat::ErrorMessage);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
2018-03-12 18:03:42 +01:00
|
|
|
}
|
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();
|
2020-04-14 15:40:07 +02:00
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
2018-06-18 13:40:02 +02:00
|
|
|
QString buildDir = bc ? bc->buildDirectory().toString() : QString();
|
|
|
|
|
if (bc && !buildDir.endsWith("/")) {
|
|
|
|
|
buildDir += "/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_deviceInfo.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString linkerName("linker");
|
|
|
|
|
QString libDirName("lib");
|
2019-12-03 09:26:05 +02:00
|
|
|
auto preferreABI = AndroidManager::apkDevicePreferredAbi(target());
|
2020-07-23 15:48:56 +02:00
|
|
|
if (preferreABI == ProjectExplorer::Constants::ANDROID_ABI_ARM64_V8A
|
|
|
|
|
|| preferreABI == ProjectExplorer::Constants::ANDROID_ABI_X86_64) {
|
2019-08-26 14:19:07 +03:00
|
|
|
m_filesToPull["/system/bin/app_process64"] = buildDir + "app_process";
|
|
|
|
|
libDirName = "lib64";
|
|
|
|
|
linkerName = "linker64";
|
2018-06-18 13:40:02 +02:00
|
|
|
} 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";
|
|
|
|
|
|
|
|
|
|
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr)
|
2020-07-01 18:10:02 +03:00
|
|
|
qCDebug(deployStepLog) << "Pulling file from device:" << itr.key() << "to:" << itr.value();
|
2018-06-18 13:40:02 +02: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
|
|
|
void AndroidDeployQtStep::doRun()
|
|
|
|
|
{
|
|
|
|
|
runInThread([this] { return runImpl(); });
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-06 16:27:55 +02:00
|
|
|
void AndroidDeployQtStep::runCommand(const CommandLine &command)
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2019-06-06 16:27:55 +02:00
|
|
|
SynchronousProcess buildProc;
|
2016-04-29 16:52:58 +02:00
|
|
|
buildProc.setTimeoutS(2 * 60);
|
2019-06-06 16:27:55 +02:00
|
|
|
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
|
|
|
|
|
OutputFormat::NormalMessage);
|
|
|
|
|
SynchronousProcessResponse response = buildProc.run(command);
|
2020-09-01 13:28:50 +03:00
|
|
|
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0) {
|
|
|
|
|
const QString error = response.exitMessage(command.executable().toString(), 2 * 60);
|
|
|
|
|
emit addOutput(error, OutputFormat::ErrorMessage);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
|
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-02 17:53:39 +02:00
|
|
|
QWidget *AndroidDeployQtStep::createConfigWidget()
|
2013-09-17 18:24:57 +02:00
|
|
|
{
|
2020-10-02 17:53:39 +02:00
|
|
|
auto widget = new QWidget;
|
2020-08-25 11:47:09 +02:00
|
|
|
|
|
|
|
|
auto resetDefaultDevices = new QPushButton(widget);
|
|
|
|
|
resetDefaultDevices->setText(tr("Reset Default Deployment Devices"));
|
|
|
|
|
|
|
|
|
|
connect(resetDefaultDevices, &QAbstractButton::clicked, this, [this] {
|
|
|
|
|
AndroidConfigurations::clearDefaultDevices(project());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
auto installCustomApkButton = new QPushButton(widget);
|
|
|
|
|
installCustomApkButton->setText(tr("Install an APK File"));
|
|
|
|
|
|
|
|
|
|
connect(installCustomApkButton, &QAbstractButton::clicked, this, [this, widget] {
|
|
|
|
|
const QString packagePath
|
|
|
|
|
= QFileDialog::getOpenFileName(widget,
|
|
|
|
|
tr("Qt Android Installer"),
|
|
|
|
|
QDir::homePath(),
|
|
|
|
|
tr("Android package (*.apk)"));
|
|
|
|
|
if (!packagePath.isEmpty())
|
|
|
|
|
AndroidManager::installQASIPackage(target(), packagePath);
|
|
|
|
|
});
|
|
|
|
|
|
2021-03-11 19:02:42 +01:00
|
|
|
Layouting::Form builder;
|
2020-10-09 15:24:33 +02:00
|
|
|
builder.addRow(m_uninstallPreviousPackage);
|
|
|
|
|
builder.addRow(resetDefaultDevices);
|
|
|
|
|
builder.addRow(installCustomApkButton);
|
2021-03-11 19:02:42 +01:00
|
|
|
builder.attachTo(widget);
|
2020-08-25 11:47:09 +02:00
|
|
|
|
|
|
|
|
return widget;
|
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);
|
2020-09-01 13:28:50 +03:00
|
|
|
|
2020-11-20 18:11:33 +02:00
|
|
|
QString newOutput = line;
|
|
|
|
|
newOutput.remove(QRegularExpression("^(\\n)+"));
|
|
|
|
|
|
2020-11-23 15:53:19 +02:00
|
|
|
if (newOutput.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2020-11-20 18:11:33 +02:00
|
|
|
if (newOutput.startsWith("warning", Qt::CaseInsensitive)
|
|
|
|
|
|| newOutput.startsWith("note", Qt::CaseInsensitive))
|
|
|
|
|
TaskHub::addTask(DeploymentTask(Task::Warning, newOutput));
|
2021-03-19 11:57:58 +01:00
|
|
|
else if (newOutput != QLatin1String("All files should be loaded. Notifying the device."))
|
2020-11-20 18:11:33 +02:00
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, newOutput));
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-25 11:47:09 +02:00
|
|
|
// AndroidDeployQtStepFactory
|
|
|
|
|
|
|
|
|
|
AndroidDeployQtStepFactory::AndroidDeployQtStepFactory()
|
|
|
|
|
{
|
|
|
|
|
registerStep<AndroidDeployQtStep>(Constants::ANDROID_DEPLOY_QT_ID);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
|
|
|
|
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
setRepeatable(false);
|
2020-09-24 17:29:46 +02:00
|
|
|
setDisplayName(AndroidDeployQtStep::tr("Deploy to Android device"));
|
2020-08-25 11:47:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-29 18:11:38 +02:00
|
|
|
} // Internal
|
|
|
|
|
} // Android
|