Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nathan OBrian
Nebulo
Commits
89c1350a
Commit
89c1350a
authored
Aug 10, 2019
by
Daniel Wolf
Browse files
Don't consider the app being stopped for an update as being killed by the system
parent
0f9116ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/activity/MainActivity.kt
View file @
89c1350a
...
...
@@ -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
()
}
...
...
app/src/main/java/com/frostnerd/smokescreen/service/DnsVpnService.kt
View file @
89c1350a
...
...
@@ -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."
)
...
...
app/src/main/java/com/frostnerd/smokescreen/util/preferences/AppSettings.kt
View file @
89c1350a
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment