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 "androidsettingswidget.h"
|
|
|
|
|
|
|
|
|
|
#include "ui_androidsettingswidget.h"
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
#include "androidavdmanager.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
#include "androidconfigurations.h"
|
|
|
|
|
#include "androidconstants.h"
|
2019-12-23 16:13:23 +02:00
|
|
|
#include "androidsdkdownloader.h"
|
2020-05-20 12:51:21 +02:00
|
|
|
#include "androidsdkmanager.h"
|
2017-09-18 13:48:00 +02:00
|
|
|
#include "androidsdkmanagerwidget.h"
|
2020-05-20 12:51:21 +02:00
|
|
|
#include "androidtoolchain.h"
|
|
|
|
|
#include "avddialog.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2013-11-19 17:25:32 +01:00
|
|
|
#include <utils/environment.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2019-12-12 23:15:48 +01:00
|
|
|
#include <utils/infolabel.h>
|
2020-05-20 06:35:10 +02:00
|
|
|
#include <utils/listmodel.h>
|
2014-03-03 12:05:01 +01:00
|
|
|
#include <utils/pathchooser.h>
|
2020-05-20 12:51:21 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2020-02-28 19:27:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2020-03-23 14:40:37 +01:00
|
|
|
#include <utils/synchronousprocess.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
|
2014-02-18 20:20:32 +01:00
|
|
|
#include <QDesktopServices>
|
2019-12-23 16:13:23 +02:00
|
|
|
#include <QDir>
|
2020-03-11 18:49:02 +02:00
|
|
|
#include <QFileDialog>
|
2020-01-10 12:53:28 +01:00
|
|
|
#include <QFutureWatcher>
|
|
|
|
|
#include <QList>
|
2020-04-17 14:23:21 +03:00
|
|
|
#include <QLoggingCategory>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QModelIndex>
|
2020-01-13 15:18:35 +02:00
|
|
|
#include <QSettings>
|
2020-01-10 12:53:28 +01:00
|
|
|
#include <QString>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2020-04-17 14:23:21 +03:00
|
|
|
namespace {
|
|
|
|
|
static Q_LOGGING_CATEGORY(androidsettingswidget, "qtc.android.androidsettingswidget", QtWarningMsg);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2020-01-10 12:53:28 +01:00
|
|
|
class AndroidSdkManagerWidget;
|
|
|
|
|
class AndroidAvdManager;
|
2020-05-20 12:51:21 +02:00
|
|
|
class SummaryWidget;
|
2020-01-10 12:53:28 +01:00
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
class AvdModel final : public ListModel<AndroidDeviceInfo>
|
2020-01-10 12:53:28 +01:00
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Android::Internal::AvdModel)
|
|
|
|
|
|
|
|
|
|
public:
|
2020-05-20 06:35:10 +02:00
|
|
|
AvdModel();
|
2020-01-10 12:53:28 +01:00
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
QVariant itemData(const AndroidDeviceInfo &info, int column, int role) const final;
|
2020-01-10 12:53:28 +01:00
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
QString avdName(const QModelIndex &index) const;
|
|
|
|
|
QModelIndex indexForAvdName(const QString &avdName) const;
|
2020-01-10 12:53:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class AndroidSettingsWidget final : public Core::IOptionsPageWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Android::Internal::AndroidSettingsWidget)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Todo: This would be so much simpler if it just used Utils::PathChooser!!!
|
|
|
|
|
AndroidSettingsWidget();
|
|
|
|
|
~AndroidSettingsWidget() final;
|
|
|
|
|
|
|
|
|
|
private:
|
2020-01-15 13:27:27 +01:00
|
|
|
void apply() final { AndroidConfigurations::setConfig(m_androidConfig); }
|
2020-01-10 12:53:28 +01:00
|
|
|
|
2020-05-18 18:58:32 +03:00
|
|
|
void showEvent(QShowEvent *event) override;
|
|
|
|
|
|
2020-01-10 12:53:28 +01:00
|
|
|
void validateJdk();
|
2019-12-23 16:13:23 +02:00
|
|
|
void updateNdkList();
|
2020-01-10 12:53:28 +01:00
|
|
|
void onSdkPathChanged();
|
|
|
|
|
void validateSdk();
|
|
|
|
|
void openSDKDownloadUrl();
|
|
|
|
|
void openNDKDownloadUrl();
|
|
|
|
|
void openOpenJDKDownloadUrl();
|
2020-02-28 19:27:03 +02:00
|
|
|
void downloadOpenSslRepo(const bool silent = false);
|
2020-01-10 12:53:28 +01:00
|
|
|
void addAVD();
|
|
|
|
|
void avdAdded();
|
|
|
|
|
void removeAVD();
|
|
|
|
|
void startAVD();
|
|
|
|
|
void avdActivated(const QModelIndex &);
|
|
|
|
|
void dataPartitionSizeEditingFinished();
|
|
|
|
|
void createKitToggled();
|
|
|
|
|
|
|
|
|
|
void updateUI();
|
|
|
|
|
void updateAvds();
|
|
|
|
|
|
|
|
|
|
void startUpdateAvd();
|
|
|
|
|
void enableAvdControls();
|
|
|
|
|
void disableAvdControls();
|
|
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
void downloadSdk();
|
2020-02-24 11:19:02 +02:00
|
|
|
void addCustomNdkItem();
|
2020-02-28 19:27:03 +02:00
|
|
|
void validateOpenSsl();
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
Ui_AndroidSettingsWidget m_ui;
|
2020-01-10 12:53:28 +01:00
|
|
|
AndroidSdkManagerWidget *m_sdkManagerWidget = nullptr;
|
2020-05-20 09:54:50 +02:00
|
|
|
AndroidConfig m_androidConfig{AndroidConfigurations::currentConfig()};
|
2020-01-10 12:53:28 +01:00
|
|
|
AvdModel m_AVDModel;
|
|
|
|
|
QFutureWatcher<CreateAvdInfo> m_futureWatcher;
|
|
|
|
|
|
|
|
|
|
QFutureWatcher<AndroidDeviceInfoList> m_virtualDevicesWatcher;
|
|
|
|
|
QString m_lastAddedAvd;
|
2020-06-16 13:05:27 +03:00
|
|
|
AndroidAvdManager m_avdManager{m_androidConfig};
|
|
|
|
|
AndroidSdkManager m_sdkManager{m_androidConfig};
|
2020-05-20 09:54:50 +02:00
|
|
|
AndroidSdkDownloader m_sdkDownloader;
|
2020-02-10 20:25:24 +02:00
|
|
|
bool m_isInitialReloadDone = false;
|
2020-05-20 12:51:21 +02:00
|
|
|
|
|
|
|
|
SummaryWidget *m_androidSummary = nullptr;
|
|
|
|
|
SummaryWidget *m_javaSummary = nullptr;
|
|
|
|
|
SummaryWidget *m_openSslSummary = nullptr;
|
2020-01-10 12:53:28 +01:00
|
|
|
};
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
enum JavaValidation {
|
|
|
|
|
JavaPathExistsRow,
|
2020-06-26 00:33:43 +03:00
|
|
|
JavaJdkValidRow
|
2017-09-14 13:29:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum AndroidValidation {
|
|
|
|
|
SdkPathExistsRow,
|
2019-08-12 01:41:41 +02:00
|
|
|
SdkPathWritableRow,
|
2017-09-14 13:29:46 +02:00
|
|
|
SdkToolsInstalledRow,
|
|
|
|
|
PlatformToolsInstalledRow,
|
|
|
|
|
BuildToolsInstalledRow,
|
2019-08-05 14:46:01 +02:00
|
|
|
SdkManagerSuccessfulRow,
|
2017-09-14 13:29:46 +02:00
|
|
|
PlatformSdkInstalledRow,
|
2019-12-23 16:13:23 +02:00
|
|
|
AllEssentialsInstalledRow,
|
2017-09-14 13:29:46 +02:00
|
|
|
};
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
enum OpenSslValidation {
|
|
|
|
|
OpenSslPathExistsRow,
|
|
|
|
|
OpenSslPriPathExists,
|
|
|
|
|
OpenSslCmakeListsPathExists
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
class SummaryWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
class RowData {
|
|
|
|
|
public:
|
2020-05-20 09:54:50 +02:00
|
|
|
InfoLabel *m_infoLabel = nullptr;
|
2017-09-14 13:29:46 +02:00
|
|
|
bool m_valid = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SummaryWidget(const QMap<int, QString> &validationPoints, const QString &validText,
|
2020-05-20 09:54:50 +02:00
|
|
|
const QString &invalidText, DetailsWidget *detailsWidget) :
|
2017-09-14 13:29:46 +02:00
|
|
|
QWidget(detailsWidget),
|
|
|
|
|
m_validText(validText),
|
|
|
|
|
m_invalidText(invalidText),
|
|
|
|
|
m_detailsWidget(detailsWidget)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_detailsWidget);
|
2019-12-12 23:15:48 +01:00
|
|
|
auto layout = new QVBoxLayout(this);
|
2019-08-29 10:36:01 +02:00
|
|
|
layout->setContentsMargins(12, 12, 12, 12);
|
2017-09-14 13:29:46 +02:00
|
|
|
for (auto itr = validationPoints.cbegin(); itr != validationPoints.cend(); ++itr) {
|
|
|
|
|
RowData data;
|
2020-05-20 09:54:50 +02:00
|
|
|
data.m_infoLabel = new InfoLabel(itr.value());
|
2019-12-12 23:15:48 +01:00
|
|
|
layout->addWidget(data.m_infoLabel);
|
2017-09-14 13:29:46 +02:00
|
|
|
m_validationData[itr.key()] = data;
|
|
|
|
|
setPointValid(itr.key(), true);
|
|
|
|
|
}
|
2020-05-20 12:51:21 +02:00
|
|
|
m_detailsWidget->setWidget(this);
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setPointValid(int key, bool valid)
|
|
|
|
|
{
|
|
|
|
|
if (!m_validationData.contains(key))
|
|
|
|
|
return;
|
2020-05-20 12:51:21 +02:00
|
|
|
RowData &data = m_validationData[key];
|
2017-09-14 13:29:46 +02:00
|
|
|
data.m_valid = valid;
|
2020-05-20 09:54:50 +02:00
|
|
|
data.m_infoLabel->setType(valid ? InfoLabel::Ok : InfoLabel::NotOk);
|
2017-09-18 13:48:00 +02:00
|
|
|
updateUi();
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
bool rowsOk(const QList<int> &keys) const
|
2017-09-14 13:29:46 +02:00
|
|
|
{
|
2017-09-18 13:48:00 +02:00
|
|
|
for (auto key : keys) {
|
|
|
|
|
if (!m_validationData[key].m_valid)
|
2017-09-14 13:29:46 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
bool allRowsOk() const
|
|
|
|
|
{
|
|
|
|
|
return rowsOk(m_validationData.keys());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setInfoText(const QString &text)
|
|
|
|
|
{
|
2017-09-18 13:48:00 +02:00
|
|
|
m_infoText = text;
|
|
|
|
|
updateUi();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
void setSetupOk(bool ok)
|
|
|
|
|
{
|
|
|
|
|
m_detailsWidget->setState(ok ? DetailsWidget::Collapsed : DetailsWidget::Expanded);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
private:
|
2017-09-18 13:48:00 +02:00
|
|
|
void updateUi() {
|
|
|
|
|
bool ok = allRowsOk();
|
2020-05-20 09:54:50 +02:00
|
|
|
m_detailsWidget->setIcon(ok ? Icons::OK.icon() : Icons::CRITICAL.icon());
|
2017-09-18 13:48:00 +02:00
|
|
|
m_detailsWidget->setSummaryText(ok ? QString("%1 %2").arg(m_validText).arg(m_infoText)
|
|
|
|
|
: m_invalidText);
|
|
|
|
|
}
|
2017-09-14 13:29:46 +02:00
|
|
|
QString m_validText;
|
|
|
|
|
QString m_invalidText;
|
2017-09-18 13:48:00 +02:00
|
|
|
QString m_infoText;
|
2020-05-20 09:54:50 +02:00
|
|
|
DetailsWidget *m_detailsWidget = nullptr;
|
2017-09-14 13:29:46 +02:00
|
|
|
QMap<int, RowData> m_validationData;
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-11 13:31:01 +02:00
|
|
|
QModelIndex AvdModel::indexForAvdName(const QString &avdName) const
|
|
|
|
|
{
|
2020-05-20 06:35:10 +02:00
|
|
|
return findIndex([avdName](const AndroidDeviceInfo &info) { return info.avdname == avdName; });
|
2014-04-11 13:31:01 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-11 13:30:26 +02:00
|
|
|
QString AvdModel::avdName(const QModelIndex &index) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-05-20 06:35:10 +02:00
|
|
|
return dataAt(index.row()).avdname;
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
QVariant AvdModel::itemData(const AndroidDeviceInfo &info, int column, int role) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-05-20 06:35:10 +02:00
|
|
|
if (role != Qt::DisplayRole)
|
|
|
|
|
return {};
|
2019-12-20 16:49:13 +02:00
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
switch (column) {
|
2012-04-18 20:30:57 +03:00
|
|
|
case 0:
|
2020-05-20 06:35:10 +02:00
|
|
|
return info.avdname;
|
2012-04-18 20:30:57 +03:00
|
|
|
case 1:
|
2020-05-20 06:35:10 +02:00
|
|
|
return info.sdk;
|
|
|
|
|
case 2:
|
|
|
|
|
return info.cpuAbi.isEmpty() ? QVariant() : QVariant(info.cpuAbi.first());
|
2019-12-20 16:49:13 +02:00
|
|
|
case 3:
|
2020-05-20 06:35:10 +02:00
|
|
|
return info.avdDevice.isEmpty() ? QVariant("Custom") : info.avdDevice;
|
2019-12-20 16:49:13 +02:00
|
|
|
case 4:
|
2020-05-20 06:35:10 +02:00
|
|
|
return info.avdTarget;
|
2019-12-20 16:49:13 +02:00
|
|
|
case 5:
|
2020-05-20 06:35:10 +02:00
|
|
|
return info.avdSdcardSize;
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
2020-05-20 06:35:10 +02:00
|
|
|
return {};
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
AvdModel::AvdModel()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-05-20 06:35:10 +02:00
|
|
|
//: AVD - Android Virtual Device
|
|
|
|
|
setHeader({tr("AVD Name"), tr("API"), tr("CPU/ABI"), tr("Device type"), tr("Target"), tr("SD-card size")});
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2020-02-10 20:25:24 +02:00
|
|
|
void AndroidSettingsWidget::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(event)
|
|
|
|
|
if (!m_isInitialReloadDone) {
|
2020-06-26 00:34:51 +03:00
|
|
|
validateJdk();
|
2020-02-10 20:25:24 +02:00
|
|
|
// Reloading SDK packages (force) is still synchronous. Use zero timer
|
|
|
|
|
// to let settings dialog open first.
|
|
|
|
|
QTimer::singleShot(0, std::bind(&AndroidSdkManager::reloadPackages,
|
2020-05-20 09:54:50 +02:00
|
|
|
&m_sdkManager, false));
|
2020-02-28 19:27:03 +02:00
|
|
|
validateOpenSsl();
|
2020-02-10 20:25:24 +02:00
|
|
|
m_isInitialReloadDone = true;
|
|
|
|
|
}
|
2019-12-23 16:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::updateNdkList()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.ndkListWidget->clear();
|
|
|
|
|
for (const Ndk *ndk : m_sdkManager.installedNdkPackages()) {
|
|
|
|
|
m_ui.ndkListWidget->addItem(new QListWidgetItem(Icons::LOCKED.icon(),
|
|
|
|
|
ndk->installedLocation().toString()));
|
2020-03-11 18:49:02 +02:00
|
|
|
}
|
2020-02-24 11:19:02 +02:00
|
|
|
|
|
|
|
|
for (const QString &ndk : m_androidConfig.getCustomNdkList()) {
|
2020-03-11 18:49:02 +02:00
|
|
|
if (m_androidConfig.isValidNdk(ndk)) {
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.ndkListWidget->addItem(new QListWidgetItem(Icons::UNLOCKED.icon(), ndk));
|
2020-03-11 18:49:02 +02:00
|
|
|
} else {
|
2020-02-24 11:19:02 +02:00
|
|
|
m_androidConfig.removeCustomNdk(ndk);
|
2020-03-11 18:49:02 +02:00
|
|
|
}
|
2020-02-24 11:19:02 +02:00
|
|
|
}
|
2020-03-11 18:49:02 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.ndkListWidget->setCurrentRow(0);
|
2020-02-24 11:19:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::addCustomNdkItem()
|
|
|
|
|
{
|
2020-03-11 18:49:02 +02:00
|
|
|
const QString homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first();
|
|
|
|
|
const QString ndkPath = QFileDialog::getExistingDirectory(this, tr("Select an NDK"), homePath);
|
|
|
|
|
|
|
|
|
|
if (m_androidConfig.isValidNdk(ndkPath)) {
|
|
|
|
|
m_androidConfig.addCustomNdk(ndkPath);
|
2020-05-20 09:54:50 +02:00
|
|
|
if (m_ui.ndkListWidget->findItems(ndkPath, Qt::MatchExactly).size() == 0) {
|
|
|
|
|
m_ui.ndkListWidget->addItem(new QListWidgetItem(Icons::UNLOCKED.icon(), ndkPath));
|
2020-03-11 18:49:02 +02:00
|
|
|
}
|
|
|
|
|
} else if (!ndkPath.isEmpty()) {
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
this,
|
|
|
|
|
tr("Add Custom NDK"),
|
|
|
|
|
tr("The selected path has an invalid NDK. This might mean that the path contains space "
|
|
|
|
|
"characters, or that it does not have a \"toolchains\" sub-directory, or that the "
|
|
|
|
|
"NDK version could not be retrieved because of a missing \"source.properties\" or "
|
|
|
|
|
"\"RELEASE.TXT\" file"));
|
|
|
|
|
}
|
2019-12-23 16:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 13:54:07 +01:00
|
|
|
AndroidSettingsWidget::AndroidSettingsWidget()
|
2020-05-20 09:54:50 +02:00
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager,
|
|
|
|
|
m_ui.sdkManagerTab);
|
|
|
|
|
auto sdkMangerLayout = new QVBoxLayout(m_ui.sdkManagerTab);
|
2019-08-29 10:36:01 +02:00
|
|
|
sdkMangerLayout->setContentsMargins(0, 0, 0, 0);
|
2017-09-18 13:48:00 +02:00
|
|
|
sdkMangerLayout->addWidget(m_sdkManagerWidget);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_sdkManagerWidget, &AndroidSdkManagerWidget::updatingSdk, [this] {
|
|
|
|
|
m_ui.SDKLocationPathChooser->setEnabled(false);
|
2017-09-18 13:48:00 +02:00
|
|
|
// Disable the tab bar to restrict the user moving away from sdk manager tab untill
|
|
|
|
|
// operations finish.
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.managerTabWidget->tabBar()->setEnabled(false);
|
2017-09-18 13:48:00 +02:00
|
|
|
});
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_sdkManagerWidget, &AndroidSdkManagerWidget::updatingSdkFinished, [this] {
|
|
|
|
|
m_ui.SDKLocationPathChooser->setEnabled(true);
|
|
|
|
|
m_ui.managerTabWidget->tabBar()->setEnabled(true);
|
2017-09-18 13:48:00 +02:00
|
|
|
});
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_sdkManagerWidget, &AndroidSdkManagerWidget::licenseWorkflowStarted, [this] {
|
|
|
|
|
m_ui.scrollArea->ensureWidgetVisible(m_ui.managerTabWidget);
|
2020-03-24 06:54:15 +01:00
|
|
|
});
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
QMap<int, QString> javaValidationPoints;
|
|
|
|
|
javaValidationPoints[JavaPathExistsRow] = tr("JDK path exists.");
|
|
|
|
|
javaValidationPoints[JavaJdkValidRow] = tr("JDK path is a valid JDK root folder.");
|
2020-05-20 12:51:21 +02:00
|
|
|
m_javaSummary = new SummaryWidget(javaValidationPoints, tr("Java Settings are OK."),
|
|
|
|
|
tr("Java settings have errors."), m_ui.javaDetailsWidget);
|
2017-09-14 13:29:46 +02:00
|
|
|
|
|
|
|
|
QMap<int, QString> androidValidationPoints;
|
|
|
|
|
androidValidationPoints[SdkPathExistsRow] = tr("Android SDK path exists.");
|
2019-08-12 01:41:41 +02:00
|
|
|
androidValidationPoints[SdkPathWritableRow] = tr("Android SDK path writable.");
|
2017-09-14 13:29:46 +02:00
|
|
|
androidValidationPoints[SdkToolsInstalledRow] = tr("SDK tools installed.");
|
|
|
|
|
androidValidationPoints[PlatformToolsInstalledRow] = tr("Platform tools installed.");
|
2019-08-05 14:46:01 +02:00
|
|
|
androidValidationPoints[SdkManagerSuccessfulRow] = tr(
|
2020-06-26 00:33:43 +03:00
|
|
|
"SDK manager runs (SDK Tools versions <= 26.x require exactly Java 1.8).");
|
2019-12-23 16:13:23 +02:00
|
|
|
androidValidationPoints[AllEssentialsInstalledRow] = tr(
|
|
|
|
|
"All essential packages installed for all installed Qt versions.");
|
2017-09-14 13:29:46 +02:00
|
|
|
androidValidationPoints[BuildToolsInstalledRow] = tr("Build tools installed.");
|
|
|
|
|
androidValidationPoints[PlatformSdkInstalledRow] = tr("Platform SDK installed.");
|
2020-05-20 12:51:21 +02:00
|
|
|
m_androidSummary = new SummaryWidget(androidValidationPoints, tr("Android settings are OK."),
|
|
|
|
|
tr("Android settings have errors."),
|
|
|
|
|
m_ui.androidDetailsWidget);
|
2017-09-14 13:29:46 +02:00
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
QMap<int, QString> openSslValidationPoints;
|
|
|
|
|
openSslValidationPoints[OpenSslPathExistsRow] = tr("OpenSSL path exists.");
|
|
|
|
|
openSslValidationPoints[OpenSslPriPathExists] = tr(
|
|
|
|
|
"QMake include project (openssl.pri) exists.");
|
|
|
|
|
openSslValidationPoints[OpenSslCmakeListsPathExists] = tr(
|
|
|
|
|
"CMake include project (CMakeLists.txt) exists.");
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary = new SummaryWidget(openSslValidationPoints,
|
|
|
|
|
tr("OpenSSL Settings are OK."),
|
|
|
|
|
tr("OpenSSL settings have errors."),
|
|
|
|
|
m_ui.openSslDetailsWidget);
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.OpenJDKLocationPathChooser, &PathChooser::rawPathChanged,
|
2019-12-23 16:13:23 +02:00
|
|
|
this, &AndroidSettingsWidget::validateJdk);
|
2020-05-20 09:54:50 +02:00
|
|
|
FilePath currentJdkPath = m_androidConfig.openJDKLocation();
|
2020-01-13 15:18:35 +02:00
|
|
|
if (currentJdkPath.isEmpty())
|
2020-06-26 00:33:43 +03:00
|
|
|
currentJdkPath = AndroidConfig::getJdkPath();
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.OpenJDKLocationPathChooser->setFilePath(currentJdkPath);
|
|
|
|
|
m_ui.OpenJDKLocationPathChooser->setPromptDialogTitle(tr("Select JDK Path"));
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
FilePath currentSDKPath = m_androidConfig.sdkLocation();
|
2019-12-23 16:13:23 +02:00
|
|
|
if (currentSDKPath.isEmpty())
|
2020-05-18 18:58:32 +03:00
|
|
|
currentSDKPath = AndroidConfig::defaultSdkPath();
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.SDKLocationPathChooser->setFilePath(currentSDKPath);
|
|
|
|
|
m_ui.SDKLocationPathChooser->setPromptDialogTitle(tr("Select Android SDK folder"));
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.openSslPathChooser->setPromptDialogTitle(tr("Select OpenSSL Include Project File"));
|
|
|
|
|
FilePath currentOpenSslPath = m_androidConfig.openSslLocation();
|
2020-02-28 19:27:03 +02:00
|
|
|
if (currentOpenSslPath.isEmpty())
|
|
|
|
|
currentOpenSslPath = currentSDKPath.pathAppended("android_openssl");
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.openSslPathChooser->setFilePath(currentOpenSslPath);
|
|
|
|
|
|
|
|
|
|
m_ui.DataPartitionSizeSpinBox->setValue(m_androidConfig.partitionSize());
|
|
|
|
|
m_ui.CreateKitCheckBox->setChecked(m_androidConfig.automaticKitCreation());
|
|
|
|
|
m_ui.AVDTableView->setModel(&m_AVDModel);
|
|
|
|
|
m_ui.AVDTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
m_ui.AVDTableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
|
|
2020-06-26 12:23:01 +02:00
|
|
|
const QIcon downloadIcon = Icons::ONLINE.icon();
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.downloadSDKToolButton->setIcon(downloadIcon);
|
|
|
|
|
m_ui.downloadNDKToolButton->setIcon(downloadIcon);
|
|
|
|
|
m_ui.downloadOpenJDKToolButton->setIcon(downloadIcon);
|
|
|
|
|
m_ui.sdkToolsAutoDownloadButton->setToolTip(tr(
|
2020-03-16 20:14:56 +02:00
|
|
|
"Automatically download Android SDK Tools to selected location.\n\n"
|
|
|
|
|
"If the selected path contains no valid SDK Tools, the SDK Tools package "
|
|
|
|
|
"is downloaded from %1, and extracted to the selected path.\n"
|
|
|
|
|
"After the SDK Tools are properly set up, you are prompted to install "
|
2020-03-24 17:25:23 +01:00
|
|
|
"any essential packages required for Qt to build for Android.")
|
2020-03-16 20:14:56 +02:00
|
|
|
.arg(m_androidConfig.sdkToolsUrl().toString()));
|
2019-08-23 19:13:51 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.SDKLocationPathChooser, &PathChooser::rawPathChanged,
|
2020-02-10 20:25:24 +02:00
|
|
|
this, &AndroidSettingsWidget::onSdkPathChanged);
|
2020-03-11 18:49:02 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.ndkListWidget, &QListWidget::currentTextChanged, [this](const QString &ndk) {
|
2020-06-30 12:21:38 +03:00
|
|
|
updateUI();
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.removeCustomNdkButton->setEnabled(m_androidConfig.getCustomNdkList().contains(ndk));
|
2020-02-24 11:19:02 +02:00
|
|
|
});
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.addCustomNdkButton, &QPushButton::clicked, this,
|
2020-02-24 11:19:02 +02:00
|
|
|
&AndroidSettingsWidget::addCustomNdkItem);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.removeCustomNdkButton, &QPushButton::clicked, this, [this] {
|
|
|
|
|
m_androidConfig.removeCustomNdk(m_ui.ndkListWidget->currentItem()->text());
|
|
|
|
|
m_ui.ndkListWidget->takeItem(m_ui.ndkListWidget->currentRow());
|
2020-02-24 11:19:02 +02:00
|
|
|
});
|
|
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.openSslPathChooser, &PathChooser::rawPathChanged,
|
|
|
|
|
this, &AndroidSettingsWidget::validateOpenSsl);
|
2016-06-26 22:52:59 +03:00
|
|
|
connect(&m_virtualDevicesWatcher, &QFutureWatcherBase::finished,
|
|
|
|
|
this, &AndroidSettingsWidget::updateAvds);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.AVDRefreshPushButton, &QAbstractButton::clicked,
|
2019-12-20 16:41:25 +02:00
|
|
|
this, &AndroidSettingsWidget::startUpdateAvd);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_futureWatcher, &QFutureWatcherBase::finished,
|
|
|
|
|
this, &AndroidSettingsWidget::avdAdded);
|
|
|
|
|
connect(m_ui.AVDAddPushButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::addAVD);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.AVDRemovePushButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::removeAVD);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.AVDStartPushButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::startAVD);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.AVDTableView, &QAbstractItemView::activated,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::avdActivated);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.AVDTableView, &QAbstractItemView::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::avdActivated);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.DataPartitionSizeSpinBox, &QAbstractSpinBox::editingFinished,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::dataPartitionSizeEditingFinished);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.CreateKitCheckBox, &QAbstractButton::toggled,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::createKitToggled);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.downloadNDKToolButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::openNDKDownloadUrl);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.downloadSDKToolButton, &QAbstractButton::clicked,
|
2019-12-23 16:13:23 +02:00
|
|
|
this, &AndroidSettingsWidget::openSDKDownloadUrl);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.downloadOpenSSLPrebuiltLibs, &QAbstractButton::clicked,
|
2020-02-28 19:27:03 +02:00
|
|
|
this, &AndroidSettingsWidget::downloadOpenSslRepo);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.downloadOpenJDKToolButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::openOpenJDKDownloadUrl);
|
2017-09-18 13:48:00 +02:00
|
|
|
// Validate SDK again after any change in SDK packages.
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_sdkManager, &AndroidSdkManager::packageReloadFinished,
|
2020-03-16 20:14:56 +02:00
|
|
|
this, &AndroidSettingsWidget::validateSdk);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(m_ui.sdkToolsAutoDownloadButton, &QAbstractButton::clicked,
|
2020-03-16 20:14:56 +02:00
|
|
|
this, &AndroidSettingsWidget::downloadSdk);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkDownloaderError, this, [this](const QString &error) {
|
2020-03-16 20:14:56 +02:00
|
|
|
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(), error);
|
|
|
|
|
});
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkExtracted, this, [this] {
|
|
|
|
|
m_sdkManager.reloadPackages(true);
|
2020-03-16 20:14:56 +02:00
|
|
|
updateUI();
|
|
|
|
|
apply();
|
|
|
|
|
|
|
|
|
|
QMetaObject::Connection *const openSslOneShot = new QMetaObject::Connection;
|
2020-05-20 09:54:50 +02:00
|
|
|
*openSslOneShot = connect(&m_sdkManager, &AndroidSdkManager::packageReloadFinished,
|
|
|
|
|
this, [this, openSslOneShot] {
|
2020-03-16 20:14:56 +02:00
|
|
|
QObject::disconnect(*openSslOneShot);
|
|
|
|
|
downloadOpenSslRepo(true);
|
|
|
|
|
delete openSslOneShot;
|
|
|
|
|
});
|
2019-12-23 16:13:23 +02:00
|
|
|
});
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2013-12-16 20:19:07 +01:00
|
|
|
AndroidSettingsWidget::~AndroidSettingsWidget()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2017-09-18 13:48:00 +02:00
|
|
|
// Deleting m_sdkManagerWidget will cancel all ongoing and pending sdkmanager operations.
|
|
|
|
|
delete m_sdkManagerWidget;
|
2014-04-11 13:31:01 +02:00
|
|
|
m_futureWatcher.waitForFinished();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2015-01-08 17:05:09 +01:00
|
|
|
void AndroidSettingsWidget::disableAvdControls()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.AVDAddPushButton->setEnabled(false);
|
|
|
|
|
m_ui.AVDTableView->setEnabled(false);
|
|
|
|
|
m_ui.AVDRemovePushButton->setEnabled(false);
|
|
|
|
|
m_ui.AVDStartPushButton->setEnabled(false);
|
2015-01-08 17:05:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::enableAvdControls()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.AVDTableView->setEnabled(true);
|
|
|
|
|
m_ui.AVDAddPushButton->setEnabled(true);
|
|
|
|
|
avdActivated(m_ui.AVDTableView->currentIndex());
|
2015-01-08 17:05:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::startUpdateAvd()
|
|
|
|
|
{
|
|
|
|
|
disableAvdControls();
|
2020-05-20 09:54:50 +02:00
|
|
|
m_virtualDevicesWatcher.setFuture(m_avdManager.avdList());
|
2015-01-08 17:05:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::updateAvds()
|
|
|
|
|
{
|
2020-05-20 06:35:10 +02:00
|
|
|
m_AVDModel.setAllData(m_virtualDevicesWatcher.result());
|
2015-01-08 17:05:09 +01:00
|
|
|
if (!m_lastAddedAvd.isEmpty()) {
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.AVDTableView->setCurrentIndex(m_AVDModel.indexForAvdName(m_lastAddedAvd));
|
2015-01-08 17:05:09 +01:00
|
|
|
m_lastAddedAvd.clear();
|
|
|
|
|
}
|
|
|
|
|
enableAvdControls();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
void AndroidSettingsWidget::validateJdk()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_androidConfig.setOpenJDKLocation(m_ui.OpenJDKLocationPathChooser->filePath());
|
2017-09-14 13:29:46 +02:00
|
|
|
bool jdkPathExists = m_androidConfig.openJDKLocation().exists();
|
2020-05-20 12:51:21 +02:00
|
|
|
m_javaSummary->setPointValid(JavaPathExistsRow, jdkPathExists);
|
2017-09-14 13:29:46 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
const FilePath bin = m_androidConfig.openJDKLocation().pathAppended("bin/javac" QTC_HOST_EXE_SUFFIX);
|
2020-05-20 12:51:21 +02:00
|
|
|
m_javaSummary->setPointValid(JavaJdkValidRow, jdkPathExists && bin.exists());
|
2020-03-23 14:40:37 +01:00
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
updateUI();
|
2020-06-26 00:34:51 +03:00
|
|
|
|
|
|
|
|
if (m_isInitialReloadDone)
|
|
|
|
|
m_sdkManager.reloadPackages(true);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
void AndroidSettingsWidget::validateOpenSsl()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_androidConfig.setOpenSslLocation(m_ui.openSslPathChooser->filePath());
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary->setPointValid(OpenSslPathExistsRow, m_androidConfig.openSslLocation().exists());
|
2020-02-28 19:27:03 +02:00
|
|
|
|
|
|
|
|
const bool priFileExists = m_androidConfig.openSslLocation().pathAppended("openssl.pri").exists();
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary->setPointValid(OpenSslPriPathExists, priFileExists);
|
2020-02-28 19:27:03 +02:00
|
|
|
const bool cmakeListsExists
|
|
|
|
|
= m_androidConfig.openSslLocation().pathAppended("CMakeLists.txt").exists();
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary->setPointValid(OpenSslCmakeListsPathExists, cmakeListsExists);
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
updateUI();
|
2020-01-13 15:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-26 11:24:16 +02:00
|
|
|
void AndroidSettingsWidget::onSdkPathChanged()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
auto sdkPath = FilePath::fromUserInput(m_ui.SDKLocationPathChooser->rawPath());
|
2017-09-14 13:29:46 +02:00
|
|
|
m_androidConfig.setSdkLocation(sdkPath);
|
2020-05-20 09:54:50 +02:00
|
|
|
FilePath currentOpenSslPath = m_androidConfig.openSslLocation();
|
2020-04-17 14:23:21 +03:00
|
|
|
if (currentOpenSslPath.isEmpty() || !currentOpenSslPath.exists())
|
|
|
|
|
currentOpenSslPath = sdkPath.pathAppended("android_openssl");
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.openSslPathChooser->setFileName(currentOpenSslPath);
|
2017-09-26 11:24:16 +02:00
|
|
|
// Package reload will trigger validateSdk.
|
2020-05-20 09:54:50 +02:00
|
|
|
m_sdkManager.reloadPackages();
|
2017-09-26 11:24:16 +02:00
|
|
|
}
|
2017-09-14 13:29:46 +02:00
|
|
|
|
2017-09-26 11:24:16 +02:00
|
|
|
void AndroidSettingsWidget::validateSdk()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
auto sdkPath = FilePath::fromUserInput(m_ui.SDKLocationPathChooser->rawPath());
|
2019-12-23 16:13:23 +02:00
|
|
|
m_androidConfig.setSdkLocation(sdkPath);
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
m_androidSummary->setPointValid(SdkPathExistsRow, m_androidConfig.sdkLocation().exists());
|
|
|
|
|
m_androidSummary->setPointValid(SdkPathWritableRow, m_androidConfig.sdkLocation().isWritablePath());
|
|
|
|
|
m_androidSummary->setPointValid(SdkToolsInstalledRow,
|
|
|
|
|
!m_androidConfig.sdkToolsVersion().isNull());
|
|
|
|
|
m_androidSummary->setPointValid(PlatformToolsInstalledRow,
|
|
|
|
|
m_androidConfig.adbToolPath().exists());
|
|
|
|
|
m_androidSummary->setPointValid(BuildToolsInstalledRow,
|
|
|
|
|
!m_androidConfig.buildToolsVersion().isNull());
|
|
|
|
|
m_androidSummary->setPointValid(SdkManagerSuccessfulRow, m_sdkManager.packageListingSuccessful());
|
2017-09-26 11:24:16 +02:00
|
|
|
// installedSdkPlatforms should not trigger a package reload as validate SDK is only called
|
|
|
|
|
// after AndroidSdkManager::packageReloadFinished.
|
2020-05-20 12:51:21 +02:00
|
|
|
m_androidSummary->setPointValid(PlatformSdkInstalledRow,
|
|
|
|
|
!m_sdkManager.installedSdkPlatforms().isEmpty());
|
2020-05-18 18:58:32 +03:00
|
|
|
m_androidSummary->setPointValid(AllEssentialsInstalledRow, m_androidConfig.allEssentialsInstalled());
|
2020-05-20 12:51:21 +02:00
|
|
|
|
|
|
|
|
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsRow,
|
|
|
|
|
SdkPathWritableRow,
|
|
|
|
|
SdkToolsInstalledRow,
|
|
|
|
|
SdkManagerSuccessfulRow});
|
|
|
|
|
const bool componentsOk = m_androidSummary->rowsOk({PlatformToolsInstalledRow,
|
|
|
|
|
BuildToolsInstalledRow,
|
|
|
|
|
PlatformSdkInstalledRow,
|
|
|
|
|
AllEssentialsInstalledRow});
|
2019-12-23 16:13:23 +02:00
|
|
|
m_androidConfig.setSdkFullyConfigured(sdkToolsOk && componentsOk);
|
2020-06-26 01:06:16 +03:00
|
|
|
if (sdkToolsOk && !componentsOk) {
|
2017-09-26 11:24:16 +02:00
|
|
|
// Ask user to install essential SDK components. Works only for sdk tools version >= 26.0.0
|
|
|
|
|
QString message = tr("Android SDK installation is missing necessary packages. Do you "
|
|
|
|
|
"want to install the missing packages?");
|
|
|
|
|
auto userInput = QMessageBox::information(this, tr("Missing Android SDK packages"),
|
|
|
|
|
message, QMessageBox::Yes | QMessageBox::No);
|
|
|
|
|
if (userInput == QMessageBox::Yes) {
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.managerTabWidget->setCurrentWidget(m_ui.sdkManagerTab);
|
2017-09-26 11:24:16 +02:00
|
|
|
m_sdkManagerWidget->installEssentials();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2020-02-10 20:25:24 +02:00
|
|
|
startUpdateAvd();
|
2019-12-23 16:13:23 +02:00
|
|
|
updateNdkList();
|
2020-06-30 12:21:38 +03:00
|
|
|
updateUI();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2014-02-18 20:20:32 +01:00
|
|
|
void AndroidSettingsWidget::openSDKDownloadUrl()
|
|
|
|
|
{
|
2016-09-22 20:45:00 +02:00
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://developer.android.com/studio/"));
|
2014-02-18 20:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::openNDKDownloadUrl()
|
|
|
|
|
{
|
2016-09-22 20:45:00 +02:00
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://developer.android.com/ndk/downloads/"));
|
2014-02-18 20:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::openOpenJDKDownloadUrl()
|
|
|
|
|
{
|
2020-06-26 14:37:48 +03:00
|
|
|
if (HostOsInfo::isLinuxHost())
|
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://openjdk.java.net/install/"));
|
|
|
|
|
else
|
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://adoptopenjdk.net/"));
|
2014-02-18 20:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
const FilePath openSslPath = m_ui.openSslPathChooser->filePath();
|
2020-02-28 19:27:03 +02:00
|
|
|
const QString openSslCloneTitle(tr("OpenSSL Cloning"));
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
if (m_openSslSummary->allRowsOk()) {
|
2020-03-15 01:49:59 +02:00
|
|
|
if (!silent) {
|
2020-02-28 19:27:03 +02:00
|
|
|
QMessageBox::information(this, openSslCloneTitle,
|
|
|
|
|
tr("OpenSSL prebuilt libraries repository is already configured."));
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString openSslRepo("https://github.com/KDAB/android_openssl.git");
|
2020-05-20 09:54:50 +02:00
|
|
|
QtcProcess *gitCloner = new QtcProcess(this);
|
|
|
|
|
CommandLine gitCloneCommand("git", {"clone", "--depth=1", openSslRepo, openSslPath.toString()});
|
2020-04-17 14:23:21 +03:00
|
|
|
gitCloner->setCommand(gitCloneCommand);
|
|
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
qCDebug(androidsettingswidget) << "Cloning OpenSSL repo: " << gitCloneCommand.toUserOutput();
|
2020-02-28 19:27:03 +02:00
|
|
|
|
|
|
|
|
QDir openSslDir(openSslPath.toString());
|
2020-06-11 15:51:20 +03:00
|
|
|
const bool isEmptyDir = openSslDir.isEmpty(QDir::AllEntries | QDir::NoDotAndDotDot
|
|
|
|
|
| QDir::Hidden | QDir::System);
|
|
|
|
|
if (openSslDir.exists() && !isEmptyDir) {
|
|
|
|
|
QMessageBox::information(
|
|
|
|
|
this,
|
|
|
|
|
openSslCloneTitle,
|
|
|
|
|
tr("The selected download path (%1) for OpenSSL already exists and the directory is "
|
|
|
|
|
"not empty. Select a different path or make sure it is an empty directory.")
|
|
|
|
|
.arg(QDir::toNativeSeparators(openSslPath.toString())));
|
|
|
|
|
return;
|
2020-02-28 19:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QProgressDialog *openSslProgressDialog
|
2020-03-14 17:48:11 +02:00
|
|
|
= new QProgressDialog(tr("Cloning OpenSSL prebuilt libraries..."),
|
2020-02-28 19:27:03 +02:00
|
|
|
tr("Cancel"), 0, 0);
|
2020-06-25 12:11:45 +02:00
|
|
|
openSslProgressDialog->setWindowModality(Qt::ApplicationModal);
|
2020-02-28 19:27:03 +02:00
|
|
|
openSslProgressDialog->setWindowTitle(openSslCloneTitle);
|
|
|
|
|
openSslProgressDialog->setFixedSize(openSslProgressDialog->sizeHint());
|
|
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(openSslProgressDialog, &QProgressDialog::canceled, gitCloner, &QtcProcess::kill);
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-06-24 14:25:17 +03:00
|
|
|
auto failDialog = [=](const QString &msgSuffix = {}) {
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setText(tr("OpenSSL prebuilt libraries cloning failed. ") + msgSuffix
|
|
|
|
|
+ tr("Opening OpenSSL URL for manual download."));
|
|
|
|
|
msgBox.addButton(tr("OK"), QMessageBox::YesRole);
|
|
|
|
|
QAbstractButton *openButton = msgBox.addButton(tr("Open download URL"), QMessageBox::ActionRole);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
|
|
|
|
|
if (msgBox.clickedButton() == openButton)
|
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput(openSslRepo));
|
|
|
|
|
openButton->deleteLater();
|
|
|
|
|
};
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-06-24 14:25:17 +03:00
|
|
|
connect(gitCloner,
|
|
|
|
|
QOverload<int, QtcProcess::ExitStatus>::of(&QtcProcess::finished),
|
2020-02-28 19:27:03 +02:00
|
|
|
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
|
|
|
|
openSslProgressDialog->close();
|
|
|
|
|
validateOpenSsl();
|
2020-06-25 12:24:58 +02:00
|
|
|
m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-06-24 14:25:17 +03:00
|
|
|
if (!openSslProgressDialog->wasCanceled()
|
|
|
|
|
|| (exitStatus == QtcProcess::NormalExit && exitCode != 0)) {
|
|
|
|
|
failDialog();
|
2020-02-28 19:27:03 +02:00
|
|
|
}
|
|
|
|
|
});
|
2020-06-24 14:25:17 +03:00
|
|
|
|
|
|
|
|
connect(gitCloner, &QtcProcess::errorOccurred, this, [=](QProcess::ProcessError error) {
|
|
|
|
|
openSslProgressDialog->close();
|
|
|
|
|
if (error == QProcess::FailedToStart) {
|
|
|
|
|
failDialog(tr("The git tool might not be installed properly on your system. "));
|
|
|
|
|
} else {
|
|
|
|
|
failDialog();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
openSslProgressDialog->show();
|
|
|
|
|
gitCloner->start();
|
2020-02-28 19:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
void AndroidSettingsWidget::addAVD()
|
|
|
|
|
{
|
2015-01-08 17:05:09 +01:00
|
|
|
disableAvdControls();
|
2020-05-20 09:54:50 +02:00
|
|
|
CreateAvdInfo info = AvdDialog::gatherCreateAVDInfo(this, &m_sdkManager, m_androidConfig);
|
2014-04-11 13:31:01 +02:00
|
|
|
|
2017-08-18 08:22:34 +02:00
|
|
|
if (!info.isValid()) {
|
2015-01-08 17:05:09 +01:00
|
|
|
enableAvdControls();
|
2014-04-11 13:31:01 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
m_futureWatcher.setFuture(m_avdManager.createAvd(info));
|
2014-04-11 13:31:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::avdAdded()
|
|
|
|
|
{
|
2017-08-18 08:22:34 +02:00
|
|
|
CreateAvdInfo info = m_futureWatcher.result();
|
2014-04-11 13:31:01 +02:00
|
|
|
if (!info.error.isEmpty()) {
|
2015-01-08 17:05:09 +01:00
|
|
|
enableAvdControls();
|
2014-04-11 13:31:01 +02:00
|
|
|
QMessageBox::critical(this, QApplication::translate("AndroidConfig", "Error Creating AVD"), info.error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-08 17:05:09 +01:00
|
|
|
startUpdateAvd();
|
|
|
|
|
m_lastAddedAvd = info.name;
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::removeAVD()
|
|
|
|
|
{
|
2015-01-08 17:05:09 +01:00
|
|
|
disableAvdControls();
|
2020-05-20 09:54:50 +02:00
|
|
|
QString avdName = m_AVDModel.avdName(m_ui.AVDTableView->currentIndex());
|
2014-04-11 11:45:35 +02:00
|
|
|
if (QMessageBox::question(this, tr("Remove Android Virtual Device"),
|
|
|
|
|
tr("Remove device \"%1\"? This cannot be undone.").arg(avdName),
|
|
|
|
|
QMessageBox::Yes | QMessageBox::No)
|
2015-01-08 17:05:09 +01:00
|
|
|
== QMessageBox::No) {
|
|
|
|
|
enableAvdControls();
|
2014-04-11 11:45:35 +02:00
|
|
|
return;
|
2015-01-08 17:05:09 +01:00
|
|
|
}
|
2014-04-11 11:45:35 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
m_avdManager.removeAvd(avdName);
|
2015-01-08 17:05:09 +01:00
|
|
|
startUpdateAvd();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::startAVD()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_avdManager.startAvdAsync(m_AVDModel.avdName(m_ui.AVDTableView->currentIndex()));
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2014-05-19 23:31:01 +03:00
|
|
|
void AndroidSettingsWidget::avdActivated(const QModelIndex &index)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.AVDRemovePushButton->setEnabled(index.isValid());
|
|
|
|
|
m_ui.AVDStartPushButton->setEnabled(index.isValid());
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::dataPartitionSizeEditingFinished()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_androidConfig.setPartitionSize(m_ui.DataPartitionSizeSpinBox->value());
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 15:51:59 +01:00
|
|
|
void AndroidSettingsWidget::createKitToggled()
|
|
|
|
|
{
|
2020-05-20 09:54:50 +02:00
|
|
|
m_androidConfig.setAutomaticKitCreation(m_ui.CreateKitCheckBox->isChecked());
|
2013-02-14 15:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
void AndroidSettingsWidget::updateUI()
|
|
|
|
|
{
|
2020-05-20 12:51:21 +02:00
|
|
|
const bool javaSetupOk = m_javaSummary->allRowsOk();
|
|
|
|
|
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsRow, SdkPathWritableRow, SdkToolsInstalledRow});
|
|
|
|
|
const bool androidSetupOk = m_androidSummary->allRowsOk();
|
|
|
|
|
const bool openSslOk = m_openSslSummary->allRowsOk();
|
2017-09-18 13:48:00 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
m_ui.avdManagerTab->setEnabled(javaSetupOk && androidSetupOk);
|
|
|
|
|
m_ui.sdkManagerTab->setEnabled(sdkToolsOk);
|
2017-09-18 13:48:00 +02:00
|
|
|
|
2020-05-20 09:54:50 +02:00
|
|
|
const QListWidgetItem *currentItem = m_ui.ndkListWidget->currentItem();
|
2020-05-20 12:51:21 +02:00
|
|
|
const FilePath currentNdk = FilePath::fromString(currentItem ? currentItem->text() : "");
|
2020-06-30 12:10:21 +03:00
|
|
|
const QString infoText = tr("(SDK Version: %1, NDK Version: %2)")
|
2020-05-20 12:51:21 +02:00
|
|
|
.arg(m_androidConfig.sdkToolsVersion().toString())
|
|
|
|
|
.arg(currentNdk.isEmpty() ? "" : m_androidConfig.ndkVersion(currentNdk).toString());
|
|
|
|
|
m_androidSummary->setInfoText(androidSetupOk ? infoText : "");
|
2017-09-18 13:48:00 +02:00
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
m_javaSummary->setSetupOk(javaSetupOk);
|
|
|
|
|
m_androidSummary->setSetupOk(androidSetupOk);
|
|
|
|
|
m_openSslSummary->setSetupOk(openSslOk);
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
void AndroidSettingsWidget::downloadSdk()
|
|
|
|
|
{
|
2020-05-18 18:58:32 +03:00
|
|
|
if (m_androidConfig.sdkToolsOk()) {
|
2020-03-16 20:14:56 +02:00
|
|
|
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
|
|
|
|
tr("The selected path already has a valid SDK Tools package."));
|
|
|
|
|
validateSdk();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
const QString message = tr("Download and install Android SDK Tools to: %1?")
|
|
|
|
|
.arg(QDir::toNativeSeparators(m_ui.SDKLocationPathChooser->rawPath()));
|
2019-12-23 16:13:23 +02:00
|
|
|
auto userInput = QMessageBox::information(this, AndroidSdkDownloader::dialogTitle(),
|
|
|
|
|
message, QMessageBox::Yes | QMessageBox::No);
|
|
|
|
|
if (userInput == QMessageBox::Yes) {
|
2020-05-20 12:51:21 +02:00
|
|
|
if (m_javaSummary->allRowsOk()) {
|
2020-05-20 09:54:50 +02:00
|
|
|
auto javaPath = FilePath::fromUserInput(m_ui.OpenJDKLocationPathChooser->rawPath());
|
|
|
|
|
m_sdkDownloader.downloadAndExtractSdk(javaPath.toString(),
|
|
|
|
|
m_ui.SDKLocationPathChooser->filePath().toString());
|
2019-12-23 16:13:23 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-10 12:53:28 +01:00
|
|
|
// AndroidSettingsPage
|
|
|
|
|
|
|
|
|
|
AndroidSettingsPage::AndroidSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::ANDROID_SETTINGS_ID);
|
|
|
|
|
setDisplayName(AndroidSettingsWidget::tr("Android"));
|
|
|
|
|
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
2020-03-24 06:54:15 +01:00
|
|
|
setWidgetCreator([] {
|
|
|
|
|
auto widget = new AndroidSettingsWidget;
|
|
|
|
|
QPalette pal = widget->palette();
|
2020-05-20 09:54:50 +02:00
|
|
|
pal.setColor(QPalette::Window, Utils::creatorTheme()->color(Theme::BackgroundColorNormal));
|
2020-03-24 06:54:15 +01:00
|
|
|
widget->setPalette(pal);
|
|
|
|
|
return widget;
|
|
|
|
|
});
|
2020-01-10 12:53:28 +01:00
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Android
|