Commit 11f89ece authored by hjk's avatar hjk

Android: Separate debug and analyze support

The common base class contains only unused functionality.

Change-Id: I5f6db59a2972d6ab8383ce209937090cd46ae39d
Reviewed-by: default avatarUlf Hermann <ulf.hermann@digia.com>
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent 3fb7c81a
......@@ -30,7 +30,6 @@ HEADERS += \
androiddevice.h \
androidgdbserverkitinformation.h \
androidanalyzesupport.h \
androidrunsupport.h \
androidmanifesteditorfactory.h \
androidmanifesteditor.h \
androidmanifesteditorwidget.h \
......@@ -73,7 +72,6 @@ SOURCES += \
androiddevice.cpp \
androidgdbserverkitinformation.cpp \
androidanalyzesupport.cpp \
androidrunsupport.cpp \
androidmanifesteditorfactory.cpp \
androidmanifesteditor.cpp \
androidmanifesteditorwidget.cpp \
......
......@@ -80,8 +80,6 @@ QtcPlugin {
"androidrunfactories.h",
"androidrunner.cpp",
"androidrunner.h",
"androidrunsupport.cpp",
"androidrunsupport.h",
"androidsettingspage.cpp",
"androidsettingspage.h",
"androidsettingswidget.cpp",
......
......@@ -75,61 +75,48 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
AnalyzerRunControl *runControl)
: AndroidRunSupport(runConfig, runControl),
m_runControl(0),
: QObject(runControl),
m_qmlPort(0)
{
if (runControl) {
m_runControl = runControl;
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
m_runner, SLOT(start()));
}
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
SLOT(remoteIsRunning()));
QTC_ASSERT(runControl, return);
connect(m_runner, &AndroidRunner::remoteProcessStarted,
[this](int, int qmlPort) { m_qmlPort = qmlPort; });
auto runner = new AndroidRunner(this, runConfig, runControl->runMode());
connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
SLOT(handleRemoteProcessFinished(QString)));
connect(runControl, &AnalyzerRunControl::finished,
[runner]() { runner->stop(); });
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
SLOT(handleRemoteErrorOutput(QByteArray)));
connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
SLOT(handleRemoteOutput(QByteArray)));
}
connect(runControl, &AnalyzerRunControl::starting,
[runner]() { runner->start(); });
void AndroidAnalyzeSupport::handleRemoteProcessFinished(const QString &errorMsg)
{
if (m_runControl)
m_runControl->notifyRemoteFinished();
AndroidRunSupport::handleRemoteProcessFinished(errorMsg);
}
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
[this, runControl](quint16) {
runControl->notifyRemoteSetupDone(m_qmlPort);
});
void AndroidAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
{
connect(runner, &AndroidRunner::remoteProcessStarted,
[this](int, int qmlPort) {
m_qmlPort = qmlPort;
});
connect(runner, &AndroidRunner::remoteProcessFinished,
[this, runControl](const QString &errorMsg) {
runControl->notifyRemoteFinished();
runControl->appendMessage(errorMsg, Utils::NormalMessageFormat);
});
connect(runner, &AndroidRunner::remoteErrorOutput,
[this, runControl](const QByteArray &output) {
const QString msg = QString::fromUtf8(output);
if (m_runControl)
m_runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
else
AndroidRunSupport::handleRemoteOutput(output);
runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
m_outputParser.processOutput(msg);
}
});
void AndroidAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output)
{
connect(runner, &AndroidRunner::remoteOutput,
[this, runControl](const QByteArray &output) {
const QString msg = QString::fromUtf8(output);
if (m_runControl)
m_runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
else
AndroidRunSupport::handleRemoteErrorOutput(output);
runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
m_outputParser.processOutput(msg);
}
void AndroidAnalyzeSupport::remoteIsRunning()
{
if (m_runControl)
m_runControl->notifyRemoteSetupDone(m_qmlPort);
});
}
} // namespace Internal
......
......@@ -30,7 +30,7 @@
#ifndef ANDROIDANALYZESUPPORT_H
#define ANDROIDANALYZESUPPORT_H
#include "androidrunsupport.h"
#include "androidrunconfiguration.h"
#include <qmldebug/qmloutputparser.h>
namespace Analyzer { class AnalyzerRunControl; }
......@@ -40,28 +40,19 @@ namespace Android {
class AndroidRunConfiguration;
namespace Internal {
class AndroidRunner;
class AndroidAnalyzeSupport : public AndroidRunSupport
class AndroidAnalyzeSupport : public QObject
{
Q_OBJECT
public:
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode);
AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
Analyzer::AnalyzerRunControl *runControl);
private slots:
void handleRemoteProcessFinished(const QString &errorMsg);
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
void remoteIsRunning();
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode);
private:
Analyzer::AnalyzerRunControl *m_runControl;
QmlDebug::QmlOutputParser m_outputParser;
int m_qmlPort;
};
......
......@@ -127,83 +127,66 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
DebuggerRunControl *runControl)
: AndroidRunSupport(runConfig, runControl),
m_engine(0)
: QObject(runControl),
m_engine(0),
m_runControl(runControl),
m_runner(new AndroidRunner(this, runConfig, runControl->runMode()))
{
QTC_ASSERT(runControl, return);
connect(m_runControl, SIGNAL(finished()),
m_runner, SLOT(stop()));
Debugger::DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
Q_ASSERT(aspect->useCppDebugger() || aspect->useQmlDebugger());
Q_UNUSED(aspect)
if (runControl)
m_engine = runControl->engine();
if (m_engine) {
connect(m_engine, SIGNAL(requestRemoteSetup()),
m_runner, SLOT(start()));
connect(m_engine, &DebuggerEngine::requestRemoteSetup,
m_runner, &AndroidRunner::start);
// FIXME: Move signal to base class and generalize handling.
connect(m_engine, SIGNAL(aboutToNotifyInferiorSetupOk()),
m_runner, SLOT(handleRemoteDebuggerRunning()));
}
connect(m_runner, SIGNAL(remoteServerRunning(QByteArray,int)),
SLOT(handleRemoteServerRunning(QByteArray,int)));
connect(m_runner, SIGNAL(remoteProcessStarted(int,int)),
SLOT(handleRemoteProcessStarted(int,int)));
connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
SLOT(handleRemoteProcessFinished(QString)));
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
SLOT(handleRemoteErrorOutput(QByteArray)));
connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
SLOT(handleRemoteOutput(QByteArray)));
}
void AndroidDebugSupport::handleRemoteServerRunning(const QByteArray &serverChannel, int pid)
{
if (m_engine)
connect(m_runner, &AndroidRunner::remoteServerRunning,
[this](const QByteArray &serverChannel, int pid) {
QTC_ASSERT(m_engine, return);
m_engine->notifyEngineRemoteServerRunning(serverChannel, pid);
}
});
void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort)
{
disconnect(m_runner, SIGNAL(remoteProcessStarted(int,int)),
this, SLOT(handleRemoteProcessStarted(int,int)));
if (m_engine)
m_engine->notifyEngineRemoteSetupDone(gdbServerPort, qmlPort);
}
connect(m_runner, &AndroidRunner::remoteProcessStarted,
this, &AndroidDebugSupport::handleRemoteProcessStarted);
void AndroidDebugSupport::handleRemoteProcessFinished(const QString &errorMsg)
{
DebuggerRunControl *runControl = qobject_cast<DebuggerRunControl *>(m_runControl);
if (runControl)
runControl->showMessage(errorMsg, AppStuff);
else
AndroidRunSupport::handleRemoteProcessFinished(errorMsg);
}
connect(m_runner, &AndroidRunner::remoteProcessFinished,
[this](const QString &errorMsg) {
QTC_ASSERT(m_runControl, return);
m_runControl->showMessage(errorMsg, AppStuff);
});
void AndroidDebugSupport::handleRemoteOutput(const QByteArray &output)
{
if (m_engine) {
connect(m_runner, &AndroidRunner::remoteErrorOutput,
[this](const QByteArray &output) {
QTC_ASSERT(m_engine, return);
m_engine->showMessage(QString::fromUtf8(output), AppError);
});
connect(m_runner, &AndroidRunner::remoteOutput,
[this](const QByteArray &output) {
QTC_ASSERT(m_engine, return);
m_engine->showMessage(QString::fromUtf8(output), AppOutput);
} else {
DebuggerRunControl *runControl = qobject_cast<DebuggerRunControl *>(m_runControl);
if (runControl)
runControl->showMessage(QString::fromUtf8(output), AppOutput);
else
AndroidRunSupport::handleRemoteOutput(output);
}
});
}
void AndroidDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort)
{
if (m_engine) {
m_engine->showMessage(QString::fromUtf8(output), AppError);
} else {
DebuggerRunControl *runControl = qobject_cast<DebuggerRunControl *>(m_runControl);
if (runControl)
runControl->showMessage(QString::fromUtf8(output), AppError);
else
AndroidRunSupport::handleRemoteErrorOutput(output);
}
disconnect(m_runner, &AndroidRunner::remoteProcessStarted,
this, &AndroidDebugSupport::handleRemoteProcessStarted);
QTC_ASSERT(m_engine, return);
m_engine->notifyEngineRemoteSetupDone(gdbServerPort, qmlPort);
}
} // namespace Internal
......
......@@ -30,12 +30,13 @@
#ifndef ANDROIDDEBUGSUPPORT_H
#define ANDROIDDEBUGSUPPORT_H
#include "androidrunsupport.h"
#include "androidrunconfiguration.h"
namespace Debugger {
class DebuggerEngine;
class DebuggerRunControl;
}
namespace ProjectExplorer { class RunControl; }
namespace Android {
......@@ -44,27 +45,23 @@ class AndroidRunConfiguration;
namespace Internal {
class AndroidRunner;
class AndroidDebugSupport : public AndroidRunSupport
class AndroidDebugSupport : public QObject
{
Q_OBJECT
public:
static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig,
QString *errorMessage);
AndroidDebugSupport(AndroidRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl);
private slots:
void handleRemoteServerRunning(const QByteArray &serverChannel, int pid);
void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
void handleRemoteProcessFinished(const QString &errorMsg);
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig,
QString *errorMessage);
private:
void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
Debugger::DebuggerEngine *m_engine;
Debugger::DebuggerRunControl *m_runControl;
AndroidRunner * const m_runner;
};
} // namespace Internal
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "androidrunsupport.h"
#include "androidrunner.h"
using namespace ProjectExplorer;
namespace Android {
namespace Internal {
AndroidRunSupport::AndroidRunSupport(AndroidRunConfiguration *runConfig,
RunControl *runControl)
: QObject(runControl),
m_runControl(runControl),
m_runner(new AndroidRunner(this, runConfig, runControl->runMode()))
{
connect(m_runControl, SIGNAL(finished()),
m_runner, SLOT(stop()));
}
void AndroidRunSupport::handleRemoteProcessFinished(const QString &errorMsg)
{
if (m_runControl)
m_runControl->appendMessage(errorMsg, Utils::NormalMessageFormat);
}
void AndroidRunSupport::handleRemoteOutput(const QByteArray &output)
{
if (m_runControl)
m_runControl->appendMessage(QString::fromUtf8(output), Utils::StdOutFormatSameLine);
}
void AndroidRunSupport::handleRemoteErrorOutput(const QByteArray &output)
{
if (m_runControl)
m_runControl->appendMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
}
} // namespace Internal
} // namespace Android
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef ANDROIDRUNSUPPORT_H
#define ANDROIDRUNSUPPORT_H
#include "androidrunconfiguration.h"
namespace ProjectExplorer { class RunControl; }
namespace Android {
namespace Internal {
class AndroidRunner;
class AndroidRunSupport : public QObject
{
Q_OBJECT
public:
AndroidRunSupport(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunControl *runControl);
protected slots:
virtual void handleRemoteProcessFinished(const QString &errorMsg);
virtual void handleRemoteOutput(const QByteArray &output);
virtual void handleRemoteErrorOutput(const QByteArray &output);
protected:
ProjectExplorer::RunControl* m_runControl;
AndroidRunner * const m_runner;
};
} // namespace Internal
} // namespace Android
#endif // ANDROIDRUNSUPPORT_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment