diff options
author | hjk <[email protected]> | 2023-01-05 10:34:21 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2023-01-23 11:18:03 +0000 |
commit | 978639b995cd5041698fba01bd0e9f4acbe2a628 (patch) | |
tree | 83980b85874a6489b751fc891d07afd801f35d98 /src/plugins | |
parent | 9c57ed6bd28c4ec55fcd68cf49c17603b06c9b39 (diff) |
Android: Use specific classes for run worker factories
Slimmer file interfaces.
Change-Id: I2cf846c04000eb29fe53219db9a97088b6b9a1aa
Reviewed-by: Alessandro Portale <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/android/androidconstants.h | 1 | ||||
-rw-r--r-- | src/plugins/android/androiddebugsupport.cpp | 46 | ||||
-rw-r--r-- | src/plugins/android/androiddebugsupport.h | 22 | ||||
-rw-r--r-- | src/plugins/android/androidplugin.cpp | 36 | ||||
-rw-r--r-- | src/plugins/android/androidplugin.h | 6 | ||||
-rw-r--r-- | src/plugins/android/androidqmlpreviewworker.cpp | 89 | ||||
-rw-r--r-- | src/plugins/android/androidqmlpreviewworker.h | 64 | ||||
-rw-r--r-- | src/plugins/android/androidqmltoolingsupport.cpp | 49 | ||||
-rw-r--r-- | src/plugins/android/androidqmltoolingsupport.h | 18 | ||||
-rw-r--r-- | src/plugins/android/androidruncontrol.cpp | 25 | ||||
-rw-r--r-- | src/plugins/android/androidruncontrol.h | 17 |
11 files changed, 188 insertions, 185 deletions
diff --git a/src/plugins/android/androidconstants.h b/src/plugins/android/androidconstants.h index 9fff3a29ab7..7fde310ccfd 100644 --- a/src/plugins/android/androidconstants.h +++ b/src/plugins/android/androidconstants.h @@ -50,6 +50,7 @@ const char ANDROID_DEPLOYMENT_SETTINGS_FILE[] = "ANDROID_DEPLOYMENT_SETTINGS_FIL const char ANDROID_SO_LIBS_PATHS[] = "ANDROID_SO_LIBS_PATHS"; const char JAVA_HOME_ENV_VAR[] = "JAVA_HOME"; +const char ANDROID_RUNCONFIG_ID[] = "Qt4ProjectManager.AndroidRunConfiguration:"; const char ANDROID_PACKAGE_INSTALL_STEP_ID[] = "Qt4ProjectManager.AndroidPackageInstallationStep"; const char ANDROID_BUILD_APK_ID[] = "QmakeProjectManager.AndroidBuildApkStep"; const char ANDROID_DEPLOY_QT_ID[] = "Qt4ProjectManager.AndroidDeployQtStep"; diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index dad6e91aac1..75e8fbab434 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -10,6 +10,7 @@ #include <debugger/debuggerkitinformation.h> #include <debugger/debuggerrunconfigurationaspect.h> +#include <debugger/debuggerruncontrol.h> #include <projectexplorer/project.h> #include <projectexplorer/projectnodes.h> @@ -20,9 +21,12 @@ #include <utils/fileutils.h> #include <utils/hostosinfo.h> +#include <utils/qtcprocess.h> +#include <QFutureWatcher> #include <QHostAddress> #include <QJsonDocument> +#include <QJsonObject> #include <QLoggingCategory> namespace { @@ -33,8 +37,7 @@ using namespace Debugger; using namespace ProjectExplorer; using namespace Utils; -namespace Android { -namespace Internal { +namespace Android::Internal { static FilePaths getSoLibSearchPath(const ProjectNode *node) { @@ -77,14 +80,23 @@ static FilePaths getExtraLibs(const ProjectNode *node) return res; } -AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl, const QString &intentName) - : Debugger::DebuggerRunTool(runControl) +class AndroidDebugSupport : public Debugger::DebuggerRunTool { - setId("AndroidDebugger"); - setLldbPlatform("remote-android"); - m_runner = new AndroidRunner(runControl, intentName); - addStartDependency(m_runner); -} +public: + explicit AndroidDebugSupport(RunControl *runControl) : Debugger::DebuggerRunTool(runControl) + { + setId("AndroidDebugger"); + setLldbPlatform("remote-android"); + m_runner = new AndroidRunner(runControl, {}); + addStartDependency(m_runner); + } + + void start() override; + void stop() override; + +private: + AndroidRunner *m_runner = nullptr; +}; void AndroidDebugSupport::start() { @@ -98,7 +110,7 @@ void AndroidDebugSupport::start() setAttachPid(m_runner->pid()); QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit); - if (!Utils::HostOsInfo::isWindowsHost() + if (!HostOsInfo::isWindowsHost() && (qtVersion && AndroidConfigurations::currentConfig().ndkVersion(qtVersion) >= QVersionNumber(11, 0, 0))) { @@ -157,7 +169,7 @@ void AndroidDebugSupport::start() if (qtVersion) { const FilePath ndkLocation = AndroidConfigurations::currentConfig().ndkLocation(qtVersion); - Utils::FilePath sysRoot = ndkLocation + FilePath sysRoot = ndkLocation / "platforms" / QString("android-%1").arg(sdkVersion) / devicePreferredAbi; // Legacy Ndk structure @@ -187,5 +199,13 @@ void AndroidDebugSupport::stop() DebuggerRunTool::stop(); } -} // namespace Internal -} // namespace Android +// AndroidDebugWorkerFactory + +AndroidDebugWorkerFactory::AndroidDebugWorkerFactory() +{ + setProduct<AndroidDebugSupport>(); + addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE); + addSupportedRunConfig(Constants::ANDROID_RUNCONFIG_ID); +} + +} // Android::Internal diff --git a/src/plugins/android/androiddebugsupport.h b/src/plugins/android/androiddebugsupport.h index ce9dfb90923..3c91722179f 100644 --- a/src/plugins/android/androiddebugsupport.h +++ b/src/plugins/android/androiddebugsupport.h @@ -3,26 +3,14 @@ #pragma once -#include "androidrunner.h" -#include <debugger/debuggerruncontrol.h> +#include <projectexplorer/runcontrol.h> -namespace Android { -namespace Internal { +namespace Android::Internal { -class AndroidDebugSupport : public Debugger::DebuggerRunTool +class AndroidDebugWorkerFactory final : public ProjectExplorer::RunWorkerFactory { - Q_OBJECT - public: - AndroidDebugSupport(ProjectExplorer::RunControl *runControl, - const QString &intentName = QString()); - - void start() override; - void stop() override; - -private: - AndroidRunner *m_runner = nullptr; + AndroidDebugWorkerFactory(); }; -} // namespace Internal -} // namespace Android +} // Android::Internal diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp index 070a62a1baa..717238b1fc6 100644 --- a/src/plugins/android/androidplugin.cpp +++ b/src/plugins/android/androidplugin.cpp @@ -1,6 +1,8 @@ // Copyright (C) 2016 BogDan Vatra <[email protected]> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include "androidplugin.h" + #include "androidconfigurations.h" #include "androidbuildapkstep.h" #include "androidconstants.h" @@ -9,7 +11,6 @@ #include "androiddevice.h" #include "androidmanifesteditorfactory.h" #include "androidpackageinstallationstep.h" -#include "androidplugin.h" #include "androidpotentialkit.h" #include "androidqmlpreviewworker.h" #include "androidqmltoolingsupport.h" @@ -48,8 +49,7 @@ using namespace ProjectExplorer::Constants; const char kSetupAndroidSetting[] = "ConfigureAndroid"; -namespace Android { -namespace Internal { +namespace Android::Internal { class AndroidDeployConfigurationFactory : public DeployConfigurationFactory { @@ -89,29 +89,10 @@ public: AndroidPackageInstallationFactory packackeInstallationFactory; AndroidManifestEditorFactory manifestEditorFactory; AndroidRunConfigurationFactory runConfigFactory; - - RunWorkerFactory runWorkerFactory{ - RunWorkerFactory::make<AndroidRunSupport>(), - {NORMAL_RUN_MODE}, - {runConfigFactory.runConfigurationId()} - }; - RunWorkerFactory debugWorkerFactory{ - RunWorkerFactory::make<AndroidDebugSupport>(), - {DEBUG_RUN_MODE}, - {runConfigFactory.runConfigurationId()} - }; - RunWorkerFactory profilerWorkerFactory{ - RunWorkerFactory::make<AndroidQmlToolingSupport>(), - {QML_PROFILER_RUN_MODE}, - {runConfigFactory.runConfigurationId()} - }; - RunWorkerFactory qmlPreviewWorkerFactory{ - RunWorkerFactory::make<AndroidQmlPreviewWorker>(), - {QML_PREVIEW_RUN_MODE}, - {"QmlProjectManager.QmlRunConfiguration.Qml", runConfigFactory.runConfigurationId()}, - {Android::Constants::ANDROID_DEVICE_TYPE} - }; - + AndroidRunWorkerFactory runWorkerFactory; + AndroidDebugWorkerFactory debugWorkerFactory; + AndroidQmlToolingSupportFactory profilerWorkerFactory; + AndroidQmlPreviewWorkerFactory qmlPreviewWorkerFactory; AndroidBuildApkStepFactory buildApkStepFactory; AndroidDeviceManager deviceManager; }; @@ -177,5 +158,4 @@ void AndroidPlugin::askUserAboutAndroidSetup() Core::ICore::infoBar()->addInfo(info); } -} // namespace Internal -} // namespace Android +} // Android::Internal diff --git a/src/plugins/android/androidplugin.h b/src/plugins/android/androidplugin.h index d0eb8d9507d..2b0fc3fe081 100644 --- a/src/plugins/android/androidplugin.h +++ b/src/plugins/android/androidplugin.h @@ -5,8 +5,7 @@ #include <extensionsystem/iplugin.h> -namespace Android { -namespace Internal { +namespace Android::Internal { class AndroidPlugin final : public ExtensionSystem::IPlugin { @@ -31,5 +30,4 @@ private slots: #endif // WITH_TESTS }; -} // namespace Internal -} // namespace Android +} // Android::Internal diff --git a/src/plugins/android/androidqmlpreviewworker.cpp b/src/plugins/android/androidqmlpreviewworker.cpp index c29dadae957..ab9fb34de5a 100644 --- a/src/plugins/android/androidqmlpreviewworker.cpp +++ b/src/plugins/android/androidqmlpreviewworker.cpp @@ -1,11 +1,14 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include "androidqmlpreviewworker.h" + #include "androidavdmanager.h" +#include "androidconfigurations.h" +#include "androidconstants.h" #include "androiddevice.h" #include "androiddeviceinfo.h" #include "androidmanager.h" -#include "androidqmlpreviewworker.h" #include "androidtr.h" #include <coreplugin/icore.h> @@ -24,20 +27,23 @@ #include <qtsupport/baseqtversion.h> #include <qtsupport/qtkitinformation.h> +#include <utils/qtcprocess.h> #include <utils/runextensions.h> #include <QDateTime> #include <QDeadlineTimer> +#include <QFutureWatcher> #include <QThread> -namespace Android { -namespace Internal { - +using namespace ProjectExplorer; using namespace Utils; +namespace Android::Internal { + #define APP_ID "io.qt.qtdesignviewer" -class ApkInfo { +class ApkInfo +{ public: ApkInfo(); const QStringList abis; @@ -62,8 +68,60 @@ ApkInfo::ApkInfo() : Q_GLOBAL_STATIC(ApkInfo, apkInfo) +class UploadInfo +{ +public: + FilePath uploadPackage; + FilePath projectFolder; +}; + static const char packageSuffix[] = ".qmlrc"; +class AndroidQmlPreviewWorker : public RunWorker +{ + Q_OBJECT +public: + AndroidQmlPreviewWorker(RunControl *runControl); + ~AndroidQmlPreviewWorker(); + +signals: + void previewPidChanged(); + +private: + void start() override; + void stop() override; + + bool ensureAvdIsRunning(); + bool checkAndInstallPreviewApp(); + bool preparePreviewArtefacts(); + bool uploadPreviewArtefacts(); + + SdkToolResult runAdbCommand(const QStringList &arguments) const; + SdkToolResult runAdbShellCommand(const QStringList &arguments) const; + int pidofPreview() const; + bool isPreviewRunning(int lastKnownPid = -1) const; + + void startPidWatcher(); + void startLogcat(); + void filterLogcatAndAppendMessage(const QString &stdOut); + + bool startPreviewApp(); + bool stopPreviewApp(); + + Utils::FilePath designViewerApkPath(const QString &abi) const; + Utils::FilePath createQmlrcFile(const Utils::FilePath &workFolder, const QString &basename); + + RunControl *m_rc = nullptr; + const AndroidConfig &m_androidConfig; + QString m_serialNumber; + QStringList m_avdAbis; + int m_viewerPid = -1; + QFutureWatcher<void> m_pidFutureWatcher; + Utils::QtcProcess m_logcatProcess; + QString m_logcatStartTimeStamp; + UploadInfo m_uploadInfo; +}; + FilePath AndroidQmlPreviewWorker::designViewerApkPath(const QString &abi) const { if (abi.isEmpty()) @@ -158,8 +216,8 @@ void AndroidQmlPreviewWorker::filterLogcatAndAppendMessage(const QString &stdOut } } -AndroidQmlPreviewWorker::AndroidQmlPreviewWorker(ProjectExplorer::RunControl *runControl) - : ProjectExplorer::RunWorker(runControl), +AndroidQmlPreviewWorker::AndroidQmlPreviewWorker(RunControl *runControl) + : RunWorker(runControl), m_rc(runControl), m_androidConfig(AndroidConfigurations::currentConfig()) { @@ -213,7 +271,6 @@ bool AndroidQmlPreviewWorker::ensureAvdIsRunning() devSN = m_serialNumber; if (!avdMananager.isAvdBooted(devSN)) { - using namespace ProjectExplorer; const IDevice *dev = DeviceKitAspect::device(m_rc->target()->kit()).data(); if (!dev) { appendMessage(Tr::tr("Selected device is invalid."), ErrorMessageFormat); @@ -430,5 +487,17 @@ bool AndroidQmlPreviewWorker::stopPreviewApp() return res.success(); } -} // namespace Internal -} // namespace Android +// AndroidQmlPreviewWorkerFactory + +AndroidQmlPreviewWorkerFactory::AndroidQmlPreviewWorkerFactory() +{ + setProduct<AndroidQmlPreviewWorker>(); + addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE); + addSupportedRunConfig("QmlProjectManager.QmlRunConfiguration.Qml"); + addSupportedRunConfig(Constants::ANDROID_RUNCONFIG_ID); + addSupportedDeviceType(Android::Constants::ANDROID_DEVICE_TYPE); +} + +} // Android::Internal + +#include "androidqmlpreviewworker.moc" diff --git a/src/plugins/android/androidqmlpreviewworker.h b/src/plugins/android/androidqmlpreviewworker.h index 818364278ca..5b4b18b5dca 100644 --- a/src/plugins/android/androidqmlpreviewworker.h +++ b/src/plugins/android/androidqmlpreviewworker.h @@ -3,70 +3,14 @@ #pragma once -#include "androidconfigurations.h" - #include <projectexplorer/runcontrol.h> -#include <utils/qtcprocess.h> - -#include <QFutureWatcher> - -namespace Android { -class SdkToolResult; - -namespace Internal { - -class UploadInfo -{ -public: - Utils::FilePath uploadPackage; - Utils::FilePath projectFolder; -}; +namespace Android::Internal { -class AndroidQmlPreviewWorker : public ProjectExplorer::RunWorker +class AndroidQmlPreviewWorkerFactory final : public ProjectExplorer::RunWorkerFactory { - Q_OBJECT public: - AndroidQmlPreviewWorker(ProjectExplorer::RunControl *runControl); - ~AndroidQmlPreviewWorker(); - -signals: - void previewPidChanged(); - -private: - void start() override; - void stop() override; - - bool ensureAvdIsRunning(); - bool checkAndInstallPreviewApp(); - bool preparePreviewArtefacts(); - bool uploadPreviewArtefacts(); - - SdkToolResult runAdbCommand(const QStringList &arguments) const; - SdkToolResult runAdbShellCommand(const QStringList &arguments) const; - int pidofPreview() const; - bool isPreviewRunning(int lastKnownPid = -1) const; - - void startPidWatcher(); - void startLogcat(); - void filterLogcatAndAppendMessage(const QString &stdOut); - - bool startPreviewApp(); - bool stopPreviewApp(); - - Utils::FilePath designViewerApkPath(const QString &abi) const; - Utils::FilePath createQmlrcFile(const Utils::FilePath &workFolder, const QString &basename); - - ProjectExplorer::RunControl *m_rc = nullptr; - const AndroidConfig &m_androidConfig; - QString m_serialNumber; - QStringList m_avdAbis; - int m_viewerPid = -1; - QFutureWatcher<void> m_pidFutureWatcher; - Utils::QtcProcess m_logcatProcess; - QString m_logcatStartTimeStamp; - UploadInfo m_uploadInfo; + AndroidQmlPreviewWorkerFactory(); }; -} // namespace Internal -} // namespace Android +} // Android::Internal diff --git a/src/plugins/android/androidqmltoolingsupport.cpp b/src/plugins/android/androidqmltoolingsupport.cpp index f90305769ec..fd1996fd0a3 100644 --- a/src/plugins/android/androidqmltoolingsupport.cpp +++ b/src/plugins/android/androidqmltoolingsupport.cpp @@ -2,39 +2,44 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "androidqmltoolingsupport.h" + +#include "androidconstants.h" #include "androidrunner.h" using namespace ProjectExplorer; -namespace Android { -namespace Internal { +namespace Android::Internal { -AndroidQmlToolingSupport::AndroidQmlToolingSupport(RunControl *runControl, - const QString &intentName) - : RunWorker(runControl) +class AndroidQmlToolingSupport final : public RunWorker { - setId("AndroidQmlToolingSupport"); +public: + explicit AndroidQmlToolingSupport(RunControl *runControl) : RunWorker(runControl) + { + setId("AndroidQmlToolingSupport"); - auto runner = new AndroidRunner(runControl, intentName); - addStartDependency(runner); + auto runner = new AndroidRunner(runControl, {}); + addStartDependency(runner); - auto worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); - worker->addStartDependency(this); + auto worker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); + worker->addStartDependency(this); - connect(runner, &AndroidRunner::qmlServerReady, this, [this, worker](const QUrl &server) { - worker->recordData("QmlServerUrl", server); - reportStarted(); - }); -} + connect(runner, &AndroidRunner::qmlServerReady, this, [this, worker](const QUrl &server) { + worker->recordData("QmlServerUrl", server); + reportStarted(); + }); + } + +private: + void start() override {} + void stop() override { reportStopped(); } +}; -void AndroidQmlToolingSupport::start() -{ -} -void AndroidQmlToolingSupport::stop() +AndroidQmlToolingSupportFactory::AndroidQmlToolingSupportFactory() { - reportStopped(); + setProduct<AndroidQmlToolingSupport>(); + addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + addSupportedRunConfig(Constants::ANDROID_RUNCONFIG_ID); } -} // namespace Internal -} // namespace Android +} // Android::Internal diff --git a/src/plugins/android/androidqmltoolingsupport.h b/src/plugins/android/androidqmltoolingsupport.h index a9ff9e867b4..503bbe0d107 100644 --- a/src/plugins/android/androidqmltoolingsupport.h +++ b/src/plugins/android/androidqmltoolingsupport.h @@ -4,23 +4,13 @@ #pragma once #include <projectexplorer/runcontrol.h> -#include <utils/environment.h> -namespace Android { -namespace Internal { +namespace Android::Internal { -class AndroidQmlToolingSupport : public ProjectExplorer::RunWorker +class AndroidQmlToolingSupportFactory final : public ProjectExplorer::RunWorkerFactory { - Q_OBJECT - public: - explicit AndroidQmlToolingSupport(ProjectExplorer::RunControl *runControl, - const QString &intentName = QString()); - -private: - void start() override; - void stop() override; + AndroidQmlToolingSupportFactory(); }; -} // namespace Internal -} // namespace Android +} // Android::Internal diff --git a/src/plugins/android/androidruncontrol.cpp b/src/plugins/android/androidruncontrol.cpp index 4ffd7de0097..16a20b627ad 100644 --- a/src/plugins/android/androidruncontrol.cpp +++ b/src/plugins/android/androidruncontrol.cpp @@ -3,6 +3,7 @@ #include "androidruncontrol.h" +#include "androidconstants.h" #include "androidglobal.h" #include "androidrunconfiguration.h" #include "androidrunner.h" @@ -13,8 +14,18 @@ using namespace ProjectExplorer; -namespace Android { -namespace Internal { +namespace Android::Internal { + +class AndroidRunSupport final : public AndroidRunner +{ +public: + explicit AndroidRunSupport(ProjectExplorer::RunControl *runControl, + const QString &intentName = QString()); + ~AndroidRunSupport() override; + + void start() override; + void stop() override; +}; AndroidRunSupport::AndroidRunSupport(RunControl *runControl, const QString &intentName) : AndroidRunner(runControl, intentName) @@ -37,5 +48,11 @@ void AndroidRunSupport::stop() AndroidRunner::stop(); } -} // namespace Internal -} // namespace Android +AndroidRunWorkerFactory::AndroidRunWorkerFactory() +{ + setProduct<AndroidRunSupport>(); + addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE); + addSupportedRunConfig(Constants::ANDROID_RUNCONFIG_ID); +} + +} // Android::Internal diff --git a/src/plugins/android/androidruncontrol.h b/src/plugins/android/androidruncontrol.h index c52865db86d..a466de72269 100644 --- a/src/plugins/android/androidruncontrol.h +++ b/src/plugins/android/androidruncontrol.h @@ -7,23 +7,14 @@ #include <projectexplorer/runconfiguration.h> -namespace Android { -namespace Internal { +namespace Android::Internal { class AndroidRunner; -class AndroidRunSupport final : public AndroidRunner +class AndroidRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory { - Q_OBJECT - public: - explicit AndroidRunSupport(ProjectExplorer::RunControl *runControl, - const QString &intentName = QString()); - ~AndroidRunSupport() override; - - void start() override; - void stop() override; + AndroidRunWorkerFactory(); }; -} // namespace Internal -} // namespace Android +} // Android::Internal |