Android: Adapt to ProjectExplorer::ToolRunner introduction

Change-Id: I71cc25ef3daa0eee51a4c94285174e0f3b45d41f
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2017-03-28 18:19:00 +02:00
parent c69b6f0ea9
commit eee51e8c1d
9 changed files with 58 additions and 71 deletions

View File

@@ -45,8 +45,7 @@ using namespace ProjectExplorer;
namespace Android {
namespace Internal {
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
Core::Id runMode)
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(RunConfiguration *runConfig, Core::Id runMode)
{
AnalyzerRunControl *runControl = Debugger::createAnalyzerRunControl(runConfig, runMode);
QTC_ASSERT(runControl, return 0);
@@ -59,18 +58,15 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
}
runControl->setDisplayName(AndroidManager::packageName(runConfig->target()));
runControl->setConnection(connection);
(void) new AndroidAnalyzeSupport(runConfig, runControl);
(void) new AndroidAnalyzeSupport(runControl);
return runControl;
}
AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
AnalyzerRunControl *runControl)
: QObject(runControl),
m_qmlPort(0)
AndroidAnalyzeSupport::AndroidAnalyzeSupport(RunControl *runControl)
: ToolRunner(runControl)
{
QTC_ASSERT(runControl, return);
auto runner = new AndroidRunner(this, runConfig, runControl->runMode());
auto runner = new AndroidRunner(this, runControl->runConfiguration(), runControl->runMode());
auto analyzerRunControl = qobject_cast<AnalyzerRunControl *>(runControl);
connect(runControl, &AnalyzerRunControl::finished, runner,
[runner]() { runner->stop(); });
@@ -79,8 +75,8 @@ AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
[runner]() { runner->start(); });
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this,
[this, runControl](Utils::Port) {
runControl->notifyRemoteSetupDone(m_qmlPort);
[this, analyzerRunControl](Utils::Port) {
analyzerRunControl->notifyRemoteSetupDone(m_qmlPort);
});
connect(runner, &AndroidRunner::remoteProcessStarted, this,
@@ -89,8 +85,8 @@ AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
});
connect(runner, &AndroidRunner::remoteProcessFinished, this,
[this, runControl](const QString &errorMsg) {
runControl->notifyRemoteFinished();
[this, runControl, analyzerRunControl](const QString &errorMsg) {
analyzerRunControl->notifyRemoteFinished();
runControl->appendMessage(errorMsg, Utils::NormalMessageFormat);
});

View File

@@ -26,25 +26,24 @@
#pragma once
#include "androidrunconfiguration.h"
#include <projectexplorer/runconfiguration.h>
#include <qmldebug/qmloutputparser.h>
namespace Debugger { class AnalyzerRunControl; }
namespace ProjectExplorer { class RunControl; }
namespace Android {
class AndroidRunConfiguration;
namespace Internal {
class AndroidAnalyzeSupport : public QObject
class AndroidAnalyzeSupport : public ProjectExplorer::ToolRunner
{
Q_OBJECT
public:
AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
Debugger::AnalyzerRunControl *runControl);
explicit AndroidAnalyzeSupport(ProjectExplorer::RunControl *runControl);
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
static ProjectExplorer::RunControl *createAnalyzeRunControl(ProjectExplorer::RunConfiguration *runConfig,
Core::Id runMode);
private:

View File

@@ -95,7 +95,7 @@ static QString toNdkArch(const QString &arch)
return QLatin1String("arch-") + arch;
}
RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig, QString *errorMessage)
RunControl *AndroidDebugSupport::createDebugRunControl(RunConfiguration *runConfig, QString *errorMessage)
{
Target *target = runConfig->target();
@@ -108,12 +108,14 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
params.useTargetAsync = true;
auto aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>();
if (aspect->useCppDebugger()) {
Kit *kit = target->kit();
params.symbolFile = target->activeBuildConfiguration()->buildDirectory().toString()
+ QLatin1String("/app_process");
params.skipExecutableValidation = true;
params.remoteChannel = runConfig->remoteChannel();
auto androidRunConfig = qobject_cast<AndroidRunConfiguration *>(runConfig);
params.remoteChannel = androidRunConfig->remoteChannel();
params.solibSearchPath = AndroidManager::androidQtSupport(target)->soLibSearchPath(target);
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
params.solibSearchPath.append(qtSoPaths(version));
@@ -136,33 +138,28 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
}
}
DebuggerRunControl * const debuggerRunControl = createDebuggerRunControl(params, runConfig, errorMessage);
new AndroidDebugSupport(runConfig, debuggerRunControl);
return debuggerRunControl;
RunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage);
new AndroidDebugSupport(runControl);
return runControl;
}
AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
DebuggerRunControl *runControl)
: QObject(runControl),
m_runControl(runControl),
m_runner(new AndroidRunner(this, runConfig, runControl->runMode()))
AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl)
: ToolRunner(runControl),
m_runner(new AndroidRunner(this, runControl->runConfiguration(), runControl->runMode()))
{
QTC_ASSERT(runControl, return);
connect(m_runControl, &RunControl::finished,
connect(runControl, &RunControl::finished,
m_runner, &AndroidRunner::stop);
connect(m_runControl, &DebuggerRunControl::requestRemoteSetup,
connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup,
m_runner, &AndroidRunner::start);
// FIXME: Move signal to base class and generalize handling.
connect(m_runControl, &DebuggerRunControl::aboutToNotifyInferiorSetupOk,
connect(this->runControl(), &DebuggerRunControl::aboutToNotifyInferiorSetupOk,
m_runner, &AndroidRunner::remoteDebuggerRunning);
connect(m_runner, &AndroidRunner::remoteServerRunning,
[this](const QByteArray &serverChannel, int pid) {
QTC_ASSERT(m_runControl, return);
m_runControl->notifyEngineRemoteServerRunning(serverChannel, pid);
this->runControl()->notifyEngineRemoteServerRunning(serverChannel, pid);
});
connect(m_runner, &AndroidRunner::remoteProcessStarted,
@@ -170,21 +167,18 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
connect(m_runner, &AndroidRunner::remoteProcessFinished,
[this](const QString &errorMsg) {
QTC_ASSERT(m_runControl, return);
m_runControl->appendMessage(errorMsg, Utils::DebugFormat);
QMetaObject::invokeMethod(m_runControl, "notifyInferiorExited", Qt::QueuedConnection);
appendMessage(errorMsg, Utils::DebugFormat);
QMetaObject::invokeMethod(this->runControl(), "notifyInferiorExited", Qt::QueuedConnection);
});
connect(m_runner, &AndroidRunner::remoteErrorOutput,
[this](const QString &output) {
QTC_ASSERT(m_runControl, return);
m_runControl->showMessage(output, AppError);
this->runControl()->showMessage(output, AppError);
});
connect(m_runner, &AndroidRunner::remoteOutput,
[this](const QString &output) {
QTC_ASSERT(m_runControl, return);
m_runControl->showMessage(output, AppOutput);
this->runControl()->showMessage(output, AppOutput);
});
}
@@ -192,12 +186,16 @@ void AndroidDebugSupport::handleRemoteProcessStarted(Utils::Port gdbServerPort,
{
disconnect(m_runner, &AndroidRunner::remoteProcessStarted,
this, &AndroidDebugSupport::handleRemoteProcessStarted);
QTC_ASSERT(m_runControl, return);
RemoteSetupResult result;
result.success = true;
result.gdbServerPort = gdbServerPort;
result.qmlServerPort = qmlPort;
m_runControl->notifyEngineRemoteSetupFinished(result);
runControl()->notifyEngineRemoteSetupFinished(result);
}
DebuggerRunControl *AndroidDebugSupport::runControl()
{
return qobject_cast<DebuggerRunControl *>(ToolRunner::runControl());
}
} // namespace Internal

View File

@@ -25,33 +25,31 @@
#pragma once
#include <projectexplorer/runconfiguration.h>
#include "androidrunconfiguration.h"
namespace Debugger { class DebuggerRunControl; }
namespace ProjectExplorer { class RunControl; }
namespace Android {
class AndroidRunConfiguration;
namespace Internal {
class AndroidRunner;
class AndroidDebugSupport : public QObject
class AndroidDebugSupport : public ProjectExplorer::ToolRunner
{
Q_OBJECT
public:
AndroidDebugSupport(AndroidRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl);
explicit AndroidDebugSupport(ProjectExplorer::RunControl *runControl);
static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig,
static ProjectExplorer::RunControl *createDebugRunControl(ProjectExplorer::RunConfiguration *runConfig,
QString *errorMessage);
private:
void handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort);
Debugger::DebuggerRunControl *runControl();
Debugger::DebuggerRunControl *m_runControl;
AndroidRunner * const m_runner;
};

View File

@@ -38,7 +38,7 @@ using namespace ProjectExplorer;
namespace Android {
namespace Internal {
AndroidRunControl::AndroidRunControl(AndroidRunConfiguration *rc)
AndroidRunControl::AndroidRunControl(RunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new AndroidRunner(this, rc, ProjectExplorer::Constants::NORMAL_RUN_MODE))
{

View File

@@ -28,9 +28,8 @@
#include <projectexplorer/runconfiguration.h>
namespace Android {
class AndroidRunConfiguration;
namespace Internal {
class AndroidRunner;
class AndroidRunControl : public ProjectExplorer::RunControl
@@ -38,7 +37,7 @@ class AndroidRunControl : public ProjectExplorer::RunControl
Q_OBJECT
public:
explicit AndroidRunControl(AndroidRunConfiguration *runConfig);
explicit AndroidRunControl(ProjectExplorer::RunConfiguration *runConfig);
~AndroidRunControl() override;
void start() override;

View File

@@ -56,17 +56,15 @@ bool AndroidRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::
}
RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
Core::Id mode, QString *errorMessage)
Core::Id mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig);
Q_ASSERT(rc);
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
return new AndroidRunControl(rc);
return new AndroidRunControl(runConfig);
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
return AndroidDebugSupport::createDebugRunControl(rc, errorMessage);
return AndroidDebugSupport::createDebugRunControl(runConfig, errorMessage);
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode);
return AndroidAnalyzeSupport::createAnalyzeRunControl(runConfig, mode);
QTC_CHECK(false); // The other run modes are not supported
return 0;
}

View File

@@ -684,8 +684,8 @@ void AndroidRunnerWorker::adbKill(qint64 pid)
<< "kill" << "-9" << QString::number(pid));
}
AndroidRunner::AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig, Core::Id runMode)
: QObject(parent), m_runConfig(runConfig)
AndroidRunner::AndroidRunner(QObject *parent, RunConfiguration *runConfig, Core::Id runMode)
: QObject(parent), m_runConfig(qobject_cast<AndroidRunConfiguration *>(runConfig))
{
static const int metaTypes[] = {
qRegisterMetaType<QVector<QStringList> >("QVector<QStringList>"),
@@ -703,7 +703,7 @@ AndroidRunner::AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig
m_androidRunnable.deviceSerialNumber = AndroidManager::deviceSerialNumber(target);
m_worker.reset(new AndroidRunnerWorker(
runConfig, runMode, m_androidRunnable.packageName,
m_runConfig, runMode, m_androidRunnable.packageName,
AndroidDeviceInfo::adbSelector(m_androidRunnable.deviceSerialNumber)));
m_worker->moveToThread(&m_thread);

View File

@@ -50,8 +50,7 @@ class AndroidRunner : public QObject
Q_OBJECT
public:
AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig,
Core::Id runMode);
AndroidRunner(QObject *parent, ProjectExplorer::RunConfiguration *runConfig, Core::Id runMode);
~AndroidRunner();
QString displayName() const;