forked from qt-creator/qt-creator
Android: Use more direct access to current config singleton
Change-Id: Ica5ba556ac022fe39ed4439d023cda1742344eed Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -35,11 +35,11 @@ static Q_LOGGING_CATEGORY(avdManagerLog, "qtc.android.avdManager", QtWarningMsg)
|
||||
\c true if the command is successfully executed. Output is copied into \a output. The function
|
||||
blocks the calling thread.
|
||||
*/
|
||||
bool AndroidAvdManager::avdManagerCommand(const AndroidConfig &config, const QStringList &args, QString *output)
|
||||
bool AndroidAvdManager::avdManagerCommand(const QStringList &args, QString *output)
|
||||
{
|
||||
CommandLine cmd(config.avdManagerToolPath(), args);
|
||||
CommandLine cmd(androidConfig().avdManagerToolPath(), args);
|
||||
Process proc;
|
||||
proc.setEnvironment(config.toolsEnvironment());
|
||||
proc.setEnvironment(androidConfig().toolsEnvironment());
|
||||
qCDebug(avdManagerLog).noquote() << "Running AVD Manager command:" << cmd.toUserOutput();
|
||||
proc.setCommand(cmd);
|
||||
proc.runBlocking();
|
||||
@@ -61,7 +61,7 @@ static bool checkForTimeout(const chrono::steady_clock::time_point &start,
|
||||
return timedOut;
|
||||
}
|
||||
|
||||
static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateAvdInfo &info)
|
||||
static CreateAvdInfo createAvdCommand(const CreateAvdInfo &info)
|
||||
{
|
||||
CreateAvdInfo result = info;
|
||||
|
||||
@@ -72,7 +72,7 @@ static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateA
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandLine avdManager(config.avdManagerToolPath(), {"create", "avd", "-n", result.name});
|
||||
CommandLine avdManager(androidConfig().avdManagerToolPath(), {"create", "avd", "-n", result.name});
|
||||
avdManager.addArgs({"-k", result.systemImage->sdkStylePath()});
|
||||
|
||||
if (result.sdcardSize > 0)
|
||||
@@ -87,7 +87,7 @@ static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateA
|
||||
qCDebug(avdManagerLog).noquote() << "Running AVD Manager command:" << avdManager.toUserOutput();
|
||||
Process proc;
|
||||
proc.setProcessMode(ProcessMode::Writer);
|
||||
proc.setEnvironment(config.toolsEnvironment());
|
||||
proc.setEnvironment(androidConfig().toolsEnvironment());
|
||||
proc.setCommand(avdManager);
|
||||
proc.start();
|
||||
if (!proc.waitForStarted()) {
|
||||
@@ -129,17 +129,13 @@ static CreateAvdInfo createAvdCommand(const AndroidConfig &config, const CreateA
|
||||
return result;
|
||||
}
|
||||
|
||||
AndroidAvdManager::AndroidAvdManager(const AndroidConfig &config)
|
||||
: m_config(config)
|
||||
{
|
||||
|
||||
}
|
||||
AndroidAvdManager::AndroidAvdManager() = default;
|
||||
|
||||
AndroidAvdManager::~AndroidAvdManager() = default;
|
||||
|
||||
QFuture<CreateAvdInfo> AndroidAvdManager::createAvd(CreateAvdInfo info) const
|
||||
{
|
||||
return Utils::asyncRun(&createAvdCommand, m_config, info);
|
||||
return Utils::asyncRun(&createAvdCommand, info);
|
||||
}
|
||||
|
||||
static void avdConfigEditManufacturerTag(const FilePath &avdPath, bool recoverMode = false)
|
||||
@@ -168,7 +164,7 @@ static void avdConfigEditManufacturerTag(const FilePath &avdPath, bool recoverMo
|
||||
saver.finalize();
|
||||
}
|
||||
|
||||
static AndroidDeviceInfoList listVirtualDevices(const AndroidConfig &config)
|
||||
static AndroidDeviceInfoList listVirtualDevices()
|
||||
{
|
||||
QString output;
|
||||
AndroidDeviceInfoList avdList;
|
||||
@@ -184,9 +180,9 @@ static AndroidDeviceInfoList listVirtualDevices(const AndroidConfig &config)
|
||||
FilePaths avdErrorPaths;
|
||||
|
||||
do {
|
||||
if (!AndroidAvdManager::avdManagerCommand(config, {"list", "avd"}, &output)) {
|
||||
if (!AndroidAvdManager::avdManagerCommand({"list", "avd"}, &output)) {
|
||||
qCDebug(avdManagerLog)
|
||||
<< "Avd list command failed" << output << config.sdkToolsVersion();
|
||||
<< "Avd list command failed" << output << androidConfig().sdkToolsVersion();
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -205,7 +201,7 @@ static AndroidDeviceInfoList listVirtualDevices(const AndroidConfig &config)
|
||||
|
||||
QFuture<AndroidDeviceInfoList> AndroidAvdManager::avdList() const
|
||||
{
|
||||
return Utils::asyncRun(listVirtualDevices, m_config);
|
||||
return Utils::asyncRun(listVirtualDevices);
|
||||
}
|
||||
|
||||
QString AndroidAvdManager::startAvd(const QString &name) const
|
||||
@@ -233,7 +229,7 @@ static bool is32BitUserSpace()
|
||||
|
||||
bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
|
||||
{
|
||||
const FilePath emulator = m_config.emulatorToolPath();
|
||||
const FilePath emulator = androidConfig().emulatorToolPath();
|
||||
if (!emulator.exists()) {
|
||||
QMetaObject::invokeMethod(Core::ICore::mainWindow(), [emulator] {
|
||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||
@@ -263,11 +259,11 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
|
||||
});
|
||||
|
||||
// start the emulator
|
||||
CommandLine cmd(m_config.emulatorToolPath());
|
||||
CommandLine cmd(androidConfig().emulatorToolPath());
|
||||
if (is32BitUserSpace())
|
||||
cmd.addArg("-force-32bit");
|
||||
|
||||
cmd.addArgs(m_config.emulatorArgs(), CommandLine::Raw);
|
||||
cmd.addArgs(androidConfig().emulatorArgs(), CommandLine::Raw);
|
||||
cmd.addArgs({"-avd", avdName});
|
||||
qCDebug(avdManagerLog).noquote() << "Running command (startAvdAsync):" << cmd.toUserOutput();
|
||||
avdProcess->setCommand(cmd);
|
||||
@@ -277,7 +273,7 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
|
||||
|
||||
QString AndroidAvdManager::findAvd(const QString &avdName) const
|
||||
{
|
||||
const QVector<AndroidDeviceInfo> devices = m_config.connectedDevices();
|
||||
const QVector<AndroidDeviceInfo> devices = androidConfig().connectedDevices();
|
||||
for (const AndroidDeviceInfo &device : devices) {
|
||||
if (device.type != ProjectExplorer::IDevice::Emulator)
|
||||
continue;
|
||||
@@ -309,7 +305,7 @@ bool AndroidAvdManager::isAvdBooted(const QString &device) const
|
||||
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
||||
arguments << "shell" << "getprop" << "init.svc.bootanim";
|
||||
|
||||
const CommandLine command({m_config.adbToolPath(), arguments});
|
||||
const CommandLine command({androidConfig().adbToolPath(), arguments});
|
||||
qCDebug(avdManagerLog).noquote() << "Running command (isAvdBooted):" << command.toUserOutput();
|
||||
Process adbProc;
|
||||
adbProc.setCommand(command);
|
||||
@@ -330,7 +326,7 @@ bool AndroidAvdManager::waitForBooted(const QString &serialNumber,
|
||||
if (isAvdBooted(serialNumber))
|
||||
return true;
|
||||
QThread::sleep(2);
|
||||
if (!m_config.isConnected(serialNumber)) // device was disconnected
|
||||
if (!androidConfig().isConnected(serialNumber)) // device was disconnected
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
@@ -13,7 +13,7 @@ namespace Android::Internal {
|
||||
class AndroidAvdManager
|
||||
{
|
||||
public:
|
||||
AndroidAvdManager(const AndroidConfig& config = AndroidConfigurations::currentConfig());
|
||||
AndroidAvdManager();
|
||||
~AndroidAvdManager();
|
||||
|
||||
QFuture<CreateAvdInfo> createAvd(CreateAvdInfo info) const;
|
||||
@@ -24,16 +24,10 @@ public:
|
||||
QString findAvd(const QString &avdName) const;
|
||||
QString waitForAvd(const QString &avdName, const std::optional<QFuture<void>> &future = {}) const;
|
||||
bool isAvdBooted(const QString &device) const;
|
||||
static bool avdManagerCommand(const AndroidConfig &config,
|
||||
const QStringList &args,
|
||||
QString *output);
|
||||
const AndroidConfig &config() const { return m_config; }
|
||||
static bool avdManagerCommand(const QStringList &args, QString *output);
|
||||
|
||||
private:
|
||||
bool waitForBooted(const QString &serialNumber, const std::optional<QFuture<void>> &future = {}) const;
|
||||
|
||||
private:
|
||||
const AndroidConfig &m_config;
|
||||
};
|
||||
|
||||
} // Android::Internal
|
||||
|
@@ -414,7 +414,7 @@ bool AndroidBuildApkWidget::isOpenSslLibsIncluded()
|
||||
|
||||
QString AndroidBuildApkWidget::openSslIncludeFileContent(const FilePath &projectPath)
|
||||
{
|
||||
QString openSslPath = AndroidConfigurations::currentConfig().openSslLocation().toString();
|
||||
QString openSslPath = androidConfig().openSslLocation().toString();
|
||||
if (projectPath.endsWith(".pro"))
|
||||
return "android: include(" + openSslPath + "/openssl.pri)";
|
||||
if (projectPath.endsWith("CMakeLists.txt"))
|
||||
@@ -540,7 +540,7 @@ bool AndroidBuildApkStep::init()
|
||||
QStringList arguments = {"--input", m_inputFile.path(),
|
||||
"--output", outputDir.path(),
|
||||
"--android-platform", m_buildTargetSdk,
|
||||
"--jdk", AndroidConfigurations::currentConfig().openJDKLocation().path()};
|
||||
"--jdk", androidConfig().openJDKLocation().path()};
|
||||
|
||||
if (verboseOutput())
|
||||
arguments << "--verbose";
|
||||
@@ -928,17 +928,17 @@ QVariant AndroidBuildApkStep::data(Utils::Id id) const
|
||||
{
|
||||
if (id == Constants::AndroidNdkPlatform) {
|
||||
if (auto qtVersion = QtKitAspect::qtVersion(kit()))
|
||||
return AndroidConfigurations::currentConfig()
|
||||
return androidConfig()
|
||||
.bestNdkPlatformMatch(AndroidManager::minimumSDK(target()), qtVersion);
|
||||
return {};
|
||||
}
|
||||
if (id == Constants::NdkLocation) {
|
||||
if (auto qtVersion = QtKitAspect::qtVersion(kit()))
|
||||
return QVariant::fromValue(AndroidConfigurations::currentConfig().ndkLocation(qtVersion));
|
||||
return QVariant::fromValue(androidConfig().ndkLocation(qtVersion));
|
||||
return {};
|
||||
}
|
||||
if (id == Constants::SdkLocation)
|
||||
return QVariant::fromValue(AndroidConfigurations::currentConfig().sdkLocation());
|
||||
return QVariant::fromValue(androidConfig().sdkLocation());
|
||||
|
||||
if (id == Constants::AndroidMkSpecAbis)
|
||||
return AndroidManager::applicationAbis(target());
|
||||
@@ -999,7 +999,7 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
||||
"-storepass", m_keystorePasswd, "-J-Duser.language=en"};
|
||||
|
||||
Process keytoolProc;
|
||||
keytoolProc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), params});
|
||||
keytoolProc.setCommand({androidConfig().keytoolPath(), params});
|
||||
using namespace std::chrono_literals;
|
||||
keytoolProc.runBlocking(30s, EventLoopMode::On);
|
||||
if (keytoolProc.result() > ProcessResult::FinishedWithError)
|
||||
|
@@ -661,8 +661,7 @@ bool AndroidConfig::isConnected(const QString &serialNumber) const
|
||||
QString AndroidConfig::getDeviceProperty(const QString &device, const QString &property)
|
||||
{
|
||||
// workaround for '????????????' serial numbers
|
||||
CommandLine cmd(AndroidConfigurations::currentConfig().adbToolPath(),
|
||||
AndroidDeviceInfo::adbSelector(device));
|
||||
CommandLine cmd(androidConfig().adbToolPath(), AndroidDeviceInfo::adbSelector(device));
|
||||
cmd.addArgs({"shell", "getprop", property});
|
||||
|
||||
Process adbProc;
|
||||
@@ -736,7 +735,7 @@ QString AndroidConfig::getProductModel(const QString &device) const
|
||||
|
||||
QStringList AndroidConfig::getAbis(const QString &device)
|
||||
{
|
||||
const FilePath adbTool = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
const FilePath adbTool = androidConfig().adbToolPath();
|
||||
QStringList result;
|
||||
// First try via ro.product.cpu.abilist
|
||||
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
|
||||
@@ -1103,7 +1102,7 @@ FilePath AndroidConfig::defaultSdkPath()
|
||||
AndroidConfigurations *m_instance = nullptr;
|
||||
|
||||
AndroidConfigurations::AndroidConfigurations()
|
||||
: m_sdkManager(new AndroidSdkManager(m_config))
|
||||
: m_sdkManager(new AndroidSdkManager)
|
||||
{
|
||||
load();
|
||||
connect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
|
||||
@@ -1115,7 +1114,7 @@ AndroidConfigurations::AndroidConfigurations()
|
||||
void AndroidConfigurations::setConfig(const AndroidConfig &devConfigs)
|
||||
{
|
||||
emit m_instance->aboutToUpdate();
|
||||
m_instance->m_config = devConfigs;
|
||||
androidConfig() = devConfigs;
|
||||
|
||||
m_instance->save();
|
||||
updateAndroidDevice();
|
||||
@@ -1170,12 +1169,12 @@ void AndroidConfigurations::removeUnusedDebuggers()
|
||||
|
||||
QVector<FilePath> uniqueNdks;
|
||||
for (const QtVersion *qt : qtVersions) {
|
||||
FilePath ndkLocation = currentConfig().ndkLocation(qt);
|
||||
FilePath ndkLocation = androidConfig().ndkLocation(qt);
|
||||
if (!uniqueNdks.contains(ndkLocation))
|
||||
uniqueNdks.append(ndkLocation);
|
||||
}
|
||||
|
||||
uniqueNdks.append(FileUtils::toFilePathList(currentConfig().getCustomNdkList()));
|
||||
uniqueNdks.append(FileUtils::toFilePathList(androidConfig().getCustomNdkList()));
|
||||
|
||||
const QList<Debugger::DebuggerItem> allDebuggers = Debugger::DebuggerItemManager::debuggers();
|
||||
for (const Debugger::DebuggerItem &debugger : allDebuggers) {
|
||||
@@ -1239,16 +1238,15 @@ static QVariant findOrRegisterDebugger(Toolchain *tc,
|
||||
const QStringList &abisList,
|
||||
bool customDebugger = false)
|
||||
{
|
||||
const auto ¤tConfig = AndroidConfigurations::currentConfig();
|
||||
const FilePath ndk = static_cast<AndroidToolchain *>(tc)->ndkLocation();
|
||||
const FilePath lldbCommand = currentConfig.lldbPathFromNdk(ndk);
|
||||
const FilePath lldbCommand = androidConfig().lldbPathFromNdk(ndk);
|
||||
const Debugger::DebuggerItem *existingLldb = existingDebugger(lldbCommand,
|
||||
Debugger::LldbEngineType);
|
||||
// Return existing debugger with same command - prefer lldb (limit to sdk/ndk min version?)
|
||||
if (existingLldb)
|
||||
return existingLldb->id();
|
||||
|
||||
const FilePath gdbCommand = currentConfig.gdbPathFromNdk(tc->targetAbi(), ndk);
|
||||
const FilePath gdbCommand = androidConfig().gdbPathFromNdk(tc->targetAbi(), ndk);
|
||||
|
||||
// check if the debugger is already registered, but ignoring the display name
|
||||
const Debugger::DebuggerItem *existingGdb = existingDebugger(gdbCommand,
|
||||
@@ -1268,7 +1266,7 @@ static QVariant findOrRegisterDebugger(Toolchain *tc,
|
||||
debugger.setEngineType(Debugger::LldbEngineType);
|
||||
debugger.setUnexpandedDisplayName(custom + mainName
|
||||
.arg(getMultiOrSingleAbiString(allSupportedAbis()))
|
||||
.arg(AndroidConfigurations::currentConfig().ndkVersion(ndk).toString())
|
||||
.arg(androidConfig().ndkVersion(ndk).toString())
|
||||
+ ' ' + debugger.engineTypeName());
|
||||
debugger.setAutoDetected(true);
|
||||
debugger.reinitializeFromFile();
|
||||
@@ -1287,10 +1285,10 @@ static QVariant findOrRegisterDebugger(Toolchain *tc,
|
||||
debugger.setEngineType(Debugger::GdbEngineType);
|
||||
|
||||
// NDK 10 and older have multiple gdb versions per ABI, so check for that.
|
||||
const bool oldNdkVersion = currentConfig.ndkVersion(ndk) <= QVersionNumber{11};
|
||||
const bool oldNdkVersion = androidConfig().ndkVersion(ndk) <= QVersionNumber{11};
|
||||
debugger.setUnexpandedDisplayName(custom + mainName
|
||||
.arg(getMultiOrSingleAbiString(oldNdkVersion ? abisList : allSupportedAbis()))
|
||||
.arg(AndroidConfigurations::currentConfig().ndkVersion(ndk).toString())
|
||||
.arg(androidConfig().ndkVersion(ndk).toString())
|
||||
+ ' ' + debugger.engineTypeName());
|
||||
debugger.setAutoDetected(true);
|
||||
debugger.reinitializeFromFile();
|
||||
@@ -1303,7 +1301,7 @@ void AndroidConfigurations::registerCustomToolchainsAndDebuggers()
|
||||
const Toolchains existingAndroidToolchains = ToolchainManager::toolchains(
|
||||
Utils::equal(&Toolchain::typeId, Utils::Id(Constants::ANDROID_TOOLCHAIN_TYPEID)));
|
||||
|
||||
const FilePaths customNdks = FileUtils::toFilePathList(currentConfig().getCustomNdkList());
|
||||
const FilePaths customNdks = FileUtils::toFilePathList(androidConfig().getCustomNdkList());
|
||||
const Toolchains customToolchains
|
||||
= autodetectToolchainsFromNdks(existingAndroidToolchains, customNdks, true);
|
||||
|
||||
@@ -1322,8 +1320,8 @@ void AndroidConfigurations::updateAutomaticKitList()
|
||||
if (DeviceTypeKitAspect::deviceTypeId(k) == Constants::ANDROID_DEVICE_TYPE) {
|
||||
if (k->value(Constants::ANDROID_KIT_NDK).isNull() || k->value(Constants::ANDROID_KIT_SDK).isNull()) {
|
||||
if (QtVersion *qt = QtKitAspect::qtVersion(k)) {
|
||||
k->setValueSilently(Constants::ANDROID_KIT_NDK, currentConfig().ndkLocation(qt).toString());
|
||||
k->setValue(Constants::ANDROID_KIT_SDK, currentConfig().sdkLocation().toString());
|
||||
k->setValueSilently(Constants::ANDROID_KIT_NDK, androidConfig().ndkLocation(qt).toString());
|
||||
k->setValue(Constants::ANDROID_KIT_SDK, androidConfig().sdkLocation().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1363,7 +1361,7 @@ void AndroidConfigurations::updateAutomaticKitList()
|
||||
|
||||
for (const QtVersion *qt : qtVersionsForArch.value(tc->targetAbi())) {
|
||||
FilePath tcNdk = static_cast<const AndroidToolchain *>(tc)->ndkLocation();
|
||||
if (tcNdk != currentConfig().ndkLocation(qt))
|
||||
if (tcNdk != androidConfig().ndkLocation(qt))
|
||||
continue;
|
||||
|
||||
const Toolchains allLanguages
|
||||
@@ -1405,8 +1403,8 @@ void AndroidConfigurations::updateAutomaticKitList()
|
||||
k->setUnexpandedDisplayName(Tr::tr("Android %1 Clang %2")
|
||||
.arg(versionStr)
|
||||
.arg(getMultiOrSingleAbiString(abis)));
|
||||
k->setValueSilently(Constants::ANDROID_KIT_NDK, currentConfig().ndkLocation(qt).toString());
|
||||
k->setValueSilently(Constants::ANDROID_KIT_SDK, currentConfig().sdkLocation().toString());
|
||||
k->setValueSilently(Constants::ANDROID_KIT_NDK, androidConfig().ndkLocation(qt).toString());
|
||||
k->setValueSilently(Constants::ANDROID_KIT_SDK, androidConfig().sdkLocation().toString());
|
||||
};
|
||||
|
||||
if (existingKit) {
|
||||
@@ -1434,9 +1432,10 @@ Environment AndroidConfig::toolsEnvironment() const
|
||||
return env;
|
||||
}
|
||||
|
||||
AndroidConfig &AndroidConfigurations::currentConfig()
|
||||
AndroidConfig &androidConfig()
|
||||
{
|
||||
return m_instance->m_config; // ensure that m_instance is initialized
|
||||
static AndroidConfig theCurrentConfig;
|
||||
return theCurrentConfig;
|
||||
}
|
||||
|
||||
AndroidSdkManager *AndroidConfigurations::sdkManager()
|
||||
@@ -1453,7 +1452,7 @@ void AndroidConfigurations::save()
|
||||
{
|
||||
QtcSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(SettingsGroup);
|
||||
m_config.save(*settings);
|
||||
androidConfig().save(*settings);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -1540,7 +1539,7 @@ void AndroidConfigurations::load()
|
||||
{
|
||||
QtcSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(SettingsGroup);
|
||||
m_config.load(*settings);
|
||||
androidConfig().load(*settings);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -175,12 +175,13 @@ private:
|
||||
mutable QHash<QString, QString> m_serialNumberToDeviceName;
|
||||
};
|
||||
|
||||
AndroidConfig &androidConfig();
|
||||
|
||||
class AndroidConfigurations : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static AndroidConfig ¤tConfig();
|
||||
static Internal::AndroidSdkManager *sdkManager();
|
||||
static void setConfig(const AndroidConfig &config);
|
||||
static AndroidConfigurations *instance();
|
||||
@@ -204,7 +205,6 @@ private:
|
||||
void save();
|
||||
|
||||
static void updateAndroidDevice();
|
||||
AndroidConfig m_config;
|
||||
std::unique_ptr<Internal::AndroidSdkManager> m_sdkManager;
|
||||
};
|
||||
|
||||
|
@@ -262,7 +262,7 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
|
||||
if (!m_stateNameLineEdit->text().isEmpty())
|
||||
distinguishedNames += QLatin1String(", S=") + m_stateNameLineEdit->text().replace(',', QLatin1String("\\,"));
|
||||
|
||||
const CommandLine command(AndroidConfigurations::currentConfig().keytoolPath(),
|
||||
const CommandLine command(androidConfig().keytoolPath(),
|
||||
{ "-genkey", "-keyalg", "RSA",
|
||||
"-keystore", m_keystoreFilePath.toString(),
|
||||
"-storepass", keystorePassword(),
|
||||
|
@@ -111,8 +111,7 @@ void AndroidDebugSupport::start()
|
||||
QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit);
|
||||
if (!HostOsInfo::isWindowsHost()
|
||||
&& (qtVersion
|
||||
&& AndroidConfigurations::currentConfig().ndkVersion(qtVersion)
|
||||
>= QVersionNumber(11, 0, 0))) {
|
||||
&& androidConfig().ndkVersion(qtVersion) >= QVersionNumber(11, 0, 0))) {
|
||||
qCDebug(androidDebugSupportLog) << "UseTargetAsync: " << true;
|
||||
setUseTargetAsync(true);
|
||||
}
|
||||
@@ -166,8 +165,7 @@ void AndroidDebugSupport::start()
|
||||
|
||||
int sdkVersion = qMax(AndroidManager::minimumSDK(kit), minimumNdk);
|
||||
if (qtVersion) {
|
||||
const FilePath ndkLocation =
|
||||
AndroidConfigurations::currentConfig().ndkLocation(qtVersion);
|
||||
const FilePath ndkLocation = androidConfig().ndkLocation(qtVersion);
|
||||
FilePath sysRoot = ndkLocation
|
||||
/ "platforms"
|
||||
/ QString("android-%1").arg(sdkVersion)
|
||||
|
@@ -288,7 +288,7 @@ bool AndroidDeployQtStep::init()
|
||||
m_apkPath = FilePath::fromString(node->data(Constants::AndroidApk).toString());
|
||||
if (!m_apkPath.isEmpty()) {
|
||||
m_manifestName = FilePath::fromString(node->data(Constants::AndroidManifest).toString());
|
||||
m_command = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
m_command = androidConfig().adbToolPath();
|
||||
AndroidManager::setManifestPath(target(), m_manifestName);
|
||||
} else {
|
||||
QString jsonFile = AndroidQtVersion::androidDeploymentSettings(target()).toString();
|
||||
@@ -326,13 +326,13 @@ bool AndroidDeployQtStep::init()
|
||||
}
|
||||
} else {
|
||||
m_uninstallPreviousPackageRun = true;
|
||||
m_command = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
m_command = androidConfig().adbToolPath();
|
||||
m_apkPath = AndroidManager::packagePath(target());
|
||||
m_workingDirectory = bc ? AndroidManager::buildDirectory(target()): FilePath();
|
||||
}
|
||||
m_environment = bc ? bc->environment() : Environment();
|
||||
|
||||
m_adbPath = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
m_adbPath = androidConfig().adbToolPath();
|
||||
|
||||
AndroidAvdManager avdManager;
|
||||
// Start the AVD if not running.
|
||||
|
@@ -244,7 +244,7 @@ AndroidDeviceInfo AndroidDevice::androidDeviceInfoFromIDevice(const IDevice *dev
|
||||
QString AndroidDevice::displayNameFromInfo(const AndroidDeviceInfo &info)
|
||||
{
|
||||
return info.type == IDevice::Hardware
|
||||
? AndroidConfigurations::currentConfig().getProductModel(info.serialNumber)
|
||||
? androidConfig().getProductModel(info.serialNumber)
|
||||
: info.avdName;
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ void AndroidDevice::initAvdSettings()
|
||||
|
||||
void AndroidDeviceManager::updateAvdsList()
|
||||
{
|
||||
if (!m_avdsFutureWatcher.isRunning() && m_androidConfig.adbToolPath().exists())
|
||||
if (!m_avdsFutureWatcher.isRunning() && androidConfig().adbToolPath().exists())
|
||||
m_avdsFutureWatcher.setFuture(m_avdManager.avdList());
|
||||
}
|
||||
|
||||
@@ -474,10 +474,9 @@ void AndroidDeviceManager::eraseAvd(const IDevice::Ptr &device, QWidget *parent)
|
||||
|
||||
qCDebug(androidDeviceLog) << QString("Erasing Android AVD \"%1\" from the system.").arg(name);
|
||||
m_removeAvdProcess.reset(new Process);
|
||||
const AndroidConfig &config = m_avdManager.config();
|
||||
const CommandLine command(config.avdManagerToolPath(), {"delete", "avd", "-n", name});
|
||||
const CommandLine command(androidConfig().avdManagerToolPath(), {"delete", "avd", "-n", name});
|
||||
qCDebug(androidDeviceLog).noquote() << "Running command (removeAvd):" << command.toUserOutput();
|
||||
m_removeAvdProcess->setEnvironment(config.toolsEnvironment());
|
||||
m_removeAvdProcess->setEnvironment(androidConfig().toolsEnvironment());
|
||||
m_removeAvdProcess->setCommand(command);
|
||||
connect(m_removeAvdProcess.get(), &Process::done, this, [this, device] {
|
||||
const QString name = device->displayName();
|
||||
@@ -572,7 +571,7 @@ void AndroidDeviceManager::setEmulatorArguments(QWidget *parent)
|
||||
dialog.setLabelText(Tr::tr("Emulator command-line startup options "
|
||||
"(<a href=\"%1\">Help Web Page</a>):")
|
||||
.arg(helpUrl));
|
||||
dialog.setTextValue(m_androidConfig.emulatorArgs());
|
||||
dialog.setTextValue(androidConfig().emulatorArgs());
|
||||
|
||||
if (auto label = dialog.findChild<QLabel*>()) {
|
||||
label->setOpenExternalLinks(true);
|
||||
@@ -582,12 +581,12 @@ void AndroidDeviceManager::setEmulatorArguments(QWidget *parent)
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
m_androidConfig.setEmulatorArgs(dialog.textValue());
|
||||
androidConfig().setEmulatorArgs(dialog.textValue());
|
||||
}
|
||||
|
||||
QString AndroidDeviceManager::getRunningAvdsSerialNumber(const QString &name) const
|
||||
{
|
||||
for (const AndroidDeviceInfo &dev : m_androidConfig.connectedDevices()) {
|
||||
for (const AndroidDeviceInfo &dev : androidConfig().connectedDevices()) {
|
||||
if (!dev.serialNumber.startsWith("emulator"))
|
||||
continue;
|
||||
const QString stdOut = emulatorName(dev.serialNumber);
|
||||
@@ -603,7 +602,7 @@ QString AndroidDeviceManager::getRunningAvdsSerialNumber(const QString &name) co
|
||||
|
||||
void AndroidDeviceManager::setupDevicesWatcher()
|
||||
{
|
||||
if (!m_androidConfig.adbToolPath().exists()) {
|
||||
if (!androidConfig().adbToolPath().exists()) {
|
||||
qCDebug(androidDeviceLog) << "Cannot start ADB device watcher"
|
||||
<< "because adb path does not exist.";
|
||||
return;
|
||||
@@ -635,10 +634,10 @@ void AndroidDeviceManager::setupDevicesWatcher()
|
||||
HandleDevicesListChange(output);
|
||||
});
|
||||
|
||||
const CommandLine command = CommandLine(m_androidConfig.adbToolPath(), {"track-devices"});
|
||||
const CommandLine command = CommandLine(androidConfig().adbToolPath(), {"track-devices"});
|
||||
m_adbDeviceWatcherProcess->setCommand(command);
|
||||
m_adbDeviceWatcherProcess->setWorkingDirectory(command.executable().parentDir());
|
||||
m_adbDeviceWatcherProcess->setEnvironment(m_androidConfig.toolsEnvironment());
|
||||
m_adbDeviceWatcherProcess->setEnvironment(androidConfig().toolsEnvironment());
|
||||
m_adbDeviceWatcherProcess->start();
|
||||
|
||||
// Setup AVD filesystem watcher to listen for changes when an avd is created/deleted,
|
||||
@@ -772,7 +771,7 @@ void AndroidDeviceManager::HandleDevicesListChange(const QString &serialNumber)
|
||||
devMgr->setDeviceState(avdId, state);
|
||||
} else {
|
||||
const Id id = Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + serial);
|
||||
QString displayName = AndroidConfigurations::currentConfig().getProductModel(serial);
|
||||
QString displayName = androidConfig().getProductModel(serial);
|
||||
// Check if the device is connected via WiFi. A sample serial of such devices can be
|
||||
// like: "192.168.1.190:5555"
|
||||
static const auto ipRegex = QRegularExpression(ipRegexStr + QStringLiteral(":(\\d{1,5})"));
|
||||
@@ -794,8 +793,8 @@ void AndroidDeviceManager::HandleDevicesListChange(const QString &serialNumber)
|
||||
newDev->setDeviceState(state);
|
||||
|
||||
newDev->setExtraData(Constants::AndroidSerialNumber, serial);
|
||||
newDev->setExtraData(Constants::AndroidCpuAbi, m_androidConfig.getAbis(serial));
|
||||
newDev->setExtraData(Constants::AndroidSdk, m_androidConfig.getSDKVersion(serial));
|
||||
newDev->setExtraData(Constants::AndroidCpuAbi, androidConfig().getAbis(serial));
|
||||
newDev->setExtraData(Constants::AndroidSdk, androidConfig().getSDKVersion(serial));
|
||||
|
||||
qCDebug(androidDeviceLog, "Registering new Android device id \"%s\".",
|
||||
newDev->id().toString().toUtf8().data());
|
||||
@@ -812,9 +811,7 @@ AndroidDeviceManager *AndroidDeviceManager::instance()
|
||||
}
|
||||
|
||||
AndroidDeviceManager::AndroidDeviceManager(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_androidConfig(AndroidConfigurations::currentConfig()),
|
||||
m_avdManager(m_androidConfig)
|
||||
: QObject(parent)
|
||||
{
|
||||
QTC_ASSERT(!s_instance, return);
|
||||
s_instance = this;
|
||||
@@ -833,16 +830,15 @@ class AndroidDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
||||
{
|
||||
public:
|
||||
AndroidDeviceFactory()
|
||||
: IDeviceFactory(Constants::ANDROID_DEVICE_TYPE),
|
||||
m_androidConfig(AndroidConfigurations::currentConfig())
|
||||
: IDeviceFactory(Constants::ANDROID_DEVICE_TYPE)
|
||||
{
|
||||
setDisplayName(Tr::tr("Android Device"));
|
||||
setCombinedIcon(":/android/images/androiddevicesmall.png",
|
||||
":/android/images/androiddevice.png");
|
||||
setConstructionFunction(&AndroidDevice::create);
|
||||
if (m_androidConfig.sdkToolsOk()) {
|
||||
if (androidConfig().sdkToolsOk()) {
|
||||
setCreator([this] {
|
||||
AvdDialog dialog = AvdDialog(m_androidConfig, Core::ICore::dialogParent());
|
||||
AvdDialog dialog = AvdDialog(Core::ICore::dialogParent());
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return IDevice::Ptr();
|
||||
|
||||
@@ -859,9 +855,6 @@ public:
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const AndroidConfig &m_androidConfig;
|
||||
};
|
||||
|
||||
void setupAndroidDevice()
|
||||
|
@@ -99,7 +99,6 @@ private:
|
||||
std::unique_ptr<Utils::Process> m_removeAvdProcess;
|
||||
QFileSystemWatcher m_avdFileSystemWatcher;
|
||||
std::unique_ptr<Utils::Process> m_adbDeviceWatcherProcess;
|
||||
AndroidConfig &m_androidConfig;
|
||||
AndroidAvdManager m_avdManager;
|
||||
|
||||
friend void setupAndroidDeviceManager(QObject *guard);
|
||||
|
@@ -190,17 +190,17 @@ QJsonObject deploymentSettings(const Target *target)
|
||||
QJsonObject settings;
|
||||
settings["_description"] = qtcSignature;
|
||||
settings["qt"] = qt->prefix().toString();
|
||||
settings["ndk"] = AndroidConfigurations::currentConfig().ndkLocation(qt).toString();
|
||||
settings["sdk"] = AndroidConfigurations::currentConfig().sdkLocation().toString();
|
||||
settings["ndk"] = androidConfig().ndkLocation(qt).toString();
|
||||
settings["sdk"] = androidConfig().sdkLocation().toString();
|
||||
if (!qt->supportsMultipleQtAbis()) {
|
||||
const QStringList abis = applicationAbis(target);
|
||||
QTC_ASSERT(abis.size() == 1, return {});
|
||||
settings["stdcpp-path"] = (AndroidConfigurations::currentConfig().toolchainPath(qt)
|
||||
settings["stdcpp-path"] = (androidConfig().toolchainPath(qt)
|
||||
/ "sysroot/usr/lib"
|
||||
/ archTriplet(abis.first())
|
||||
/ "libc++_shared.so").toString();
|
||||
} else {
|
||||
settings["stdcpp-path"] = AndroidConfigurations::currentConfig()
|
||||
settings["stdcpp-path"] = androidConfig()
|
||||
.toolchainPath(qt)
|
||||
.pathAppended("sysroot/usr/lib")
|
||||
.toString();
|
||||
@@ -208,7 +208,7 @@ QJsonObject deploymentSettings(const Target *target)
|
||||
settings["toolchain-prefix"] = "llvm";
|
||||
settings["tool-prefix"] = "llvm";
|
||||
settings["useLLVM"] = true;
|
||||
settings["ndk-host"] = AndroidConfigurations::currentConfig().toolchainHost(qt);
|
||||
settings["ndk-host"] = androidConfig().toolchainHost(qt);
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ bool checkKeystorePassword(const FilePath &keystorePath, const QString &keystore
|
||||
{
|
||||
if (keystorePasswd.isEmpty())
|
||||
return false;
|
||||
const CommandLine cmd(AndroidConfigurations::currentConfig().keytoolPath(),
|
||||
const CommandLine cmd(androidConfig().keytoolPath(),
|
||||
{"-list", "-keystore", keystorePath.toUserOutput(),
|
||||
"--storepass", keystorePasswd});
|
||||
Process proc;
|
||||
@@ -630,7 +630,7 @@ bool checkCertificatePassword(const FilePath &keystorePath, const QString &keyst
|
||||
arguments << certificatePasswd;
|
||||
|
||||
Process proc;
|
||||
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
proc.setCommand({androidConfig().keytoolPath(), arguments});
|
||||
proc.runBlocking(10s, EventLoopMode::On);
|
||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||
}
|
||||
@@ -643,7 +643,7 @@ bool checkCertificateExists(const FilePath &keystorePath, const QString &keystor
|
||||
"--storepass", keystorePasswd, "-alias", alias };
|
||||
|
||||
Process proc;
|
||||
proc.setCommand({AndroidConfigurations::currentConfig().keytoolPath(), arguments});
|
||||
proc.setCommand({androidConfig().keytoolPath(), arguments});
|
||||
proc.runBlocking(10s, EventLoopMode::On);
|
||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||
}
|
||||
@@ -651,7 +651,7 @@ bool checkCertificateExists(const FilePath &keystorePath, const QString &keystor
|
||||
Process *startAdbProcess(const QStringList &args, QString *err)
|
||||
{
|
||||
std::unique_ptr<Process> process(new Process);
|
||||
const FilePath adb = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
const FilePath adb = androidConfig().adbToolPath();
|
||||
const CommandLine command{adb, args};
|
||||
qCDebug(androidManagerLog).noquote() << "Running command (async):" << command.toUserOutput();
|
||||
process->setCommand(command);
|
||||
@@ -689,8 +689,7 @@ static SdkToolResult runCommand(const CommandLine &command, const QByteArray &wr
|
||||
|
||||
SdkToolResult runAdbCommand(const QStringList &args, const QByteArray &writeData, int timeoutS)
|
||||
{
|
||||
return runCommand({AndroidConfigurations::currentConfig().adbToolPath(), args},
|
||||
writeData, timeoutS);
|
||||
return runCommand({androidConfig().adbToolPath(), args}, writeData, timeoutS);
|
||||
}
|
||||
|
||||
} // namespace Android::AndroidManager
|
||||
|
@@ -592,7 +592,7 @@ void AndroidManifestEditorWidget::postSave()
|
||||
const FilePath docPath = m_textEditorWidget->textDocument()->filePath();
|
||||
if (Target *target = androidTarget(docPath)) {
|
||||
if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
|
||||
QString androidNdkPlatform = AndroidConfigurations::currentConfig().bestNdkPlatformMatch(
|
||||
QString androidNdkPlatform = androidConfig().bestNdkPlatformMatch(
|
||||
AndroidManager::minimumSDK(target),
|
||||
QtSupport::QtKitAspect::qtVersion(
|
||||
androidTarget(m_textEditorWidget->textDocument()->filePath())->kit()));
|
||||
|
@@ -135,7 +135,7 @@ class AndroidPlugin final : public ExtensionSystem::IPlugin
|
||||
return v->targetDeviceTypes().contains(Android::Constants::ANDROID_DEVICE_TYPE);
|
||||
}).isEmpty();
|
||||
|
||||
if (!AndroidConfigurations::currentConfig().sdkFullyConfigured() && qtForAndroidInstalled)
|
||||
if (!androidConfig().sdkFullyConfigured() && qtForAndroidInstalled)
|
||||
askUserAboutAndroidSetup();
|
||||
|
||||
AndroidConfigurations::registerNewToolchains();
|
||||
|
@@ -112,7 +112,6 @@ private:
|
||||
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;
|
||||
@@ -193,7 +192,7 @@ void AndroidQmlPreviewWorker::startLogcat()
|
||||
QString args = QString("logcat --pid=%1").arg(m_viewerPid);
|
||||
if (!m_logcatStartTimeStamp.isEmpty())
|
||||
args += QString(" -T '%1'").arg(m_logcatStartTimeStamp);
|
||||
CommandLine cmd(AndroidConfigurations::currentConfig().adbToolPath());
|
||||
CommandLine cmd(androidConfig().adbToolPath());
|
||||
cmd.setArguments(args);
|
||||
m_logcatProcess.setCommand(cmd);
|
||||
m_logcatProcess.setUseCtrlCStub(true);
|
||||
@@ -218,8 +217,7 @@ void AndroidQmlPreviewWorker::filterLogcatAndAppendMessage(const QString &stdOut
|
||||
|
||||
AndroidQmlPreviewWorker::AndroidQmlPreviewWorker(RunControl *runControl)
|
||||
: RunWorker(runControl),
|
||||
m_rc(runControl),
|
||||
m_androidConfig(AndroidConfigurations::currentConfig())
|
||||
m_rc(runControl)
|
||||
{
|
||||
connect(this, &RunWorker::started, this, &AndroidQmlPreviewWorker::startPidWatcher);
|
||||
connect(this, &RunWorker::stopped, &m_pidFutureWatcher, &QFutureWatcher<void>::cancel);
|
||||
@@ -264,7 +262,7 @@ void AndroidQmlPreviewWorker::stop()
|
||||
|
||||
bool AndroidQmlPreviewWorker::ensureAvdIsRunning()
|
||||
{
|
||||
AndroidAvdManager avdMananager(m_androidConfig);
|
||||
AndroidAvdManager avdMananager;
|
||||
QString devSN = AndroidManager::deviceSerialNumber(m_rc->target());
|
||||
|
||||
if (devSN.isEmpty())
|
||||
@@ -291,7 +289,7 @@ bool AndroidQmlPreviewWorker::ensureAvdIsRunning()
|
||||
appendMessage(Tr::tr("Could not start AVD."), ErrorMessageFormat);
|
||||
} else {
|
||||
m_serialNumber = devInfoLocal.serialNumber;
|
||||
m_avdAbis = m_androidConfig.getAbis(m_serialNumber);
|
||||
m_avdAbis = androidConfig().getAbis(m_serialNumber);
|
||||
}
|
||||
return !devInfoLocal.serialNumber.isEmpty();
|
||||
} else {
|
||||
@@ -299,7 +297,7 @@ bool AndroidQmlPreviewWorker::ensureAvdIsRunning()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
m_avdAbis = m_androidConfig.getAbis(m_serialNumber);
|
||||
m_avdAbis = androidConfig().getAbis(m_serialNumber);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -61,9 +61,9 @@ QString AndroidQtVersion::invalidReason() const
|
||||
{
|
||||
QString tmp = QtVersion::invalidReason();
|
||||
if (tmp.isEmpty()) {
|
||||
if (AndroidConfigurations::currentConfig().ndkLocation(this).isEmpty())
|
||||
if (androidConfig().ndkLocation(this).isEmpty())
|
||||
return Tr::tr("NDK is not configured in Devices > Android.");
|
||||
if (AndroidConfigurations::currentConfig().sdkLocation().isEmpty())
|
||||
if (androidConfig().sdkLocation().isEmpty())
|
||||
return Tr::tr("SDK is not configured in Devices > Android.");
|
||||
if (qtAbis().isEmpty())
|
||||
return Tr::tr("Failed to detect the ABIs used by the Qt version. Check the settings in "
|
||||
@@ -79,7 +79,7 @@ bool AndroidQtVersion::supportsMultipleQtAbis() const
|
||||
|
||||
Abis AndroidQtVersion::detectQtAbis() const
|
||||
{
|
||||
const bool conf = AndroidConfigurations::currentConfig().sdkFullyConfigured();
|
||||
const bool conf = androidConfig().sdkFullyConfigured();
|
||||
return conf ? Utils::transform<Abis>(androidAbis(), &AndroidManager::androidAbi2Abi) : Abis();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void AndroidQtVersion::addToEnvironment(const Kit *k, Utils::Environment &env) c
|
||||
{
|
||||
QtVersion::addToEnvironment(k, env);
|
||||
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
const AndroidConfig &config = androidConfig();
|
||||
// this env vars are used by qmake mkspecs to generate makefiles (check QTDIR/mkspecs/android-g++/qmake.conf for more info)
|
||||
env.set(QLatin1String("ANDROID_NDK_HOST"), config.toolchainHost(this));
|
||||
env.set(QLatin1String("ANDROID_NDK_ROOT"), config.ndkLocation(this).toUserOutput());
|
||||
@@ -98,7 +98,7 @@ void AndroidQtVersion::addToEnvironment(const Kit *k, Utils::Environment &env) c
|
||||
void AndroidQtVersion::setupQmakeRunEnvironment(Utils::Environment &env) const
|
||||
{
|
||||
env.set(QLatin1String("ANDROID_NDK_ROOT"),
|
||||
AndroidConfigurations::currentConfig().ndkLocation(this).toUserOutput());
|
||||
androidConfig().ndkLocation(this).toUserOutput());
|
||||
}
|
||||
|
||||
QString AndroidQtVersion::description() const
|
||||
|
@@ -183,8 +183,7 @@ void AndroidRunner::launchAVD()
|
||||
|
||||
void AndroidRunner::checkAVD()
|
||||
{
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
AndroidAvdManager avdManager(config);
|
||||
AndroidAvdManager avdManager;
|
||||
QString serialNumber = avdManager.findAvd(m_launchedAVDName);
|
||||
if (!serialNumber.isEmpty())
|
||||
return; // try again on next timer hit
|
||||
@@ -193,7 +192,7 @@ void AndroidRunner::checkAVD()
|
||||
m_checkAVDTimer.stop();
|
||||
AndroidManager::setDeviceSerialNumber(m_target, serialNumber);
|
||||
emit asyncStart();
|
||||
} else if (!config.isConnected(serialNumber)) {
|
||||
} else if (!androidConfig().isConnected(serialNumber)) {
|
||||
// device was disconnected
|
||||
m_checkAVDTimer.stop();
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ static void findProcessPIDAndUser(QPromise<PidUserPair> &promise,
|
||||
static const QString pidScriptPreNougat = QStringLiteral("for p in /proc/[0-9]*; "
|
||||
"do cat <$p/cmdline && echo :${p##*/}; done");
|
||||
QStringList args = {selector};
|
||||
FilePath adbPath = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
FilePath adbPath = androidConfig().adbToolPath();
|
||||
args.append("shell");
|
||||
args.append(preNougat ? pidScriptPreNougat : pidScript.arg(packageName));
|
||||
|
||||
@@ -170,7 +170,7 @@ static FilePath debugServer(bool useLldb, const Target *target)
|
||||
QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
QString preferredAbi = AndroidManager::apkDevicePreferredAbi(target);
|
||||
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
const AndroidConfig &config = androidConfig();
|
||||
|
||||
if (useLldb) {
|
||||
// Search suitable lldb-server binary.
|
||||
@@ -512,7 +512,7 @@ void Android::Internal::AndroidRunnerWorker::asyncStartLogcat()
|
||||
}
|
||||
|
||||
const QStringList logcatArgs = selector() << "logcat" << timeArg;
|
||||
const FilePath adb = AndroidConfigurations::currentConfig().adbToolPath();
|
||||
const FilePath adb = androidConfig().adbToolPath();
|
||||
qCDebug(androidRunWorkerLog).noquote() << "Running logcat command (async):"
|
||||
<< CommandLine(adb, logcatArgs).toUserOutput();
|
||||
m_adbLogcatProcess->setCommand({adb, logcatArgs});
|
||||
@@ -742,7 +742,7 @@ void AndroidRunnerWorker::handleJdbWaiting()
|
||||
}
|
||||
m_afterFinishAdbCommands.push_back(removeForward.join(' '));
|
||||
|
||||
const FilePath jdbPath = AndroidConfigurations::currentConfig().openJDKLocation()
|
||||
const FilePath jdbPath = androidConfig().openJDKLocation()
|
||||
.pathAppended("bin/jdb").withExecutableSuffix();
|
||||
|
||||
QStringList jdbArgs("-connect");
|
||||
|
@@ -29,7 +29,6 @@ namespace Android::Internal {
|
||||
* @brief Download Android SDK tools package from within Qt Creator.
|
||||
*/
|
||||
AndroidSdkDownloader::AndroidSdkDownloader()
|
||||
: m_androidConfig(AndroidConfigurations::currentConfig())
|
||||
{
|
||||
connect(&m_taskTreeRunner, &TaskTreeRunner::done, this, [this] { m_progressDialog.reset(); });
|
||||
}
|
||||
@@ -89,7 +88,7 @@ static bool verifyFileIntegrity(const FilePath fileName, const QByteArray &sha25
|
||||
|
||||
void AndroidSdkDownloader::downloadAndExtractSdk()
|
||||
{
|
||||
if (m_androidConfig.sdkToolsUrl().isEmpty()) {
|
||||
if (androidConfig().sdkToolsUrl().isEmpty()) {
|
||||
logError(Tr::tr("The SDK Tools download URL is empty."));
|
||||
return;
|
||||
}
|
||||
@@ -108,7 +107,7 @@ void AndroidSdkDownloader::downloadAndExtractSdk()
|
||||
Storage<std::optional<FilePath>> storage;
|
||||
|
||||
const auto onQuerySetup = [this](NetworkQuery &query) {
|
||||
query.setRequest(QNetworkRequest(m_androidConfig.sdkToolsUrl()));
|
||||
query.setRequest(QNetworkRequest(androidConfig().sdkToolsUrl()));
|
||||
query.setNetworkAccessManager(NetworkAccessManager::instance());
|
||||
NetworkQuery *queryPtr = &query;
|
||||
connect(queryPtr, &NetworkQuery::started, this, [this, queryPtr] {
|
||||
@@ -159,7 +158,7 @@ void AndroidSdkDownloader::downloadAndExtractSdk()
|
||||
if (!*storage)
|
||||
return SetupResult::StopWithError;
|
||||
const FilePath sdkFileName = **storage;
|
||||
if (!verifyFileIntegrity(sdkFileName, m_androidConfig.getSdkToolsSha256())) {
|
||||
if (!verifyFileIntegrity(sdkFileName, androidConfig().getSdkToolsSha256())) {
|
||||
logError(Tr::tr("Verifying the integrity of the downloaded file has failed."));
|
||||
return SetupResult::StopWithError;
|
||||
}
|
||||
@@ -177,7 +176,7 @@ void AndroidSdkDownloader::downloadAndExtractSdk()
|
||||
logError(Tr::tr("Unarchiving error."));
|
||||
return;
|
||||
}
|
||||
m_androidConfig.setTemporarySdkToolsPath(
|
||||
androidConfig().setTemporarySdkToolsPath(
|
||||
(*storage)->parentDir().pathAppended(Constants::cmdlineToolsName));
|
||||
QMetaObject::invokeMethod(this, [this] { emit sdkExtracted(); }, Qt::QueuedConnection);
|
||||
};
|
||||
|
@@ -31,7 +31,6 @@ signals:
|
||||
private:
|
||||
void logError(const QString &error);
|
||||
|
||||
AndroidConfig &m_androidConfig;
|
||||
std::unique_ptr<QProgressDialog> m_progressDialog;
|
||||
Tasking::TaskTreeRunner m_taskTreeRunner;
|
||||
};
|
||||
|
@@ -158,7 +158,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
||||
class AndroidSdkManagerPrivate
|
||||
{
|
||||
public:
|
||||
AndroidSdkManagerPrivate(AndroidSdkManager &sdkManager, const AndroidConfig &config);
|
||||
AndroidSdkManagerPrivate(AndroidSdkManager &sdkManager);
|
||||
~AndroidSdkManagerPrivate();
|
||||
|
||||
AndroidSdkPackageList filteredPackages(AndroidSdkPackage::PackageState state,
|
||||
@@ -188,7 +188,6 @@ private:
|
||||
AndroidSdkManager::OperationOutput &result, SdkCmdPromise &fi);
|
||||
|
||||
AndroidSdkManager &m_sdkManager;
|
||||
const AndroidConfig &m_config;
|
||||
AndroidSdkPackageList m_allPackages;
|
||||
FilePath lastSdkManagerPath;
|
||||
QString m_licenseTextCache;
|
||||
@@ -199,8 +198,8 @@ public:
|
||||
bool m_packageListingSuccessful = false;
|
||||
};
|
||||
|
||||
AndroidSdkManager::AndroidSdkManager(const AndroidConfig &config):
|
||||
m_d(new AndroidSdkManagerPrivate(*this, config))
|
||||
AndroidSdkManager::AndroidSdkManager()
|
||||
: m_d(new AndroidSdkManagerPrivate(*this))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -359,13 +358,10 @@ void AndroidSdkManager::acceptSdkLicense(bool accept)
|
||||
m_d->setLicenseInput(accept);
|
||||
}
|
||||
|
||||
AndroidSdkManagerPrivate::AndroidSdkManagerPrivate(AndroidSdkManager &sdkManager,
|
||||
const AndroidConfig &config):
|
||||
AndroidSdkManagerPrivate::AndroidSdkManagerPrivate(AndroidSdkManager &sdkManager):
|
||||
m_activeOperation(nullptr, watcherDeleter),
|
||||
m_sdkManager(sdkManager),
|
||||
m_config(config)
|
||||
{
|
||||
}
|
||||
m_sdkManager(sdkManager)
|
||||
{}
|
||||
|
||||
AndroidSdkManagerPrivate::~AndroidSdkManagerPrivate()
|
||||
{
|
||||
@@ -393,10 +389,10 @@ void AndroidSdkManagerPrivate::reloadSdkPackages()
|
||||
emit m_sdkManager.packageReloadBegin();
|
||||
clearPackages();
|
||||
|
||||
lastSdkManagerPath = m_config.sdkManagerToolPath();
|
||||
lastSdkManagerPath = androidConfig().sdkManagerToolPath();
|
||||
m_packageListingSuccessful = false;
|
||||
|
||||
if (m_config.sdkToolsVersion().isNull()) {
|
||||
if (androidConfig().sdkToolsVersion().isNull()) {
|
||||
// Configuration has invalid sdk path or corrupt installation.
|
||||
emit m_sdkManager.packageReloadFinished();
|
||||
return;
|
||||
@@ -404,8 +400,8 @@ void AndroidSdkManagerPrivate::reloadSdkPackages()
|
||||
|
||||
QString packageListing;
|
||||
QStringList args({"--list", "--verbose"});
|
||||
args << m_config.sdkManagerToolArgs();
|
||||
m_packageListingSuccessful = sdkManagerCommand(m_config, args, &packageListing);
|
||||
args << androidConfig().sdkManagerToolArgs();
|
||||
m_packageListingSuccessful = sdkManagerCommand(androidConfig(), args, &packageListing);
|
||||
if (m_packageListingSuccessful) {
|
||||
SdkManagerOutputParser parser(m_allPackages);
|
||||
parser.parsePackageListing(packageListing);
|
||||
@@ -417,7 +413,7 @@ void AndroidSdkManagerPrivate::refreshSdkPackages(bool forceReload)
|
||||
{
|
||||
// Sdk path changed. Updated packages.
|
||||
// QTC updates the package listing only
|
||||
if (m_config.sdkManagerToolPath() != lastSdkManagerPath || forceReload)
|
||||
if (androidConfig().sdkManagerToolPath() != lastSdkManagerPath || forceReload)
|
||||
reloadSdkPackages();
|
||||
}
|
||||
|
||||
@@ -430,9 +426,9 @@ void AndroidSdkManagerPrivate::updateInstalled(SdkCmdPromise &promise)
|
||||
result.stdOutput = Tr::tr("Updating installed packages.");
|
||||
promise.addResult(result);
|
||||
QStringList args("--update");
|
||||
args << m_config.sdkManagerToolArgs();
|
||||
args << androidConfig().sdkManagerToolArgs();
|
||||
if (!promise.isCanceled())
|
||||
sdkManagerCommand(m_config, args, m_sdkManager, promise, result, 100);
|
||||
sdkManagerCommand(androidConfig(), args, m_sdkManager, promise, result, 100);
|
||||
else
|
||||
qCDebug(sdkManagerLog) << "Update: Operation cancelled before start";
|
||||
|
||||
@@ -464,7 +460,7 @@ void AndroidSdkManagerPrivate::update(SdkCmdPromise &fi, const QStringList &inst
|
||||
if (fi.isCanceled())
|
||||
qCDebug(sdkManagerLog) << args << "Update: Operation cancelled before start";
|
||||
else
|
||||
sdkManagerCommand(m_config, args, m_sdkManager, fi, result, progressQuota, isInstall);
|
||||
sdkManagerCommand(androidConfig(), args, m_sdkManager, fi, result, progressQuota, isInstall);
|
||||
currentProgress += progressQuota;
|
||||
fi.setProgressValue(currentProgress);
|
||||
if (result.stdError.isEmpty() && !result.success)
|
||||
@@ -479,7 +475,7 @@ void AndroidSdkManagerPrivate::update(SdkCmdPromise &fi, const QStringList &inst
|
||||
for (const QString &sdkStylePath : uninstall) {
|
||||
// Uninstall operations are not interptible. We don't want to leave half uninstalled.
|
||||
QStringList args;
|
||||
args << "--uninstall" << sdkStylePath << m_config.sdkManagerToolArgs();
|
||||
args << "--uninstall" << sdkStylePath << androidConfig().sdkManagerToolArgs();
|
||||
if (doOperation(sdkStylePath, args, false))
|
||||
break;
|
||||
}
|
||||
@@ -487,7 +483,7 @@ void AndroidSdkManagerPrivate::update(SdkCmdPromise &fi, const QStringList &inst
|
||||
// Install packages
|
||||
for (const QString &sdkStylePath : install) {
|
||||
QStringList args(sdkStylePath);
|
||||
args << m_config.sdkManagerToolArgs();
|
||||
args << androidConfig().sdkManagerToolArgs();
|
||||
if (doOperation(sdkStylePath, args, true))
|
||||
break;
|
||||
}
|
||||
@@ -500,10 +496,10 @@ void AndroidSdkManagerPrivate::checkPendingLicense(SdkCmdPromise &fi)
|
||||
fi.setProgressValue(0);
|
||||
AndroidSdkManager::OperationOutput result;
|
||||
result.type = AndroidSdkManager::LicenseCheck;
|
||||
const QStringList args = {"--licenses", sdkRootArg(m_config)};
|
||||
const QStringList args = {"--licenses", sdkRootArg(androidConfig())};
|
||||
if (!fi.isCanceled()) {
|
||||
const int timeOutS = 4; // Short timeout as workaround for QTCREATORBUG-25667
|
||||
sdkManagerCommand(m_config, args, m_sdkManager, fi, result, 100.0, true, timeOutS);
|
||||
sdkManagerCommand(androidConfig(), args, m_sdkManager, fi, result, 100.0, true, timeOutS);
|
||||
} else {
|
||||
qCDebug(sdkManagerLog) << "Update: Operation cancelled before start";
|
||||
}
|
||||
@@ -522,9 +518,10 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
|
||||
|
||||
Process licenseCommand;
|
||||
licenseCommand.setProcessMode(ProcessMode::Writer);
|
||||
licenseCommand.setEnvironment(m_config.toolsEnvironment());
|
||||
licenseCommand.setEnvironment(androidConfig().toolsEnvironment());
|
||||
bool reviewingLicenses = false;
|
||||
licenseCommand.setCommand(CommandLine(m_config.sdkManagerToolPath(), {"--licenses", sdkRootArg(m_config)}));
|
||||
licenseCommand.setCommand(CommandLine(androidConfig().sdkManagerToolPath(),
|
||||
{"--licenses", sdkRootArg(androidConfig())}));
|
||||
licenseCommand.setUseCtrlCStub(true);
|
||||
licenseCommand.start();
|
||||
QTextCodec *codec = QTextCodec::codecForLocale();
|
||||
@@ -623,7 +620,7 @@ void AndroidSdkManagerPrivate::parseCommonArguments(QPromise<QString> &promise)
|
||||
{
|
||||
QString argumentDetails;
|
||||
QString output;
|
||||
sdkManagerCommand(m_config, QStringList("--help"), &output);
|
||||
sdkManagerCommand(androidConfig(), QStringList("--help"), &output);
|
||||
bool foundTag = false;
|
||||
const auto lines = output.split('\n');
|
||||
for (const QString& line : lines) {
|
||||
|
@@ -40,7 +40,7 @@ public:
|
||||
QString stdError;
|
||||
};
|
||||
|
||||
explicit AndroidSdkManager(const AndroidConfig &config);
|
||||
AndroidSdkManager();
|
||||
~AndroidSdkManager() override;
|
||||
|
||||
SdkPlatformList installedSdkPlatforms();
|
||||
|
@@ -44,12 +44,10 @@ private:
|
||||
QString m_searchText;
|
||||
};
|
||||
|
||||
AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
|
||||
AndroidSdkManager *sdkManager, QWidget *parent) :
|
||||
AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidSdkManager *sdkManager, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_androidConfig(config),
|
||||
m_sdkManager(sdkManager),
|
||||
m_sdkModel(new AndroidSdkModel(m_androidConfig, m_sdkManager, this))
|
||||
m_sdkModel(new AndroidSdkModel(m_sdkManager, this))
|
||||
{
|
||||
QTC_CHECK(sdkManager);
|
||||
|
||||
@@ -224,19 +222,19 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
|
||||
|
||||
connect(obsoleteCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||
const QString obsoleteArg = "--include_obsolete";
|
||||
QStringList args = m_androidConfig.sdkManagerToolArgs();
|
||||
QStringList args = androidConfig().sdkManagerToolArgs();
|
||||
if (state == Qt::Checked && !args.contains(obsoleteArg)) {
|
||||
args.append(obsoleteArg);
|
||||
m_androidConfig.setSdkManagerToolArgs(args);
|
||||
androidConfig().setSdkManagerToolArgs(args);
|
||||
} else if (state == Qt::Unchecked && args.contains(obsoleteArg)) {
|
||||
args.removeAll(obsoleteArg);
|
||||
m_androidConfig.setSdkManagerToolArgs(args);
|
||||
androidConfig().setSdkManagerToolArgs(args);
|
||||
}
|
||||
m_sdkManager->reloadPackages(true);
|
||||
});
|
||||
|
||||
connect(channelCheckbox, &QComboBox::currentIndexChanged, this, [this](int index) {
|
||||
QStringList args = m_androidConfig.sdkManagerToolArgs();
|
||||
QStringList args = androidConfig().sdkManagerToolArgs();
|
||||
QString existingArg;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const QString arg = "--channel=" + QString::number(i);
|
||||
@@ -248,17 +246,17 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
|
||||
|
||||
if (index == 0 && !existingArg.isEmpty()) {
|
||||
args.removeAll(existingArg);
|
||||
m_androidConfig.setSdkManagerToolArgs(args);
|
||||
androidConfig().setSdkManagerToolArgs(args);
|
||||
} else if (index > 0) {
|
||||
// Add 1 to account for Stable (second item) being channel 0
|
||||
const QString channelArg = "--channel=" + QString::number(index - 1);
|
||||
if (existingArg != channelArg) {
|
||||
if (!existingArg.isEmpty()) {
|
||||
args.removeAll(existingArg);
|
||||
m_androidConfig.setSdkManagerToolArgs(args);
|
||||
androidConfig().setSdkManagerToolArgs(args);
|
||||
}
|
||||
args.append(channelArg);
|
||||
m_androidConfig.setSdkManagerToolArgs(args);
|
||||
androidConfig().setSdkManagerToolArgs(args);
|
||||
}
|
||||
}
|
||||
m_sdkManager->reloadPackages(true);
|
||||
@@ -569,11 +567,11 @@ void AndroidSdkManagerWidget::runPendingCommand()
|
||||
|
||||
void AndroidSdkManagerWidget::onSdkManagerOptions()
|
||||
{
|
||||
OptionsDialog dlg(m_sdkManager, m_androidConfig.sdkManagerToolArgs(), this);
|
||||
OptionsDialog dlg(m_sdkManager, androidConfig().sdkManagerToolArgs(), this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QStringList arguments = dlg.sdkManagerArguments();
|
||||
if (arguments != m_androidConfig.sdkManagerToolArgs()) {
|
||||
m_androidConfig.setSdkManagerToolArgs(arguments);
|
||||
if (arguments != androidConfig().sdkManagerToolArgs()) {
|
||||
androidConfig().setSdkManagerToolArgs(arguments);
|
||||
m_sdkManager->reloadPackages(true);
|
||||
}
|
||||
}
|
||||
|
@@ -67,8 +67,7 @@ class AndroidSdkManagerWidget : public QDialog
|
||||
};
|
||||
|
||||
public:
|
||||
AndroidSdkManagerWidget(AndroidConfig &config, AndroidSdkManager *sdkManager,
|
||||
QWidget *parent = nullptr);
|
||||
AndroidSdkManagerWidget(AndroidSdkManager *sdkManager, QWidget *parent = nullptr);
|
||||
~AndroidSdkManagerWidget() override;
|
||||
|
||||
void installEssentials();
|
||||
@@ -96,7 +95,6 @@ private:
|
||||
void switchView(View view);
|
||||
void runPendingCommand();
|
||||
|
||||
AndroidConfig &m_androidConfig;
|
||||
AndroidSdkManager::CommandType m_pendingCommand = AndroidSdkManager::None;
|
||||
View m_currentView = PackageListing;
|
||||
AndroidSdkManager *m_sdkManager = nullptr;
|
||||
|
@@ -22,10 +22,8 @@ namespace Internal {
|
||||
|
||||
const int packageColCount = 3;
|
||||
|
||||
AndroidSdkModel::AndroidSdkModel(const AndroidConfig &config, AndroidSdkManager *sdkManager,
|
||||
QObject *parent)
|
||||
AndroidSdkModel::AndroidSdkModel(AndroidSdkManager *sdkManager, QObject *parent)
|
||||
: QAbstractItemModel(parent),
|
||||
m_config(config),
|
||||
m_sdkManager(sdkManager)
|
||||
{
|
||||
QTC_CHECK(m_sdkManager);
|
||||
@@ -263,7 +261,7 @@ bool AndroidSdkModel::setData(const QModelIndex &index, const QVariant &value, i
|
||||
void AndroidSdkModel::selectMissingEssentials()
|
||||
{
|
||||
resetSelection();
|
||||
QStringList pendingPkgs(m_config.allEssentials());
|
||||
QStringList pendingPkgs(androidConfig().allEssentials());
|
||||
auto addTool = [this](QList<const AndroidSdkPackage *>::const_iterator itr) {
|
||||
if ((*itr)->installedLocation().isEmpty()) {
|
||||
m_changeState << *itr;
|
||||
|
@@ -27,8 +27,7 @@ public:
|
||||
PackageStateRole
|
||||
};
|
||||
|
||||
explicit AndroidSdkModel(const AndroidConfig &config, AndroidSdkManager *sdkManager,
|
||||
QObject *parent = nullptr);
|
||||
explicit AndroidSdkModel(AndroidSdkManager *sdkManager, QObject *parent = nullptr);
|
||||
|
||||
// QAbstractItemModel overrides.
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
@@ -52,7 +51,6 @@ private:
|
||||
void clearContainers();
|
||||
void refreshData();
|
||||
|
||||
const AndroidConfig &m_config;
|
||||
AndroidSdkManager *m_sdkManager;
|
||||
QList<const SdkPlatform *> m_sdkPlatforms;
|
||||
QList<const AndroidSdkPackage *> m_tools;
|
||||
|
@@ -168,9 +168,8 @@ private:
|
||||
void validateOpenSsl();
|
||||
|
||||
AndroidSdkManagerWidget *m_sdkManagerWidget = nullptr;
|
||||
AndroidConfig &m_androidConfig{AndroidConfigurations::currentConfig()};
|
||||
|
||||
AndroidSdkManager m_sdkManager{m_androidConfig};
|
||||
AndroidSdkManager m_sdkManager;
|
||||
AndroidSdkDownloader m_sdkDownloader;
|
||||
bool m_isInitialReloadDone = false;
|
||||
|
||||
@@ -252,7 +251,7 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
"and extracted to the selected path.\n"
|
||||
"After the SDK Tools are properly set up, you are prompted to install any essential\n"
|
||||
"packages required for Qt to build for Android.")
|
||||
.arg(m_androidConfig.sdkToolsUrl().toString()));
|
||||
.arg(androidConfig().sdkToolsUrl().toString()));
|
||||
|
||||
auto sdkManagerToolButton = new QPushButton(Tr::tr("SDK Manager"));
|
||||
|
||||
@@ -277,7 +276,7 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
"in the system's browser for manual download."));
|
||||
|
||||
|
||||
m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, this);
|
||||
m_sdkManagerWidget = new AndroidSdkManagerWidget(&m_sdkManager, this);
|
||||
|
||||
const QMap<int, QString> androidValidationPoints = {
|
||||
{ JavaPathExistsAndWritableRow, Tr::tr("JDK path exists and is writable.") },
|
||||
@@ -310,22 +309,22 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
|
||||
connect(m_openJdkLocationPathChooser, &PathChooser::rawPathChanged,
|
||||
this, &AndroidSettingsWidget::validateJdk);
|
||||
if (m_androidConfig.openJDKLocation().isEmpty())
|
||||
m_androidConfig.setOpenJDKLocation(AndroidConfig::getJdkPath());
|
||||
m_openJdkLocationPathChooser->setFilePath(m_androidConfig.openJDKLocation());
|
||||
if (androidConfig().openJDKLocation().isEmpty())
|
||||
androidConfig().setOpenJDKLocation(AndroidConfig::getJdkPath());
|
||||
m_openJdkLocationPathChooser->setFilePath(androidConfig().openJDKLocation());
|
||||
m_openJdkLocationPathChooser->setPromptDialogTitle(Tr::tr("Select JDK Path"));
|
||||
|
||||
if (m_androidConfig.sdkLocation().isEmpty())
|
||||
m_androidConfig.setSdkLocation(AndroidConfig::defaultSdkPath());
|
||||
m_sdkLocationPathChooser->setFilePath(m_androidConfig.sdkLocation());
|
||||
if (androidConfig().sdkLocation().isEmpty())
|
||||
androidConfig().setSdkLocation(AndroidConfig::defaultSdkPath());
|
||||
m_sdkLocationPathChooser->setFilePath(androidConfig().sdkLocation());
|
||||
m_sdkLocationPathChooser->setPromptDialogTitle(Tr::tr("Select Android SDK Folder"));
|
||||
|
||||
m_openSslPathChooser->setPromptDialogTitle(Tr::tr("Select OpenSSL Include Project File"));
|
||||
if (m_androidConfig.openSslLocation().isEmpty())
|
||||
m_androidConfig.setOpenSslLocation(m_androidConfig.sdkLocation() / ("android_openssl"));
|
||||
m_openSslPathChooser->setFilePath(m_androidConfig.openSslLocation());
|
||||
if (androidConfig().openSslLocation().isEmpty())
|
||||
androidConfig().setOpenSslLocation(androidConfig().sdkLocation() / ("android_openssl"));
|
||||
m_openSslPathChooser->setFilePath(androidConfig().openSslLocation());
|
||||
|
||||
m_createKitCheckBox->setChecked(m_androidConfig.automaticKitCreation());
|
||||
m_createKitCheckBox->setChecked(androidConfig().automaticKitCreation());
|
||||
|
||||
downloadNdkToolButton->setIcon(downloadIcon);
|
||||
|
||||
@@ -384,21 +383,21 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
connect(m_ndkListWidget, &QListWidget::currentTextChanged,
|
||||
this, [this, removeCustomNdkButton](const QString &ndk) {
|
||||
updateUI();
|
||||
removeCustomNdkButton->setEnabled(m_androidConfig.getCustomNdkList().contains(ndk));
|
||||
removeCustomNdkButton->setEnabled(androidConfig().getCustomNdkList().contains(ndk));
|
||||
});
|
||||
connect(addCustomNdkButton, &QPushButton::clicked, this,
|
||||
&AndroidSettingsWidget::addCustomNdkItem);
|
||||
connect(removeCustomNdkButton, &QPushButton::clicked, this, [this] {
|
||||
if (isDefaultNdkSelected())
|
||||
m_androidConfig.setDefaultNdk({});
|
||||
m_androidConfig.removeCustomNdk(m_ndkListWidget->currentItem()->text());
|
||||
androidConfig().setDefaultNdk({});
|
||||
androidConfig().removeCustomNdk(m_ndkListWidget->currentItem()->text());
|
||||
m_ndkListWidget->takeItem(m_ndkListWidget->currentRow());
|
||||
});
|
||||
connect(m_makeDefaultNdkButton, &QPushButton::clicked, this, [this] {
|
||||
const FilePath defaultNdk = isDefaultNdkSelected()
|
||||
? FilePath()
|
||||
: FilePath::fromUserInput(m_ndkListWidget->currentItem()->text());
|
||||
m_androidConfig.setDefaultNdk(defaultNdk);
|
||||
androidConfig().setDefaultNdk(defaultNdk);
|
||||
updateUI();
|
||||
});
|
||||
|
||||
@@ -433,7 +432,7 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
});
|
||||
connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkExtracted, this, [this] {
|
||||
// Make sure the sdk path is created before installing packages
|
||||
const FilePath sdkPath = m_androidConfig.sdkLocation();
|
||||
const FilePath sdkPath = androidConfig().sdkLocation();
|
||||
if (!sdkPath.createDir()) {
|
||||
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
||||
Tr::tr("Failed to create the SDK Tools path %1.")
|
||||
@@ -452,7 +451,7 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
});
|
||||
});
|
||||
|
||||
setOnApply([this] { AndroidConfigurations::setConfig(m_androidConfig); });
|
||||
setOnApply([this] { AndroidConfigurations::setConfig(androidConfig()); });
|
||||
}
|
||||
|
||||
AndroidSettingsWidget::~AndroidSettingsWidget()
|
||||
@@ -484,12 +483,12 @@ void AndroidSettingsWidget::updateNdkList()
|
||||
ndk->installedLocation().toUserOutput()));
|
||||
}
|
||||
|
||||
const auto customNdks = m_androidConfig.getCustomNdkList();
|
||||
const auto customNdks = androidConfig().getCustomNdkList();
|
||||
for (const QString &ndk : customNdks) {
|
||||
if (m_androidConfig.isValidNdk(ndk)) {
|
||||
if (androidConfig().isValidNdk(ndk)) {
|
||||
m_ndkListWidget->addItem(new QListWidgetItem(Icons::UNLOCKED.icon(), ndk));
|
||||
} else {
|
||||
m_androidConfig.removeCustomNdk(ndk);
|
||||
androidConfig().removeCustomNdk(ndk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,8 +503,8 @@ void AndroidSettingsWidget::addCustomNdkItem()
|
||||
.constFirst();
|
||||
const QString ndkPath = QFileDialog::getExistingDirectory(this, Tr::tr("Select an NDK"), homePath);
|
||||
|
||||
if (m_androidConfig.isValidNdk(ndkPath)) {
|
||||
m_androidConfig.addCustomNdk(ndkPath);
|
||||
if (androidConfig().isValidNdk(ndkPath)) {
|
||||
androidConfig().addCustomNdk(ndkPath);
|
||||
if (m_ndkListWidget->findItems(ndkPath, Qt::MatchExactly).size() == 0) {
|
||||
m_ndkListWidget->addItem(new QListWidgetItem(Icons::UNLOCKED.icon(), ndkPath));
|
||||
}
|
||||
@@ -523,9 +522,9 @@ void AndroidSettingsWidget::addCustomNdkItem()
|
||||
|
||||
bool AndroidSettingsWidget::isDefaultNdkSelected() const
|
||||
{
|
||||
if (!m_androidConfig.defaultNdk().isEmpty()) {
|
||||
if (!androidConfig().defaultNdk().isEmpty()) {
|
||||
if (const QListWidgetItem *item = m_ndkListWidget->currentItem()) {
|
||||
return FilePath::fromUserInput(item->text()) == m_androidConfig.defaultNdk();
|
||||
return FilePath::fromUserInput(item->text()) == androidConfig().defaultNdk();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -533,9 +532,9 @@ bool AndroidSettingsWidget::isDefaultNdkSelected() const
|
||||
|
||||
void AndroidSettingsWidget::validateJdk()
|
||||
{
|
||||
m_androidConfig.setOpenJDKLocation(m_openJdkLocationPathChooser->filePath());
|
||||
bool jdkPathExists = m_androidConfig.openJDKLocation().exists();
|
||||
const FilePath bin = m_androidConfig.openJDKLocation()
|
||||
androidConfig().setOpenJDKLocation(m_openJdkLocationPathChooser->filePath());
|
||||
bool jdkPathExists = androidConfig().openJDKLocation().exists();
|
||||
const FilePath bin = androidConfig().openJDKLocation()
|
||||
.pathAppended("bin/javac" QTC_HOST_EXE_SUFFIX);
|
||||
m_androidSummary->setPointValid(JavaPathExistsAndWritableRow, jdkPathExists && bin.exists());
|
||||
|
||||
@@ -547,14 +546,14 @@ void AndroidSettingsWidget::validateJdk()
|
||||
|
||||
void AndroidSettingsWidget::validateOpenSsl()
|
||||
{
|
||||
m_androidConfig.setOpenSslLocation(m_openSslPathChooser->filePath());
|
||||
androidConfig().setOpenSslLocation(m_openSslPathChooser->filePath());
|
||||
|
||||
m_openSslSummary->setPointValid(OpenSslPathExistsRow, m_androidConfig.openSslLocation().exists());
|
||||
m_openSslSummary->setPointValid(OpenSslPathExistsRow, androidConfig().openSslLocation().exists());
|
||||
|
||||
const bool priFileExists = m_androidConfig.openSslLocation().pathAppended("openssl.pri").exists();
|
||||
const bool priFileExists = androidConfig().openSslLocation().pathAppended("openssl.pri").exists();
|
||||
m_openSslSummary->setPointValid(OpenSslPriPathExists, priFileExists);
|
||||
const bool cmakeListsExists
|
||||
= m_androidConfig.openSslLocation().pathAppended("CMakeLists.txt").exists();
|
||||
= androidConfig().openSslLocation().pathAppended("CMakeLists.txt").exists();
|
||||
m_openSslSummary->setPointValid(OpenSslCmakeListsPathExists, cmakeListsExists);
|
||||
|
||||
updateUI();
|
||||
@@ -563,8 +562,8 @@ void AndroidSettingsWidget::validateOpenSsl()
|
||||
void AndroidSettingsWidget::onSdkPathChanged()
|
||||
{
|
||||
const FilePath sdkPath = m_sdkLocationPathChooser->filePath().cleanPath();
|
||||
m_androidConfig.setSdkLocation(sdkPath);
|
||||
FilePath currentOpenSslPath = m_androidConfig.openSslLocation();
|
||||
androidConfig().setSdkLocation(sdkPath);
|
||||
FilePath currentOpenSslPath = androidConfig().openSslLocation();
|
||||
if (currentOpenSslPath.isEmpty() || !currentOpenSslPath.exists())
|
||||
currentOpenSslPath = sdkPath.pathAppended("android_openssl");
|
||||
m_openSslPathChooser->setFilePath(currentOpenSslPath);
|
||||
@@ -575,24 +574,24 @@ void AndroidSettingsWidget::onSdkPathChanged()
|
||||
void AndroidSettingsWidget::validateSdk()
|
||||
{
|
||||
const FilePath sdkPath = m_sdkLocationPathChooser->filePath().cleanPath();
|
||||
m_androidConfig.setSdkLocation(sdkPath);
|
||||
androidConfig().setSdkLocation(sdkPath);
|
||||
|
||||
const FilePath path = m_androidConfig.sdkLocation();
|
||||
const FilePath path = androidConfig().sdkLocation();
|
||||
m_androidSummary->setPointValid(SdkPathExistsAndWritableRow,
|
||||
path.exists() && path.isWritableDir());
|
||||
m_androidSummary->setPointValid(SdkToolsInstalledRow,
|
||||
!m_androidConfig.sdkToolsVersion().isNull());
|
||||
!androidConfig().sdkToolsVersion().isNull());
|
||||
m_androidSummary->setPointValid(PlatformToolsInstalledRow,
|
||||
m_androidConfig.adbToolPath().exists());
|
||||
androidConfig().adbToolPath().exists());
|
||||
m_androidSummary->setPointValid(BuildToolsInstalledRow,
|
||||
!m_androidConfig.buildToolsVersion().isNull());
|
||||
!androidConfig().buildToolsVersion().isNull());
|
||||
m_androidSummary->setPointValid(SdkManagerSuccessfulRow, m_sdkManager.packageListingSuccessful());
|
||||
// installedSdkPlatforms should not trigger a package reload as validate SDK is only called
|
||||
// after AndroidSdkManager::packageReloadFinished.
|
||||
m_androidSummary->setPointValid(PlatformSdkInstalledRow,
|
||||
!m_sdkManager.installedSdkPlatforms().isEmpty());
|
||||
m_androidSummary->setPointValid(AllEssentialsInstalledRow,
|
||||
m_androidConfig.allEssentialsInstalled(&m_sdkManager));
|
||||
androidConfig().allEssentialsInstalled(&m_sdkManager));
|
||||
|
||||
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsAndWritableRow,
|
||||
SdkToolsInstalledRow,
|
||||
@@ -601,7 +600,7 @@ void AndroidSettingsWidget::validateSdk()
|
||||
BuildToolsInstalledRow,
|
||||
PlatformSdkInstalledRow,
|
||||
AllEssentialsInstalledRow});
|
||||
m_androidConfig.setSdkFullyConfigured(sdkToolsOk && componentsOk);
|
||||
androidConfig().setSdkFullyConfigured(sdkToolsOk && componentsOk);
|
||||
if (sdkToolsOk && !componentsOk)
|
||||
m_sdkManagerWidget->installEssentials();
|
||||
|
||||
@@ -712,7 +711,7 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
|
||||
|
||||
void AndroidSettingsWidget::createKitToggled()
|
||||
{
|
||||
m_androidConfig.setAutomaticKitCreation(m_createKitCheckBox->isChecked());
|
||||
androidConfig().setAutomaticKitCreation(m_createKitCheckBox->isChecked());
|
||||
}
|
||||
|
||||
void AndroidSettingsWidget::updateUI()
|
||||
@@ -723,8 +722,8 @@ void AndroidSettingsWidget::updateUI()
|
||||
const QListWidgetItem *currentItem = m_ndkListWidget->currentItem();
|
||||
const FilePath currentNdk = FilePath::fromUserInput(currentItem ? currentItem->text() : "");
|
||||
const QString infoText = Tr::tr("(SDK Version: %1, NDK Version: %2)")
|
||||
.arg(m_androidConfig.sdkToolsVersion().toString())
|
||||
.arg(currentNdk.isEmpty() ? "" : m_androidConfig.ndkVersion(currentNdk).toString());
|
||||
.arg(androidConfig().sdkToolsVersion().toString())
|
||||
.arg(currentNdk.isEmpty() ? "" : androidConfig().ndkVersion(currentNdk).toString());
|
||||
m_androidSummary->setInfoText(androidSetupOk ? infoText : "");
|
||||
|
||||
m_androidSummary->setSetupOk(androidSetupOk);
|
||||
@@ -738,7 +737,7 @@ void AndroidSettingsWidget::updateUI()
|
||||
for (int row = 0; row < m_ndkListWidget->count(); ++row) {
|
||||
QListWidgetItem *item = m_ndkListWidget->item(row);
|
||||
const bool isDefaultNdk =
|
||||
FilePath::fromUserInput(item->text()) == m_androidConfig.defaultNdk();
|
||||
FilePath::fromUserInput(item->text()) == androidConfig().defaultNdk();
|
||||
item->setFont(isDefaultNdk ? markedFont : font);
|
||||
}
|
||||
}
|
||||
@@ -749,7 +748,7 @@ void AndroidSettingsWidget::updateUI()
|
||||
|
||||
void AndroidSettingsWidget::downloadSdk()
|
||||
{
|
||||
if (m_androidConfig.sdkToolsOk()) {
|
||||
if (androidConfig().sdkToolsOk()) {
|
||||
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
||||
Tr::tr("The selected path already has a valid SDK Tools package."));
|
||||
validateSdk();
|
||||
|
@@ -13,7 +13,7 @@ namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidSignalOperation::AndroidSignalOperation()
|
||||
: m_adbPath(AndroidConfigurations::currentConfig().adbToolPath())
|
||||
: m_adbPath(androidConfig().adbToolPath())
|
||||
, m_timeout(new QTimer(this))
|
||||
{
|
||||
m_timeout->setInterval(5000);
|
||||
|
@@ -77,8 +77,7 @@ bool AndroidToolchain::isValid() const
|
||||
}
|
||||
|
||||
const bool isChildofNdk = compilerCommand().isChildOf(m_ndkLocation);
|
||||
const bool isChildofSdk = compilerCommand().isChildOf(
|
||||
AndroidConfigurations::currentConfig().sdkLocation());
|
||||
const bool isChildofSdk = compilerCommand().isChildOf(androidConfig().sdkLocation());
|
||||
|
||||
return GccToolchain::isValid() && typeId() == Constants::ANDROID_TOOLCHAIN_TYPEID
|
||||
&& targetAbi().isValid() && (isChildofNdk || isChildofSdk)
|
||||
@@ -87,7 +86,7 @@ bool AndroidToolchain::isValid() const
|
||||
|
||||
void AndroidToolchain::addToEnvironment(Environment &env) const
|
||||
{
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
const AndroidConfig &config = androidConfig();
|
||||
env.set(QLatin1String("ANDROID_NDK_HOST"), config.toolchainHostFromNdk(m_ndkLocation));
|
||||
const FilePath javaHome = config.openJDKLocation();
|
||||
if (javaHome.exists()) {
|
||||
@@ -119,7 +118,7 @@ QStringList AndroidToolchain::suggestedMkspecList() const
|
||||
FilePath AndroidToolchain::makeCommand(const Environment &env) const
|
||||
{
|
||||
Q_UNUSED(env)
|
||||
FilePath makePath = AndroidConfigurations::currentConfig().makePathFromNdk(m_ndkLocation);
|
||||
FilePath makePath = androidConfig().makePathFromNdk(m_ndkLocation);
|
||||
return makePath.exists() ? makePath : FilePath("make");
|
||||
}
|
||||
|
||||
@@ -141,8 +140,6 @@ static FilePath clangPlusPlusPath(const FilePath &clangPath)
|
||||
|
||||
static FilePaths uniqueNdksForCurrentQtVersions()
|
||||
{
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
|
||||
auto androidQtVersions = QtSupport::QtVersionManager::versions(
|
||||
[](const QtSupport::QtVersion *v) {
|
||||
return v->targetDeviceTypes().contains(Android::Constants::ANDROID_DEVICE_TYPE);
|
||||
@@ -150,7 +147,7 @@ static FilePaths uniqueNdksForCurrentQtVersions()
|
||||
|
||||
FilePaths uniqueNdks;
|
||||
for (const QtSupport::QtVersion *version : androidQtVersions) {
|
||||
FilePath ndk = config.ndkLocation(version);
|
||||
FilePath ndk = androidConfig().ndkLocation(version);
|
||||
if (!uniqueNdks.contains(ndk))
|
||||
uniqueNdks.append(ndk);
|
||||
}
|
||||
@@ -164,7 +161,7 @@ ToolchainList autodetectToolchainsFromNdks(
|
||||
const bool isCustom)
|
||||
{
|
||||
QList<Toolchain *> result;
|
||||
const AndroidConfig config = AndroidConfigurations::currentConfig();
|
||||
const AndroidConfig config = androidConfig();
|
||||
|
||||
const Id LanguageIds[] {
|
||||
ProjectExplorer::Constants::CXX_LANGUAGE_ID,
|
||||
|
@@ -34,12 +34,9 @@ namespace Android::Internal {
|
||||
|
||||
static Q_LOGGING_CATEGORY(avdDialogLog, "qtc.android.avdDialog", QtWarningMsg)
|
||||
|
||||
|
||||
AvdDialog::AvdDialog(const AndroidConfig &config, QWidget *parent)
|
||||
AvdDialog::AvdDialog(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
m_allowedNameChars(QLatin1String("[a-z|A-Z|0-9|._-]*")),
|
||||
m_androidConfig(config),
|
||||
m_sdkManager(m_androidConfig)
|
||||
m_allowedNameChars(QLatin1String("[a-z|A-Z|0-9|._-]*"))
|
||||
{
|
||||
resize(800, 0);
|
||||
setWindowTitle(Tr::tr("Create new AVD"));
|
||||
@@ -129,7 +126,7 @@ int AvdDialog::exec()
|
||||
result.sdcardSize = sdcardSize();
|
||||
result.overwrite = m_overwriteCheckBox->isChecked();
|
||||
|
||||
const AndroidAvdManager avdManager = AndroidAvdManager(m_androidConfig);
|
||||
const AndroidAvdManager avdManager;
|
||||
QFutureWatcher<CreateAvdInfo> createAvdFutureWatcher;
|
||||
|
||||
QEventLoop loop;
|
||||
@@ -190,9 +187,9 @@ void AvdDialog::parseDeviceDefinitionsList()
|
||||
{
|
||||
QString output;
|
||||
|
||||
if (!AndroidAvdManager::avdManagerCommand(m_androidConfig, {"list", "device"}, &output)) {
|
||||
if (!AndroidAvdManager::avdManagerCommand({"list", "device"}, &output)) {
|
||||
qCDebug(avdDialogLog) << "Avd list command failed" << output
|
||||
<< m_androidConfig.sdkToolsVersion();
|
||||
<< androidConfig().sdkToolsVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class AndroidSdkManager;
|
||||
class AvdDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
explicit AvdDialog(const AndroidConfig &config, QWidget *parent = nullptr);
|
||||
explicit AvdDialog(QWidget *parent = nullptr);
|
||||
int exec() override;
|
||||
|
||||
enum DeviceType { Phone, Tablet, Automotive, TV, Wear, PhoneOrTablet };
|
||||
@@ -63,7 +63,6 @@ private:
|
||||
QTimer m_hideTipTimer;
|
||||
QRegularExpression m_allowedNameChars;
|
||||
QList<DeviceDefinitionStruct> m_deviceDefinitionsList;
|
||||
const AndroidConfig &m_androidConfig;
|
||||
AndroidSdkManager m_sdkManager;
|
||||
QMap<AvdDialog::DeviceType, QString> m_deviceTypeToStringMap;
|
||||
|
||||
|
@@ -308,7 +308,7 @@ void JLSClient::updateProjectFiles()
|
||||
|
||||
const QStringList classPaths = node->data(Constants::AndroidClassPaths).toStringList();
|
||||
|
||||
const FilePath &sdkLocation = AndroidConfigurations::currentConfig().sdkLocation();
|
||||
const FilePath &sdkLocation = androidConfig().sdkLocation();
|
||||
const QString &targetSDK = AndroidManager::buildTargetSDK(m_currentTarget);
|
||||
const FilePath androidJar = sdkLocation / QString("platforms/%2/android.jar")
|
||||
.arg(targetSDK);
|
||||
|
Reference in New Issue
Block a user