Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
b18072e1
Commit
b18072e1
authored
Apr 26, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto start service on package upgrade
parent
0eef4711
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
core/src/main/AndroidManifest.xml
core/src/main/AndroidManifest.xml
+1
-0
core/src/main/java/com/github/shadowsocks/BootReceiver.kt
core/src/main/java/com/github/shadowsocks/BootReceiver.kt
+9
-5
No files found.
core/src/main/AndroidManifest.xml
View file @
b18072e1
...
...
@@ -69,6 +69,7 @@
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.LOCKED_BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.MY_PACKAGE_REPLACED"
/>
</intent-filter>
</receiver>
...
...
core/src/main/java/com/github/shadowsocks/BootReceiver.kt
View file @
b18072e1
...
...
@@ -25,6 +25,9 @@ import android.content.ComponentName
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.os.Build
import
android.os.UserManager
import
androidx.core.content.getSystemService
import
com.github.shadowsocks.Core.app
import
com.github.shadowsocks.preference.DataStore
...
...
@@ -40,11 +43,12 @@ class BootReceiver : BroadcastReceiver() {
}
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
val
locked
=
when
(
intent
.
action
)
{
Intent
.
ACTION_BOOT_COMPLETED
->
false
Intent
.
ACTION_LOCKED_BOOT_COMPLETED
->
true
// constant will be folded so no need to do version checks
else
->
return
val
doStart
=
when
(
intent
.
action
)
{
Intent
.
ACTION_BOOT_COMPLETED
->
!
DataStore
.
directBootAware
Intent
.
ACTION_LOCKED_BOOT_COMPLETED
->
DataStore
.
directBootAware
else
->
DataStore
.
directBootAware
||
Build
.
VERSION
.
SDK_INT
>=
24
&&
app
.
getSystemService
<
UserManager
>()
?.
isUserUnlocked
!=
false
}
if
(
DataStore
.
directBootAware
==
locked
)
Core
.
startService
()
if
(
doStart
)
Core
.
startService
()
}
}
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