mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
fix: android tv auto tunnel bug
Also fixed bug that could cause need to click start twice on mobile when starting auto tunneling Fix nightly cd to bump app versionCode
This commit is contained in:
+26
-11
@@ -1,3 +1,5 @@
|
||||
import com.android.build.gradle.internal.scope.ProjectInfo.Companion.getBaseName
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
@@ -20,7 +22,7 @@ android {
|
||||
applicationId = Constants.APP_ID
|
||||
minSdk = Constants.MIN_SDK
|
||||
targetSdk = Constants.TARGET_SDK
|
||||
versionCode = determineVersionCode()
|
||||
versionCode = Constants.VERSION_CODE + (versionCode ?: 0)
|
||||
versionName = determineVersionName()
|
||||
|
||||
ksp { arg("room.schemaLocation", "$projectDir/schemas") }
|
||||
@@ -199,16 +201,6 @@ dependencies {
|
||||
implementation(libs.androidx.core.splashscreen)
|
||||
}
|
||||
|
||||
fun determineVersionCode(): Int {
|
||||
return with(getBuildTaskName().lowercase()) {
|
||||
when {
|
||||
contains(Constants.NIGHTLY) -> Constants.VERSION_CODE + Constants.NIGHTLY_CODE
|
||||
contains(Constants.PRERELEASE) -> Constants.VERSION_CODE + Constants.PRERELEASE_CODE
|
||||
else -> Constants.VERSION_CODE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun determineVersionName(): String {
|
||||
return with(getBuildTaskName().lowercase()) {
|
||||
when {
|
||||
@@ -219,3 +211,26 @@ fun determineVersionName(): String {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val incrementVersionCode by tasks.registering {
|
||||
doLast {
|
||||
val versionCodeFile = file("$rootDir/versionCode.txt")
|
||||
val currentVersionCode = if (versionCodeFile.exists()) {
|
||||
versionCodeFile.readText().toInt()
|
||||
} else {
|
||||
1
|
||||
}
|
||||
val newVersionCode = currentVersionCode + 1
|
||||
versionCodeFile.writeText(newVersionCode.toString())
|
||||
println("Incremented versionCode to $newVersionCode")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.whenTaskAdded {
|
||||
if (name.startsWith("assemble")) {
|
||||
dependsOn(incrementVersionCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-17
@@ -5,6 +5,7 @@ import android.app.Activity
|
||||
import android.content.Context.POWER_SERVICE
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.net.VpnService
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.provider.Settings
|
||||
@@ -111,7 +112,7 @@ fun SettingsScreen(
|
||||
var isBackgroundLocationGranted by remember { mutableStateOf(true) }
|
||||
var showVpnPermissionDialog by remember { mutableStateOf(false) }
|
||||
var showLocationServicesAlertDialog by remember { mutableStateOf(false) }
|
||||
var didExportFiles by remember { mutableStateOf(false) }
|
||||
val didExportFiles by remember { mutableStateOf(false) }
|
||||
var showAuthPrompt by remember { mutableStateOf(false) }
|
||||
var showLocationDialog by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -126,13 +127,6 @@ fun SettingsScreen(
|
||||
currentText = ""
|
||||
}
|
||||
|
||||
val notificationPermissionState =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
rememberPermissionState(Manifest.permission.POST_NOTIFICATIONS)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val startForResult =
|
||||
rememberLauncherForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult(),
|
||||
@@ -165,22 +159,20 @@ fun SettingsScreen(
|
||||
fun requestBatteryOptimizationsDisabled() {
|
||||
val intent =
|
||||
Intent().apply {
|
||||
this.action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
data = Uri.fromParts("package", context.packageName, null)
|
||||
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
data = Uri.parse("package:${context.packageName}")
|
||||
}
|
||||
startForResult.launch(intent)
|
||||
}
|
||||
|
||||
fun handleAutoTunnelToggle() {
|
||||
if (!uiState.generalState.isBatteryOptimizationDisableShown || !isBatteryOptimizationsDisabled()) return requestBatteryOptimizationsDisabled()
|
||||
if (notificationPermissionState != null && !notificationPermissionState.status.isGranted) {
|
||||
snackbar.showMessage(
|
||||
context.getString(R.string.notification_permission_required),
|
||||
)
|
||||
return notificationPermissionState.launchPermissionRequest()
|
||||
if (!uiState.generalState.isBatteryOptimizationDisableShown &&
|
||||
!isBatteryOptimizationsDisabled() && !context.isRunningOnTv()
|
||||
) {
|
||||
return requestBatteryOptimizationsDisabled()
|
||||
}
|
||||
val intent = if (!uiState.settings.isKernelEnabled) {
|
||||
com.wireguard.android.backend.GoBackend.VpnService.prepare(context)
|
||||
VpnService.prepare(context)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user