From 5454dda2492f388f17e842f50e7c0731772c647f Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Sat, 28 Nov 2020 15:44:37 +0200 Subject: 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 --- src/plugins/android/androidsdkdownloader.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/plugins/android/androidsdkdownloader.cpp') 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 #include @@ -61,7 +63,7 @@ void AndroidSdkDownloader::sslErrors(const QList &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; } -- cgit v1.2.1