diff options
author | hjk <hjk@qt.io> | 2017-06-14 14:59:23 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-06-29 14:00:22 +0000 |
commit | ef7c633de2692f2c4e909a1a8f1a24ef0772256d (patch) | |
tree | f083856ff9345b6c2d9e8a4984afd263e657e6bd /src/plugins/android | |
parent | f501c19ebc8dba4cc1ee2dfb481e9297d7e0d5ab (diff) | |
download | qt-creator-ef7c633de2692f2c4e909a1a8f1a24ef0772256d.tar.gz |
Android: Re-enable QmlProfiler
Change-Id: Icd73475be421e6813b0d496020461e7020b547dd
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/android')
-rw-r--r-- | src/plugins/android/androidanalyzesupport.cpp | 61 | ||||
-rw-r--r-- | src/plugins/android/androidanalyzesupport.h | 12 | ||||
-rw-r--r-- | src/plugins/android/androidrunfactories.cpp | 4 | ||||
-rw-r--r-- | src/plugins/android/androidrunner.cpp | 22 | ||||
-rw-r--r-- | src/plugins/android/androidrunner.h | 10 |
5 files changed, 49 insertions, 60 deletions
diff --git a/src/plugins/android/androidanalyzesupport.cpp b/src/plugins/android/androidanalyzesupport.cpp index 38d84d4863..eaea7196ba 100644 --- a/src/plugins/android/androidanalyzesupport.cpp +++ b/src/plugins/android/androidanalyzesupport.cpp @@ -24,66 +24,37 @@ ****************************************************************************/ #include "androidanalyzesupport.h" - #include "androidrunner.h" -#include "androidmanager.h" - -#include <debugger/analyzer/analyzermanager.h> - -#include <projectexplorer/project.h> -#include <projectexplorer/runconfiguration.h> -#include <projectexplorer/target.h> -#include <qtsupport/qtkitinformation.h> - -using namespace Debugger; using namespace ProjectExplorer; namespace Android { namespace Internal { -AndroidAnalyzeSupport::AndroidAnalyzeSupport(RunControl *runControl) +AndroidQmlProfilerSupport::AndroidQmlProfilerSupport(RunControl *runControl) : RunWorker(runControl) { - setDisplayName("AndroidAnalyzeSupport"); - - RunConfiguration *runConfig = runControl->runConfiguration(); - runControl->setDisplayName(AndroidManager::packageName(runConfig->target())); - runControl->setConnection(UrlConnection::localHostWithoutPort()); + setDisplayName("AndroidQmlProfilerSupport"); auto runner = new AndroidRunner(runControl); + addDependency(runner); - connect(runControl, &RunControl::finished, runner, [runner] { runner->stop(); }); - - connect(runControl, &RunControl::starting, runner, [runner] { runner->start(); }); + auto profiler = runControl->createWorker(runControl->runMode()); + profiler->addDependency(this); - connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this, - [this, runControl](Utils::Port) { - runControl->notifyRemoteSetupDone(m_qmlPort); - }); - -// connect(runner, &AndroidRunner::handleRemoteProcessStarted, this, -// [this](Utils::Port, Utils::Port qmlPort) { -// m_qmlPort = qmlPort; -// }); - -// connect(runner, &AndroidRunner::handleRemoteProcessFinished, this, -// [this, runControl](const QString &errorMsg) { -// runControl->notifyRemoteFinished(); -// appendMessage(errorMsg, Utils::NormalMessageFormat); -// }); + connect(runner, &AndroidRunner::qmlServerReady, [this, runner, profiler](const QUrl &server) { + profiler->recordData("QmlServerUrl", server); + reportStarted(); + }); +} - connect(runner, &AndroidRunner::remoteErrorOutput, this, - [this, runControl](const QString &msg) { - appendMessage(msg, Utils::StdErrFormatSameLine); - m_outputParser.processOutput(msg); - }); +void AndroidQmlProfilerSupport::start() +{ +} - connect(runner, &AndroidRunner::remoteOutput, this, - [this, runControl](const QString &msg) { - appendMessage(msg, Utils::StdOutFormatSameLine); - m_outputParser.processOutput(msg); - }); +void AndroidQmlProfilerSupport::stop() +{ + reportStopped(); } } // namespace Internal diff --git a/src/plugins/android/androidanalyzesupport.h b/src/plugins/android/androidanalyzesupport.h index c9ceb45146..b788bf40a6 100644 --- a/src/plugins/android/androidanalyzesupport.h +++ b/src/plugins/android/androidanalyzesupport.h @@ -25,25 +25,21 @@ #pragma once -#include "androidrunconfiguration.h" - #include <projectexplorer/runconfiguration.h> -#include <qmldebug/qmloutputparser.h> - namespace Android { namespace Internal { -class AndroidAnalyzeSupport : public ProjectExplorer::RunWorker +class AndroidQmlProfilerSupport : public ProjectExplorer::RunWorker { Q_OBJECT public: - explicit AndroidAnalyzeSupport(ProjectExplorer::RunControl *runControl); + explicit AndroidQmlProfilerSupport(ProjectExplorer::RunControl *runControl); private: - QmlDebug::QmlOutputParser m_outputParser; - Utils::Port m_qmlPort; + void start() override; + void stop() override; }; } // namespace Internal diff --git a/src/plugins/android/androidrunfactories.cpp b/src/plugins/android/androidrunfactories.cpp index 7d4e4a7945..3f894783c7 100644 --- a/src/plugins/android/androidrunfactories.cpp +++ b/src/plugins/android/androidrunfactories.cpp @@ -71,9 +71,7 @@ RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig, Core:: } if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { auto runControl = new RunControl(runConfig, mode); - auto profiler = runControl->createWorker(mode); - auto profilee = new AndroidAnalyzeSupport(runControl); - profiler->addDependency(profilee); + (void) new AndroidQmlProfilerSupport(runControl); return runControl; } QTC_CHECK(false); // The other run modes are not supported diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp index f6d4ce2032..4a62e028fe 100644 --- a/src/plugins/android/androidrunner.cpp +++ b/src/plugins/android/androidrunner.cpp @@ -34,6 +34,7 @@ #include "androidavdmanager.h" #include <debugger/debuggerrunconfigurationaspect.h> +#include <coreplugin/messagemanager.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorersettings.h> @@ -632,7 +633,7 @@ void AndroidRunnerWorker::onProcessIdChanged(qint64 pid) // Don't write to m_psProc from a different thread QTC_ASSERT(QThread::currentThread() == thread(), return); m_processPID = pid; - if (m_processPID == -1) { + if (pid == -1) { emit remoteProcessFinished(QLatin1String("\n\n") + tr("\"%1\" died.") .arg(m_packageName)); // App died/killed. Reset log and monitor processes. @@ -714,6 +715,9 @@ AndroidRunner::AndroidRunner(RunControl *runControl) connect(m_worker.data(), &AndroidRunnerWorker::remoteErrorOutput, this, &AndroidRunner::remoteErrorOutput); + connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, + this, &AndroidRunner::qmlServerPortReady); + m_thread.start(); } @@ -749,14 +753,28 @@ void AndroidRunner::stop() emit asyncStop(m_androidRunnable); } +void AndroidRunner::qmlServerPortReady(Port port) +{ + // FIXME: Note that the passed is nonsense, as the port is on the + // device side. It only happens to work since we redirect + // host port n to target port n via adb. + QUrl serverUrl; + serverUrl.setPort(port.number()); + emit qmlServerReady(serverUrl); +} + void AndroidRunner::remoteOutput(const QString &output) { + Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent); appendMessage(output, Utils::StdOutFormatSameLine); + m_outputParser.processOutput(output); } void AndroidRunner::remoteErrorOutput(const QString &output) { + Core::MessageManager::write("LOGCAT: " + output, Core::MessageManager::Silent); appendMessage(output, Utils::StdErrFormatSameLine); + m_outputParser.processOutput(output); } void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort, int pid) @@ -770,6 +788,8 @@ void AndroidRunner::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils: void AndroidRunner::handleRemoteProcessFinished(const QString &errString) { appendMessage(errString, Utils::DebugFormat); + if (runControl()->isRunning()) + runControl()->initiateStop(); reportStopped(); } diff --git a/src/plugins/android/androidrunner.h b/src/plugins/android/androidrunner.h index 9c5f3dd781..cf24d8423b 100644 --- a/src/plugins/android/androidrunner.h +++ b/src/plugins/android/androidrunner.h @@ -30,6 +30,7 @@ #include <projectexplorer/runconfiguration.h> #include <qmldebug/qmldebugcommandlinearguments.h> +#include <qmldebug/qmloutputparser.h> #include <QFutureInterface> #include <QObject> @@ -62,18 +63,20 @@ public: void start() override; void stop() override; - virtual void remoteOutput(const QString &output); - virtual void remoteErrorOutput(const QString &output); - signals: void asyncStart(const AndroidRunnable &runnable); void asyncStop(const AndroidRunnable &runnable); void remoteDebuggerRunning(); + void qmlServerReady(const QUrl &serverUrl); void adbParametersChanged(const QString &packageName, const QStringList &selector); void avdDetected(); private: + void qmlServerPortReady(Utils::Port port); + void remoteOutput(const QString &output); + void remoteErrorOutput(const QString &output); + void gotRemoteOutput(const QString &output); void handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlServerPort, int pid); void handleRemoteProcessFinished(const QString &errString = QString()); void checkAVD(); @@ -88,6 +91,7 @@ private: Utils::Port m_gdbServerPort; Utils::Port m_qmlServerPort; Utils::ProcessHandle m_pid; + QmlDebug::QmlOutputParser m_outputParser; }; } // namespace Internal |