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: new zygisk detection method implemented and deprecated old method
Currently only supports ReZygisk and soon ZygiskNext will hopefully follow (ZN users will have issues detecting zygisk injections until then)
This commit is contained in:
@@ -73,6 +73,11 @@ object Natives {
|
||||
*/
|
||||
external fun getHookMode(): String?
|
||||
|
||||
/**
|
||||
* Check if Zygisk injection is enabled in the environment.
|
||||
*/
|
||||
external fun isZygiskEnabled(): Boolean
|
||||
|
||||
/**
|
||||
* Get the profile of the given package.
|
||||
* @param key usually the package name
|
||||
|
||||
@@ -34,6 +34,7 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.intl.Locale
|
||||
import androidx.compose.ui.text.toUpperCase
|
||||
@@ -141,6 +142,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
|
||||
@Composable
|
||||
private fun SuperuserCard() {
|
||||
val count = getSuperuserCount()
|
||||
ElevatedCard(
|
||||
colors = CardDefaults.elevatedCardColors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer
|
||||
@@ -157,11 +159,11 @@ private fun SuperuserCard() {
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.home_superuser_count),
|
||||
text = pluralStringResource(R.plurals.home_superuser_count, count),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = getSuperuserCount().toString(),
|
||||
text = count.toString(),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
@@ -172,6 +174,7 @@ private fun SuperuserCard() {
|
||||
|
||||
@Composable
|
||||
private fun ModuleCard() {
|
||||
val count = getModuleCount()
|
||||
ElevatedCard(
|
||||
colors = CardDefaults.elevatedCardColors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer
|
||||
@@ -188,11 +191,11 @@ private fun ModuleCard() {
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.home_module_count),
|
||||
text = pluralStringResource(R.plurals.home_module_count, count),
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = getModuleCount().toString(),
|
||||
text = count.toString(),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
@@ -645,6 +648,15 @@ private fun InfoCard(autoExpand: Boolean = false) {
|
||||
icon = painterResource(R.drawable.ic_sus),
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
if (Natives.isZygiskEnabled()) {
|
||||
InfoCardItem(
|
||||
label = stringResource(R.string.zygisk_status),
|
||||
content = stringResource(R.string.enabled),
|
||||
icon = Icons.Filled.Vaccines
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!expanded) {
|
||||
|
||||
@@ -823,7 +823,7 @@ fun ModuleItem(
|
||||
)
|
||||
}
|
||||
|
||||
val filterZygiskModules = zygiskAvailable() || !module.zygiskRequired
|
||||
val filterZygiskModules = Natives.isZygiskEnabled() || !module.zygiskRequired
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
||||
@@ -867,7 +867,7 @@ fun ModuleItem(
|
||||
)
|
||||
)
|
||||
}
|
||||
if (!zygiskAvailable() && module.zygiskRequired && !module.remove) {
|
||||
if (!Natives.isZygiskEnabled() && module.zygiskRequired && !module.remove) {
|
||||
LabelItem(
|
||||
text = stringResource(R.string.zygisk_required),
|
||||
style = LabelItemDefaults.style.copy(
|
||||
|
||||
@@ -641,31 +641,6 @@ fun zygiskRequired(dir: File): Boolean {
|
||||
return result
|
||||
}
|
||||
|
||||
fun zygiskAvailable(): Boolean {
|
||||
val shell = getRootShell()
|
||||
val zygiskLib = "libzygisk.so"
|
||||
val rezygisk64 = "/data/adb/modules/rezygisk/lib64/$zygiskLib"
|
||||
val rezygisk = "/data/adb/modules/rezygisk/lib/$zygiskLib"
|
||||
val zygiskNext64 = "/data/adb/modules/zygisksu/lib64/$zygiskLib"
|
||||
val zygiskNext = "/data/adb/modules/zygisksu/lib/$zygiskLib"
|
||||
|
||||
val cmdRezygisk64 = "[ -f \"$rezygisk64\" ]"
|
||||
if (ShellUtils.fastCmdResult(shell, cmdRezygisk64)) {
|
||||
return true
|
||||
}
|
||||
val cmdZygiskNext64 = "[ -f \"$zygiskNext64\" ]"
|
||||
if (ShellUtils.fastCmdResult(shell, cmdZygiskNext64)) {
|
||||
return true
|
||||
}
|
||||
|
||||
val cmdRezygisk = "[ -f \"$rezygisk\" ]"
|
||||
if (ShellUtils.fastCmdResult(shell, cmdRezygisk)) {
|
||||
return true
|
||||
}
|
||||
val cmdZygiskNext = "[ -f \"$zygiskNext\" ]"
|
||||
return ShellUtils.fastCmdResult(shell, cmdZygiskNext)
|
||||
}
|
||||
|
||||
fun setAppProfileTemplate(id: String, template: String): Boolean {
|
||||
val shell = getRootShell()
|
||||
val escapedTemplate = template.replace("\"", "\\\"")
|
||||
|
||||
@@ -22,7 +22,6 @@ 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user