summaryrefslogtreecommitdiff
path: root/src/plugins/android/androidsdkdownloader.cpp
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2020-11-28 15:44:37 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2022-03-17 20:45:07 +0000
commit5454dda2492f388f17e842f50e7c0731772c647f (patch)
tree034d62bdb5033db604cb2241ca2a4773f24e07ca /src/plugins/android/androidsdkdownloader.cpp
parent188544052c17879cf711d1d2e20a3ae59d4f714f (diff)
downloadqt-creator-5454dda2492f388f17e842f50e7c0731772c647f.tar.gz
Android: keep up with sdk tools changing folder structure
The cmdline-tools package used to have the folder structure "tools/bin". However, latest packages are using the structure "cmdline-tools/bin". And since subsequent updates we are installing "cmdline-tools;latest" package, it will be put in "cmdline-tools/latest" folder, so we cannot extract to that path, or otherwise sdkmanager will complain that the path is in use. Currently we extract it and put it under the SDK path, then use it to install the essential packages, then it won't be used at all. This patch changes that by extracting the downloaded package into a temporary location, and use sdkmanager from there directly. Also, this patch updates the links to the cmdline-tools along the way. Fixes: QTCREATORBUG-27174 Change-Id: I1f5d0e38f5a026631e8a3852821d85a69d543c32 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/android/androidsdkdownloader.cpp')
-rw-r--r--src/plugins/android/androidsdkdownloader.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/plugins/android/androidsdkdownloader.cpp b/src/plugins/android/androidsdkdownloader.cpp
index c9512b464a..91319cb8a9 100644
--- a/src/plugins/android/androidsdkdownloader.cpp
+++ b/src/plugins/android/androidsdkdownloader.cpp
@@ -25,6 +25,8 @@
#include "androidsdkdownloader.h"
+#include "androidconstants.h"
+
#include <utils/archive.h>
#include <utils/filepath.h>
@@ -61,7 +63,7 @@ void AndroidSdkDownloader::sslErrors(const QList<QSslError> &sslErrors)
}
#endif
-void AndroidSdkDownloader::downloadAndExtractSdk(const FilePath &sdkExtractPath)
+void AndroidSdkDownloader::downloadAndExtractSdk()
{
if (m_androidConfig.sdkToolsUrl().isEmpty()) {
logError(tr("The SDK Tools download URL is empty."));
@@ -88,11 +90,17 @@ void AndroidSdkDownloader::downloadAndExtractSdk(const FilePath &sdkExtractPath)
connect(m_progressDialog, &QProgressDialog::canceled, this, &AndroidSdkDownloader::cancel);
- connect(this, &AndroidSdkDownloader::sdkPackageWriteFinished, this, [this, sdkExtractPath]() {
- if (Archive *archive = Archive::unarchive(m_sdkFilename, sdkExtractPath)) {
- connect(archive, &Archive::finished, [this, sdkExtractPath](bool success){
- if (success)
+ connect(this, &AndroidSdkDownloader::sdkPackageWriteFinished, this, [this]() {
+ const FilePath extractDir = m_sdkFilename.parentDir();
+ if (Archive *archive = Archive::unarchive(m_sdkFilename, extractDir)) {
+ connect(archive, &Archive::finished, [this, extractDir](bool success) {
+ if (success) {
+ // Save the extraction path temporarily which can be used by sdkmanager
+ // to install essential packages at firt time setup.
+ m_androidConfig.setTemporarySdkToolsPath(
+ extractDir.pathAppended(Constants::cmdlineToolsName));
emit sdkExtracted();
+ }
});
}
});
@@ -153,7 +161,7 @@ FilePath AndroidSdkDownloader::getSaveFilename(const QUrl &url)
basename += QString::number(i);
}
- return FilePath::fromString(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation))
+ return FilePath::fromString(QStandardPaths::writableLocation(QStandardPaths::TempLocation))
/ basename;
}