1. Service status fix #48

This commit is contained in:
vadym 2021-06-26 18:28:14 +03:00
parent 35c5dd3ba1
commit 259aa4cbc8
3 changed files with 7 additions and 2 deletions

View File

@ -8,8 +8,8 @@ android {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 29 targetSdkVersion 29
versionCode 30 versionCode 32
versionName "2.0.12" versionName "2.0.14"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", project.getParent().name+"-"+versionName) setProperty("archivesBaseName", project.getParent().name+"-"+versionName)
} }

View File

@ -398,6 +398,9 @@ class MainActivity : AppCompatActivity() {
//TODO reimplement it //TODO reimplement it
private fun isYggServiceRunning(context: Context): Boolean { private fun isYggServiceRunning(context: Context): Boolean {
if(this.intent.hasExtra(YggdrasilTunService.IS_VPN_SERVICE_STOPPED)){
return !this.intent.getBooleanExtra(YggdrasilTunService.IS_VPN_SERVICE_STOPPED, true)
}
val manager = val manager =
context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (service in manager.getRunningServices(Int.MAX_VALUE)) { for (service in manager.getRunningServices(Int.MAX_VALUE)) {

View File

@ -42,6 +42,7 @@ class YggdrasilTunService : VpnService() {
companion object { companion object {
private const val TAG = "Yggdrasil-service" private const val TAG = "Yggdrasil-service"
public const val IS_VPN_SERVICE_STOPPED = "VPN_STATUS"
} }
private val FOREGROUND_ID = 1338 private val FOREGROUND_ID = 1338
@ -273,6 +274,7 @@ class YggdrasilTunService : VpnService() {
"" ""
} }
var intent = Intent(this, MainActivity::class.java) var intent = Intent(this, MainActivity::class.java)
intent.putExtra(IS_VPN_SERVICE_STOPPED, isClosed);
var stackBuilder = TaskStackBuilder.create(this) var stackBuilder = TaskStackBuilder.create(this)
stackBuilder.addNextIntentWithParentStack(intent) stackBuilder.addNextIntentWithParentStack(intent)
var pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) var pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)