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.toggleModule
|
||||||
import com.rifsxd.ksunext.ui.util.uninstallModule
|
import com.rifsxd.ksunext.ui.util.uninstallModule
|
||||||
import com.rifsxd.ksunext.ui.util.restoreModule
|
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.viewmodel.ModuleViewModel
|
||||||
import com.rifsxd.ksunext.ui.webui.WebUIActivity
|
import com.rifsxd.ksunext.ui.webui.WebUIActivity
|
||||||
import com.rifsxd.ksunext.ui.webui.WebUIXActivity
|
import com.rifsxd.ksunext.ui.webui.WebUIXActivity
|
||||||
@@ -783,6 +784,8 @@ fun ModuleItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val filterZygiskModules = zygiskAvailable() || !module.zygiskRequired
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
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) {
|
if (updateUrl.isNotEmpty() && !module.remove && !module.update) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = stringResource(R.string.module_update),
|
text = stringResource(R.string.module_update),
|
||||||
@@ -846,7 +858,7 @@ fun ModuleItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (module.enabled && !module.remove) {
|
if (module.enabled && !module.remove) {
|
||||||
if (module.hasWebUi) {
|
if (module.hasWebUi && filterZygiskModules) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = stringResource(R.string.webui),
|
text = stringResource(R.string.webui),
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
@@ -855,7 +867,7 @@ fun ModuleItem(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (module.hasActionScript) {
|
if (module.hasActionScript && filterZygiskModules) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = stringResource(R.string.action),
|
text = stringResource(R.string.action),
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
@@ -961,7 +973,7 @@ fun ModuleItem(
|
|||||||
if (module.hasActionScript) {
|
if (module.hasActionScript) {
|
||||||
FilledTonalButton(
|
FilledTonalButton(
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
enabled = !module.remove && module.enabled,
|
enabled = !module.remove && module.enabled && filterZygiskModules,
|
||||||
onClick = {
|
onClick = {
|
||||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
viewModel.markNeedRefresh()
|
viewModel.markNeedRefresh()
|
||||||
@@ -989,7 +1001,7 @@ fun ModuleItem(
|
|||||||
if (module.hasWebUi) {
|
if (module.hasWebUi) {
|
||||||
FilledTonalButton(
|
FilledTonalButton(
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
enabled = !module.remove && module.enabled,
|
enabled = !module.remove && module.enabled && filterZygiskModules,
|
||||||
onClick = { onClick(module) },
|
onClick = { onClick(module) },
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
@@ -1119,7 +1131,8 @@ fun ModuleItemPreview() {
|
|||||||
hasActionScript = false,
|
hasActionScript = false,
|
||||||
dirId = "dirId",
|
dirId = "dirId",
|
||||||
size = 12345678L,
|
size = 12345678L,
|
||||||
banner = ""
|
banner = "",
|
||||||
|
zygiskRequired = false
|
||||||
)
|
)
|
||||||
ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {}, {}, false, {})
|
ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {}, {}, false, {})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -633,6 +633,29 @@ fun isSuCompatDisabled(): Boolean {
|
|||||||
return Natives.version >= Natives.MINIMAL_SUPPORTED_SU_COMPAT && !Natives.isSuEnabled()
|
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 {
|
fun setAppProfileTemplate(id: String, template: String): Boolean {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
val escapedTemplate = template.replace("\"", "\\\"")
|
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.HanziToPinyin
|
||||||
import com.rifsxd.ksunext.ui.util.listModules
|
import com.rifsxd.ksunext.ui.util.listModules
|
||||||
import com.rifsxd.ksunext.ui.util.getModuleSize
|
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.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
@@ -48,7 +50,8 @@ class ModuleViewModel : ViewModel() {
|
|||||||
val hasActionScript: Boolean,
|
val hasActionScript: Boolean,
|
||||||
val dirId: String,
|
val dirId: String,
|
||||||
val size: Long,
|
val size: Long,
|
||||||
val banner: String
|
val banner: String,
|
||||||
|
val zygiskRequired: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
data class ModuleUpdateInfo(
|
data class ModuleUpdateInfo(
|
||||||
@@ -139,6 +142,7 @@ class ModuleViewModel : ViewModel() {
|
|||||||
val dirId = obj.getString("dir_id")
|
val dirId = obj.getString("dir_id")
|
||||||
val moduleDir = File("/data/adb/modules/$dirId")
|
val moduleDir = File("/data/adb/modules/$dirId")
|
||||||
val size = getModuleSize(moduleDir)
|
val size = getModuleSize(moduleDir)
|
||||||
|
val zygiskRequired = zygiskRequired(moduleDir)
|
||||||
|
|
||||||
ModuleInfo(
|
ModuleInfo(
|
||||||
id,
|
id,
|
||||||
@@ -155,7 +159,8 @@ class ModuleViewModel : ViewModel() {
|
|||||||
obj.optBoolean("action"),
|
obj.optBoolean("action"),
|
||||||
dirId,
|
dirId,
|
||||||
size,
|
size,
|
||||||
obj.optString("banner")
|
obj.optString("banner"),
|
||||||
|
zygiskRequired
|
||||||
)
|
)
|
||||||
}.toList()
|
}.toList()
|
||||||
isNeedRefresh = false
|
isNeedRefresh = false
|
||||||
|
|||||||
@@ -224,4 +224,5 @@
|
|||||||
<string name="customization">Customization</string>
|
<string name="customization">Customization</string>
|
||||||
<string name="developer">Developer</string>
|
<string name="developer">Developer</string>
|
||||||
<string name="sucompat_disabled">SUCOMPAT DISABLED</string>
|
<string name="sucompat_disabled">SUCOMPAT DISABLED</string>
|
||||||
|
<string name="zygisk_required">Zygisk Required</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user