Commit 89c1350a authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Don't consider the app being stopped for an update as being killed by the system

parent 0f9116ce
......@@ -133,7 +133,10 @@ class MainActivity : NavigationDrawerActivity() {
}
}
handleDeepAction()
if(!isServiceRunning(DnsVpnService::class.java) && getPreferences().vpnServiceState == VpnServiceState.STARTED && !getPreferences().ignoreServiceKilled) {
if(!isServiceRunning(DnsVpnService::class.java) &&
getPreferences().vpnServiceState == VpnServiceState.STARTED &&
!getPreferences().ignoreServiceKilled &&
getPreferences().vpnLaunchLastVersion == BuildConfig.VERSION_CODE) {
getPreferences().vpnServiceState = VpnServiceState.STOPPED
BatteryOptimizationInfoDialog(this).show()
}
......
......@@ -155,7 +155,9 @@ class DnsVpnService : VpnService(), Runnable {
override fun onCreate() {
super.onCreate()
if(getPreferences().vpnServiceState == VpnServiceState.STARTED && !getPreferences().ignoreServiceKilled) { // The app didn't stop properly
if(getPreferences().vpnServiceState == VpnServiceState.STARTED &&
!getPreferences().ignoreServiceKilled &&
getPreferences().vpnLaunchLastVersion == BuildConfig.VERSION_CODE) { // The app didn't stop properly
val ignoreIntent = Intent(this, DnsVpnService::class.java).putExtra("command", Command.IGNORE_SERVICE_KILLED)
val ignorePendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PendingIntent.getForegroundService(this@DnsVpnService, REQUEST_CODE_IGNORE_SERVICE_KILLED, ignoreIntent, PendingIntent.FLAG_ONE_SHOT)
......@@ -175,6 +177,7 @@ class DnsVpnService : VpnService(), Runnable {
}
}
getPreferences().vpnServiceState = VpnServiceState.STARTED
getPreferences().vpnLaunchLastVersion = BuildConfig.VERSION_CODE
LeakSentry.refWatcher.watch(this, "DnsVpnService")
Thread.setDefaultUncaughtExceptionHandler { t, e ->
log("Encountered an uncaught exception.")
......
......@@ -244,6 +244,7 @@ class AppSettingsSharedPreferences(context: Context) : AppSettings, SimpleTypedP
var vpnServiceState:VpnServiceState by enumPref("vpn_service_state", VpnServiceState.STOPPED)
var ignoreServiceKilled:Boolean by booleanPref("ignore_service_killed", false)
var vpnLaunchLastVersion:Int by intPref("vpn_last_version", 43)
var automaticHostRefresh:Boolean by booleanPref("automatic_host_refresh", false)
var automaticHostRefreshWifiOnly:Boolean by booleanPref("automatic_host_refresh_wifi_only", true)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment