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 += \ ...@@ -30,7 +30,6 @@ HEADERS += \
androiddevice.h \ androiddevice.h \
androidgdbserverkitinformation.h \ androidgdbserverkitinformation.h \
androidanalyzesupport.h \ androidanalyzesupport.h \
androidrunsupport.h \
androidmanifesteditorfactory.h \ androidmanifesteditorfactory.h \
androidmanifesteditor.h \ androidmanifesteditor.h \
androidmanifesteditorwidget.h \ androidmanifesteditorwidget.h \
...@@ -73,7 +72,6 @@ SOURCES += \ ...@@ -73,7 +72,6 @@ SOURCES += \
androiddevice.cpp \ androiddevice.cpp \
androidgdbserverkitinformation.cpp \ androidgdbserverkitinformation.cpp \
androidanalyzesupport.cpp \ androidanalyzesupport.cpp \
androidrunsupport.cpp \
androidmanifesteditorfactory.cpp \ androidmanifesteditorfactory.cpp \
androidmanifesteditor.cpp \ androidmanifesteditor.cpp \
androidmanifesteditorwidget.cpp \ androidmanifesteditorwidget.cpp \
......
...@@ -80,8 +80,6 @@ QtcPlugin { ...@@ -80,8 +80,6 @@ QtcPlugin {
"androidrunfactories.h", "androidrunfactories.h",
"androidrunner.cpp", "androidrunner.cpp",
"androidrunner.h", "androidrunner.h",
"androidrunsupport.cpp",
"androidrunsupport.h",
"androidsettingspage.cpp", "androidsettingspage.cpp",
"androidsettingspage.h", "androidsettingspage.h",
"androidsettingswidget.cpp", "androidsettingswidget.cpp",
......
...@@ -75,61 +75,48 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati ...@@ -75,61 +75,48 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig, AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
AnalyzerRunControl *runControl) AnalyzerRunControl *runControl)
: AndroidRunSupport(runConfig, runControl), : QObject(runControl),
m_runControl(0),
m_qmlPort(0) m_qmlPort(0)
{ {
if (runControl) { QTC_ASSERT(runControl, return);
m_runControl = runControl;
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), auto runner = new AndroidRunner(this, runConfig, runControl->runMode());
m_runner, SLOT(start()));
} connect(runControl, &AnalyzerRunControl::finished,
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)), [runner]() { runner->stop(); });
SLOT(remoteIsRunning()));
connect(runControl, &AnalyzerRunControl::starting,
connect(m_runner, &AndroidRunner::remoteProcessStarted, [runner]() { runner->start(); });
[this](int, int qmlPort) { m_qmlPort = qmlPort; });
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
connect(m_runner, SIGNAL(remoteProcessFinished(QString)), [this, runControl](quint16) {
SLOT(handleRemoteProcessFinished(QString))); runControl->notifyRemoteSetupDone(m_qmlPort);
});
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
SLOT(handleRemoteErrorOutput(QByteArray))); connect(runner, &AndroidRunner::remoteProcessStarted,
connect(m_runner, SIGNAL(remoteOutput(QByteArray)), [this](int, int qmlPort) {
SLOT(handleRemoteOutput(QByteArray))); m_qmlPort = qmlPort;
} });
void AndroidAnalyzeSupport::handleRemoteProcessFinished(const QString &errorMsg) connect(runner, &AndroidRunner::remoteProcessFinished,
{ [this, runControl](const QString &errorMsg) {
if (m_runControl) runControl->notifyRemoteFinished();
m_runControl->notifyRemoteFinished(); runControl->appendMessage(errorMsg, Utils::NormalMessageFormat);
AndroidRunSupport::handleRemoteProcessFinished(errorMsg); });
}
connect(runner, &AndroidRunner::remoteErrorOutput,
void AndroidAnalyzeSupport::handleRemoteOutput(const QByteArray &output) [this, runControl](const QByteArray &output) {
{ const QString msg = QString::fromUtf8(output);
const QString msg = QString::fromUtf8(output); runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
if (m_runControl) m_outputParser.processOutput(msg);
m_runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine); });
else
AndroidRunSupport::handleRemoteOutput(output); connect(runner, &AndroidRunner::remoteOutput,
m_outputParser.processOutput(msg); [this, runControl](const QByteArray &output) {
} const QString msg = QString::fromUtf8(output);
runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
void AndroidAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output) m_outputParser.processOutput(msg);
{ });
const QString msg = QString::fromUtf8(output);
if (m_runControl)
m_runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
else
AndroidRunSupport::handleRemoteErrorOutput(output);
m_outputParser.processOutput(msg);
}
void AndroidAnalyzeSupport::remoteIsRunning()
{
if (m_runControl)
m_runControl->notifyRemoteSetupDone(m_qmlPort);
} }
} // namespace Internal } // namespace Internal
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef ANDROIDANALYZESUPPORT_H #ifndef ANDROIDANALYZESUPPORT_H
#define ANDROIDANALYZESUPPORT_H #define ANDROIDANALYZESUPPORT_H
#include "androidrunsupport.h" #include "androidrunconfiguration.h"
#include <qmldebug/qmloutputparser.h> #include <qmldebug/qmloutputparser.h>
namespace Analyzer { class AnalyzerRunControl; } namespace Analyzer { class AnalyzerRunControl; }
...@@ -40,28 +40,19 @@ namespace Android { ...@@ -40,28 +40,19 @@ namespace Android {
class AndroidRunConfiguration; class AndroidRunConfiguration;
namespace Internal { namespace Internal {
class AndroidRunner;
class AndroidAnalyzeSupport : public AndroidRunSupport class AndroidAnalyzeSupport : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode);
AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig, AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
Analyzer::AnalyzerRunControl *runControl); Analyzer::AnalyzerRunControl *runControl);
private slots: static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
void handleRemoteProcessFinished(const QString &errorMsg); ProjectExplorer::RunMode runMode);
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
void remoteIsRunning();
private: private:
Analyzer::AnalyzerRunControl *m_runControl;
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
int m_qmlPort; int m_qmlPort;
}; };
......
...@@ -127,83 +127,66 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration * ...@@ -127,83 +127,66 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig, AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
DebuggerRunControl *runControl) DebuggerRunControl *runControl)
: AndroidRunSupport(runConfig, runControl), : QObject(runControl),
m_engine(0) 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 Debugger::DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>(); = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
Q_ASSERT(aspect->useCppDebugger() || aspect->useQmlDebugger()); Q_ASSERT(aspect->useCppDebugger() || aspect->useQmlDebugger());
Q_UNUSED(aspect) Q_UNUSED(aspect)
if (runControl) m_engine = runControl->engine();
m_engine = runControl->engine();
if (m_engine) { if (m_engine) {
connect(m_engine, SIGNAL(requestRemoteSetup()), connect(m_engine, &DebuggerEngine::requestRemoteSetup,
m_runner, SLOT(start())); m_runner, &AndroidRunner::start);
// FIXME: Move signal to base class and generalize handling.
connect(m_engine, SIGNAL(aboutToNotifyInferiorSetupOk()), connect(m_engine, SIGNAL(aboutToNotifyInferiorSetupOk()),
m_runner, SLOT(handleRemoteDebuggerRunning())); 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) connect(m_runner, &AndroidRunner::remoteServerRunning,
{ [this](const QByteArray &serverChannel, int pid) {
if (m_engine) QTC_ASSERT(m_engine, return);
m_engine->notifyEngineRemoteServerRunning(serverChannel, pid); m_engine->notifyEngineRemoteServerRunning(serverChannel, pid);
});
connect(m_runner, &AndroidRunner::remoteProcessStarted,
this, &AndroidDebugSupport::handleRemoteProcessStarted);
connect(m_runner, &AndroidRunner::remoteProcessFinished,
[this](const QString &errorMsg) {
QTC_ASSERT(m_runControl, return);
m_runControl->showMessage(errorMsg, AppStuff);
});
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);
});
} }
void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort) void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort)
{ {
disconnect(m_runner, SIGNAL(remoteProcessStarted(int,int)), disconnect(m_runner, &AndroidRunner::remoteProcessStarted,
this, SLOT(handleRemoteProcessStarted(int,int))); this, &AndroidDebugSupport::handleRemoteProcessStarted);
if (m_engine) QTC_ASSERT(m_engine, return);
m_engine->notifyEngineRemoteSetupDone(gdbServerPort, qmlPort); m_engine->notifyEngineRemoteSetupDone(gdbServerPort, qmlPort);
}
void AndroidDebugSupport::handleRemoteProcessFinished(const QString &errorMsg)
{
DebuggerRunControl *runControl = qobject_cast<DebuggerRunControl *>(m_runControl);
if (runControl)
runControl->showMessage(errorMsg, AppStuff);
else
AndroidRunSupport::handleRemoteProcessFinished(errorMsg);
}
void AndroidDebugSupport::handleRemoteOutput(const QByteArray &output)
{
if (m_engine) {
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)
{
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);
}
} }
} // namespace Internal } // namespace Internal
......
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
#ifndef ANDROIDDEBUGSUPPORT_H #ifndef ANDROIDDEBUGSUPPORT_H
#define ANDROIDDEBUGSUPPORT_H #define ANDROIDDEBUGSUPPORT_H
#include "androidrunsupport.h" #include "androidrunconfiguration.h"
namespace Debugger { namespace Debugger {
class DebuggerEngine; class DebuggerEngine;
class DebuggerRunControl; class DebuggerRunControl;
} }
namespace ProjectExplorer { class RunControl; } namespace ProjectExplorer { class RunControl; }
namespace Android { namespace Android {
...@@ -44,27 +45,23 @@ class AndroidRunConfiguration; ...@@ -44,27 +45,23 @@ class AndroidRunConfiguration;
namespace Internal { namespace Internal {
class AndroidRunner; class AndroidRunner;
class AndroidDebugSupport : public AndroidRunSupport class AndroidDebugSupport : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig,
QString *errorMessage);
AndroidDebugSupport(AndroidRunConfiguration *runConfig, AndroidDebugSupport(AndroidRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl); Debugger::DebuggerRunControl *runControl);
private slots: static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig,
void handleRemoteServerRunning(const QByteArray &serverChannel, int pid); QString *errorMessage);
void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
void handleRemoteProcessFinished(const QString &errorMsg);
void handleRemoteOutput(const QByteArray &output);
void handleRemoteErrorOutput(const QByteArray &output);
private: private:
void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
Debugger::DebuggerEngine *m_engine; Debugger::DebuggerEngine *m_engine;
Debugger::DebuggerRunControl *m_runControl;
AndroidRunner * const m_runner;
}; };
} // namespace Internal } // 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