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"
|
2021-08-22 01:51:57 +03:00
|
|
|
#include "androiddevice.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);
|
2021-10-04 12:19:43 +03:00
|
|
|
setUserExpanded(true);
|
2020-10-09 15:24:33 +02:00
|
|
|
|
|
|
|
|
m_uninstallPreviousPackage = addAspect<BoolAspect>();
|
|
|
|
|
m_uninstallPreviousPackage->setSettingsKey(UninstallPreviousPackageKey);
|
2021-10-04 12:19:43 +03:00
|
|
|
m_uninstallPreviousPackage->setLabel(tr("Uninstall the existing app before deployment"),
|
2020-10-24 19:41:09 +03:00
|
|
|
BoolAspect::LabelPlacement::AtCheckBox);
|
2020-10-09 15:24:33 +02:00
|
|
|
m_uninstallPreviousPackage->setValue(false);
|
|
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
const QtSupport::QtVersion * 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
|
|
|
{
|
2022-01-21 16:06:36 +01:00
|
|
|
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
|
2020-06-30 16:07:09 +03:00
|
|
|
if (!version) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("The Qt version for kit %1 is invalid.").arg(kit()->displayName()),
|
|
|
|
|
Task::Error);
|
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()) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("No Android architecture (ABI) is set by the project."),
|
|
|
|
|
Task::Error);
|
2013-10-09 16:24:25 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-11-17 16:22:28 +01:00
|
|
|
|
2021-10-03 13:13:13 +03:00
|
|
|
emit addOutput(tr("Initializing deployment to Android device/simulator"),
|
|
|
|
|
OutputFormat::NormalMessage);
|
2018-07-17 13:58:50 +02:00
|
|
|
|
2018-06-18 13:40:02 +02:00
|
|
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
2021-10-03 13:13:13 +03:00
|
|
|
QTC_ASSERT(rc, reportWarningOrError(tr("The kit's run configuration is invalid."), Task::Error);
|
|
|
|
|
return false);
|
2020-04-14 15:40:07 +02:00
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
2021-10-03 13:13:13 +03:00
|
|
|
QTC_ASSERT(bc, reportWarningOrError(tr("The kit's build configuration is invalid."),
|
|
|
|
|
Task::Error);
|
|
|
|
|
return false);
|
2018-06-18 13:40:02 +02:00
|
|
|
|
2019-12-20 10:54:54 +01:00
|
|
|
auto androidBuildApkStep = bc->buildSteps()->firstOfType<AndroidBuildApkStep>();
|
2021-09-07 13:40:12 +02:00
|
|
|
const 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();
|
2021-10-03 13:13:13 +03:00
|
|
|
QTC_ASSERT(bsl, reportWarningOrError(tr("The kit's build steps list is invalid."), Task::Error);
|
|
|
|
|
return false);
|
2019-01-10 16:23:05 +01:00
|
|
|
auto androidDeployQtStep = bsl->firstOfType<AndroidDeployQtStep>();
|
2021-10-03 13:13:13 +03:00
|
|
|
QTC_ASSERT(androidDeployQtStep,
|
|
|
|
|
reportWarningOrError(tr("The kit's deploy configuration is invalid."), Task::Error);
|
|
|
|
|
return false);
|
2019-01-10 16:23:05 +01:00
|
|
|
AndroidDeviceInfo info;
|
|
|
|
|
if (androidDeployQtStep != this)
|
|
|
|
|
info = androidDeployQtStep->m_deviceInfo;
|
|
|
|
|
|
2021-09-04 23:21:56 +03:00
|
|
|
const BuildSystem *bs = buildSystem();
|
2021-09-05 18:49:26 +03:00
|
|
|
auto selectedAbis = bs->property(Constants::AndroidAbis).toStringList();
|
2021-09-04 23:21:56 +03:00
|
|
|
|
2020-07-14 15:23:26 +03:00
|
|
|
const QString buildKey = target()->activeBuildKey();
|
2021-09-04 23:21:56 +03:00
|
|
|
if (selectedAbis.isEmpty())
|
2021-09-05 18:49:26 +03:00
|
|
|
selectedAbis = bs->extraData(buildKey, Constants::AndroidAbis).toStringList();
|
2020-07-14 15:23:26 +03:00
|
|
|
|
2020-11-05 01:55:58 +02:00
|
|
|
if (selectedAbis.isEmpty())
|
2021-09-05 18:49:26 +03:00
|
|
|
selectedAbis.append(bs->extraData(buildKey, Constants::AndroidAbi).toString());
|
2020-11-05 01:55:58 +02:00
|
|
|
|
2021-08-22 01:51:57 +03:00
|
|
|
if (!info.isValid()) {
|
2022-01-14 17:14:02 +01:00
|
|
|
const auto dev =
|
|
|
|
|
static_cast<const AndroidDevice *>(DeviceKitAspect::device(kit()).data());
|
2021-10-03 13:13:13 +03:00
|
|
|
if (!dev) {
|
2021-11-05 15:25:13 +02:00
|
|
|
reportWarningOrError(tr("No valid deployment device is set."), Task::Error);
|
2021-10-03 13:13:13 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 17:14:02 +01:00
|
|
|
// TODO: use AndroidDevice directly instead of AndroidDeviceInfo.
|
2021-08-22 01:51:57 +03:00
|
|
|
info = AndroidDevice::androidDeviceInfoFromIDevice(dev);
|
|
|
|
|
m_deviceInfo = info; // Keep around for later steps
|
|
|
|
|
|
|
|
|
|
if (!info.isValid()) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("The deployment device \"%1\" is invalid.")
|
|
|
|
|
.arg(dev->displayName()), Task::Error);
|
2021-08-22 01:51:57 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 18:46:15 +02:00
|
|
|
const bool abiListNotEmpty = !selectedAbis.isEmpty() && !dev->supportedAbis().isEmpty();
|
|
|
|
|
if (abiListNotEmpty && !dev->canSupportAbis(selectedAbis)) {
|
2021-10-03 13:13:13 +03:00
|
|
|
const QString error = tr("The deployment device \"%1\" does not support the "
|
2021-08-22 01:51:57 +03:00
|
|
|
"architectures used by the kit.\n"
|
|
|
|
|
"The kit supports \"%2\", but the device uses \"%3\".")
|
|
|
|
|
.arg(dev->displayName()).arg(selectedAbis.join(", "))
|
2022-01-14 17:14:02 +01:00
|
|
|
.arg(dev->supportedAbis().join(", "));
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(error, Task::Error);
|
2021-08-22 01:51:57 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 17:14:02 +01:00
|
|
|
if (!dev->canHandleDeployments()) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("The deployment device \"%1\" is disconnected.")
|
|
|
|
|
.arg(dev->displayName()), Task::Error);
|
2021-08-22 01:51:57 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
const QtSupport::QtVersion * const qt = QtSupport::QtKitAspect::qtVersion(kit());
|
2020-11-05 01:55:58 +02:00
|
|
|
if (qt && qt->supportsMultipleQtAbis() && !selectedAbis.contains(info.cpuAbi.first())) {
|
2021-10-03 13:13:13 +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
|
|
|
}
|
|
|
|
|
|
2021-10-13 21:18:13 +03:00
|
|
|
m_avdName = info.avdName;
|
2015-04-23 16:25:44 +02:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2022-06-22 15:15:48 +03:00
|
|
|
gatherFilesToPull();
|
|
|
|
|
|
2021-10-03 13:13:13 +03:00
|
|
|
emit addOutput(tr("Deploying to %1").arg(m_serialNumber), OutputFormat::NormalMessage);
|
2018-07-17 13:58:50 +02:00
|
|
|
|
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);
|
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);
|
2021-10-03 13:13:13 +03:00
|
|
|
if (!node) {
|
|
|
|
|
reportWarningOrError(tr("The deployment step's project node is invalid."), Task::Error);
|
2019-06-15 10:12:31 +03:00
|
|
|
return false;
|
2021-10-03 13:13:13 +03:00
|
|
|
}
|
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()) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("Cannot find the androiddeployqt input JSON file."),
|
|
|
|
|
Task::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()) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("Cannot find the androiddeployqt tool."), Task::Error);
|
2019-04-03 18:10:35 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2021-08-11 08:28:29 +02:00
|
|
|
m_command = m_command.pathAppended("androiddeployqt").withExecutableSuffix();
|
2019-04-03 18:10:35 +02:00
|
|
|
|
2021-08-23 21:36:55 +03:00
|
|
|
m_workingDirectory = AndroidManager::androidBuildDirectory(target());
|
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());
|
2021-08-23 21:36:55 +03:00
|
|
|
m_workingDirectory = bc ? AndroidManager::buildDirectory(target()): 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()) {
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("Cannot find the package name from the Android Manifest "
|
|
|
|
|
"file \"%1\".").arg(m_manifestName.toUserOutput()),
|
|
|
|
|
Task::Error);
|
2014-11-26 12:19:46 +01:00
|
|
|
return Failure;
|
2014-10-24 17:53:05 +02:00
|
|
|
}
|
2021-10-03 13:13:13 +03:00
|
|
|
const QString msg = tr("Uninstalling the previous package \"%1\".").arg(packageName);
|
|
|
|
|
qCDebug(deployStepLog) << msg;
|
|
|
|
|
emit addOutput(msg, 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
|
|
|
|
2022-03-21 17:47:24 +01:00
|
|
|
QtcProcess process;
|
|
|
|
|
process.setCommand(cmd);
|
|
|
|
|
process.setWorkingDirectory(m_workingDirectory);
|
|
|
|
|
process.setEnvironment(m_environment);
|
|
|
|
|
process.setUseCtrlCStub(true);
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2016-07-28 17:32:08 +02:00
|
|
|
DeployErrorCode deployError = NoError;
|
2021-06-04 11:41:35 +02:00
|
|
|
|
2022-03-21 17:47:24 +01:00
|
|
|
process.setStdOutLineCallback([this, &deployError](const QString &line) {
|
2021-06-04 11:41:35 +02:00
|
|
|
deployError |= parseDeployErrors(line);
|
|
|
|
|
stdOutput(line);
|
|
|
|
|
});
|
2022-03-21 17:47:24 +01:00
|
|
|
process.setStdErrLineCallback([this, &deployError](const QString &line) {
|
2021-06-04 11:41:35 +02:00
|
|
|
deployError |= parseDeployErrors(line);
|
|
|
|
|
stdError(line);
|
|
|
|
|
});
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2022-03-21 17:47:24 +01:00
|
|
|
process.start();
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2021-10-03 13:13:13 +03:00
|
|
|
emit addOutput(tr("Starting: \"%1\"").arg(cmd.toUserOutput()), OutputFormat::NormalMessage);
|
2014-11-26 12:19:46 +01:00
|
|
|
|
2022-03-21 17:47:24 +01:00
|
|
|
while (!process.waitForFinished(200)) {
|
|
|
|
|
if (process.state() == QProcess::NotRunning)
|
2016-04-29 16:52:58 +02:00
|
|
|
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()) {
|
2022-03-21 17:47:24 +01:00
|
|
|
process.kill();
|
|
|
|
|
process.waitForFinished();
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-21 17:47:24 +01:00
|
|
|
const QProcess::ExitStatus exitStatus = process.exitStatus();
|
|
|
|
|
const int exitCode = process.exitCode();
|
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()),
|
2021-10-03 13:13:13 +03:00
|
|
|
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));
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(error, Task::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());
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(error, Task::Error);
|
2014-11-26 12:19:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 13:59:13 +02:00
|
|
|
if (deployError != NoError) {
|
2021-10-03 13:13:13 +03:00
|
|
|
if (m_uninstallPreviousPackageRun) {
|
2018-04-16 13:59:13 +02:00
|
|
|
deployError = Failure; // Even re-install failed. Set to Failure.
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(
|
|
|
|
|
tr("Installing the app failed even after uninstalling the previous one."),
|
|
|
|
|
Task::Error);
|
|
|
|
|
}
|
2018-04-16 13:59:13 +02:00
|
|
|
} 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.
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(tr("Installing the app failed with an unknown error."), Task::Error);
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-03 13:13:13 +03:00
|
|
|
uninstallMsg.append(tr("\nUninstalling the installed package may solve the issue.\n"
|
|
|
|
|
"Do 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;
|
2021-10-03 13:13:13 +03:00
|
|
|
if (serialNumber.isEmpty()) {
|
|
|
|
|
reportWarningOrError(tr("The deployment AVD \"%1\" cannot be started.")
|
|
|
|
|
.arg(m_avdName), Task::Error);
|
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 false;
|
2021-10-03 13:13:13 +03:00
|
|
|
}
|
2014-11-26 12:19:46 +01:00
|
|
|
m_serialNumber = serialNumber;
|
2021-10-03 13:13:13 +03:00
|
|
|
qCDebug(deployStepLog) << "Deployment device serial number changed:" << serialNumber;
|
2020-08-25 11:47:09 +02:00
|
|
|
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);
|
|
|
|
|
|
2021-10-03 13:13:13 +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());
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(error, Task::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();
|
2021-08-23 21:36:55 +03:00
|
|
|
QString buildDir = AndroidManager::buildDirectory(target()).toString();
|
|
|
|
|
if (!buildDir.endsWith("/")) {
|
2018-06-18 13:40:02 +02:00
|
|
|
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
|
|
|
{
|
2021-06-22 04:33:47 +02:00
|
|
|
QtcProcess 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);
|
2021-05-14 13:12:46 +02:00
|
|
|
|
2021-05-17 12:02:42 +02:00
|
|
|
buildProc.setCommand(command);
|
2022-03-02 04:12:25 +01:00
|
|
|
buildProc.runBlocking(EventLoopMode::On);
|
|
|
|
|
if (buildProc.result() != ProcessResult::FinishedWithSuccess)
|
2021-10-03 13:13:13 +03:00
|
|
|
reportWarningOrError(buildProc.exitMessage(), Task::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 installCustomApkButton = new QPushButton(widget);
|
|
|
|
|
installCustomApkButton->setText(tr("Install an APK File"));
|
|
|
|
|
|
|
|
|
|
connect(installCustomApkButton, &QAbstractButton::clicked, this, [this, widget] {
|
2021-08-17 15:01:16 +02:00
|
|
|
const FilePath packagePath
|
|
|
|
|
= FileUtils::getOpenFilePath(widget,
|
|
|
|
|
tr("Qt Android Installer"),
|
|
|
|
|
FileUtils::homePath(),
|
|
|
|
|
tr("Android package (*.apk)"));
|
2020-08-25 11:47:09 +02:00
|
|
|
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(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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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)
|
2021-08-31 12:59:26 +03:00
|
|
|
|| newOutput.startsWith("note", Qt::CaseInsensitive)
|
|
|
|
|
|| newOutput.startsWith(QLatin1String("All files should be loaded."))) {
|
2020-11-20 18:11:33 +02:00
|
|
|
TaskHub::addTask(DeploymentTask(Task::Warning, newOutput));
|
2021-08-31 12:59:26 +03:00
|
|
|
} else {
|
2020-11-20 18:11:33 +02:00
|
|
|
TaskHub::addTask(DeploymentTask(Task::Error, newOutput));
|
2021-08-31 12:59:26 +03:00
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-06-04 11:41:35 +02:00
|
|
|
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::parseDeployErrors(
|
|
|
|
|
const QString &deployOutputLine) const
|
2016-07-28 17:32:08 +02:00
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-03 13:13:13 +03:00
|
|
|
void AndroidDeployQtStep::reportWarningOrError(const QString &message, Task::TaskType type)
|
|
|
|
|
{
|
|
|
|
|
qCDebug(deployStepLog) << message;
|
|
|
|
|
emit addOutput(message, OutputFormat::ErrorMessage);
|
|
|
|
|
TaskHub::addTask(DeploymentTask(type, message));
|
|
|
|
|
}
|
|
|
|
|
|
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
|