mirror of
https://github.com/amnezia-vpn/amneziawg-android.git
synced 2026-07-03 14:05:13 +02:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79c5eb41c3 | |||
| 9e30c7d2e9 | |||
| d80129ba46 | |||
| 6907663f07 | |||
| dca96a52b4 | |||
| cf4fca8086 | |||
| 318f36a205 | |||
| 87aa73cc64 | |||
| 4e28d57aee | |||
| 6d67a3d5f5 | |||
| 1b5f4d6dfd | |||
| bed2f2e5d6 | |||
| 7d91666860 | |||
| 8800f861ed |
@@ -26,12 +26,12 @@ The library makes use of Java 8 features, so be sure to support those in your gr
|
||||
|
||||
```
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
coreLibraryDesugaringEnabled = true
|
||||
}
|
||||
dependencies {
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.3"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
buildscript {
|
||||
ext {
|
||||
activityVersion = '1.7.1'
|
||||
annotationsVersion = '1.6.0'
|
||||
appcompatVersion = '1.6.1'
|
||||
biometricVersion = '1.1.0'
|
||||
collectionVersion = '1.2.0'
|
||||
constraintLayoutVersion = '2.1.4'
|
||||
coordinatorLayoutVersion = '1.2.0'
|
||||
coreKtxVersion = '1.10.0'
|
||||
coroutinesVersion = '1.6.4'
|
||||
datastoreVersion = '1.0.0'
|
||||
desugarVersion = '1.1.5'
|
||||
fragmentVersion = '1.5.7'
|
||||
jsr305Version = '3.0.2'
|
||||
junitVersion = '4.13.2'
|
||||
lifecycleRuntimeKtxVersion = '2.6.1'
|
||||
materialComponentsVersion = '1.8.0'
|
||||
preferenceVersion = '1.2.0'
|
||||
zxingEmbeddedVersion = '4.3.0'
|
||||
|
||||
groupName = 'com.wireguard.android'
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
wrapper {
|
||||
gradleVersion = "8.0.2"
|
||||
distributionSha256Sum = "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7"
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "version.gradle"
|
||||
@@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.kotlin.kapt) apply false
|
||||
}
|
||||
|
||||
tasks {
|
||||
wrapper {
|
||||
gradleVersion = "8.1.1"
|
||||
distributionSha256Sum = "e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
wireguardVersionCode=502
|
||||
wireguardVersionName=1.0.20230504
|
||||
wireguardPackageName=com.wireguard.android
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
[versions]
|
||||
agp = "8.0.1"
|
||||
kotlin = "1.8.21"
|
||||
|
||||
[libraries]
|
||||
androidx-activity-ktx = "androidx.activity:activity-ktx:1.7.1"
|
||||
androidx-annotation = "androidx.annotation:annotation:1.6.0"
|
||||
androidx-appcompat = "androidx.appcompat:appcompat:1.6.1"
|
||||
androidx-biometric = "androidx.biometric:biometric:1.1.0"
|
||||
androidx-collection = "androidx.collection:collection:1.2.0"
|
||||
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||
androidx-coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.2.0"
|
||||
androidx-core-ktx = "androidx.core:core-ktx:1.10.0"
|
||||
androidx-datastore-preferences = "androidx.datastore:datastore-preferences:1.0.0"
|
||||
androidx-fragment-ktx = "androidx.fragment:fragment-ktx:1.5.7"
|
||||
androidx-lifecycle-runtime-ktx = "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
|
||||
androidx-preference-ktx = "androidx.preference:preference-ktx:1.2.0"
|
||||
desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.0.3"
|
||||
google-material = "com.google.android.material:material:1.8.0"
|
||||
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
|
||||
junit = "junit:junit:4.13.2"
|
||||
kotlinx-coroutines-android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
|
||||
zxing-android-embedded = "com.journeyapps:zxing-android-embedded:4.3.0"
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -85,9 +85,6 @@ done
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
pluginManagement {
|
||||
def agpVersion = '8.0.0'
|
||||
def kotlinVersion = "1.8.0"
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
plugins {
|
||||
id("com.android.application") version "$agpVersion"
|
||||
id("com.android.library") version "$agpVersion"
|
||||
id("org.jetbrains.kotlin.android") version "$kotlinVersion"
|
||||
id("org.jetbrains.kotlin.kapt") version "$kotlinVersion"
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "wireguard-android"
|
||||
|
||||
include ':tunnel'
|
||||
include ':ui'
|
||||
@@ -0,0 +1,22 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "wireguard-android"
|
||||
|
||||
include(":tunnel")
|
||||
include(":ui")
|
||||
@@ -1,72 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
|
||||
version wireguardVersionName
|
||||
group groupName
|
||||
|
||||
android {
|
||||
compileSdk 33
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
namespace 'com.wireguard.android.tunnel'
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode wireguardVersionCode
|
||||
versionName wireguardVersionName
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path 'tools/CMakeLists.txt'
|
||||
}
|
||||
}
|
||||
testOptions.unitTests.all {
|
||||
testLogging {
|
||||
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
all {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
targets 'libwg-go.so', 'libwg.so', 'libwg-quick.so'
|
||||
arguments "-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}"
|
||||
}
|
||||
}
|
||||
}
|
||||
release {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DANDROID_PACKAGE_NAME=${groupName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
debug {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DANDROID_PACKAGE_NAME=${groupName}.debug"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lint {
|
||||
disable 'LongLogTag', 'NewApi'
|
||||
}
|
||||
publishing {
|
||||
multipleVariants("release") {
|
||||
allVariants()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "androidx.annotation:annotation:$annotationsVersion"
|
||||
implementation "androidx.collection:collection:$collectionVersion"
|
||||
compileOnly "com.google.code.findbugs:jsr305:$jsr305Version"
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
}
|
||||
|
||||
apply from: "publish.gradle"
|
||||
@@ -0,0 +1,130 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
|
||||
val pkg: String = providers.gradleProperty("wireguardPackageName").get()
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
`maven-publish`
|
||||
signing
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 33
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
namespace = "${pkg}.tunnel"
|
||||
defaultConfig {
|
||||
minSdk = 21
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path("tools/CMakeLists.txt")
|
||||
}
|
||||
}
|
||||
testOptions.unitTests.all {
|
||||
it.testLogging { events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) }
|
||||
}
|
||||
buildTypes {
|
||||
all {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
targets("libwg-go.so", "libwg.so", "libwg-quick.so")
|
||||
arguments("-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}")
|
||||
}
|
||||
}
|
||||
}
|
||||
release {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments("-DANDROID_PACKAGE_NAME=${pkg}")
|
||||
}
|
||||
}
|
||||
}
|
||||
debug {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments("-DANDROID_PACKAGE_NAME=${pkg}.debug")
|
||||
}
|
||||
}
|
||||
}
|
||||
create("googleplay") {
|
||||
initWith(getByName("release"))
|
||||
}
|
||||
}
|
||||
lint {
|
||||
disable += "LongLogTag"
|
||||
disable += "NewApi"
|
||||
}
|
||||
publishing {
|
||||
singleVariant("release") {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.annotation)
|
||||
implementation(libs.androidx.collection)
|
||||
compileOnly(libs.jsr305)
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
register<MavenPublication>("release") {
|
||||
groupId = pkg
|
||||
artifactId = "tunnel"
|
||||
version = providers.gradleProperty("wireguardVersionName").get()
|
||||
afterEvaluate {
|
||||
from(components["release"])
|
||||
}
|
||||
pom {
|
||||
name.set("WireGuard Tunnel Library")
|
||||
description.set("Embeddable tunnel library for WireGuard for Android")
|
||||
url.set("https://www.wireguard.com/")
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection.set("scm:git:https://git.zx2c4.com/wireguard-android")
|
||||
developerConnection.set("scm:git:https://git.zx2c4.com/wireguard-android")
|
||||
url.set("https://git.zx2c4.com/wireguard-android")
|
||||
}
|
||||
developers {
|
||||
organization {
|
||||
name.set("WireGuard")
|
||||
url.set("https://www.wireguard.com/")
|
||||
}
|
||||
developer {
|
||||
name.set("WireGuard")
|
||||
email.set("team@wireguard.com")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||
credentials {
|
||||
username = providers.environmentVariable("SONATYPE_USER").orNull
|
||||
password = providers.environmentVariable("SONATYPE_PASSWORD").orNull
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(publishing.publications)
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'signing'
|
||||
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
groupId = groupName
|
||||
artifactId = 'tunnel'
|
||||
version wireguardVersionName
|
||||
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
|
||||
from components.getByName("release")
|
||||
|
||||
pom {
|
||||
name = 'WireGuard Tunnel Library'
|
||||
description = 'Embeddable tunnel library for WireGuard for Android'
|
||||
url = 'https://www.wireguard.com/'
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name = 'The Apache Software License, Version 2.0'
|
||||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution = 'repo'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = 'scm:git:https://git.zx2c4.com/wireguard-android'
|
||||
developerConnection = 'scm:git:https://git.zx2c4.com/wireguard-android'
|
||||
url = 'https://git.zx2c4.com/wireguard-android'
|
||||
}
|
||||
developers {
|
||||
organization {
|
||||
name = 'WireGuard'
|
||||
url = 'https://www.wireguard.com/'
|
||||
}
|
||||
developer {
|
||||
name = 'WireGuard'
|
||||
email = 'team@wireguard.com'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||
credentials {
|
||||
username = hasProperty('SONATYPE_USER') ? getProperty('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||
password = hasProperty('SONATYPE_PASSWORD') ? getProperty('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android.libraryVariants.all { variant ->
|
||||
if (variant.name == 'release') {
|
||||
task javadoc(type: Javadoc) {
|
||||
source = variant.javaCompileProvider.get().source
|
||||
classpath = files((android.bootClasspath.join(File.pathSeparator)))
|
||||
classpath += variant.javaCompileProvider.get().classpath
|
||||
title = 'Embeddable WireGuard Tunnel for Android v$wireguardVersionName'
|
||||
}
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
archiveClassifier = 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
task sourcesJar(type: Jar) {
|
||||
archiveClassifier = 'sources'
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign publishing.publications
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'org.jetbrains.kotlin.kapt'
|
||||
}
|
||||
|
||||
version wireguardVersionName
|
||||
group groupName
|
||||
|
||||
android {
|
||||
compileSdk 33
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
}
|
||||
namespace = 'com.wireguard.android'
|
||||
defaultConfig {
|
||||
applicationId 'com.wireguard.android'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode wireguardVersionCode
|
||||
versionName wireguardVersionName
|
||||
buildConfigField 'int', 'MIN_SDK_VERSION', "$minSdkVersion.apiLevel"
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
coreLibraryDesugaringEnabled = true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles "proguard-android-optimize.txt"
|
||||
packagingOptions {
|
||||
exclude "DebugProbesKt.bin"
|
||||
exclude "kotlin-tooling-metadata.json"
|
||||
}
|
||||
}
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
versionNameSuffix "-debug"
|
||||
}
|
||||
}
|
||||
lint {
|
||||
disable 'LongLogTag'
|
||||
warning 'MissingTranslation', 'ImpliedQuantity'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":tunnel")
|
||||
implementation "androidx.activity:activity-ktx:$activityVersion"
|
||||
implementation "androidx.annotation:annotation:$annotationsVersion"
|
||||
implementation "androidx.appcompat:appcompat:$appcompatVersion"
|
||||
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:$coordinatorLayoutVersion"
|
||||
implementation "androidx.biometric:biometric:$biometricVersion"
|
||||
implementation "androidx.core:core-ktx:$coreKtxVersion"
|
||||
implementation "androidx.fragment:fragment-ktx:$fragmentVersion"
|
||||
implementation "androidx.preference:preference-ktx:$preferenceVersion"
|
||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleRuntimeKtxVersion"
|
||||
implementation "androidx.datastore:datastore-preferences:$datastoreVersion"
|
||||
implementation "com.google.android.material:material:$materialComponentsVersion"
|
||||
implementation "com.journeyapps:zxing-android-embedded:$zxingEmbeddedVersion"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarVersion"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.compilerArgs << '-Xlint:unchecked'
|
||||
options.deprecation = true
|
||||
}
|
||||
|
||||
tasks.withType(KotlinCompile).configureEach {
|
||||
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
val pkg: String = providers.gradleProperty("wireguardPackageName").get()
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.kapt)
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 33
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
}
|
||||
namespace = pkg
|
||||
defaultConfig {
|
||||
applicationId = pkg
|
||||
minSdk = 21
|
||||
targetSdk = 33
|
||||
versionCode = providers.gradleProperty("wireguardVersionCode").get().toInt()
|
||||
versionName = providers.gradleProperty("wireguardVersionName").get()
|
||||
buildConfigField("int", "MIN_SDK_VERSION", minSdk.toString())
|
||||
buildConfigField("boolean", "IS_GOOGLE_PLAY", false.toString())
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
proguardFiles("proguard-android-optimize.txt")
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "DebugProbesKt.bin"
|
||||
excludes += "kotlin-tooling-metadata.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
debug {
|
||||
applicationIdSuffix = ".debug"
|
||||
versionNameSuffix = "-debug"
|
||||
}
|
||||
create("googleplay") {
|
||||
initWith(getByName("release"))
|
||||
buildConfigField("boolean", "IS_GOOGLE_PLAY", true.toString())
|
||||
}
|
||||
}
|
||||
lint {
|
||||
disable += "LongLogTag"
|
||||
warning += "MissingTranslation"
|
||||
warning += "ImpliedQuantity"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":tunnel"))
|
||||
implementation(libs.androidx.activity.ktx)
|
||||
implementation(libs.androidx.annotation)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.constraintlayout)
|
||||
implementation(libs.androidx.coordinatorlayout)
|
||||
implementation(libs.androidx.biometric)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.fragment.ktx)
|
||||
implementation(libs.androidx.preference.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation(libs.androidx.datastore.preferences)
|
||||
implementation(libs.google.material)
|
||||
implementation(libs.zxing.android.embedded)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
coreLibraryDesugaring(libs.desugarJdkLibs)
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-Xlint:unchecked")
|
||||
options.isDeprecation = true
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove" />
|
||||
<application>
|
||||
<receiver android:name=".updater.Updater$AppUpdatedReceiver" tools:node="remove" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -104,6 +104,11 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".updater.Updater$AppUpdatedReceiver" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
@@ -8,25 +8,13 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.wireguard.android.activity.MainActivity
|
||||
import com.wireguard.android.backend.WgQuickBackend
|
||||
import com.wireguard.android.updater.Updater
|
||||
import com.wireguard.android.util.applicationScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class BootShutdownReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val action = intent.action ?: return
|
||||
|
||||
if (Intent.ACTION_MY_PACKAGE_REPLACED == action && Updater.installer() == context.packageName) {
|
||||
/* TODO: does not work because of restrictions placed on broadcast receivers. */
|
||||
val start = Intent(context, MainActivity::class.java)
|
||||
start.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
start.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(start)
|
||||
return
|
||||
}
|
||||
|
||||
applicationScope.launch {
|
||||
if (Application.getBackend() !is WgQuickBackend) return@launch
|
||||
val tunnelManager = Application.getTunnelManager()
|
||||
|
||||
@@ -8,13 +8,12 @@ package com.wireguard.android.preference
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.widget.Toast
|
||||
import androidx.preference.Preference
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.wireguard.android.BuildConfig
|
||||
import com.wireguard.android.R
|
||||
import com.wireguard.android.updater.Updater
|
||||
import com.wireguard.android.util.ErrorMessages
|
||||
|
||||
class DonatePreference(context: Context, attrs: AttributeSet?) : Preference(context, attrs) {
|
||||
@@ -24,7 +23,7 @@ class DonatePreference(context: Context, attrs: AttributeSet?) : Preference(cont
|
||||
|
||||
override fun onClick() {
|
||||
/* Google Play Store forbids links to our donation page. */
|
||||
if (Updater.installerIsGooglePlay()) {
|
||||
if (BuildConfig.IS_GOOGLE_PLAY) {
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.donate_title)
|
||||
.setMessage(R.string.donate_google_play_disappointment)
|
||||
|
||||
@@ -11,6 +11,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.wireguard.android.BuildConfig
|
||||
import com.wireguard.android.R
|
||||
import com.wireguard.android.util.ErrorMessages
|
||||
import com.wireguard.android.util.QuantityFormatter
|
||||
@@ -88,6 +89,9 @@ object SnackbarUpdateShower {
|
||||
}
|
||||
|
||||
fun attachToActivity(activity: FragmentActivity, view: View, anchor: View?) {
|
||||
if (BuildConfig.IS_GOOGLE_PLAY)
|
||||
return
|
||||
|
||||
val snackbar = SwapableSnackbar(activity, view, anchor)
|
||||
val context = activity.applicationContext
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.IntentCompat
|
||||
import com.wireguard.android.Application
|
||||
import com.wireguard.android.BuildConfig
|
||||
import com.wireguard.android.activity.MainActivity
|
||||
import com.wireguard.android.util.UserKnobs
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
@@ -41,12 +44,16 @@ import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
object Updater {
|
||||
private const val TAG = "WireGuard/Updater"
|
||||
private const val LATEST_VERSION_URL = "https://download.wireguard.com/android-client/latest.sig"
|
||||
private const val LATEST_VERSION_URL =
|
||||
"https://download.wireguard.com/android-client/latest.sig"
|
||||
private const val APK_PATH_URL = "https://download.wireguard.com/android-client/%s"
|
||||
private const val APK_NAME_PREFIX = BuildConfig.APPLICATION_ID + "-"
|
||||
private val APK_NAME_PREFIX = BuildConfig.APPLICATION_ID.removeSuffix(".debug") + "-"
|
||||
private const val APK_NAME_SUFFIX = ".apk"
|
||||
private const val RELEASE_PUBLIC_KEY_BASE64 = "RWTAzwGRYr3EC9px0Ia3fbttz8WcVN6wrOwWp2delz4el6SI8XmkKSMp"
|
||||
private val CURRENT_VERSION = BuildConfig.VERSION_NAME.removeSuffix("-debug")
|
||||
private const val RELEASE_PUBLIC_KEY_BASE64 =
|
||||
"RWTAzwGRYr3EC9px0Ia3fbttz8WcVN6wrOwWp2delz4el6SI8XmkKSMp"
|
||||
private val CURRENT_VERSION = Version(BuildConfig.VERSION_NAME.removeSuffix("-debug"))
|
||||
|
||||
private val updaterScope = CoroutineScope(Job() + Dispatchers.IO)
|
||||
|
||||
sealed class Progress {
|
||||
object Complete : Progress()
|
||||
@@ -89,7 +96,7 @@ object Updater {
|
||||
|
||||
class Failure(val error: Throwable) : Progress() {
|
||||
fun retry() {
|
||||
Application.getCoroutineScope().launch {
|
||||
updaterScope.launch {
|
||||
downloadAndUpdateWrapErrors()
|
||||
}
|
||||
}
|
||||
@@ -104,29 +111,61 @@ object Updater {
|
||||
mutableState.emit(progress)
|
||||
}
|
||||
|
||||
private fun versionIsNewer(lhs: String, rhs: String): Boolean {
|
||||
val lhsParts = lhs.split(".")
|
||||
val rhsParts = rhs.split(".")
|
||||
if (lhsParts.isEmpty() || rhsParts.isEmpty())
|
||||
throw InvalidParameterException("Version is empty")
|
||||
private class Sha256Digest(hex: String) {
|
||||
val bytes: ByteArray
|
||||
|
||||
for (i in 0 until max(lhsParts.size, rhsParts.size)) {
|
||||
val lhsPart = if (i < lhsParts.size) lhsParts[i].toULong() else 0UL
|
||||
val rhsPart = if (i < rhsParts.size) rhsParts[i].toULong() else 0UL
|
||||
if (lhsPart == rhsPart)
|
||||
continue
|
||||
return lhsPart > rhsPart
|
||||
init {
|
||||
if (hex.length != 64)
|
||||
throw InvalidParameterException("SHA256 hashes must be 32 bytes long")
|
||||
bytes = hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun versionOfFile(name: String): String? {
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
private class Version(version: String) : Comparable<Version> {
|
||||
val parts: ULongArray
|
||||
|
||||
init {
|
||||
val strParts = version.split(".")
|
||||
if (strParts.isEmpty())
|
||||
throw InvalidParameterException("Version has no parts")
|
||||
parts = ULongArray(strParts.size)
|
||||
for (i in parts.indices) {
|
||||
parts[i] = strParts[i].toULong()
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return parts.joinToString(".")
|
||||
}
|
||||
|
||||
override fun compareTo(other: Version): Int {
|
||||
for (i in 0 until max(parts.size, other.parts.size)) {
|
||||
val lhsPart = if (i < parts.size) parts[i] else 0UL
|
||||
val rhsPart = if (i < other.parts.size) other.parts[i] else 0UL
|
||||
if (lhsPart > rhsPart)
|
||||
return 1
|
||||
else if (lhsPart < rhsPart)
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
private class Update(val fileName: String, val version: Version, val hash: Sha256Digest)
|
||||
|
||||
private fun versionOfFile(name: String): Version? {
|
||||
if (!name.startsWith(APK_NAME_PREFIX) || !name.endsWith(APK_NAME_SUFFIX))
|
||||
return null
|
||||
return name.substring(APK_NAME_PREFIX.length, name.length - APK_NAME_SUFFIX.length)
|
||||
return try {
|
||||
Version(name.substring(APK_NAME_PREFIX.length, name.length - APK_NAME_SUFFIX.length))
|
||||
} catch (_: Throwable) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun verifySignedFileList(signifyDigest: String): Map<String, Sha256Digest> {
|
||||
private fun verifySignedFileList(signifyDigest: String): List<Update> {
|
||||
val updates = ArrayList<Update>(1)
|
||||
val publicKeyBytes = Base64.decode(RELEASE_PUBLIC_KEY_BASE64, Base64.DEFAULT)
|
||||
if (publicKeyBytes == null || publicKeyBytes.size != 32 + 10 || publicKeyBytes[0] != 'E'.code.toByte() || publicKeyBytes[1] != 'd'.code.toByte())
|
||||
throw InvalidKeyException("Invalid public key")
|
||||
@@ -149,32 +188,23 @@ object Updater {
|
||||
)
|
||||
)
|
||||
throw SecurityException("Invalid signature")
|
||||
val hashes: MutableMap<String, Sha256Digest> = HashMap()
|
||||
for (line in lines[2].split("\n").dropLastWhile { it.isEmpty() }) {
|
||||
val components = line.split(" ", limit = 2)
|
||||
if (components.size != 2)
|
||||
throw InvalidParameterException("Invalid file list format: too few components")
|
||||
hashes[components[1]] = Sha256Digest(components[0])
|
||||
/* If version is null, it's not a file we understand, but still a legitimate entry, so don't throw. */
|
||||
val version = versionOfFile(components[1]) ?: continue
|
||||
updates.add(Update(components[1], version, Sha256Digest(components[0])))
|
||||
}
|
||||
return hashes
|
||||
return updates
|
||||
}
|
||||
|
||||
private class Sha256Digest(hex: String) {
|
||||
val bytes: ByteArray
|
||||
|
||||
init {
|
||||
if (hex.length != 64)
|
||||
throw InvalidParameterException("SHA256 hashes must be 32 bytes long")
|
||||
bytes = hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkForUpdates(): Pair<String, Sha256Digest> {
|
||||
private fun checkForUpdates(): Update? {
|
||||
val connection = URL(LATEST_VERSION_URL).openConnection() as HttpURLConnection
|
||||
connection.setRequestProperty("User-Agent", Application.USER_AGENT)
|
||||
connection.connect()
|
||||
if (connection.responseCode != HttpURLConnection.HTTP_OK)
|
||||
throw IOException("File list could not be fetched: ${connection.responseCode}")
|
||||
throw IOException(connection.responseMessage)
|
||||
var fileListBytes = ByteArray(1024 * 512 /* 512 KiB */)
|
||||
connection.inputStream.use {
|
||||
val len = it.read(fileListBytes)
|
||||
@@ -182,26 +212,7 @@ object Updater {
|
||||
throw IOException("File list is empty")
|
||||
fileListBytes = fileListBytes.sliceArray(0 until len)
|
||||
}
|
||||
val fileList = verifySignedFileList(fileListBytes.decodeToString())
|
||||
if (fileList.isEmpty())
|
||||
throw InvalidParameterException("File list is empty")
|
||||
var newestFile: String? = null
|
||||
var newestVersion: String? = null
|
||||
var newestFileHash: Sha256Digest? = null
|
||||
for (file in fileList) {
|
||||
val fileVersion = versionOfFile(file.key)
|
||||
try {
|
||||
if (fileVersion != null && (newestVersion == null || versionIsNewer(fileVersion, newestVersion))) {
|
||||
newestVersion = fileVersion
|
||||
newestFile = file.key
|
||||
newestFileHash = file.value
|
||||
}
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
}
|
||||
if (newestFile == null || newestFileHash == null)
|
||||
throw InvalidParameterException("File list is empty")
|
||||
return Pair(newestFile, newestFileHash)
|
||||
return verifySignedFileList(fileListBytes.decodeToString()).maxByOrNull { it.version }
|
||||
}
|
||||
|
||||
private suspend fun downloadAndUpdate() = withContext(Dispatchers.IO) {
|
||||
@@ -224,14 +235,14 @@ object Updater {
|
||||
|
||||
emitProgress(Progress.Rechecking)
|
||||
val update = checkForUpdates()
|
||||
val updateVersion = versionOfFile(checkForUpdates().first) ?: throw Exception("No versions returned")
|
||||
if (!versionIsNewer(updateVersion, CURRENT_VERSION)) {
|
||||
if (update == null || update.version <= CURRENT_VERSION) {
|
||||
emitProgress(Progress.Complete)
|
||||
return@withContext
|
||||
}
|
||||
|
||||
emitProgress(Progress.Downloading(0UL, 0UL), true)
|
||||
val connection = URL(APK_PATH_URL.format(update.first)).openConnection() as HttpURLConnection
|
||||
val connection =
|
||||
URL(APK_PATH_URL.format(update.fileName)).openConnection() as HttpURLConnection
|
||||
connection.setRequestProperty("User-Agent", Application.USER_AGENT)
|
||||
connection.connect()
|
||||
if (connection.responseCode != HttpURLConnection.HTTP_OK)
|
||||
@@ -246,7 +257,8 @@ object Updater {
|
||||
emitProgress(Progress.Downloading(downloadedByteLen, totalByteLen), true)
|
||||
|
||||
val installer = context.packageManager.packageInstaller
|
||||
val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
|
||||
val params =
|
||||
PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
params.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)
|
||||
params.setAppPackageName(context.packageName) /* Enforces updates; disallows new apps. */
|
||||
@@ -275,7 +287,7 @@ object Updater {
|
||||
}
|
||||
|
||||
emitProgress(Progress.Installing)
|
||||
if (!digest.digest().contentEquals(update.second.bytes))
|
||||
if (!digest.digest().contentEquals(update.hash.bytes))
|
||||
throw SecurityException("Update has invalid hash")
|
||||
sessionFailure = false
|
||||
} finally {
|
||||
@@ -305,10 +317,17 @@ object Updater {
|
||||
return
|
||||
|
||||
when (val status =
|
||||
intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE_INVALID)) {
|
||||
intent.getIntExtra(
|
||||
PackageInstaller.EXTRA_STATUS,
|
||||
PackageInstaller.STATUS_FAILURE_INVALID
|
||||
)) {
|
||||
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
|
||||
val id = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, 0)
|
||||
val userIntervention = IntentCompat.getParcelableExtra(intent, Intent.EXTRA_INTENT, Intent::class.java)!!
|
||||
val userIntervention = IntentCompat.getParcelableExtra(
|
||||
intent,
|
||||
Intent.EXTRA_INTENT,
|
||||
Intent::class.java
|
||||
)!!
|
||||
Application.getCoroutineScope().launch {
|
||||
emitProgress(Progress.NeedsUserIntervention(userIntervention, id))
|
||||
}
|
||||
@@ -328,7 +347,8 @@ object Updater {
|
||||
} catch (_: SecurityException) {
|
||||
}
|
||||
val message =
|
||||
intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) ?: "Installation error $status"
|
||||
intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
|
||||
?: "Installation error $status"
|
||||
Application.getCoroutineScope().launch {
|
||||
val e = Exception(message)
|
||||
Log.e(TAG, "Update failure", e)
|
||||
@@ -341,24 +361,25 @@ object Updater {
|
||||
}
|
||||
|
||||
fun monitorForUpdates() {
|
||||
if (installerIsGooglePlay())
|
||||
if (BuildConfig.IS_GOOGLE_PLAY)
|
||||
return
|
||||
|
||||
Application.getCoroutineScope().launch(Dispatchers.IO) {
|
||||
if (UserKnobs.updaterNewerVersionSeen.firstOrNull()?.let { versionIsNewer(it, CURRENT_VERSION) } == true)
|
||||
updaterScope.launch {
|
||||
if (UserKnobs.updaterNewerVersionSeen.firstOrNull()
|
||||
?.let { Version(it) > CURRENT_VERSION } == true
|
||||
)
|
||||
return@launch
|
||||
|
||||
var waitTime = 15
|
||||
while (true) {
|
||||
try {
|
||||
val updateVersion = versionOfFile(checkForUpdates().first) ?: throw IllegalStateException("No versions returned")
|
||||
if (versionIsNewer(updateVersion, CURRENT_VERSION)) {
|
||||
Log.i(TAG, "Update available: $updateVersion")
|
||||
UserKnobs.setUpdaterNewerVersionSeen(updateVersion)
|
||||
val update = checkForUpdates() ?: continue
|
||||
if (update.version > CURRENT_VERSION) {
|
||||
Log.i(TAG, "Update available: ${update.version}")
|
||||
UserKnobs.setUpdaterNewerVersionSeen(update.version.toString())
|
||||
return@launch
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Log.e(TAG, "Failed to check for updates", e)
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
delay(waitTime.minutes)
|
||||
waitTime = 45
|
||||
@@ -366,36 +387,48 @@ object Updater {
|
||||
}
|
||||
|
||||
UserKnobs.updaterNewerVersionSeen.onEach { ver ->
|
||||
if (ver != null && versionIsNewer(
|
||||
ver,
|
||||
CURRENT_VERSION
|
||||
) && UserKnobs.updaterNewerVersionConsented.firstOrNull()
|
||||
?.let { versionIsNewer(it, CURRENT_VERSION) } != true
|
||||
if (ver != null && Version(ver) > CURRENT_VERSION && UserKnobs.updaterNewerVersionConsented.firstOrNull()
|
||||
?.let { Version(it) > CURRENT_VERSION } != true
|
||||
)
|
||||
emitProgress(Progress.Available(ver))
|
||||
}.launchIn(Application.getCoroutineScope())
|
||||
|
||||
UserKnobs.updaterNewerVersionConsented.onEach { ver ->
|
||||
if (ver != null && versionIsNewer(ver, CURRENT_VERSION))
|
||||
downloadAndUpdateWrapErrors()
|
||||
if (ver != null && Version(ver) > CURRENT_VERSION)
|
||||
updaterScope.launch {
|
||||
downloadAndUpdateWrapErrors()
|
||||
}
|
||||
}.launchIn(Application.getCoroutineScope())
|
||||
}
|
||||
|
||||
fun installer(): String {
|
||||
val context = Application.get().applicationContext
|
||||
return try {
|
||||
val packageName = context.packageName
|
||||
val pm = context.packageManager
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
pm.getInstallSourceInfo(packageName).installingPackageName ?: ""
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
pm.getInstallerPackageName(packageName) ?: ""
|
||||
class AppUpdatedReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (BuildConfig.IS_GOOGLE_PLAY)
|
||||
return
|
||||
|
||||
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED)
|
||||
return
|
||||
|
||||
val installer = try {
|
||||
val packageName = context.packageName
|
||||
val pm = context.packageManager
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
pm.getInstallSourceInfo(packageName).installingPackageName ?: ""
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
pm.getInstallerPackageName(packageName) ?: ""
|
||||
}
|
||||
} catch (_: Throwable) {
|
||||
""
|
||||
}
|
||||
} catch (_: Throwable) {
|
||||
""
|
||||
if (installer != context.packageName)
|
||||
return
|
||||
|
||||
/* TODO: does not work because of restrictions placed on broadcast receivers. */
|
||||
val start = Intent(context, MainActivity::class.java)
|
||||
start.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
start.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(start)
|
||||
}
|
||||
}
|
||||
|
||||
fun installerIsGooglePlay(): Boolean = installer() == "com.android.vending"
|
||||
}
|
||||
@@ -107,6 +107,9 @@
|
||||
<string name="tv_select_a_storage_drive">Selecciones un dispositivo de almacenamiento</string>
|
||||
<string name="tv_no_file_picker">Por favor, instale una herramienta de gestión de archivos para navegar por archivos</string>
|
||||
<string name="tv_add_tunnel_get_started">Agregue un túnel para empezar</string>
|
||||
<string name="donate_title">♥ Donar al Proyecto WireGuard</string>
|
||||
<string name="donate_summary">Todas las contribuciones ayudan</string>
|
||||
<string name="donate_google_play_disappointment">¡Gracias por apoyar el proyecto WireGuard!\n\nLamentablemente, debido a las políticas de Google, no estamos autorizados a enlazar a la parte de la página web del proyecto donde puedes hacer una donación. ¡Esperemos que puedas averiguar esto!\n\nGracias de nuevo por tu contribución.</string>
|
||||
<string name="disable_config_export_title">Inhabilitar la exportación de configuración</string>
|
||||
<string name="disable_config_export_description">Desactivar la exportación de configuración hace que las claves privadas sean menos accesibles</string>
|
||||
<string name="dns_servers">Servidores DNS</string>
|
||||
@@ -116,6 +119,7 @@
|
||||
<string name="error_down">Error al bajar el túnel: %s</string>
|
||||
<string name="error_fetching_apps">Error al obtener la lista de aplicaciones: %s</string>
|
||||
<string name="error_root">Por favor, obtén acceso root y vuelve a intentarlo</string>
|
||||
<string name="error_prepare">Error al preparar el túnel: %s</string>
|
||||
<string name="error_up">Error al abrir el túnel: %s</string>
|
||||
<string name="exclude_private_ips">Excluir direcciones privadas</string>
|
||||
<string name="generate_new_private_key">Generar nueva clave privada</string>
|
||||
@@ -135,6 +139,8 @@
|
||||
<string name="key_length_explanation_base64">Las claves base64 de WireGuard deben tener 44 caracteres (32 bytes)</string>
|
||||
<string name="key_length_explanation_binary">: Las claves WireGuard deben tener 32 bytes</string>
|
||||
<string name="key_length_explanation_hex">: Las claves hexadecimales de Wirex deben tener 64 caracteres (32 bytes)</string>
|
||||
<string name="latest_handshake">Última comunicación</string>
|
||||
<string name="latest_handshake_ago">hace %s</string>
|
||||
<string name="listen_port">Puerto de escucha</string>
|
||||
<string name="log_export_error">No se pudo exportar el registro: %s</string>
|
||||
<string name="log_export_subject">Archivo de registro WireGuard Android</string>
|
||||
@@ -213,6 +219,7 @@
|
||||
<string name="tunnel_create_success">Túnel creado con éxito “%s”</string>
|
||||
<string name="tunnel_error_already_exists">Túnel “%s” ya existe</string>
|
||||
<string name="tunnel_error_invalid_name">Nombre inválido</string>
|
||||
<string name="tunnel_list_placeholder">Añadir un túnel usando el botón azul de abajo</string>
|
||||
<string name="tunnel_name">Nombre del túnel</string>
|
||||
<string name="tunnel_on_error">No se puede activar el túnel (wgTurnOn devolvió %d)</string>
|
||||
<string name="tunnel_dns_failure">No se puede resolver el nombre de host DNS: “%s”</string>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<item quantity="other">%d välistatud rakendust</item>
|
||||
</plurals>
|
||||
<plurals name="set_included_applications">
|
||||
<item quantity="one">%d kaasatud rakendust</item>
|
||||
<item quantity="one">%d kaasatud rakendus</item>
|
||||
<item quantity="other">%d kaasatud rakendust</item>
|
||||
</plurals>
|
||||
<plurals name="n_excluded_applications">
|
||||
@@ -79,8 +79,8 @@
|
||||
<string name="bad_config_reason_unknown_section">Tundmatu sektsioon</string>
|
||||
<string name="bad_config_reason_value_out_of_range">Väärtus lubatud vahemikust väljas</string>
|
||||
<string name="bad_extension_error">Faililaiend peab olema .conf või .zip</string>
|
||||
<string name="error_no_qr_found">QR koodi ei leitud pildilt</string>
|
||||
<string name="error_qr_checksum">QR koodi kontrollsumma verifitseerimine ebaõnnestus</string>
|
||||
<string name="error_no_qr_found">QR-koodi ei leitud pildilt</string>
|
||||
<string name="error_qr_checksum">QR-koodi kontrollsumma verifitseerimine ebaõnnestus</string>
|
||||
<string name="cancel">Tühista</string>
|
||||
<string name="config_delete_error">Seadistusfaili %s kustutamine ebaõnnestus</string>
|
||||
<string name="config_exists_error">\"%s\" seadistus on juba olemas</string>
|
||||
@@ -90,8 +90,8 @@
|
||||
<string name="config_save_error">\"%1$s\" seadistuse salvestamine ebaõnnestus: %2$s</string>
|
||||
<string name="config_save_success">\"%s\" seadistus salvestatud</string>
|
||||
<string name="create_activity_title">Loo WireGuard tunnel</string>
|
||||
<string name="create_bin_dir_error">Ei saa luua lokaalset binary kataloogi</string>
|
||||
<string name="create_downloads_file_error">Ei saa luua faili allalaadimiste kataloogis</string>
|
||||
<string name="create_bin_dir_error">Lokaalse programmfaili kataloogi tekitamine ebaõnnestus</string>
|
||||
<string name="create_downloads_file_error">Faili loomine allalaadimiste kataloogis ebaõnnestus</string>
|
||||
<string name="create_empty">Sisesta käsitsi</string>
|
||||
<string name="create_from_file">Impordi failist või arhiivist</string>
|
||||
<string name="create_from_qr_code">Skaneeri QR-koodist</string>
|
||||
@@ -107,15 +107,20 @@
|
||||
<string name="tv_select_a_storage_drive">Vali salvestusseade</string>
|
||||
<string name="tv_no_file_picker">Failide vaatamiseks paigalda failide haldusvahend</string>
|
||||
<string name="tv_add_tunnel_get_started">Alustamiseks lisa uus tunnel</string>
|
||||
<string name="donate_title">♥ Anneta WireGuard\'i projektile</string>
|
||||
<string name="donate_summary">Iga panus aitab</string>
|
||||
<string name="donate_google_play_disappointment">Aitäh, et toetad WireGuard\'i projekti!\n\nKahjuks ei saa me Google\'i eeskirjade tõttu linkida projekti veebilehele, kus saab annetusi teha. Loodetavasti leiad selle ise!\n\n
|
||||
Aitäh veelkord sinu panuse eest.</string>
|
||||
<string name="disable_config_export_title">Keela seadistuste eksportimine</string>
|
||||
<string name="disable_config_export_description">Seadistuste eksportimise keelamine teeb privaatvõtmetele ligipääsu keerulisemaks</string>
|
||||
<string name="dns_servers">DNS serverid</string>
|
||||
<string name="dns_servers">DNS-serverid</string>
|
||||
<string name="dns_search_domains">DNS-i otsingudomeenid</string>
|
||||
<string name="edit">Muuda</string>
|
||||
<string name="endpoint">Lõpp-punkt</string>
|
||||
<string name="error_down">Viga tunneli väljalülitamisel: %s</string>
|
||||
<string name="error_fetching_apps">Viga rakenduste nimekirja pärimisel: %s</string>
|
||||
<string name="error_root">Hangi juurkasutaja õigused ja proovi uuesti</string>
|
||||
<string name="error_prepare">Viga tunneli ettevalmistamisel: %s</string>
|
||||
<string name="error_up">Viga tunneli sisselülitamisel: %s</string>
|
||||
<string name="exclude_private_ips">Keela privaatsed IP\'d</string>
|
||||
<string name="generate_new_private_key">Tekita uus privaatvõti</string>
|
||||
@@ -135,6 +140,8 @@
|
||||
<string name="key_length_explanation_base64">: WireGuard base64 võti peab olema 44 sümbolit (32 baiti) pikk</string>
|
||||
<string name="key_length_explanation_binary">: WireGuard võtmed peavad olema 32 baiti</string>
|
||||
<string name="key_length_explanation_hex">: WireGuard hex võti peab olema 64 sümbolit (32 baiti) pikk</string>
|
||||
<string name="latest_handshake">Viimane kätlus</string>
|
||||
<string name="latest_handshake_ago">%s tagasi</string>
|
||||
<string name="listen_port">Kuulamisport</string>
|
||||
<string name="log_export_error">Logifaili eksportimine ebaõnnestus: %s</string>
|
||||
<string name="log_export_subject">WireGuard Android logifail</string>
|
||||
@@ -164,7 +171,7 @@
|
||||
<string name="no_configs_error">Seadistusi ei leitud</string>
|
||||
<string name="no_tunnels_error">Tunneleid ei ole</string>
|
||||
<string name="parse_error_generic">string</string>
|
||||
<string name="parse_error_inet_address">IP aadress</string>
|
||||
<string name="parse_error_inet_address">IP-aadress</string>
|
||||
<string name="parse_error_inet_endpoint">lõpp-punkt</string>
|
||||
<string name="parse_error_inet_network">IP võrk</string>
|
||||
<string name="parse_error_integer">number</string>
|
||||
@@ -184,9 +191,9 @@
|
||||
<string name="save">Salvesta</string>
|
||||
<string name="select_all">Vali kõik</string>
|
||||
<string name="settings">Seaded</string>
|
||||
<string name="shell_exit_status_read_error">Kest, shell, ei saa lugeda väljumise olekut</string>
|
||||
<string name="shell_marker_count_error">Kest, shell, ootas 4 markerit, saadi %d</string>
|
||||
<string name="shell_start_error">Kest, shell, ebaõnnestus käivitamisel: %d</string>
|
||||
<string name="shell_exit_status_read_error">Kest ei saa lugeda väljundstaatust</string>
|
||||
<string name="shell_marker_count_error">Kest ootas 4 markerit, saadi %d</string>
|
||||
<string name="shell_start_error">Kesta käivitumine ebaõnnestus: %d</string>
|
||||
<string name="success_application_will_restart">Tegevus õnnestus. Rakendus taaskäivitub…</string>
|
||||
<string name="toggle_all">Vaheta kõik</string>
|
||||
<string name="toggle_error">WireGuard tunneli lülitamine ebaõnnestus: %s</string>
|
||||
@@ -213,6 +220,7 @@
|
||||
<string name="tunnel_create_success">Tunnel \"%s\" lisatud</string>
|
||||
<string name="tunnel_error_already_exists">Tunnel \"%s\" on juba olemas</string>
|
||||
<string name="tunnel_error_invalid_name">Sobimatu nimi</string>
|
||||
<string name="tunnel_list_placeholder">Lisa tunnel alloleva nupu abil</string>
|
||||
<string name="tunnel_name">Tunneli nimi</string>
|
||||
<string name="tunnel_on_error">Tunneli sisselülitamine ebaõnnestus (wgTurnOn tagastas %d)</string>
|
||||
<string name="tunnel_dns_failure">Ei saa lahendada DNS hostinime: \"%s\"</string>
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
<string name="bad_config_reason_unknown_section">未知のセクション</string>
|
||||
<string name="bad_config_reason_value_out_of_range">範囲外の値</string>
|
||||
<string name="bad_extension_error">ファイルの拡張子は .conf か .zip です</string>
|
||||
<string name="error_no_qr_found">QRコードが見つかりません</string>
|
||||
<string name="error_qr_checksum">QRコードのチェックサムの確認に失敗しました</string>
|
||||
<string name="cancel">キャンセル</string>
|
||||
<string name="config_delete_error">設定ファイル %s を削除できません</string>
|
||||
<string name="config_exists_error">\"%s\" の定義はすでに存在します</string>
|
||||
@@ -91,7 +93,9 @@
|
||||
<string name="tv_delete">削除するトンネルを選択</string>
|
||||
<string name="tv_select_a_storage_drive">ストレージを選択</string>
|
||||
<string name="tv_no_file_picker">ファイルを参照するにはファイル管理アプリをインストールしてください</string>
|
||||
<string name="tv_add_tunnel_get_started">Add a tunnel to get started</string>
|
||||
<string name="tv_add_tunnel_get_started">トンネルを追加して開始する</string>
|
||||
<string name="donate_title">♥ WireGuard プロジェクトに寄付する</string>
|
||||
<string name="donate_summary">すべての貢献が役立ちます</string>
|
||||
<string name="disable_config_export_title">設定のエクスポートを無効にする</string>
|
||||
<string name="disable_config_export_description">設定のエクスポートを無効にすると、秘密鍵にアクセスされにくくなります</string>
|
||||
<string name="dns_servers">DNS サーバ</string>
|
||||
@@ -101,6 +105,7 @@
|
||||
<string name="error_down">トンネル停止時エラー: %s</string>
|
||||
<string name="error_fetching_apps">アプリ一覧取得エラー: %s</string>
|
||||
<string name="error_root">root 権限を取得して再試行してください</string>
|
||||
<string name="error_prepare">トンネル準備中エラー: %s</string>
|
||||
<string name="error_up">トンネル起動時エラー: %s</string>
|
||||
<string name="exclude_private_ips">プライベート IP アドレスを除外</string>
|
||||
<string name="generate_new_private_key">新しい秘密鍵を生成する</string>
|
||||
@@ -120,6 +125,8 @@
|
||||
<string name="key_length_explanation_base64">: WireGuard base64 鍵は44文字 (32バイト) でなければなりません</string>
|
||||
<string name="key_length_explanation_binary">: WireGuard 鍵は32バイトでなければなりません</string>
|
||||
<string name="key_length_explanation_hex">: WireGuard hex 鍵は64文字 (32バイト) でなければなりません</string>
|
||||
<string name="latest_handshake">直近のハンドシェイク</string>
|
||||
<string name="latest_handshake_ago">%s 前</string>
|
||||
<string name="listen_port">Listen ポート</string>
|
||||
<string name="log_export_error">ログをエクスポートできません: %s</string>
|
||||
<string name="log_export_subject">WireGuard Android ログファイル</string>
|
||||
@@ -198,6 +205,7 @@
|
||||
<string name="tunnel_create_success">トンネル \"%s\" を作成しました</string>
|
||||
<string name="tunnel_error_already_exists">トンネル “%s” はすでに存在します</string>
|
||||
<string name="tunnel_error_invalid_name">不正な名前</string>
|
||||
<string name="tunnel_list_placeholder">下のボタンを使用してトンネルを追加</string>
|
||||
<string name="tunnel_name">トンネル名</string>
|
||||
<string name="tunnel_on_error">トンネルを有効にできません (wgTurnOn が %d を返却)</string>
|
||||
<string name="tunnel_dns_failure">DNSホスト名を解決できませんでした: “%s”</string>
|
||||
|
||||
@@ -133,6 +133,8 @@
|
||||
<string name="tv_select_a_storage_drive">Виберіть диск зберігання</string>
|
||||
<string name="tv_no_file_picker">Будь ласка, встановіть провідник для перегляду файлів</string>
|
||||
<string name="tv_add_tunnel_get_started">Додайте тунель, щоб почати</string>
|
||||
<string name="donate_title">♥️ Пожертвуйте на проект WireGuard</string>
|
||||
<string name="donate_summary">Кожен внесок допомагає</string>
|
||||
<string name="disable_config_export_title">Вимкнути експорт конфігурації</string>
|
||||
<string name="disable_config_export_description">Вимкнення експорту налаштувань робить приватні ключі менш доступними</string>
|
||||
<string name="dns_servers">DNS-сервери</string>
|
||||
@@ -142,6 +144,7 @@
|
||||
<string name="error_down">Помилка вимкнення тунелю: %s</string>
|
||||
<string name="error_fetching_apps">Помилка при отриманні списку додатків: %s</string>
|
||||
<string name="error_root">Будь ласка, отримайте root-доступ і спробуйте ще раз</string>
|
||||
<string name="error_prepare">Помилка підготовки тунелю: %s</string>
|
||||
<string name="error_up">Помилка при увімкненні тунелю: %s</string>
|
||||
<string name="exclude_private_ips">Виключити приватні IP</string>
|
||||
<string name="generate_new_private_key">Згенерувати новий приватний ключ</string>
|
||||
@@ -161,6 +164,8 @@
|
||||
<string name="key_length_explanation_base64">: Ключі WireGuard base64 повинні мати довжину 44 символи (32 байти)</string>
|
||||
<string name="key_length_explanation_binary">: Ключі WireGuard повинні мати довжину 32 байти</string>
|
||||
<string name="key_length_explanation_hex">: hex ключі WireGuard повинні мати довжину 64 символи (32 байти)</string>
|
||||
<string name="latest_handshake">Останнє рукостискання</string>
|
||||
<string name="latest_handshake_ago">%s тому</string>
|
||||
<string name="listen_port">Порт</string>
|
||||
<string name="log_export_error">Не вдалося експортувати журнал: %s</string>
|
||||
<string name="log_export_subject">Файл журналу WireGuard</string>
|
||||
@@ -239,6 +244,7 @@
|
||||
<string name="tunnel_create_success">Тунель успішно створено “%s”</string>
|
||||
<string name="tunnel_error_already_exists">Тунель \"%s\" вже існує</string>
|
||||
<string name="tunnel_error_invalid_name">Неприпустиме ім\'я</string>
|
||||
<string name="tunnel_list_placeholder">Додайте тунель, використовуючи кнопку нижче</string>
|
||||
<string name="tunnel_name">Назва тунелю</string>
|
||||
<string name="tunnel_on_error">Неможливо ввімкнути тунель (wgTurnon returned %d)</string>
|
||||
<string name="tunnel_dns_failure">Не вдалося знайти DNS хост: “%s</string>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
buildscript {
|
||||
ext {
|
||||
wireguardVersionCode = 501
|
||||
wireguardVersionName = '1.0.20230502'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user