Compare commits

..
14 changed files with 191 additions and 74 deletions

No files matched your search

+11 -27
View File
@@ -1695,21 +1695,13 @@ jobs:
# ------------------------------------------------------
Pre-Release:
if: ${{ always() && startsWith(github.ref, 'refs/tags/') }}
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}
needs: [Build-Linux-Ubuntu, Build-Windows, Build-iOS, Build-MacOS, Build-MacOS-NE, Build-Android]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: 'Check builds'
working-directory: .
env:
NEEDS: ${{ toJSON(needs) }}
run: |
jq -c 'map_values(.result)' <<< "$NEEDS"
jq -e 'all(.[]; .result == "success" or .result == "skipped")' <<< "$NEEDS"
- name: 'Get release notes template'
uses: actions/checkout@v4
with:
@@ -1730,6 +1722,14 @@ jobs:
path: dist
merge-multiple: true
- name: 'Compute SHA-256 checksums'
working-directory: dist
run: |
for f in *; do
sha256sum "$f" > "$f.sha256"
done
cat *.sha256
- name: 'Publish pre-release'
env:
GH_TOKEN: ${{ github.token }}
@@ -1750,7 +1750,7 @@ jobs:
# ------------------------------------------------------
TestFlight:
if: ${{ always() && startsWith(github.ref, 'refs/tags/') }}
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}
needs: [Build-Linux-Ubuntu, Build-Windows, Build-iOS, Build-MacOS, Build-MacOS-NE, Build-Android]
runs-on: macos-26
@@ -1765,14 +1765,6 @@ jobs:
shell: bash
steps:
- name: 'Check builds'
working-directory: .
env:
NEEDS: ${{ toJSON(needs) }}
run: |
jq -c 'map_values(.result)' <<< "$NEEDS"
jq -e 'all(.[]; .result == "success" or .result == "skipped")' <<< "$NEEDS"
- name: 'Get fastlane config'
uses: actions/checkout@v4
with:
@@ -1802,7 +1794,7 @@ jobs:
# ------------------------------------------------------
Google-Play:
if: ${{ always() && startsWith(github.ref, 'refs/tags/') }}
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}
needs: [Build-Linux-Ubuntu, Build-Windows, Build-iOS, Build-MacOS, Build-MacOS-NE, Build-Android]
runs-on: ubuntu-24.04
@@ -1812,14 +1804,6 @@ jobs:
shell: bash
steps:
- name: 'Check builds'
working-directory: .
env:
NEEDS: ${{ toJSON(needs) }}
run: |
jq -c 'map_values(.result)' <<< "$NEEDS"
jq -e 'all(.[]; .result == "success" or .result == "skipped")' <<< "$NEEDS"
- name: 'Get fastlane config'
uses: actions/checkout@v4
with:
+2 -2
View File
@@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PROJECT AmneziaVPN)
if(NOT AMNEZIAVPN_VERSION)
set(AMNEZIAVPN_VERSION 5.1.1.10 CACHE STRING "Client app version")
set(AMNEZIAVPN_VERSION 5.1.1.6 CACHE STRING "Client app version")
endif()
set(QT_CREATOR_SKIP_PACKAGE_MANAGER_SETUP ON CACHE BOOL "" FORCE)
@@ -34,7 +34,7 @@ set(RELEASE_DATE "${CURRENT_DATE}")
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
# bump by 2 on every release, because we're releasing two versions on the play store
set(APP_ANDROID_VERSION_CODE 2194)
set(APP_ANDROID_VERSION_CODE 2192)
if(DEFINED APP_ANDROID_VERSION_CODE_OFFSET)
math(EXPR APP_ANDROID_VERSION_CODE "${APP_ANDROID_VERSION_CODE} + ${APP_ANDROID_VERSION_CODE_OFFSET}")
endif()
+1
View File
@@ -98,6 +98,7 @@ android {
}
getByName("oss") {
manifest.srcFile("oss/AndroidManifest.xml")
java.setSrcDirs(listOf("oss"))
}
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</manifest>
@@ -806,6 +806,29 @@ class AmneziaActivity : QtActivity() {
}
}
@Suppress("unused")
fun installApk(path: String) {
Log.d(TAG, "Install apk $path")
mainScope.launch {
val uri = try {
FileProvider.getUriForFile(this@AmneziaActivity, FILE_PROVIDER_AUTHORITY, File(path))
} catch (e: IllegalArgumentException) {
Log.e(TAG, "Failed to install apk $path: $e")
return@launch
}
Intent(Intent.ACTION_VIEW).apply {
setDataAndType(uri, "application/vnd.android.package-archive")
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}.also {
try {
startActivity(it)
} catch (_: ActivityNotFoundException) {
Toast.makeText(this@AmneziaActivity, "Unsupported", Toast.LENGTH_LONG).show()
}
}
}
}
@Suppress("unused")
fun openFile(filter: String?) {
Log.v(TAG, "Open file with filter: $filter")
+121 -36
View File
@@ -1,12 +1,16 @@
#include "updateController.h"
#include <QCryptographicHash>
#include <QDesktopServices>
#include <QDir>
#include <QFileInfo>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkReply>
#include <QTimer>
#include <QUrl>
#include <QStandardPaths>
#include "amneziaApplication.h"
#include "logger.h"
@@ -18,6 +22,8 @@
#include "core/utils/selfhosted/scriptsRegistry.h"
#if defined(Q_OS_ANDROID)
#include <QOperatingSystemVersion>
#include "platforms/android/android_controller.h"
#endif
@@ -26,14 +32,73 @@ namespace
Logger logger("UpdateController");
#if defined(Q_OS_WINDOWS)
const QLatin1String kInstallerRemoteFileNamePattern("AmneziaVPN_%1_windows_x64.exe");
const QString kInstallerLocalPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN_installer.exe";
QString installerRemoteFileName(const QString &version)
{
return QStringLiteral("AmneziaVPN_%1_windows_x64.exe").arg(version);
}
QString installerLocalPath()
{
return QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN_installer.exe";
}
#elif defined(Q_OS_MACOS) && !defined(MACOS_NE)
const QLatin1String kInstallerRemoteFileNamePattern("AmneziaVPN_%1_macos_x64.pkg");
const QString kInstallerLocalPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.pkg";
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
const QLatin1String kInstallerRemoteFileNamePattern("AmneziaVPN_%1_linux_x64.run");
const QString kInstallerLocalPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.run";
QString installerRemoteFileName(const QString &version)
{
return QStringLiteral("AmneziaVPN_%1_macos_x64.pkg").arg(version);
}
QString installerLocalPath()
{
return QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.pkg";
}
#elif defined(Q_OS_ANDROID)
#if defined(Q_PROCESSOR_ARM_64)
const QLatin1String kAndroidAbi("arm64-v8a");
#elif defined(Q_PROCESSOR_ARM_32)
const QLatin1String kAndroidAbi("armeabi-v7a");
#elif defined(Q_PROCESSOR_X86_64)
const QLatin1String kAndroidAbi("x86_64");
#elif defined(Q_PROCESSOR_X86_32)
const QLatin1String kAndroidAbi("x86");
#endif
QString installerRemoteFileName(const QString &version)
{
const QLatin1String osLabel = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Android11
? QLatin1String("android11+")
: QLatin1String("android9-10");
return QStringLiteral("AmneziaVPN_%1_%2_%3.apk").arg(version, osLabel, kAndroidAbi);
}
QString installerLocalPath()
{
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/update/AmneziaVPN.apk";
}
bool isSha256Hex(const QByteArray &hash)
{
return hash.size() == 64 && QByteArray::fromHex(hash).toHex() == hash;
}
#elif defined(Q_OS_LINUX)
QString installerRemoteFileName(const QString &version)
{
return QStringLiteral("AmneziaVPN_%1_linux_x64.run").arg(version);
}
QString installerLocalPath()
{
return QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.run";
}
#endif
#if !defined(Q_OS_IOS) && !defined(MACOS_NE)
QNetworkReply *requestDownload(const QString &url)
{
QNetworkRequest request;
request.setTransferTimeout(30000);
request.setUrl(QUrl(url));
return amnApp->networkManager()->get(request);
}
#endif
QStringList stringListFromJsonValue(const QJsonValue &value)
@@ -176,7 +241,14 @@ void UpdateController::checkForUpdates()
if (m_downloadBaseUrl.endsWith('/')) {
m_downloadBaseUrl.chop(1);
}
m_releasePageUrl = gatewayData.value(apiDefs::key::releasePageUrl).toString();
#if defined(Q_OS_ANDROID)
m_installerSha256 = gatewayData.value(apiDefs::key::checksums)
.toObject()
.value(installerRemoteFileName(m_version))
.toString()
.toLower()
.toLatin1();
#endif
if (m_version.isEmpty()) {
logger.error() << "Update response has no version, ignoring";
@@ -210,27 +282,18 @@ void UpdateController::startUpdate()
return;
}
#if defined(Q_OS_ANDROID)
// GitHub build on Android: open the release page in a browser, the system downloads the APK.
if (m_releasePageUrl.isEmpty()) {
logger.error() << "Release page URL is empty";
setUpdateState(UpdateState::State::DownloadError);
return;
}
QDesktopServices::openUrl(QUrl(m_releasePageUrl));
#elif !defined(Q_OS_IOS) && !defined(MACOS_NE)
#if !defined(Q_OS_IOS) && !defined(MACOS_NE)
downloadInstaller();
#endif
}
QString UpdateController::composeDownloadUrl() const
{
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE)
#if !defined(Q_OS_IOS) && !defined(MACOS_NE)
if (m_downloadBaseUrl.isEmpty() || m_version.isEmpty()) {
return QString();
}
const QString fileName = QString(kInstallerRemoteFileNamePattern).arg(m_version);
return m_downloadBaseUrl + "/" + fileName;
return m_downloadBaseUrl + "/" + QString::fromLatin1(QUrl::toPercentEncoding(installerRemoteFileName(m_version)));
#else
return QString();
#endif
@@ -238,7 +301,7 @@ QString UpdateController::composeDownloadUrl() const
void UpdateController::downloadInstaller()
{
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE)
#if !defined(Q_OS_IOS) && !defined(MACOS_NE)
if (m_updateState == UpdateState::State::Downloading) {
return;
}
@@ -250,15 +313,25 @@ void UpdateController::downloadInstaller()
return;
}
#if defined(Q_OS_ANDROID)
if (!isSha256Hex(m_installerSha256)) {
logger.error() << "Update response has no valid checksum for the installer";
setUpdateState(UpdateState::State::DownloadError);
return;
}
#endif
setUpdateState(UpdateState::State::Downloading);
downloadInstallerFile(downloadUrl, m_installerSha256);
#endif
}
QNetworkRequest request;
request.setTransferTimeout(30000);
request.setUrl(QUrl(downloadUrl));
void UpdateController::downloadInstallerFile(const QString &downloadUrl, const QByteArray &expectedSha256)
{
#if !defined(Q_OS_IOS) && !defined(MACOS_NE)
QNetworkReply *reply = requestDownload(downloadUrl);
QNetworkReply *reply = amnApp->networkManager()->get(request);
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() {
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, expectedSha256]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
@@ -269,16 +342,26 @@ void UpdateController::downloadInstaller()
return;
}
QFile file(kInstallerLocalPath);
const QByteArray data = reply->readAll();
if (!expectedSha256.isEmpty() && QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex() != expectedSha256) {
logger.error() << "Installer checksum mismatch";
setUpdateState(UpdateState::State::DownloadError);
return;
}
const QString localPath = installerLocalPath();
QDir().mkpath(QFileInfo(localPath).absolutePath());
QFile file(localPath);
if (!file.open(QIODevice::WriteOnly)) {
logger.error() << "Failed to open installer file for writing:" << kInstallerLocalPath
logger.error() << "Failed to open installer file for writing:" << localPath
<< "Error:" << file.errorString();
setUpdateState(UpdateState::State::DownloadError);
return;
}
if (file.write(reply->readAll()) == -1) {
logger.error() << "Failed to write installer data to file:" << kInstallerLocalPath
if (file.write(data) == -1) {
logger.error() << "Failed to write installer data to file:" << localPath
<< "Error:" << file.errorString();
file.close();
setUpdateState(UpdateState::State::DownloadError);
@@ -293,18 +376,20 @@ void UpdateController::downloadInstaller()
void UpdateController::installUpdate()
{
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE)
#if !defined(Q_OS_IOS) && !defined(MACOS_NE)
if (m_updateState != UpdateState::State::ReadyToInstall) {
logger.error() << "Installer is not downloaded yet";
return;
}
#if defined(Q_OS_WINDOWS)
runWindowsInstaller(kInstallerLocalPath);
runWindowsInstaller(installerLocalPath());
#elif defined(Q_OS_MACOS) && !defined(MACOS_NE)
runMacInstaller(kInstallerLocalPath);
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
runLinuxInstaller(kInstallerLocalPath);
runMacInstaller(installerLocalPath());
#elif defined(Q_OS_ANDROID)
AndroidController::instance()->installApk(installerLocalPath());
#elif defined(Q_OS_LINUX)
runLinuxInstaller(installerLocalPath());
#endif
#endif
}
+2 -1
View File
@@ -58,6 +58,7 @@ private:
void setUpdateState(UpdateState::State state);
void setUpdateCheckRunning(bool running);
void downloadInstaller();
void downloadInstallerFile(const QString &downloadUrl, const QByteArray &expectedSha256);
QString composeDownloadUrl() const;
void openStorePage() const;
@@ -71,7 +72,7 @@ private:
QStringList m_improvements;
QStringList m_bugFixes;
QString m_downloadBaseUrl;
QString m_releasePageUrl;
QByteArray m_installerSha256;
UpdateState::State m_updateState = UpdateState::State::Idle;
bool m_updateCheckRunning = false;
+1 -1
View File
@@ -92,7 +92,7 @@ namespace apiDefs
constexpr QLatin1String improvements("improvements");
constexpr QLatin1String bugFixes("bug_fixes");
constexpr QLatin1String downloadBaseUrl("download_base_url");
constexpr QLatin1String releasePageUrl("release_page_url");
constexpr QLatin1String checksums("checksums");
constexpr QLatin1String publicKeyInfo("public_key");
constexpr QLatin1String publicKey("public_key");
@@ -65,8 +65,13 @@ namespace amnezia
"www.bing.com",
"www.samsung.com",
"www.nvidia.com",
"www.cisco.com",
"www.asus.com",
"www.logitech.com",
"www.dropbox.com",
"www.mozilla.org",
"addons.mozilla.org",
"www.speedtest.net",
};
constexpr char defaultPort[] = "443";
@@ -202,6 +202,11 @@ void AndroidController::shareFile(const QString &path, const QString &mime)
QJniObject::fromString(mime).object<jstring>());
}
void AndroidController::installApk(const QString &path)
{
callActivityMethod("installApk", "(Ljava/lang/String;)V", QJniObject::fromString(path).object<jstring>());
}
QString AndroidController::openFile(const QString &filter)
{
QEventLoop wait;
@@ -36,6 +36,7 @@ public:
void saveFile(const QString &fileName, const QString &data);
bool saveFile(const QString &fileName, const QByteArray &data, const QString &mime, bool *cancelled = nullptr);
void shareFile(const QString &path, const QString &mime);
void installApk(const QString &path);
QString openFile(const QString &filter);
int getFd(const QString &fileName);
void closeFd();
+4 -3
View File
@@ -81,8 +81,9 @@ class ScreenProtection {
public func enable(for view: UIView) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
guard self.pairs.isEmpty else { return }
self.pairs.append(ProtectionPair(from: view))
view.subviews.forEach {
self.pairs.append(ProtectionPair(from: $0))
}
}
}
@@ -127,7 +128,7 @@ struct ProtectionPair {
}
func removeProtection() {
textField.layer.superlayer?.insertSublayer(layer, above: textField.layer)
textField.superview?.superview?.layer.addSublayer(layer)
textField.layer.removeFromSuperlayer()
textField.removeFromSuperview()
}
+8
View File
@@ -38,6 +38,14 @@ download_file https://github.com/amnezia-vpn/amnezia-client/releases/download/${
download_file https://github.com/amnezia-vpn/amnezia-client/releases/download/${VERSION}/AmneziaVPN_${VERSION}_macos_x64.pkg
download_file https://github.com/amnezia-vpn/amnezia-client/releases/download/${VERSION}/AmneziaVPN_${VERSION}_windows_x64.exe
for label in android11+ android9-10; do
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
apk=AmneziaVPN_${VERSION}_${label}_${abi}.apk
download_file https://github.com/amnezia-vpn/amnezia-client/releases/download/${VERSION}/${apk}
download_file https://github.com/amnezia-vpn/amnezia-client/releases/download/${VERSION}/${apk}.sha256
done
done
cd ../
echo "Syncing to R2..."
+1 -4
View File
@@ -36,12 +36,9 @@ def upload_to_external_testers(package)
upload_to_testflight(
**package,
distribute_external: true,
groups: ["test-external"],
groups: ["test"],
changelog: "Improve stability"
)
rescue Spaceship::UnexpectedResponse => e
raise unless e.message.include?("already in beta review")
UI.important(e.message)
end
platform :ios do