Fix onRevoke ignored

This commit is contained in:
世界 2023-11-07 14:09:48 +08:00
parent fe5c4b5268
commit 273ddc7266
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 24 additions and 5 deletions

View file

@ -87,8 +87,8 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.4' implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.4' implementation 'androidx.navigation:navigation-ui-ktx:2.7.5'
implementation 'androidx.room:room-runtime:2.6.0' implementation 'androidx.room:room-runtime:2.6.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.preference:preference-ktx:1.2.1'
@ -132,7 +132,12 @@ if (playCredentialsJSON.exists()) {
play { play {
serviceAccountCredentials = playCredentialsJSON serviceAccountCredentials = playCredentialsJSON
defaultToAppBundles = true defaultToAppBundles = true
track = 'beta' def version = getProps("VERSION_NAME")
if (version.contains("alpha") || version.contains("beta") || version.contains("rc")) {
track = 'beta'
} else {
track = 'production'
}
} }
} }

View file

@ -5,8 +5,12 @@ import android.content.pm.PackageManager.NameNotFoundException
import android.net.ProxyInfo import android.net.ProxyInfo
import android.net.VpnService import android.net.VpnService
import android.os.Build import android.os.Build
import android.os.IBinder
import io.nekohasekai.libbox.TunOptions import io.nekohasekai.libbox.TunOptions
import io.nekohasekai.sfa.database.Settings import io.nekohasekai.sfa.database.Settings
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
class VPNService : VpnService(), PlatformInterfaceWrapper { class VPNService : VpnService(), PlatformInterfaceWrapper {
@ -19,13 +23,23 @@ class VPNService : VpnService(), PlatformInterfaceWrapper {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) = override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) =
service.onStartCommand(intent, flags, startId) service.onStartCommand(intent, flags, startId)
override fun onBind(intent: Intent) = service.onBind(intent) override fun onBind(intent: Intent): IBinder {
val binder = super.onBind(intent)
if (binder != null) {
return binder
}
return service.onBind(intent)
}
override fun onDestroy() { override fun onDestroy() {
service.onDestroy() service.onDestroy()
} }
override fun onRevoke() { override fun onRevoke() {
service.onRevoke() runBlocking {
withContext(Dispatchers.Main) {
service.onRevoke()
}
}
} }
override fun autoDetectInterfaceControl(fd: Int) { override fun autoDetectInterfaceControl(fd: Int) {