Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
1ed67eed
Commit
1ed67eed
authored
Aug 21, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename classes and fields
parent
abc54571
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
87 additions
and
87 deletions
+87
-87
GeneralReceiver.kt
...rc/main/java/com/topjohnwu/magisk/core/GeneralReceiver.kt
+3
-3
Action.kt
...rc/main/java/com/topjohnwu/magisk/core/download/Action.kt
+7
-7
BaseDownloadService.kt
...com/topjohnwu/magisk/core/download/BaseDownloadService.kt
+13
-13
DownloadService.kt
...ava/com/topjohnwu/magisk/core/download/DownloadService.kt
+15
-15
ManagerUpgrade.kt
...java/com/topjohnwu/magisk/core/download/ManagerUpgrade.kt
+4
-4
Subject.kt
...c/main/java/com/topjohnwu/magisk/core/download/Subject.kt
+15
-15
EnvFixDialog.kt
...n/java/com/topjohnwu/magisk/events/dialog/EnvFixDialog.kt
+2
-2
ManagerInstallDialog.kt
...om/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
+3
-3
ModuleInstallDialog.kt
...com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt
+4
-4
UninstallDialog.kt
...ava/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt
+3
-3
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+3
-3
InstallViewModel.kt
.../java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt
+9
-9
ModuleViewModel.kt
...in/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
+3
-3
SettingsViewModel.kt
...ava/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
+3
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/core/GeneralReceiver.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion
import
com.topjohnwu.magisk.core.download.
Ac
tion
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject
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
(
Configura
tion
.
APK
.
Upgrade
)
subject
=
Subject
.
Manager
(
Ac
tion
.
APK
.
Upgrade
)
}
}
Const
.
Key
.
BROADCAST_REBOOT
->
reboot
()
...
...
app/src/main/java/com/topjohnwu/magisk/core/download/
Configura
tion.kt
→
app/src/main/java/com/topjohnwu/magisk/core/download/
Ac
tion.kt
View file @
1ed67eed
...
...
@@ -4,9 +4,9 @@ import android.net.Uri
import
android.os.Parcelable
import
kotlinx.android.parcel.Parcelize
sealed
class
Configura
tion
:
Parcelable
{
sealed
class
Ac
tion
:
Parcelable
{
sealed
class
Flash
:
Configura
tion
()
{
sealed
class
Flash
:
Ac
tion
()
{
@Parcelize
object
Primary
:
Flash
()
...
...
@@ -16,7 +16,7 @@ sealed class Configuration : Parcelable {
}
sealed
class
APK
:
Configura
tion
()
{
sealed
class
APK
:
Ac
tion
()
{
@Parcelize
object
Upgrade
:
APK
()
...
...
@@ -26,15 +26,15 @@ sealed class Configuration : Parcelable {
}
@Parcelize
object
Download
:
Configura
tion
()
object
Download
:
Ac
tion
()
@Parcelize
object
Uninstall
:
Configura
tion
()
object
Uninstall
:
Ac
tion
()
@Parcelize
object
EnvFix
:
Configura
tion
()
object
EnvFix
:
Ac
tion
()
@Parcelize
data class
Patch
(
val
fileUri
:
Uri
)
:
Configura
tion
()
data class
Patch
(
val
fileUri
:
Uri
)
:
Ac
tion
()
}
app/src/main/java/com/topjohnwu/magisk/core/download/BaseDownloadService.kt
View file @
1ed67eed
...
...
@@ -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
<
Download
Subject
>(
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
Download
Subject
.
startDownload
()
{
val
skip
=
this
is
Download
Subject
.
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
Download
Subject
.
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
:
Download
Subject
):
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
Download
Subject
.
notifyID
()
=
hashCode
()
fun
Subject
.
notifyID
()
=
hashCode
()
private
fun
notifyFail
(
subject
:
Download
Subject
)
=
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
:
Download
Subject
)
=
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
:
Download
Subject
,
id
:
Int
)
protected
abstract
suspend
fun
onFinish
(
subject
:
Subject
,
id
:
Int
)
protected
abstract
fun
Notification
.
Builder
.
setIntent
(
subject
:
Download
Subject
)
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
,
Download
Subject
>>()
private
val
progressBroadcast
=
MutableLiveData
<
Pair
<
Float
,
Subject
>>()
fun
observeProgress
(
owner
:
LifecycleOwner
,
callback
:
(
Float
,
Download
Subject
)
->
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
:
Download
Subject
)
{
private
fun
broadcast
(
progress
:
Float
,
subject
:
Subject
)
{
progressBroadcast
.
postValue
(
progress
to
subject
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion.*
import
com.topjohnwu.magisk.core.download.
Configura
tion.Flash.Secondary
import
com.topjohnwu.magisk.core.download.
Download
Subject.*
import
com.topjohnwu.magisk.core.download.
Ac
tion.*
import
com.topjohnwu.magisk.core.download.
Ac
tion.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
:
Download
Subject
,
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
=
configura
tion
)
{
private
suspend
fun
Magisk
.
onFinish
(
id
:
Int
)
=
when
(
val
action
=
ac
tion
)
{
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
(
configura
tion
)
{
private
fun
Module
.
onFinish
(
id
:
Int
)
=
when
(
ac
tion
)
{
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
:
Download
Subject
)
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
.
configura
tion
)
{
=
when
(
val
action
=
subject
.
ac
tion
)
{
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
.
configura
tion
)
{
=
when
(
subject
.
ac
tion
)
{
is
Flash
->
setContentIntent
(
FlashFragment
.
installIntent
(
context
,
subject
.
file
))
else
->
setContentIntent
(
Intent
())
}
private
fun
Notification
.
Builder
.
setIntent
(
subject
:
Manager
)
=
when
(
subject
.
configura
tion
)
{
=
when
(
subject
.
ac
tion
)
{
APK
.
Upgrade
->
setContentIntent
(
APKInstall
.
installIntent
(
context
,
subject
.
file
))
else
->
setContentIntent
(
Intent
())
}
...
...
@@ -85,7 +85,7 @@ open class DownloadService : BaseDownloadService() {
// ---
class
Builder
{
lateinit
var
subject
:
Download
Subject
lateinit
var
subject
:
Subject
}
companion
object
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/download/ManagerUpgrade.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion.APK.Restore
import
com.topjohnwu.magisk.core.download.
Configura
tion.APK.Upgrade
import
com.topjohnwu.magisk.core.download.
Ac
tion.APK.Restore
import
com.topjohnwu.magisk.core.download.
Ac
tion.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
:
Download
Subject
.
Manager
)
=
when
(
subject
.
configura
tion
)
{
suspend
fun
DownloadService
.
handleAPK
(
subject
:
Subject
.
Manager
)
=
when
(
subject
.
ac
tion
)
{
is
Upgrade
->
upgrade
(
subject
.
file
,
subject
.
notifyID
())
is
Restore
->
restore
(
subject
.
file
,
subject
.
notifyID
())
}
app/src/main/java/com/topjohnwu/magisk/core/download/
Download
Subject.kt
→
app/src/main/java/com/topjohnwu/magisk/core/download/Subject.kt
View file @
1ed67eed
...
...
@@ -13,17 +13,18 @@ import kotlinx.android.parcel.IgnoredOnParcel
import
kotlinx.android.parcel.Parcelize
import
java.io.File
sealed
class
Download
Subject
:
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
:
Configura
tion
)
:
Download
Subject
()
{
override
val
action
:
Ac
tion
)
:
Subject
()
{
override
val
url
:
String
get
()
=
module
.
zipUrl
@IgnoredOnParcel
...
...
@@ -34,8 +35,8 @@ sealed class DownloadSubject : Parcelable {
@Parcelize
class
Manager
(
val
configuration
:
Configura
tion
.
APK
)
:
Download
Subject
()
{
override
val
action
:
Ac
tion
.
APK
)
:
Subject
()
{
@IgnoredOnParcel
val
manager
:
ManagerJson
=
Info
.
remote
.
app
...
...
@@ -53,14 +54,13 @@ sealed class DownloadSubject : Parcelable {
}
abstract
class
Magisk
:
Download
Subject
()
{
abstract
class
Magisk
:
Subject
()
{
abstract
val
configuration
:
Configuration
val
magisk
:
MagiskJson
=
Info
.
remote
.
magisk
@Parcelize
private
class
Download
Internal
(
override
val
configuration
:
Configura
tion
private
class
Internal
(
override
val
action
:
Ac
tion
)
:
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
()
=
Configura
tion
.
Uninstall
override
val
action
get
()
=
Ac
tion
.
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
()
=
Configura
tion
.
Download
override
val
action
get
()
=
Ac
tion
.
Download
override
val
url
:
String
get
()
=
magisk
.
link
@IgnoredOnParcel
...
...
@@ -94,10 +94,10 @@ sealed class DownloadSubject : Parcelable {
}
companion
object
{
operator
fun
invoke
(
config
uration
:
Configuration
)
=
when
(
configuration
)
{
Configura
tion
.
Download
->
Download
()
Configura
tion
.
Uninstall
->
Uninstall
()
Configuration
.
EnvFix
,
is
Configuration
.
Flash
,
is
Configuration
.
Patch
->
DownloadInternal
(
configuration
)
operator
fun
invoke
(
config
:
Action
)
=
when
(
config
)
{
Ac
tion
.
Download
->
Download
()
Ac
tion
.
Uninstall
->
Uninstall
()
Action
.
EnvFix
,
is
Action
.
Flash
,
is
Action
.
Patch
->
Internal
(
config
)
else
->
throw
IllegalArgumentException
()
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/EnvFixDialog.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion.EnvFix
import
com.topjohnwu.magisk.core.download.
Ac
tion.EnvFix
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject.Magisk
import
com.topjohnwu.magisk.core.download.Subject.Magisk
import
com.topjohnwu.magisk.view.MagiskDialog
class
EnvFixDialog
:
DialogEvent
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion
import
com.topjohnwu.magisk.core.download.
Ac
tion
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject
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
(
Configura
tion
.
APK
.
Upgrade
)
val
subject
=
Subject
.
Manager
(
Ac
tion
.
APK
.
Upgrade
)
applyTitle
(
R
.
string
.
repo_install_title
.
res
(
R
.
string
.
app_name
.
res
()))
applyMessage
(
R
.
string
.
repo_install_msg
.
res
(
subject
.
title
))
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt
View file @
1ed67eed
package
com.topjohnwu.magisk.events.dialog
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.download.
Configura
tion
import
com.topjohnwu.magisk.core.download.
Ac
tion
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject
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
Configura
tion
.
Download
subject
=
Download
Subject
.
Module
(
item
,
config
)
val
config
=
if
(
install
)
Action
.
Flash
.
Primary
else
Ac
tion
.
Download
subject
=
Subject
.
Module
(
item
,
config
)
}
applyTitle
(
context
.
getString
(
R
.
string
.
repo_install_title
,
item
.
name
))
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion
import
com.topjohnwu.magisk.core.download.
Ac
tion
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject
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
(
Configura
tion
.
Uninstall
)
subject
=
Subject
.
Magisk
(
Ac
tion
.
Uninstall
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
1ed67eed
...
...
@@ -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.
Download
Subject
import
com.topjohnwu.magisk.core.download.
Download
Subject.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
:
Download
Subject
)
{
fun
onProgressUpdate
(
progress
:
Float
,
subject
:
Subject
)
{
when
(
subject
)
{
is
Manager
->
stateManagerProgress
=
progress
.
times
(
100f
).
roundToInt
()
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion
import
com.topjohnwu.magisk.core.download.
Ac
tion
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject
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
:
Download
Subject
)
{
if
(
subject
!
is
Download
Subject
.
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
=
Download
Subject
.
Magisk
(
resolveConfiguration
())
subject
=
Subject
.
Magisk
(
resolveConfiguration
())
}.
also
{
state
=
State
.
LOADING
}
// ---
private
fun
resolveConfiguration
()
=
when
(
method
)
{
R
.
id
.
method_download
->
Configura
tion
.
Download
R
.
id
.
method_patch
->
Configura
tion
.
Patch
(
data
!!
)
R
.
id
.
method_direct
->
Configura
tion
.
Flash
.
Primary
R
.
id
.
method_inactive_slot
->
Configura
tion
.
Flash
.
Secondary
R
.
id
.
method_download
->
Ac
tion
.
Download
R
.
id
.
method_patch
->
Ac
tion
.
Patch
(
data
!!
)
R
.
id
.
method_direct
->
Ac
tion
.
Flash
.
Primary
R
.
id
.
method_inactive_slot
->
Ac
tion
.
Flash
.
Secondary
else
->
throw
IllegalArgumentException
(
"Unknown value"
)
}
}
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
View file @
1ed67eed
...
...
@@ -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.
Download
Subject
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
:
Download
Subject
)
{
if
(
subject
!
is
Download
Subject
.
Module
)
fun
onProgressUpdate
(
progress
:
Float
,
subject
:
Subject
)
{
if
(
subject
!
is
Subject
.
Module
)
return
viewModelScope
.
launch
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
View file @
1ed67eed
...
...
@@ -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.
Configura
tion
import
com.topjohnwu.magisk.core.download.
Ac
tion
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.
Download
Subject
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
(
Configura
tion
.
APK
.
Restore
)
subject
=
Subject
.
Manager
(
Ac
tion
.
APK
.
Restore
)
}
}
...
...
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