Files
qt-creator/src/plugins/android/androidsdkdownloader.h
Assam Boudjelthia 5454dda249 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>
2022-03-17 20:45:07 +00:00

81 lines
2.4 KiB
C++

/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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
** 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.
**
** 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.
**
****************************************************************************/
#ifndef ANDROIDSDKDOWNLOADER_H
#define ANDROIDSDKDOWNLOADER_H
#include "androidconfigurations.h"
#include <QNetworkReply>
#include <QObject>
#include <QProgressDialog>
namespace Utils { class FilePath; }
namespace Android {
namespace Internal {
class AndroidSdkDownloader : public QObject
{
Q_OBJECT
public:
AndroidSdkDownloader();
void downloadAndExtractSdk();
static QString dialogTitle();
void cancel();
signals:
void sdkPackageWriteFinished();
void sdkExtracted();
void sdkDownloaderError(const QString &error);
private:
static Utils::FilePath getSaveFilename(const QUrl &url);
bool saveToDisk(const Utils::FilePath &filename, QIODevice *data);
static bool isHttpRedirect(QNetworkReply *m_reply);
bool verifyFileIntegrity();
void cancelWithError(const QString &error);
void logError(const QString &error);
void downloadFinished(QNetworkReply *m_reply);
#if QT_CONFIG(ssl)
void sslErrors(const QList<QSslError> &errors);
#endif
QNetworkAccessManager m_manager;
QNetworkReply *m_reply = nullptr;
Utils::FilePath m_sdkFilename;
QProgressDialog *m_progressDialog = nullptr;
AndroidConfig &m_androidConfig;
};
} // Internal
} // Android
#endif // ANDROIDSDKDOWNLOADER_H