You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: implemented zygisk required label for module card
This commit is contained in:
@@ -123,6 +123,7 @@ import com.rifsxd.ksunext.ui.util.reboot
|
||||
import com.rifsxd.ksunext.ui.util.toggleModule
|
||||
import com.rifsxd.ksunext.ui.util.uninstallModule
|
||||
import com.rifsxd.ksunext.ui.util.restoreModule
|
||||
import com.rifsxd.ksunext.ui.util.zygiskRequired
|
||||
import com.rifsxd.ksunext.ui.viewmodel.ModuleViewModel
|
||||
import com.rifsxd.ksunext.ui.webui.WebUIActivity
|
||||
import com.rifsxd.ksunext.ui.webui.WebUIXActivity
|
||||
@@ -783,6 +784,8 @@ fun ModuleItem(
|
||||
)
|
||||
}
|
||||
|
||||
val filterZygiskModules = zygiskAvailable() || !module.zygiskRequired
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
||||
}
|
||||
@@ -825,6 +828,15 @@ fun ModuleItem(
|
||||
)
|
||||
)
|
||||
}
|
||||
if (!zygiskAvailable() && module.zygiskRequired && !module.remove) {
|
||||
LabelItem(
|
||||
text = stringResource(R.string.zygisk_required),
|
||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||
)
|
||||
)
|
||||
}
|
||||
if (updateUrl.isNotEmpty() && !module.remove && !module.update) {
|
||||
LabelItem(
|
||||
text = stringResource(R.string.module_update),
|
||||
@@ -846,7 +858,7 @@ fun ModuleItem(
|
||||
}
|
||||
}
|
||||
if (module.enabled && !module.remove) {
|
||||
if (module.hasWebUi) {
|
||||
if (module.hasWebUi && filterZygiskModules) {
|
||||
LabelItem(
|
||||
text = stringResource(R.string.webui),
|
||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||
@@ -855,7 +867,7 @@ fun ModuleItem(
|
||||
)
|
||||
)
|
||||
}
|
||||
if (module.hasActionScript) {
|
||||
if (module.hasActionScript && filterZygiskModules) {
|
||||
LabelItem(
|
||||
text = stringResource(R.string.action),
|
||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||
@@ -961,7 +973,7 @@ fun ModuleItem(
|
||||
if (module.hasActionScript) {
|
||||
FilledTonalButton(
|
||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||
enabled = !module.remove && module.enabled,
|
||||
enabled = !module.remove && module.enabled && filterZygiskModules,
|
||||
onClick = {
|
||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||
viewModel.markNeedRefresh()
|
||||
@@ -989,7 +1001,7 @@ fun ModuleItem(
|
||||
if (module.hasWebUi) {
|
||||
FilledTonalButton(
|
||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||
enabled = !module.remove && module.enabled,
|
||||
enabled = !module.remove && module.enabled && filterZygiskModules,
|
||||
onClick = { onClick(module) },
|
||||
interactionSource = interactionSource,
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||
@@ -1119,7 +1131,8 @@ fun ModuleItemPreview() {
|
||||
hasActionScript = false,
|
||||
dirId = "dirId",
|
||||
size = 12345678L,
|
||||
banner = ""
|
||||
banner = "",
|
||||
zygiskRequired = false
|
||||
)
|
||||
ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {}, {}, false, {})
|
||||
}
|
||||
|
||||
@@ -633,6 +633,29 @@ fun isSuCompatDisabled(): Boolean {
|
||||
return Natives.version >= Natives.MINIMAL_SUPPORTED_SU_COMPAT && !Natives.isSuEnabled()
|
||||
}
|
||||
|
||||
fun zygiskRequired(dir: File): Boolean {
|
||||
val shell = getRootShell()
|
||||
val zygiskLib = "${dir.absolutePath}/zygisk"
|
||||
val cmd = "ls \"$zygiskLib\""
|
||||
val result = ShellUtils.fastCmdResult(shell, cmd)
|
||||
return result
|
||||
}
|
||||
|
||||
fun zygiskAvailable(): Boolean {
|
||||
val shell = getRootShell()
|
||||
val zygiskLib = "libzygisk.so"
|
||||
val rezygisk = "/data/adb/modules/rezygisk/lib/$zygiskLib"
|
||||
val zygiskNext = "/data/adb/modules/zygisksu/lib/$zygiskLib"
|
||||
|
||||
val cmdRezygisk = "[ -f \"$rezygisk\" ]"
|
||||
if (ShellUtils.fastCmdResult(shell, cmdRezygisk)) {
|
||||
return true
|
||||
} else {
|
||||
val cmdZygiskNext = "[ -f \"$zygiskNext\" ]"
|
||||
return ShellUtils.fastCmdResult(shell, cmdZygiskNext)
|
||||
}
|
||||
}
|
||||
|
||||
fun setAppProfileTemplate(id: String, template: String): Boolean {
|
||||
val shell = getRootShell()
|
||||
val escapedTemplate = template.replace("\"", "\\\"")
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.rifsxd.ksunext.ksuApp
|
||||
import com.rifsxd.ksunext.ui.util.HanziToPinyin
|
||||
import com.rifsxd.ksunext.ui.util.listModules
|
||||
import com.rifsxd.ksunext.ui.util.getModuleSize
|
||||
import com.rifsxd.ksunext.ui.util.zygiskRequired
|
||||
import com.rifsxd.ksunext.ui.util.zygiskAvailable
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
@@ -48,7 +50,8 @@ class ModuleViewModel : ViewModel() {
|
||||
val hasActionScript: Boolean,
|
||||
val dirId: String,
|
||||
val size: Long,
|
||||
val banner: String
|
||||
val banner: String,
|
||||
val zygiskRequired: Boolean
|
||||
)
|
||||
|
||||
data class ModuleUpdateInfo(
|
||||
@@ -139,6 +142,7 @@ class ModuleViewModel : ViewModel() {
|
||||
val dirId = obj.getString("dir_id")
|
||||
val moduleDir = File("/data/adb/modules/$dirId")
|
||||
val size = getModuleSize(moduleDir)
|
||||
val zygiskRequired = zygiskRequired(moduleDir)
|
||||
|
||||
ModuleInfo(
|
||||
id,
|
||||
@@ -155,7 +159,8 @@ class ModuleViewModel : ViewModel() {
|
||||
obj.optBoolean("action"),
|
||||
dirId,
|
||||
size,
|
||||
obj.optString("banner")
|
||||
obj.optString("banner"),
|
||||
zygiskRequired
|
||||
)
|
||||
}.toList()
|
||||
isNeedRefresh = false
|
||||
|
||||
@@ -224,4 +224,5 @@
|
||||
<string name="customization">Customization</string>
|
||||
<string name="developer">Developer</string>
|
||||
<string name="sucompat_disabled">SUCOMPAT DISABLED</string>
|
||||
<string name="zygisk_required">Zygisk Required</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user