mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 22:37:38 +00:00
Make sure DownloadService always start with app context
This commit is contained in:
parent
1ababc8c7f
commit
7cfab33ebb
@ -136,14 +136,15 @@ open class DownloadService : RemoteFileService() {
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
inline operator fun invoke(context: Context, argBuilder: Builder.() -> Unit) {
|
inline operator fun invoke(context: Context, argBuilder: Builder.() -> Unit) {
|
||||||
|
val app = context.applicationContext
|
||||||
val builder = Builder().apply(argBuilder)
|
val builder = Builder().apply(argBuilder)
|
||||||
val intent = Intent(context, ClassMap[DownloadService::class.java])
|
val intent = Intent(app, ClassMap[DownloadService::class.java])
|
||||||
.putExtra(ARG_URL, builder.subject)
|
.putExtra(ARG_URL, builder.subject)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
context.startForegroundService(intent)
|
app.startForegroundService(intent)
|
||||||
} else {
|
} else {
|
||||||
context.startService(intent)
|
app.startService(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user