forked from qt-creator/qt-creator
Android: Enable setting environment variables for android apps
Change-Id: Id4625f081d6997dcabad9b01fb09d6c9c6ef7477 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
@@ -55,7 +55,8 @@ HEADERS += \
|
||||
androidsdkmanagerwidget.h \
|
||||
androidpackageinstallationstep.h \
|
||||
androidextralibrarylistmodel.h \
|
||||
createandroidmanifestwizard.h
|
||||
createandroidmanifestwizard.h \
|
||||
androidrunenvironmentaspect.h
|
||||
|
||||
SOURCES += \
|
||||
androidconfigurations.cpp \
|
||||
@@ -103,7 +104,8 @@ SOURCES += \
|
||||
androidsdkmanagerwidget.cpp \
|
||||
androidpackageinstallationstep.cpp \
|
||||
androidextralibrarylistmodel.cpp \
|
||||
createandroidmanifestwizard.cpp
|
||||
createandroidmanifestwizard.cpp \
|
||||
androidrunenvironmentaspect.cpp
|
||||
|
||||
FORMS += \
|
||||
androidsettingswidget.ui \
|
||||
|
@@ -85,6 +85,8 @@ Project {
|
||||
"androidqtversionfactory.h",
|
||||
"androidrunconfiguration.cpp",
|
||||
"androidrunconfiguration.h",
|
||||
"androidrunenvironmentaspect.h",
|
||||
"androidrunenvironmentaspect.cpp",
|
||||
"androidruncontrol.cpp",
|
||||
"androidruncontrol.h",
|
||||
"androidrunner.cpp",
|
||||
|
@@ -99,12 +99,11 @@ static QString toNdkArch(const QString &arch)
|
||||
return QLatin1String("arch-") + arch;
|
||||
}
|
||||
|
||||
AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl, const QString &intentName,
|
||||
const Utils::Environment &extraEnvVars)
|
||||
AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl, const QString &intentName)
|
||||
: Debugger::DebuggerRunTool(runControl)
|
||||
{
|
||||
setDisplayName("AndroidDebugger");
|
||||
m_runner = new AndroidRunner(runControl, intentName, extraEnvVars);
|
||||
m_runner = new AndroidRunner(runControl, intentName);
|
||||
addStartDependency(m_runner);
|
||||
}
|
||||
|
||||
|
@@ -37,8 +37,7 @@ class AndroidDebugSupport : public Debugger::DebuggerRunTool
|
||||
|
||||
public:
|
||||
AndroidDebugSupport(ProjectExplorer::RunControl *runControl,
|
||||
const QString &intentName = QString(),
|
||||
const Utils::Environment &extraEnvVars = Utils::Environment());
|
||||
const QString &intentName = QString());
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
@@ -32,13 +32,12 @@ namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidQmlToolingSupport::AndroidQmlToolingSupport(RunControl *runControl,
|
||||
const QString &intentName,
|
||||
const Utils::Environment &extraEnvVars)
|
||||
const QString &intentName)
|
||||
: RunWorker(runControl)
|
||||
{
|
||||
setDisplayName("AndroidQmlToolingSupport");
|
||||
|
||||
auto runner = new AndroidRunner(runControl, intentName, extraEnvVars);
|
||||
auto runner = new AndroidRunner(runControl, intentName);
|
||||
addStartDependency(runner);
|
||||
|
||||
auto profiler = runControl->createWorker(runControl->runMode());
|
||||
|
@@ -36,9 +36,8 @@ class AndroidQmlToolingSupport : public ProjectExplorer::RunWorker
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AndroidQmlToolingSupport(
|
||||
ProjectExplorer::RunControl *runControl, const QString &intentName = QString(),
|
||||
const Utils::Environment &extraEnvVars = Utils::Environment());
|
||||
explicit AndroidQmlToolingSupport(ProjectExplorer::RunControl *runControl,
|
||||
const QString &intentName = QString());
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "androidtoolchain.h"
|
||||
#include "androidmanager.h"
|
||||
#include "adbcommandswidget.h"
|
||||
#include "androidrunenvironmentaspect.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -110,6 +111,7 @@ void BaseStringListAspect::setLabel(const QString &label)
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
addExtraAspect(new AndroidRunEnvironmentAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this));
|
||||
|
||||
auto amStartArgsAspect = new BaseStringAspect(this);
|
||||
@@ -154,6 +156,7 @@ QWidget *AndroidRunConfiguration::createConfigurationWidget()
|
||||
|
||||
extraAspect(Constants::ANDROID_PRESTARTSHELLCMDLIST)->addToConfigurationLayout(layout);
|
||||
extraAspect(Constants::ANDROID_POSTFINISHSHELLCMDLIST)->addToConfigurationLayout(layout);
|
||||
extraAspect<AndroidRunEnvironmentAspect>()->addToConfigurationLayout(layout);
|
||||
|
||||
auto wrapped = wrapWidget(widget);
|
||||
auto detailsWidget = qobject_cast<DetailsWidget *>(wrapped);
|
||||
|
@@ -38,9 +38,8 @@ using namespace ProjectExplorer;
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidRunSupport::AndroidRunSupport(RunControl *runControl, const QString &intentName,
|
||||
const Utils::Environment &extraEnvVars)
|
||||
: AndroidRunner(runControl, intentName, extraEnvVars)
|
||||
AndroidRunSupport::AndroidRunSupport(RunControl *runControl, const QString &intentName)
|
||||
: AndroidRunner(runControl, intentName)
|
||||
{
|
||||
runControl->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
|
||||
}
|
||||
|
@@ -40,8 +40,7 @@ class AndroidRunSupport : public AndroidRunner
|
||||
|
||||
public:
|
||||
explicit AndroidRunSupport(ProjectExplorer::RunControl *runControl,
|
||||
const QString &intentName = QString(),
|
||||
const Utils::Environment &extraEnvVars = Utils::Environment());
|
||||
const QString &intentName = QString());
|
||||
~AndroidRunSupport() override;
|
||||
|
||||
void start() override;
|
||||
|
48
src/plugins/android/androidrunenvironmentaspect.cpp
Normal file
48
src/plugins/android/androidrunenvironmentaspect.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "androidrunenvironmentaspect.h"
|
||||
|
||||
namespace {
|
||||
enum BaseEnvironmentBase {
|
||||
CleanEnvironmentBase
|
||||
};
|
||||
}
|
||||
|
||||
namespace Android {
|
||||
|
||||
AndroidRunEnvironmentAspect::AndroidRunEnvironmentAspect(ProjectExplorer::RunConfiguration *rc) :
|
||||
ProjectExplorer::EnvironmentAspect (rc)
|
||||
{
|
||||
addSupportedBaseEnvironment(CleanEnvironmentBase, tr("Clean Environment"));
|
||||
}
|
||||
|
||||
Utils::Environment AndroidRunEnvironmentAspect::baseEnvironment() const
|
||||
{
|
||||
// Clean Environment
|
||||
return Utils::Environment();
|
||||
}
|
||||
|
||||
} // namespace Android
|
||||
|
42
src/plugins/android/androidrunenvironmentaspect.h
Normal file
42
src/plugins/android/androidrunenvironmentaspect.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/environmentaspect.h>
|
||||
|
||||
namespace Android {
|
||||
|
||||
class AndroidRunEnvironmentAspect : public ProjectExplorer::EnvironmentAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AndroidRunEnvironmentAspect(ProjectExplorer::RunConfiguration *rc);
|
||||
|
||||
Utils::Environment baseEnvironment() const override;
|
||||
};
|
||||
|
||||
} // namespace Android
|
||||
|
@@ -118,9 +118,7 @@ using namespace Utils;
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidRunner::AndroidRunner(RunControl *runControl,
|
||||
const QString &intentName,
|
||||
const Utils::Environment &extraEnvVars)
|
||||
AndroidRunner::AndroidRunner(RunControl *runControl, const QString &intentName)
|
||||
: RunWorker(runControl), m_target(runControl->runConfiguration()->target())
|
||||
{
|
||||
setDisplayName("AndroidRunner");
|
||||
@@ -144,7 +142,6 @@ AndroidRunner::AndroidRunner(RunControl *runControl,
|
||||
m_worker.reset(new AndroidRunnerWorker(this, m_packageName));
|
||||
m_worker->setIntentName(intent);
|
||||
m_worker->setIsPreNougat(apiLevel <= 23);
|
||||
m_worker->setExtraEnvVars(extraEnvVars);
|
||||
|
||||
m_worker->moveToThread(&m_thread);
|
||||
|
||||
|
@@ -50,8 +50,7 @@ class AndroidRunner : public ProjectExplorer::RunWorker
|
||||
|
||||
public:
|
||||
explicit AndroidRunner(ProjectExplorer::RunControl *runControl,
|
||||
const QString &intentName = QString(),
|
||||
const Utils::Environment &extraEnvVars = Utils::Environment());
|
||||
const QString &intentName = QString());
|
||||
~AndroidRunner() override;
|
||||
|
||||
Utils::Port gdbServerPort() const { return m_gdbServerPort; }
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "androidrunconfiguration.h"
|
||||
|
||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||
#include <projectexplorer/environmentaspect.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
@@ -193,6 +194,10 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
|
||||
m_deviceSerialNumber = AndroidManager::deviceSerialNumber(target);
|
||||
m_apiLevel = AndroidManager::deviceApiLevel(target);
|
||||
|
||||
m_extraEnvVars = runConfig->extraAspect<EnvironmentAspect>()->environment();
|
||||
qCDebug(androidRunWorkerLog) << "Environment variables for the app"
|
||||
<< m_extraEnvVars.toStringList();
|
||||
|
||||
m_extraAppParams = runConfig->runnable().commandLineArguments;
|
||||
|
||||
if (auto aspect = runConfig->extraAspect(Constants::ANDROID_AMSTARTARGS))
|
||||
@@ -607,12 +612,5 @@ void AndroidRunnerWorker::onProcessIdChanged(qint64 pid)
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidRunnerWorker::setExtraEnvVars(const Utils::Environment &extraEnvVars)
|
||||
{
|
||||
m_extraEnvVars = extraEnvVars;
|
||||
qCDebug(androidRunWorkerLog) << "Settings extra env:"
|
||||
<< extraEnvVars.toStringList();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
@@ -55,7 +55,6 @@ public:
|
||||
void logcatReadStandardOutput();
|
||||
void logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError);
|
||||
void setAndroidDeviceInfo(const AndroidDeviceInfo &info);
|
||||
void setExtraEnvVars(const Utils::Environment &extraEnvVars);
|
||||
void setIsPreNougat(bool isPreNougat) { m_isPreNougat = isPreNougat; }
|
||||
void setIntentName(const QString &intentName) { m_intentName = intentName; }
|
||||
|
||||
|
Reference in New Issue
Block a user