2013-05-03 12:41:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-05-03 12:41:58 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-05-03 12:41:58 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2013-05-03 12:41:58 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "androidanalyzesupport.h"
|
|
|
|
|
|
|
|
|
|
#include "androidrunner.h"
|
|
|
|
|
#include "androidmanager.h"
|
|
|
|
|
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <debugger/analyzer/analyzermanager.h>
|
|
|
|
|
#include <debugger/analyzer/analyzerruncontrol.h>
|
|
|
|
|
#include <debugger/analyzer/analyzerstartparameters.h>
|
2013-05-03 12:41:58 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QTcpServer>
|
|
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
using namespace Debugger;
|
2013-05-03 12:41:58 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
|
2015-06-29 10:36:29 +03:00
|
|
|
Core::Id runMode)
|
2013-05-03 12:41:58 +02:00
|
|
|
{
|
2016-03-02 13:57:37 +01:00
|
|
|
AnalyzerRunControl *runControl = Debugger::createAnalyzerRunControl(runConfig, runMode);
|
2016-01-19 14:57:16 +01:00
|
|
|
QTC_ASSERT(runControl, return 0);
|
|
|
|
|
AnalyzerConnection connection;
|
2015-06-29 10:36:29 +03:00
|
|
|
if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
2013-05-03 12:41:58 +02:00
|
|
|
QTcpServer server;
|
|
|
|
|
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|
|
|
|
|
|| server.listen(QHostAddress::LocalHostIPv6), return 0);
|
2016-01-19 14:57:16 +01:00
|
|
|
connection.analyzerHost = server.serverAddress().toString();
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
2016-01-19 14:57:16 +01:00
|
|
|
runControl->setDisplayName(AndroidManager::packageName(runConfig->target()));
|
|
|
|
|
runControl->setConnection(connection);
|
|
|
|
|
(void) new AndroidAnalyzeSupport(runConfig, runControl);
|
|
|
|
|
return runControl;
|
2013-05-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
|
|
|
|
|
AnalyzerRunControl *runControl)
|
2014-09-15 15:43:24 +02:00
|
|
|
: QObject(runControl),
|
2013-07-22 16:10:27 +02:00
|
|
|
m_qmlPort(0)
|
2013-05-03 12:41:58 +02:00
|
|
|
{
|
2014-09-15 15:43:24 +02:00
|
|
|
QTC_ASSERT(runControl, return);
|
|
|
|
|
|
|
|
|
|
auto runner = new AndroidRunner(this, runConfig, runControl->runMode());
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(runControl, &AnalyzerRunControl::finished, runner,
|
2014-09-15 15:43:24 +02:00
|
|
|
[runner]() { runner->stop(); });
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(runControl, &AnalyzerRunControl::starting, runner,
|
2014-09-15 15:43:24 +02:00
|
|
|
[runner]() { runner->start(); });
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this,
|
2016-04-19 16:43:30 +02:00
|
|
|
[this, runControl](Utils::Port) {
|
2014-09-15 15:43:24 +02:00
|
|
|
runControl->notifyRemoteSetupDone(m_qmlPort);
|
|
|
|
|
});
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(runner, &AndroidRunner::remoteProcessStarted, this,
|
2016-04-19 16:43:30 +02:00
|
|
|
[this](Utils::Port, Utils::Port qmlPort) {
|
2014-09-15 15:43:24 +02:00
|
|
|
m_qmlPort = qmlPort;
|
|
|
|
|
});
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(runner, &AndroidRunner::remoteProcessFinished, this,
|
2014-09-15 15:43:24 +02:00
|
|
|
[this, runControl](const QString &errorMsg) {
|
|
|
|
|
runControl->notifyRemoteFinished();
|
|
|
|
|
runControl->appendMessage(errorMsg, Utils::NormalMessageFormat);
|
|
|
|
|
});
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(runner, &AndroidRunner::remoteErrorOutput, this,
|
2015-06-12 15:36:04 +02:00
|
|
|
[this, runControl](const QString &msg) {
|
2016-05-13 11:27:51 +02:00
|
|
|
runControl->appendMessage(msg, Utils::StdErrFormatSameLine);
|
2014-09-15 15:43:24 +02:00
|
|
|
m_outputParser.processOutput(msg);
|
|
|
|
|
});
|
|
|
|
|
|
2016-07-27 15:51:20 +02:00
|
|
|
connect(runner, &AndroidRunner::remoteOutput, this,
|
2015-06-12 15:36:04 +02:00
|
|
|
[this, runControl](const QString &msg) {
|
2016-05-13 11:27:51 +02:00
|
|
|
runControl->appendMessage(msg, Utils::StdOutFormatSameLine);
|
2014-09-15 15:43:24 +02:00
|
|
|
m_outputParser.processOutput(msg);
|
|
|
|
|
});
|
2013-07-22 16:10:27 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-03 12:41:58 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Android
|