You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Updated service architecture and extracted useful tools to separate class
This commit is contained in:
committed by
John Wu
parent
452db51669
commit
967bdeae7b
@@ -8,7 +8,7 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.model.download.CompoundDownloadService
|
||||
import com.topjohnwu.magisk.model.download.DownloadService
|
||||
import com.topjohnwu.magisk.model.entity.internal.Configuration
|
||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
||||
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||
@@ -32,8 +32,9 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun flash(activity: MagiskActivity<*, *>) = activity.withExternalRW {
|
||||
onSuccess {
|
||||
val subject = DownloadSubject.Magisk(Configuration.Flash.Primary)
|
||||
CompoundDownloadService.download(context, subject)
|
||||
DownloadService(context) {
|
||||
subject = DownloadSubject.Magisk(Configuration.Flash.Primary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +47,10 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
activity.startActivityForResult(intent, Const.ID.SELECT_BOOT) { resultCode, data ->
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
val safeData = data.data ?: Uri.EMPTY
|
||||
val subject = DownloadSubject.Magisk(Configuration.Patch(safeData))
|
||||
CompoundDownloadService.download(activity, subject)
|
||||
DownloadService(activity) {
|
||||
val safeData = data.data ?: Uri.EMPTY
|
||||
subject = DownloadSubject.Magisk(Configuration.Patch(safeData))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,8 +59,9 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun downloadOnly(activity: MagiskActivity<*, *>) = activity.withExternalRW {
|
||||
onSuccess {
|
||||
val subject = DownloadSubject.Magisk(Configuration.Download)
|
||||
CompoundDownloadService.download(activity, subject)
|
||||
DownloadService(activity) {
|
||||
subject = DownloadSubject.Magisk(Configuration.Download)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +72,9 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
.setMessage(R.string.install_inactive_slot_msg)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.yes) { _, _ ->
|
||||
val subject = DownloadSubject.Magisk(Configuration.Flash.Secondary)
|
||||
CompoundDownloadService.download(activity, subject)
|
||||
DownloadService(activity) {
|
||||
subject = DownloadSubject.Magisk(Configuration.Flash.Secondary)
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
.show()
|
||||
|
||||
Reference in New Issue
Block a user