forked from qt-creator/qt-creator
Android: Automatically download SDK tools and essential packages
Automatically download Android SDK Tools to default path used by Android Studio, then essential packages will be installed using the sdkmanager tool. Automatic installation can also be triggered by an added button in the settings page. Essentials packages include NDK Bundle and other NDK versions required by previous Qt versions. An sdk_definitions.json file holds download paths for SDK Tools, and other (Qt version <-> essential packages) combinations. [ChangeLog][Android] Automatically download SDK Tools, NDKs and all essential packages for Android builds. Task-number: QTCREATORBUG-23285 Change-Id: I90e7aafecd017d2bdc959e403711d9d440a6bbb2 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -273,37 +273,44 @@ bool AndroidSdkModel::setData(const QModelIndex &index, const QVariant &value, i
|
||||
void AndroidSdkModel::selectMissingEssentials()
|
||||
{
|
||||
resetSelection();
|
||||
bool selectPlatformTool = !m_config.adbToolPath().exists();
|
||||
bool selectBuildTools = m_config.buildToolsVersion().isNull();
|
||||
QStringList pendingPkgs(m_config.allEssentials());
|
||||
auto addTool = [this](QList<const AndroidSdkPackage *>::const_iterator itr) {
|
||||
m_changeState << *itr;
|
||||
auto i = index(std::distance(m_tools.cbegin(), itr), 0, index(0, 0));
|
||||
emit dataChanged(i, i, {Qt::CheckStateRole});
|
||||
if ((*itr)->installedLocation().isEmpty()) {
|
||||
m_changeState << *itr;
|
||||
auto i = index(std::distance(m_tools.cbegin(), itr), 0, index(0, 0));
|
||||
emit dataChanged(i, i, {Qt::CheckStateRole});
|
||||
}
|
||||
};
|
||||
for (auto tool = m_tools.cbegin(); tool != m_tools.cend(); ++tool) {
|
||||
if (selectPlatformTool && (*tool)->type() == AndroidSdkPackage::PlatformToolsPackage) {
|
||||
// Select Platform tools
|
||||
addTool(tool);
|
||||
selectPlatformTool = false;
|
||||
}
|
||||
if (selectBuildTools && (*tool)->type() == AndroidSdkPackage::BuildToolsPackage) {
|
||||
// Select build tools
|
||||
addTool(tool);
|
||||
selectBuildTools = false;
|
||||
}
|
||||
if (!selectPlatformTool && !selectBuildTools)
|
||||
if (!pendingPkgs.contains((*tool)->sdkStylePath()))
|
||||
continue;
|
||||
|
||||
if ((*tool)->type() == AndroidSdkPackage::PlatformToolsPackage)
|
||||
addTool(tool); // Select Platform tools
|
||||
else if ((*tool)->type() == AndroidSdkPackage::BuildToolsPackage)
|
||||
addTool(tool); // Select build tools
|
||||
else if ((*tool)->type() == AndroidSdkPackage::NDKPackage)
|
||||
addTool(tool); // Select NDK Bundle
|
||||
|
||||
pendingPkgs.removeOne((*tool)->sdkStylePath());
|
||||
if (pendingPkgs.isEmpty())
|
||||
break;
|
||||
}
|
||||
|
||||
// Select SDK platform
|
||||
if (m_sdkManager->installedSdkPlatforms().isEmpty() && !m_sdkPlatforms.isEmpty()) {
|
||||
auto i = index(0, 0, index(1,0));
|
||||
m_changeState << m_sdkPlatforms.at(0);
|
||||
emit dataChanged(i , i, {Qt::CheckStateRole});
|
||||
for (const SdkPlatform *platform : m_sdkPlatforms) {
|
||||
if (pendingPkgs.contains(platform->sdkStylePath()) &&
|
||||
platform->installedLocation().isEmpty()) {
|
||||
auto i = index(0, 0, index(1, 0));
|
||||
m_changeState << platform;
|
||||
emit dataChanged(i, i, {Qt::CheckStateRole});
|
||||
pendingPkgs.removeOne(platform->sdkStylePath());
|
||||
}
|
||||
if (pendingPkgs.isEmpty())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList<const AndroidSdkPackage *> AndroidSdkModel::userSelection() const
|
||||
{
|
||||
return Utils::toList(m_changeState);
|
||||
|
||||
Reference in New Issue
Block a user