fix: bug fixes

This commit is contained in:
samosvalishe committed 2026-04-03 11:25:25 +03:00
1 parent 808811bea8
commit fe4ed7f935
6 files changed
+24 -16

No files matched your search

+4 -1
View File
@@ -5,6 +5,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission android:name="com.freeturn.app.permission.CONTROL_PROXY" android:protectionLevel="signature" />
<uses-permission android:name="com.freeturn.app.permission.CONTROL_PROXY" />
<uses-permission
android:name="android.permission.FOREGROUND_SERVICE"
tools:ignore="ForegroundServicesPolicy"
@@ -51,7 +53,8 @@
<receiver
android:name=".ProxyReceiver"
android:exported="true">
android:exported="true"
android:permission="com.freeturn.app.permission.CONTROL_PROXY">
<intent-filter>
<action android:name="com.freeturn.app.START_PROXY" />
<action android:name="com.freeturn.app.STOP_PROXY" />
@@ -109,7 +109,7 @@ class ProxyService : Service() {
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VkTurn::BgLock")
wakeLock?.acquire(TimeUnit.HOURS.toMillis(8))
wakeLock?.acquire(TimeUnit.HOURS.toMillis(24))
registerNetworkCallback()
@@ -195,7 +195,8 @@ class ProxyService : Service() {
if (!userStopped.get()) {
restartCount = 0
// P2-5: destroyForcibly() — SIGKILL, нативный процесс не игнорирует
process.get()?.destroyForcibly()
val p = process.get()
p?.destroyForcibly()
}
}, 2_000)
}
@@ -279,7 +280,8 @@ class ProxyService : Service() {
addLog("=== СМЕНА СЕТИ — ПЕРЕЗАПУСК ===")
updateNotification("VK TURN Proxy", "Смена сети, переподключение...")
restartCount = 0
process.get()?.destroyForcibly()
val p = process.get()
p?.destroyForcibly()
}
}
}
@@ -16,6 +16,9 @@ import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import java.io.File
class LocalProxyManager(private val context: Context) {
@@ -26,6 +29,9 @@ class LocalProxyManager(private val context: Context) {
private val _customKernelExists = MutableStateFlow(false)
val customKernelExists: StateFlow<Boolean> = _customKernelExists.asStateFlow()
private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
private var resetJob: kotlinx.coroutines.Job? = null
init {
_customKernelExists.value = File(context.filesDir, "custom_vkturn").exists()
}
@@ -88,10 +94,13 @@ class LocalProxyManager(private val context: Context) {
_proxyState.value = ProxyState.Idle
}
suspend fun setErrorWithAutoReset(message: String) {
fun setErrorWithAutoReset(message: String) {
resetJob?.cancel()
_proxyState.value = ProxyState.Error(message)
delay(3500)
if (_proxyState.value is ProxyState.Error) _proxyState.value = ProxyState.Idle
resetJob = scope.launch {
delay(3500)
if (_proxyState.value is ProxyState.Error) _proxyState.value = ProxyState.Idle
}
}
suspend fun setCustomKernel(uri: Uri) = withContext(Dispatchers.IO) {
@@ -58,7 +58,7 @@ object ServerScripts {
cd /opt/vk-turn &&
ARCH=${'$'}(uname -m);
if [ "${'$'}ARCH" = "x86_64" ]; then BIN="server-linux-amd64"; else BIN="server-linux-arm64"; fi;
nohup ./${'$'}BIN -listen $listen -connect $connect > server.log 2>&1 &
nohup ./${'$'}BIN -listen '${listen}' -connect '${connect}' > server.log 2>&1 &
echo ${'$'}! > proxy.pid && echo "STARTED"
""".trimIndent()
@@ -4,9 +4,6 @@ import android.content.Context
import android.os.VibrationEffect
import android.os.Vibrator
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
/**
* Apple-like haptic patterns for a tactile, musical feel.
@@ -32,7 +29,6 @@ object HapticUtil {
LAUNCH,
}
@OptIn(DelicateCoroutinesApi::class)
fun perform(context: Context, pattern: Pattern) {
val vibrator = context.getSystemService(Vibrator::class.java) ?: return
val effect = when (pattern) {
@@ -87,8 +83,6 @@ object HapticUtil {
-1
)
}
GlobalScope.launch(Dispatchers.Default) {
try { vibrator.vibrate(effect) } catch(_: Exception) {}
}
try { vibrator.vibrate(effect) } catch(_: Exception) {}
}
}
@@ -70,7 +70,7 @@ fun SshSetupScreen(
var ip by rememberSaveable(savedConfig.ip) { mutableStateOf(savedConfig.ip) }
var port by rememberSaveable(savedConfig.port) { mutableStateOf(savedConfig.port.toString()) }
var username by rememberSaveable(savedConfig.username) { mutableStateOf(savedConfig.username) }
var password by rememberSaveable { mutableStateOf(savedConfig.password) }
var password by remember { mutableStateOf(savedConfig.password) }
var authType by rememberSaveable(savedConfig.authType) { mutableStateOf(savedConfig.authType) }
var sshKey by rememberSaveable(savedConfig.sshKey) { mutableStateOf(savedConfig.sshKey) }
var showPassword by remember { mutableStateOf(false) }