Fixed modules screen not offering reboot when local modules change

This commit is contained in:
Viktor De Pasquale 2020-03-29 11:55:37 +02:00 committed by John Wu
parent ea855837df
commit 6e14a727b1
3 changed files with 15 additions and 11 deletions

View File

@ -18,12 +18,13 @@ class Module(path: String) : BaseModule() {
private val updateFile = SuFile(path, "update")
private val ruleFile = SuFile(path, "sepolicy.rule")
val updated: Boolean = updateFile.exists()
val updated: Boolean get() = updateFile.exists()
var enable: Boolean = !disableFile.exists()
var enable: Boolean
get() = !disableFile.exists()
set(enable) {
val dir = "$PERSIST/$id"
field = if (enable) {
if (enable) {
Shell.su("mkdir -p $dir", "cp -af $ruleFile $dir").submit()
disableFile.delete()
} else {
@ -32,9 +33,10 @@ class Module(path: String) : BaseModule() {
}
}
var remove: Boolean = removeFile.exists()
var remove: Boolean
get() = removeFile.exists()
set(remove) {
field = if (remove) {
if (remove) {
Shell.su("rm -rf $PERSIST/$id").submit()
removeFile.createNewFile()
} else {
@ -67,7 +69,7 @@ class Module(path: String) : BaseModule() {
val moduleList = mutableListOf<Module>()
val path = SuFile(Const.MAGISK_PATH)
val modules =
path.listFiles { _, name -> name != "lost+found" && name != ".core" }.orEmpty()
path.listFiles { _, name -> name != "lost+found" && name != ".core" }.orEmpty()
for (file in modules) {
if (file.isFile) continue
val module = Module(Const.MAGISK_PATH + "/" + file.name)

View File

@ -110,22 +110,23 @@ class ModuleItem(val item: Module) : ObservableItem<ModuleItem>(), Observable {
}
@get:Bindable
var isEnabled = item.enable
var isEnabled
get() = item.enable
set(value) {
field = value
item.enable = value
notifyChange(BR.enabled)
}
@get:Bindable
var isRemoved = item.remove
var isRemoved
get() = item.remove
set(value) {
field = value
item.remove = value
notifyChange(BR.removed)
}
val isUpdated get() = item.updated
val isModified get() = isRemoved || item.updated
val isModified get() = isRemoved || isUpdated
fun toggle() {
isEnabled = !isEnabled

View File

@ -193,6 +193,7 @@ class ModuleViewModel(
.doOnSuccess {
addInstalledEmptyMessage()
addUpdatableEmptyMessage()
updateActiveState()
}
.ignoreElement()!!