2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-04-18 20:30:57 +03: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.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include "androidplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "androidconfigurations.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidconstants.h"
|
|
|
|
|
#include "androiddebugsupport.h"
|
2013-09-17 18:24:57 +02:00
|
|
|
#include "androiddeployqtstep.h"
|
2012-07-03 16:57:44 +03:00
|
|
|
#include "androiddevice.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidmanager.h"
|
2013-05-08 17:52:01 +02:00
|
|
|
#include "androidmanifesteditorfactory.h"
|
2017-12-07 15:30:16 +01:00
|
|
|
#include "androidpackageinstallationstep.h"
|
2013-09-30 15:24:18 +02:00
|
|
|
#include "androidpotentialkit.h"
|
2017-12-07 15:30:16 +01:00
|
|
|
#include "androidqmltoolingsupport.h"
|
2019-02-14 12:29:00 +01:00
|
|
|
#include "androidqtversion.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidrunconfiguration.h"
|
|
|
|
|
#include "androidruncontrol.h"
|
2020-01-10 12:53:28 +01:00
|
|
|
#include "androidsettingswidget.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidtoolchain.h"
|
2014-08-20 16:29:26 +02:00
|
|
|
#include "javaeditor.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
|
2013-08-21 13:28:03 +02:00
|
|
|
#ifdef HAVE_QBS
|
|
|
|
|
# include "androidqbspropertyprovider.h"
|
|
|
|
|
#endif
|
2013-05-08 17:52:01 +02:00
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <utils/checkablemessagebox.h>
|
2020-06-17 12:23:44 +02:00
|
|
|
#include <utils/infobar.h>
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2016-04-29 23:06:26 +02:00
|
|
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
2018-12-05 13:00:36 +01:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2019-01-24 17:27:50 +01:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
2018-01-30 18:41:56 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2013-02-25 13:25:32 +01:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2018-12-05 13:00:36 +01:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
2018-01-30 18:41:56 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2016-04-29 23:06:26 +02:00
|
|
|
|
2013-02-14 15:51:59 +01:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2016-04-29 23:06:26 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2017-06-20 12:41:19 +02:00
|
|
|
using namespace ProjectExplorer::Constants;
|
2012-07-03 16:57:44 +03:00
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
const char kSetupAndroidSetting[] = "ConfigureAndroid";
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
namespace Android {
|
2018-02-09 16:16:38 +01:00
|
|
|
namespace Internal {
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2019-01-24 17:27:50 +01:00
|
|
|
class AndroidDeployConfigurationFactory : public DeployConfigurationFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AndroidDeployConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
setConfigBaseId("Qt4ProjectManager.AndroidDeployConfiguration2");
|
|
|
|
|
addSupportedTargetDeviceType(Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
setDefaultDisplayName(QCoreApplication::translate("Android::Internal",
|
|
|
|
|
"Deploy to Android device"));
|
|
|
|
|
addInitialStep(AndroidDeployQtStep::stepId());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-16 09:34:54 +02:00
|
|
|
class AndroidRunConfigurationFactory : public RunConfigurationFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AndroidRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
registerRunConfiguration<Android::AndroidRunConfiguration>
|
|
|
|
|
("Qt4ProjectManager.AndroidRunConfiguration:");
|
|
|
|
|
addSupportedTargetDeviceType(Android::Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-07 18:05:15 +02:00
|
|
|
class AndroidQmlPreviewWorker : public AndroidQmlToolingSupport
|
2019-03-20 11:40:53 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2019-08-07 18:05:15 +02:00
|
|
|
AndroidQmlPreviewWorker(RunControl *runControl)
|
2019-08-29 17:57:42 +02:00
|
|
|
: AndroidQmlToolingSupport(runControl, runControl->runnable().executable.toString())
|
2019-08-07 18:05:15 +02:00
|
|
|
{}
|
2019-03-20 11:40:53 +01:00
|
|
|
};
|
|
|
|
|
|
2018-12-05 13:00:36 +01:00
|
|
|
class AndroidPluginPrivate : public QObject
|
2018-01-26 14:57:01 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AndroidConfigurations androidConfiguration;
|
|
|
|
|
AndroidSettingsPage settingsPage;
|
|
|
|
|
AndroidDeployQtStepFactory deployQtStepFactory;
|
|
|
|
|
AndroidQtVersionFactory qtVersionFactory;
|
|
|
|
|
AndroidToolChainFactory toolChainFactory;
|
|
|
|
|
AndroidDeployConfigurationFactory deployConfigurationFactory;
|
|
|
|
|
AndroidDeviceFactory deviceFactory;
|
|
|
|
|
AndroidPotentialKit potentialKit;
|
|
|
|
|
JavaEditorFactory javaEditorFactory;
|
|
|
|
|
AndroidPackageInstallationFactory packackeInstallationFactory;
|
|
|
|
|
AndroidManifestEditorFactory manifestEditorFactory;
|
2018-05-16 09:34:54 +02:00
|
|
|
AndroidRunConfigurationFactory runConfigFactory;
|
2019-03-20 11:40:53 +01:00
|
|
|
|
2019-08-07 18:05:15 +02:00
|
|
|
RunWorkerFactory runWorkerFactory{
|
|
|
|
|
RunWorkerFactory::make<AndroidRunSupport>(),
|
|
|
|
|
{NORMAL_RUN_MODE},
|
2020-06-12 07:50:52 +02:00
|
|
|
{runConfigFactory.runConfigurationId()}
|
2019-08-07 18:05:15 +02:00
|
|
|
};
|
|
|
|
|
RunWorkerFactory debugWorkerFactory{
|
|
|
|
|
RunWorkerFactory::make<AndroidDebugSupport>(),
|
|
|
|
|
{DEBUG_RUN_MODE},
|
2020-06-12 07:50:52 +02:00
|
|
|
{runConfigFactory.runConfigurationId()}
|
2019-08-07 18:05:15 +02:00
|
|
|
};
|
|
|
|
|
RunWorkerFactory profilerWorkerFactory{
|
|
|
|
|
RunWorkerFactory::make<AndroidQmlToolingSupport>(),
|
|
|
|
|
{QML_PROFILER_RUN_MODE},
|
2020-06-12 07:50:52 +02:00
|
|
|
{runConfigFactory.runConfigurationId()}
|
2019-08-07 18:05:15 +02:00
|
|
|
};
|
|
|
|
|
RunWorkerFactory qmlPreviewWorkerFactory{
|
|
|
|
|
RunWorkerFactory::make<AndroidQmlToolingSupport>(),
|
|
|
|
|
{QML_PREVIEW_RUN_MODE},
|
2020-06-12 07:50:52 +02:00
|
|
|
{runConfigFactory.runConfigurationId()}
|
2019-08-07 18:05:15 +02:00
|
|
|
};
|
|
|
|
|
RunWorkerFactory qmlPreviewWorkerFactory2{
|
|
|
|
|
RunWorkerFactory::make<AndroidQmlPreviewWorker>(),
|
|
|
|
|
{QML_PREVIEW_RUN_MODE},
|
|
|
|
|
{"QmlProjectManager.QmlRunConfiguration"},
|
|
|
|
|
{Android::Constants::ANDROID_DEVICE_TYPE}
|
|
|
|
|
};
|
2019-03-20 11:40:53 +01:00
|
|
|
|
2018-07-02 18:40:29 +02:00
|
|
|
AndroidBuildApkStepFactory buildApkStepFactory;
|
2018-01-26 14:57:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AndroidPlugin::~AndroidPlugin()
|
|
|
|
|
{
|
2018-02-09 16:16:38 +01:00
|
|
|
delete d;
|
2018-01-26 14:57:01 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(errorMessage)
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2018-02-09 16:16:38 +01:00
|
|
|
d = new AndroidPluginPrivate;
|
2013-02-28 14:06:17 +01:00
|
|
|
|
2016-04-29 23:06:26 +02:00
|
|
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
|
|
|
|
this, &AndroidPlugin::kitsRestored);
|
2013-02-28 15:07:01 +01:00
|
|
|
|
|
|
|
|
return true;
|
2013-02-25 13:25:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidPlugin::kitsRestored()
|
|
|
|
|
{
|
2020-02-10 15:02:36 +02:00
|
|
|
const bool qtForAndroidInstalled
|
|
|
|
|
= !QtSupport::QtVersionManager::versions([](const QtSupport::BaseQtVersion *v) {
|
|
|
|
|
return v->targetDeviceTypes().contains(Android::Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
}).isEmpty();
|
|
|
|
|
|
|
|
|
|
if (!AndroidConfigurations::currentConfig().sdkFullyConfigured() && qtForAndroidInstalled) {
|
|
|
|
|
connect(Core::ICore::instance(), &Core::ICore::coreOpened, this,
|
|
|
|
|
&AndroidPlugin::askUserAboutAndroidSetup, Qt::QueuedConnection);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 20:46:23 +02:00
|
|
|
AndroidConfigurations::registerNewToolChains();
|
2020-02-25 00:19:28 +02:00
|
|
|
AndroidConfigurations::updateAutomaticKitList();
|
2016-04-29 23:06:26 +02:00
|
|
|
connect(QtSupport::QtVersionManager::instance(), &QtSupport::QtVersionManager::qtVersionsChanged,
|
2020-03-10 13:15:12 +01:00
|
|
|
AndroidConfigurations::instance(), []() {
|
|
|
|
|
AndroidConfigurations::registerNewToolChains();
|
|
|
|
|
AndroidConfigurations::updateAutomaticKitList();
|
|
|
|
|
});
|
2018-05-24 14:01:19 +02:00
|
|
|
disconnect(KitManager::instance(), &KitManager::kitsLoaded,
|
2016-04-29 23:06:26 +02:00
|
|
|
this, &AndroidPlugin::kitsRestored);
|
2012-09-06 12:07:29 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
void AndroidPlugin::askUserAboutAndroidSetup()
|
|
|
|
|
{
|
|
|
|
|
if (!Utils::CheckableMessageBox::shouldAskAgain(Core::ICore::settings(), kSetupAndroidSetting)
|
|
|
|
|
|| !Core::ICore::infoBar()->canInfoBeAdded(kSetupAndroidSetting))
|
|
|
|
|
return;
|
|
|
|
|
|
2020-06-17 12:23:44 +02:00
|
|
|
Utils::InfoBarEntry
|
|
|
|
|
info(kSetupAndroidSetting,
|
|
|
|
|
tr("Would you like to configure Android options? This will ensure "
|
|
|
|
|
"Android kits can be usable and all essential packages are installed. "
|
|
|
|
|
"To do it later, select Options > Devices > Android."),
|
|
|
|
|
Utils::InfoBarEntry::GlobalSuppression::Enabled);
|
2019-12-23 16:13:23 +02:00
|
|
|
info.setCustomButtonInfo(tr("Configure Android"), [this] {
|
|
|
|
|
Core::ICore::infoBar()->removeInfo(kSetupAndroidSetting);
|
|
|
|
|
Core::ICore::infoBar()->globallySuppressInfo(kSetupAndroidSetting);
|
|
|
|
|
QTimer::singleShot(0, this, [this]() { d->potentialKit.executeFromMenu(); });
|
|
|
|
|
});
|
|
|
|
|
Core::ICore::infoBar()->addInfo(info);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-09 16:16:38 +01:00
|
|
|
} // namespace Internal
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace Android
|