Rename classes and fields
This commit is contained in:
parent
abc5457136
commit
1ed67eed35
@ -3,9 +3,9 @@ package com.topjohnwu.magisk.core
|
||||
import android.content.ContextWrapper
|
||||
import android.content.Intent
|
||||
import com.topjohnwu.magisk.core.base.BaseReceiver
|
||||
import com.topjohnwu.magisk.core.download.Configuration
|
||||
import com.topjohnwu.magisk.core.download.Action
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.core.magiskdb.PolicyDao
|
||||
import com.topjohnwu.magisk.core.model.ManagerJson
|
||||
import com.topjohnwu.magisk.core.su.SuCallbackHandler
|
||||
@ -51,7 +51,7 @@ open class GeneralReceiver : BaseReceiver() {
|
||||
Info.remote = Info.remote.copy(app = it)
|
||||
}
|
||||
DownloadService(context) {
|
||||
subject = DownloadSubject.Manager(Configuration.APK.Upgrade)
|
||||
subject = Subject.Manager(Action.APK.Upgrade)
|
||||
}
|
||||
}
|
||||
Const.Key.BROADCAST_REBOOT -> reboot()
|
||||
|
@ -4,9 +4,9 @@ import android.net.Uri
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
sealed class Configuration : Parcelable {
|
||||
sealed class Action : Parcelable {
|
||||
|
||||
sealed class Flash : Configuration() {
|
||||
sealed class Flash : Action() {
|
||||
|
||||
@Parcelize
|
||||
object Primary : Flash()
|
||||
@ -16,7 +16,7 @@ sealed class Configuration : Parcelable {
|
||||
|
||||
}
|
||||
|
||||
sealed class APK : Configuration() {
|
||||
sealed class APK : Action() {
|
||||
|
||||
@Parcelize
|
||||
object Upgrade : APK()
|
||||
@ -26,15 +26,15 @@ sealed class Configuration : Parcelable {
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
object Download : Configuration()
|
||||
object Download : Action()
|
||||
|
||||
@Parcelize
|
||||
object Uninstall : Configuration()
|
||||
object Uninstall : Action()
|
||||
|
||||
@Parcelize
|
||||
object EnvFix : Configuration()
|
||||
object EnvFix : Action()
|
||||
|
||||
@Parcelize
|
||||
data class Patch(val fileUri: Uri) : Configuration()
|
||||
data class Patch(val fileUri: Uri) : Action()
|
||||
|
||||
}
|
@ -40,7 +40,7 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
override fun onBind(intent: Intent?): IBinder? = null
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
intent?.getParcelableExtra<DownloadSubject>(ARG_URL)?.let { subject ->
|
||||
intent?.getParcelableExtra<Subject>(ARG_URL)?.let { subject ->
|
||||
update(subject.notifyID())
|
||||
coroutineScope.launch {
|
||||
try {
|
||||
@ -67,12 +67,12 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
|
||||
// -- Download logic
|
||||
|
||||
private suspend fun DownloadSubject.startDownload() {
|
||||
val skip = this is DownloadSubject.Magisk && file.exists() && file.checkSum("MD5", magisk.md5)
|
||||
private suspend fun Subject.startDownload() {
|
||||
val skip = this is Subject.Magisk && file.exists() && file.checkSum("MD5", magisk.md5)
|
||||
if (!skip) {
|
||||
val stream = service.fetchFile(url).toProgressStream(this)
|
||||
when (this) {
|
||||
is DownloadSubject.Module -> // Download and process on-the-fly
|
||||
is Subject.Module -> // Download and process on-the-fly
|
||||
stream.toModule(file, service.fetchInstaller().byteStream())
|
||||
else ->
|
||||
stream.writeTo(file)
|
||||
@ -85,7 +85,7 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
private fun ResponseBody.toProgressStream(subject: DownloadSubject): InputStream {
|
||||
private fun ResponseBody.toProgressStream(subject: Subject): InputStream {
|
||||
val max = contentLength()
|
||||
val total = max.toFloat() / 1048576
|
||||
val id = subject.notifyID()
|
||||
@ -110,16 +110,16 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
|
||||
// --- Notification managements
|
||||
|
||||
fun DownloadSubject.notifyID() = hashCode()
|
||||
fun Subject.notifyID() = hashCode()
|
||||
|
||||
private fun notifyFail(subject: DownloadSubject) = lastNotify(subject.notifyID()) {
|
||||
private fun notifyFail(subject: Subject) = lastNotify(subject.notifyID()) {
|
||||
broadcast(-1f, subject)
|
||||
it.setContentText(getString(R.string.download_file_error))
|
||||
.setSmallIcon(android.R.drawable.stat_notify_error)
|
||||
.setOngoing(false)
|
||||
}
|
||||
|
||||
private fun notifyFinish(subject: DownloadSubject) = lastNotify(subject.notifyID()) {
|
||||
private fun notifyFinish(subject: Subject) = lastNotify(subject.notifyID()) {
|
||||
broadcast(1f, subject)
|
||||
it.setIntent(subject)
|
||||
.setContentText(getString(R.string.download_complete))
|
||||
@ -174,9 +174,9 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
|
||||
// --- Implement custom logic
|
||||
|
||||
protected abstract suspend fun onFinish(subject: DownloadSubject, id: Int)
|
||||
protected abstract suspend fun onFinish(subject: Subject, id: Int)
|
||||
|
||||
protected abstract fun Notification.Builder.setIntent(subject: DownloadSubject)
|
||||
protected abstract fun Notification.Builder.setIntent(subject: Subject)
|
||||
: Notification.Builder
|
||||
|
||||
// ---
|
||||
@ -184,9 +184,9 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
companion object : KoinComponent {
|
||||
const val ARG_URL = "arg_url"
|
||||
|
||||
private val progressBroadcast = MutableLiveData<Pair<Float, DownloadSubject>>()
|
||||
private val progressBroadcast = MutableLiveData<Pair<Float, Subject>>()
|
||||
|
||||
fun observeProgress(owner: LifecycleOwner, callback: (Float, DownloadSubject) -> Unit) {
|
||||
fun observeProgress(owner: LifecycleOwner, callback: (Float, Subject) -> Unit) {
|
||||
progressBroadcast.value = null
|
||||
progressBroadcast.observe(owner) {
|
||||
val (progress, subject) = it ?: return@observe
|
||||
@ -194,7 +194,7 @@ abstract class BaseDownloadService : BaseService(), KoinComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private fun broadcast(progress: Float, subject: DownloadSubject) {
|
||||
private fun broadcast(progress: Float, subject: Subject) {
|
||||
progressBroadcast.postValue(progress to subject)
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import com.topjohnwu.magisk.core.download.Configuration.*
|
||||
import com.topjohnwu.magisk.core.download.Configuration.Flash.Secondary
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject.*
|
||||
import com.topjohnwu.magisk.core.download.Action.*
|
||||
import com.topjohnwu.magisk.core.download.Action.Flash.Secondary
|
||||
import com.topjohnwu.magisk.core.download.Subject.*
|
||||
import com.topjohnwu.magisk.core.intent
|
||||
import com.topjohnwu.magisk.core.tasks.EnvFixTask
|
||||
import com.topjohnwu.magisk.ui.flash.FlashFragment
|
||||
@ -20,25 +20,25 @@ open class DownloadService : BaseDownloadService() {
|
||||
|
||||
private val context get() = this
|
||||
|
||||
override suspend fun onFinish(subject: DownloadSubject, id: Int) = when (subject) {
|
||||
override suspend fun onFinish(subject: Subject, id: Int) = when (subject) {
|
||||
is Magisk -> subject.onFinish(id)
|
||||
is Module -> subject.onFinish(id)
|
||||
is Manager -> subject.onFinish(id)
|
||||
}
|
||||
|
||||
private suspend fun Magisk.onFinish(id: Int) = when (val conf = configuration) {
|
||||
private suspend fun Magisk.onFinish(id: Int) = when (val action = action) {
|
||||
Uninstall -> FlashFragment.uninstall(file, id)
|
||||
EnvFix -> {
|
||||
cancel(id)
|
||||
EnvFixTask(file).exec()
|
||||
Unit
|
||||
}
|
||||
is Patch -> FlashFragment.patch(file, conf.fileUri, id)
|
||||
is Flash -> FlashFragment.flash(file, conf is Secondary, id)
|
||||
is Patch -> FlashFragment.patch(file, action.fileUri, id)
|
||||
is Flash -> FlashFragment.flash(file, action is Secondary, id)
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
private fun Module.onFinish(id: Int) = when (configuration) {
|
||||
private fun Module.onFinish(id: Int) = when (action) {
|
||||
is Flash -> FlashFragment.install(file, id)
|
||||
else -> Unit
|
||||
}
|
||||
@ -50,7 +50,7 @@ open class DownloadService : BaseDownloadService() {
|
||||
|
||||
// --- Customize finish notification
|
||||
|
||||
override fun Notification.Builder.setIntent(subject: DownloadSubject)
|
||||
override fun Notification.Builder.setIntent(subject: Subject)
|
||||
= when (subject) {
|
||||
is Magisk -> setIntent(subject)
|
||||
is Module -> setIntent(subject)
|
||||
@ -58,21 +58,21 @@ open class DownloadService : BaseDownloadService() {
|
||||
}
|
||||
|
||||
private fun Notification.Builder.setIntent(subject: Magisk)
|
||||
= when (val conf = subject.configuration) {
|
||||
= when (val action = subject.action) {
|
||||
Uninstall -> setContentIntent(FlashFragment.uninstallIntent(context, subject.file))
|
||||
is Flash -> setContentIntent(FlashFragment.flashIntent(context, subject.file, conf is Secondary))
|
||||
is Patch -> setContentIntent(FlashFragment.patchIntent(context, subject.file, conf.fileUri))
|
||||
is Flash -> setContentIntent(FlashFragment.flashIntent(context, subject.file, action is Secondary))
|
||||
is Patch -> setContentIntent(FlashFragment.patchIntent(context, subject.file, action.fileUri))
|
||||
else -> setContentIntent(Intent())
|
||||
}
|
||||
|
||||
private fun Notification.Builder.setIntent(subject: Module)
|
||||
= when (subject.configuration) {
|
||||
= when (subject.action) {
|
||||
is Flash -> setContentIntent(FlashFragment.installIntent(context, subject.file))
|
||||
else -> setContentIntent(Intent())
|
||||
}
|
||||
|
||||
private fun Notification.Builder.setIntent(subject: Manager)
|
||||
= when (subject.configuration) {
|
||||
= when (subject.action) {
|
||||
APK.Upgrade -> setContentIntent(APKInstall.installIntent(context, subject.file))
|
||||
else -> setContentIntent(Intent())
|
||||
}
|
||||
@ -85,7 +85,7 @@ open class DownloadService : BaseDownloadService() {
|
||||
// ---
|
||||
|
||||
class Builder {
|
||||
lateinit var subject: DownloadSubject
|
||||
lateinit var subject: Subject
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -6,8 +6,8 @@ import com.topjohnwu.magisk.ProcessPhoenix
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.Configuration.APK.Restore
|
||||
import com.topjohnwu.magisk.core.download.Configuration.APK.Upgrade
|
||||
import com.topjohnwu.magisk.core.download.Action.APK.Restore
|
||||
import com.topjohnwu.magisk.core.download.Action.APK.Upgrade
|
||||
import com.topjohnwu.magisk.core.intent
|
||||
import com.topjohnwu.magisk.core.isRunningAsStub
|
||||
import com.topjohnwu.magisk.core.utils.PatchAPK
|
||||
@ -66,8 +66,8 @@ private fun DownloadService.restore(apk: File, id: Int) {
|
||||
Shell.su("pm install $apk && pm uninstall $packageName").exec()
|
||||
}
|
||||
|
||||
suspend fun DownloadService.handleAPK(subject: DownloadSubject.Manager) =
|
||||
when (subject.configuration) {
|
||||
suspend fun DownloadService.handleAPK(subject: Subject.Manager) =
|
||||
when (subject.action) {
|
||||
is Upgrade -> upgrade(subject.file, subject.notifyID())
|
||||
is Restore -> restore(subject.file, subject.notifyID())
|
||||
}
|
||||
|
@ -13,17 +13,18 @@ import kotlinx.android.parcel.IgnoredOnParcel
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import java.io.File
|
||||
|
||||
sealed class DownloadSubject : Parcelable {
|
||||
sealed class Subject : Parcelable {
|
||||
|
||||
abstract val url: String
|
||||
abstract val file: File
|
||||
abstract val action: Action
|
||||
open val title: String get() = file.name
|
||||
|
||||
@Parcelize
|
||||
class Module(
|
||||
val module: Repo,
|
||||
val configuration: Configuration
|
||||
) : DownloadSubject() {
|
||||
override val action: Action
|
||||
) : Subject() {
|
||||
override val url: String get() = module.zipUrl
|
||||
|
||||
@IgnoredOnParcel
|
||||
@ -34,8 +35,8 @@ sealed class DownloadSubject : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
class Manager(
|
||||
val configuration: Configuration.APK
|
||||
) : DownloadSubject() {
|
||||
override val action: Action.APK
|
||||
) : Subject() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val manager: ManagerJson = Info.remote.app
|
||||
@ -53,14 +54,13 @@ sealed class DownloadSubject : Parcelable {
|
||||
|
||||
}
|
||||
|
||||
abstract class Magisk : DownloadSubject() {
|
||||
abstract class Magisk : Subject() {
|
||||
|
||||
abstract val configuration: Configuration
|
||||
val magisk: MagiskJson = Info.remote.magisk
|
||||
|
||||
@Parcelize
|
||||
private class DownloadInternal(
|
||||
override val configuration: Configuration
|
||||
private class Internal(
|
||||
override val action: Action
|
||||
) : Magisk() {
|
||||
override val url: String get() = magisk.link
|
||||
override val title: String get() = "Magisk-${magisk.version}(${magisk.versionCode})"
|
||||
@ -73,7 +73,7 @@ sealed class DownloadSubject : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
private class Uninstall : Magisk() {
|
||||
override val configuration get() = Configuration.Uninstall
|
||||
override val action get() = Action.Uninstall
|
||||
override val url: String get() = Info.remote.uninstaller.link
|
||||
|
||||
@IgnoredOnParcel
|
||||
@ -84,7 +84,7 @@ sealed class DownloadSubject : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
private class Download : Magisk() {
|
||||
override val configuration get() = Configuration.Download
|
||||
override val action get() = Action.Download
|
||||
override val url: String get() = magisk.link
|
||||
|
||||
@IgnoredOnParcel
|
||||
@ -94,10 +94,10 @@ sealed class DownloadSubject : Parcelable {
|
||||
}
|
||||
|
||||
companion object {
|
||||
operator fun invoke(configuration: Configuration) = when (configuration) {
|
||||
Configuration.Download -> Download()
|
||||
Configuration.Uninstall -> Uninstall()
|
||||
Configuration.EnvFix, is Configuration.Flash, is Configuration.Patch -> DownloadInternal(configuration)
|
||||
operator fun invoke(config: Action) = when (config) {
|
||||
Action.Download -> Download()
|
||||
Action.Uninstall -> Uninstall()
|
||||
Action.EnvFix, is Action.Flash, is Action.Patch -> Internal(config)
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
}
|
@ -6,9 +6,9 @@ import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.download.Configuration.EnvFix
|
||||
import com.topjohnwu.magisk.core.download.Action.EnvFix
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject.Magisk
|
||||
import com.topjohnwu.magisk.core.download.Subject.Magisk
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
|
||||
class EnvFixDialog : DialogEvent() {
|
||||
|
@ -2,9 +2,9 @@ package com.topjohnwu.magisk.events.dialog
|
||||
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.Configuration
|
||||
import com.topjohnwu.magisk.core.download.Action
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.ktx.res
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
import com.topjohnwu.magisk.view.MarkDownWindow
|
||||
@ -16,7 +16,7 @@ class ManagerInstallDialog : DialogEvent() {
|
||||
|
||||
override fun build(dialog: MagiskDialog) {
|
||||
with(dialog) {
|
||||
val subject = DownloadSubject.Manager(Configuration.APK.Upgrade)
|
||||
val subject = Subject.Manager(Action.APK.Upgrade)
|
||||
|
||||
applyTitle(R.string.repo_install_title.res(R.string.app_name.res()))
|
||||
applyMessage(R.string.repo_install_msg.res(subject.title))
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.topjohnwu.magisk.events.dialog
|
||||
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.download.Configuration
|
||||
import com.topjohnwu.magisk.core.download.Action
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.core.model.module.Repo
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
|
||||
@ -13,8 +13,8 @@ class ModuleInstallDialog(private val item: Repo) : DialogEvent() {
|
||||
with(dialog) {
|
||||
|
||||
fun download(install: Boolean) = DownloadService(context) {
|
||||
val config = if (install) Configuration.Flash.Primary else Configuration.Download
|
||||
subject = DownloadSubject.Module(item, config)
|
||||
val config = if (install) Action.Flash.Primary else Action.Download
|
||||
subject = Subject.Module(item, config)
|
||||
}
|
||||
|
||||
applyTitle(context.getString(R.string.repo_install_title, item.name))
|
||||
|
@ -3,9 +3,9 @@ package com.topjohnwu.magisk.events.dialog
|
||||
import android.widget.Toast
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.Configuration
|
||||
import com.topjohnwu.magisk.core.download.Action
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@ -48,7 +48,7 @@ class UninstallDialog : DialogEvent() {
|
||||
|
||||
private fun completeUninstall() {
|
||||
DownloadService(dialog.context) {
|
||||
subject = DownloadSubject.Magisk(Configuration.Uninstall)
|
||||
subject = Subject.Magisk(Action.Uninstall)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.*
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject.Manager
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.core.download.Subject.Manager
|
||||
import com.topjohnwu.magisk.core.model.MagiskJson
|
||||
import com.topjohnwu.magisk.core.model.ManagerJson
|
||||
import com.topjohnwu.magisk.data.repository.MagiskRepository
|
||||
@ -111,7 +111,7 @@ class HomeViewModel(
|
||||
}
|
||||
}.publish()
|
||||
|
||||
fun onProgressUpdate(progress: Float, subject: DownloadSubject) {
|
||||
fun onProgressUpdate(progress: Float, subject: Subject) {
|
||||
when (subject) {
|
||||
is Manager -> stateManagerProgress = progress.times(100f).roundToInt()
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import com.topjohnwu.magisk.BR
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseViewModel
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.Configuration
|
||||
import com.topjohnwu.magisk.core.download.Action
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.data.repository.StringRepository
|
||||
import com.topjohnwu.magisk.events.RequestFileEvent
|
||||
import com.topjohnwu.magisk.events.dialog.SecondSlotWarningDialog
|
||||
@ -64,8 +64,8 @@ class InstallViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun onProgressUpdate(progress: Float, subject: DownloadSubject) {
|
||||
if (subject !is DownloadSubject.Magisk) {
|
||||
fun onProgressUpdate(progress: Float, subject: Subject) {
|
||||
if (subject !is Subject.Magisk) {
|
||||
return
|
||||
}
|
||||
this.progress = progress.times(100).roundToInt()
|
||||
@ -79,16 +79,16 @@ class InstallViewModel(
|
||||
}
|
||||
|
||||
fun install() = DownloadService(get()) {
|
||||
subject = DownloadSubject.Magisk(resolveConfiguration())
|
||||
subject = Subject.Magisk(resolveConfiguration())
|
||||
}.also { state = State.LOADING }
|
||||
|
||||
// ---
|
||||
|
||||
private fun resolveConfiguration() = when (method) {
|
||||
R.id.method_download -> Configuration.Download
|
||||
R.id.method_patch -> Configuration.Patch(data!!)
|
||||
R.id.method_direct -> Configuration.Flash.Primary
|
||||
R.id.method_inactive_slot -> Configuration.Flash.Secondary
|
||||
R.id.method_download -> Action.Download
|
||||
R.id.method_patch -> Action.Patch(data!!)
|
||||
R.id.method_direct -> Action.Flash.Primary
|
||||
R.id.method_inactive_slot -> Action.Flash.Secondary
|
||||
else -> throw IllegalArgumentException("Unknown value")
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.topjohnwu.magisk.BR
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.*
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.core.model.module.Module
|
||||
import com.topjohnwu.magisk.core.tasks.RepoUpdater
|
||||
import com.topjohnwu.magisk.data.database.RepoByNameDao
|
||||
@ -147,8 +147,8 @@ class ModuleViewModel(
|
||||
|
||||
// ---
|
||||
|
||||
fun onProgressUpdate(progress: Float, subject: DownloadSubject) {
|
||||
if (subject !is DownloadSubject.Module)
|
||||
fun onProgressUpdate(progress: Float, subject: Subject) {
|
||||
if (subject !is Subject.Module)
|
||||
return
|
||||
|
||||
viewModelScope.launch {
|
||||
|
@ -15,9 +15,9 @@ import com.topjohnwu.magisk.arch.diffListOf
|
||||
import com.topjohnwu.magisk.arch.itemBindingOf
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.Configuration
|
||||
import com.topjohnwu.magisk.core.download.Action
|
||||
import com.topjohnwu.magisk.core.download.DownloadService
|
||||
import com.topjohnwu.magisk.core.download.DownloadSubject
|
||||
import com.topjohnwu.magisk.core.download.Subject
|
||||
import com.topjohnwu.magisk.core.utils.PatchAPK
|
||||
import com.topjohnwu.magisk.data.database.RepoDao
|
||||
import com.topjohnwu.magisk.events.AddHomeIconEvent
|
||||
@ -145,7 +145,7 @@ class SettingsViewModel(
|
||||
|
||||
private fun restoreManager() {
|
||||
DownloadService(get()) {
|
||||
subject = DownloadSubject.Manager(Configuration.APK.Restore)
|
||||
subject = Subject.Manager(Action.APK.Restore)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user