2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include "androidrunconfiguration.h"
|
2018-05-04 16:01:13 +02:00
|
|
|
|
|
|
|
|
#include "androidconstants.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
#include "androidglobal.h"
|
|
|
|
|
#include "androidtoolchain.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "androidmanager.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2020-07-31 17:41:28 +02:00
|
|
|
#include <app/app_version.h>
|
|
|
|
|
|
2019-11-15 15:44:45 +01:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2018-05-04 11:13:43 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2021-03-25 19:10:35 +01:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2018-05-04 11:13:43 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
#include <utils/detailswidget.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <utils/qtcassert.h>
|
2018-05-04 16:01:13 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
2012-07-25 17:41:01 +02:00
|
|
|
using namespace ProjectExplorer;
|
2018-05-04 16:01:13 +02:00
|
|
|
using namespace Utils;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
namespace Android {
|
2017-06-08 14:57:09 +02:00
|
|
|
|
2021-03-25 19:10:35 +01:00
|
|
|
class BaseStringListAspect final : public Utils::StringAspect
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2021-03-25 19:10:35 +01:00
|
|
|
public:
|
|
|
|
|
explicit BaseStringListAspect() = default;
|
|
|
|
|
~BaseStringListAspect() final = default;
|
|
|
|
|
|
|
|
|
|
void fromMap(const QVariantMap &map) final
|
|
|
|
|
{
|
|
|
|
|
// Pre Qt Creator 5.0 hack: Reads QStringList as QString
|
|
|
|
|
setValue(map.value(settingsKey()).toStringList().join('\n'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void toMap(QVariantMap &map) const final
|
|
|
|
|
{
|
|
|
|
|
// Pre Qt Creator 5.0 hack: Writes QString as QStringList
|
|
|
|
|
map.insert(settingsKey(), value().split('\n'));
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-05-15 14:48:39 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Utils::Id id)
|
2018-05-04 16:01:13 +02:00
|
|
|
: RunConfiguration(target, id)
|
2017-06-08 14:57:09 +02:00
|
|
|
{
|
2019-03-07 09:08:40 +01:00
|
|
|
auto envAspect = addAspect<EnvironmentAspect>();
|
2019-03-07 10:10:22 +01:00
|
|
|
envAspect->addSupportedBaseEnvironment(tr("Clean Environment"), {});
|
2019-03-07 09:08:40 +01:00
|
|
|
|
2022-05-11 16:51:46 +02:00
|
|
|
auto extraAppArgsAspect = addAspect<ArgumentsAspect>(macroExpander());
|
2020-08-24 09:24:22 +03:00
|
|
|
|
2022-05-11 16:51:46 +02:00
|
|
|
connect(extraAppArgsAspect, &BaseAspect::changed, this, [target, extraAppArgsAspect] {
|
2020-08-24 09:24:22 +03:00
|
|
|
if (target->buildConfigurations().first()->buildType() == BuildConfiguration::BuildType::Release) {
|
|
|
|
|
const QString buildKey = target->activeBuildKey();
|
|
|
|
|
target->buildSystem()->setExtraData(buildKey,
|
2021-09-05 18:49:26 +03:00
|
|
|
Android::Constants::AndroidApplicationArgs,
|
2022-05-11 16:51:46 +02:00
|
|
|
extraAppArgsAspect->arguments());
|
2020-08-24 09:24:22 +03:00
|
|
|
}
|
|
|
|
|
});
|
2018-07-31 12:21:47 +02:00
|
|
|
|
2020-08-13 09:16:00 +02:00
|
|
|
auto amStartArgsAspect = addAspect<StringAspect>();
|
2021-09-05 18:49:26 +03:00
|
|
|
amStartArgsAspect->setId(Constants::ANDROID_AM_START_ARGS);
|
2018-05-04 16:01:13 +02:00
|
|
|
amStartArgsAspect->setSettingsKey("Android.AmStartArgsKey");
|
2021-10-04 13:28:06 +03:00
|
|
|
amStartArgsAspect->setLabelText(tr("Activity manager start arguments:"));
|
2020-08-13 09:16:00 +02:00
|
|
|
amStartArgsAspect->setDisplayStyle(StringAspect::LineEditDisplay);
|
2018-05-31 14:41:59 +02:00
|
|
|
amStartArgsAspect->setHistoryCompleter("Android.AmStartArgs.History");
|
2018-05-04 16:01:13 +02:00
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
auto preStartShellCmdAspect = addAspect<BaseStringListAspect>();
|
2021-03-25 19:10:35 +01:00
|
|
|
preStartShellCmdAspect->setDisplayStyle(StringAspect::TextEditDisplay);
|
2018-05-15 12:11:54 +02:00
|
|
|
preStartShellCmdAspect->setId(Constants::ANDROID_PRESTARTSHELLCMDLIST);
|
2018-05-04 16:01:13 +02:00
|
|
|
preStartShellCmdAspect->setSettingsKey("Android.PreStartShellCmdListKey");
|
2021-03-25 19:10:35 +01:00
|
|
|
preStartShellCmdAspect->setLabelText(tr("Pre-launch on-device shell commands:"));
|
2018-05-04 16:01:13 +02:00
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
auto postStartShellCmdAspect = addAspect<BaseStringListAspect>();
|
2021-03-25 19:10:35 +01:00
|
|
|
postStartShellCmdAspect->setDisplayStyle(StringAspect::TextEditDisplay);
|
2018-05-15 12:11:54 +02:00
|
|
|
postStartShellCmdAspect->setId(Constants::ANDROID_POSTFINISHSHELLCMDLIST);
|
2018-05-04 16:01:13 +02:00
|
|
|
postStartShellCmdAspect->setSettingsKey("Android.PostStartShellCmdListKey");
|
2021-03-25 19:10:35 +01:00
|
|
|
postStartShellCmdAspect->setLabelText(tr("Post-quit on-device shell commands:"));
|
2018-05-04 16:01:13 +02:00
|
|
|
|
2019-11-25 16:57:48 +01:00
|
|
|
setUpdater([this, target] {
|
|
|
|
|
const BuildTargetInfo bti = buildTargetInfo();
|
|
|
|
|
setDisplayName(bti.displayName);
|
|
|
|
|
setDefaultDisplayName(bti.displayName);
|
|
|
|
|
AndroidManager::updateGradleProperties(target, buildKey());
|
2018-05-04 16:01:13 +02:00
|
|
|
});
|
2019-11-25 16:57:48 +01:00
|
|
|
|
|
|
|
|
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
|
2017-06-08 14:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
} // namespace Android
|