From 7cfab33ebb4873e6566c8a0d6de6219dc7dbd127 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 2 Aug 2019 01:21:22 -0700 Subject: [PATCH] Make sure DownloadService always start with app context --- .../com/topjohnwu/magisk/model/download/DownloadService.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadService.kt b/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadService.kt index 155bd3519..db7aa5df4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadService.kt @@ -136,14 +136,15 @@ open class DownloadService : RemoteFileService() { companion object { inline operator fun invoke(context: Context, argBuilder: Builder.() -> Unit) { + val app = context.applicationContext 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) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - context.startForegroundService(intent) + app.startForegroundService(intent) } else { - context.startService(intent) + app.startService(intent) } }