From 259aa4cbc82153af9b787750939abb5a18f57f61 Mon Sep 17 00:00:00 2001 From: vadym Date: Sat, 26 Jun 2021 18:28:14 +0300 Subject: [PATCH] 1. Service status fix #48 --- app/build.gradle | 4 ++-- .../main/java/io/github/chronosx88/yggdrasil/MainActivity.kt | 3 +++ .../io/github/chronosx88/yggdrasil/YggdrasilTunService.kt | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 32f0f5c..d2fee53 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdkVersion 15 targetSdkVersion 29 - versionCode 30 - versionName "2.0.12" + versionCode 32 + versionName "2.0.14" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" setProperty("archivesBaseName", project.getParent().name+"-"+versionName) } diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt index 9bf848e..b4d56ab 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt @@ -398,6 +398,9 @@ class MainActivity : AppCompatActivity() { //TODO reimplement it 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 = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager for (service in manager.getRunningServices(Int.MAX_VALUE)) { diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt index f5f0c6a..9c5f4d8 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt @@ -42,6 +42,7 @@ class YggdrasilTunService : VpnService() { companion object { private const val TAG = "Yggdrasil-service" + public const val IS_VPN_SERVICE_STOPPED = "VPN_STATUS" } private val FOREGROUND_ID = 1338 @@ -273,6 +274,7 @@ class YggdrasilTunService : VpnService() { "" } var intent = Intent(this, MainActivity::class.java) + intent.putExtra(IS_VPN_SERVICE_STOPPED, isClosed); var stackBuilder = TaskStackBuilder.create(this) stackBuilder.addNextIntentWithParentStack(intent) var pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)