manager: 显示 Zygisk 实现方式 (#264)

* manager: Add display of Zygisk Implement feature and formatting code

* manager: Change the method of detecting Zygisk Implement
Signed-off-by: YangQi0408 <a123er3643@163.com>
Co-authored-by: WenHao2130 <WenHao2130@outlook.com>
This commit is contained in:
YangQi0408
2025-07-08 22:34:34 +08:00
committed by GitHub
parent a255ea9d56
commit 213a15cdb6
5 changed files with 65 additions and 22 deletions

View File

@@ -261,8 +261,8 @@ fun UpdateCard() {
@Composable @Composable
fun RebootDropdownItem(@StringRes id: Int, reason: String = "") { fun RebootDropdownItem(@StringRes id: Int, reason: String = "") {
DropdownMenuItem( DropdownMenuItem(
text = {Text(stringResource(id))}, text = { Text(stringResource(id)) },
onClick = {reboot(reason)}) onClick = { reboot(reason) })
} }
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@@ -319,7 +319,8 @@ private fun TopBar(
}) { }) {
RebootDropdownItem(id = R.string.reboot) RebootDropdownItem(id = R.string.reboot)
val pm = LocalContext.current.getSystemService(Context.POWER_SERVICE) as PowerManager? val pm =
LocalContext.current.getSystemService(Context.POWER_SERVICE) as PowerManager?
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && pm?.isRebootingUserspaceSupported == true) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && pm?.isRebootingUserspaceSupported == true) {
RebootDropdownItem(id = R.string.reboot_userspace, reason = "userspace") RebootDropdownItem(id = R.string.reboot_userspace, reason = "userspace")
@@ -343,8 +344,10 @@ private fun StatusCard(
onClickInstall: () -> Unit = {} onClickInstall: () -> Unit = {}
) { ) {
ElevatedCard( ElevatedCard(
colors = getCardColors( if (systemStatus.ksuVersion != null)MaterialTheme.colorScheme.secondaryContainer colors = getCardColors(
else MaterialTheme.colorScheme.errorContainer), if (systemStatus.ksuVersion != null) MaterialTheme.colorScheme.secondaryContainer
else MaterialTheme.colorScheme.errorContainer
),
elevation = getCardElevation(), elevation = getCardElevation(),
) { ) {
Row( Row(
@@ -433,7 +436,10 @@ private fun StatusCard(
} }
} }
val isHideVersion = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE) val isHideVersion = LocalContext.current.getSharedPreferences(
"settings",
Context.MODE_PRIVATE
)
.getBoolean("is_hide_version", false) .getBoolean("is_hide_version", false)
if (!isHideVersion) { if (!isHideVersion) {
@@ -679,7 +685,7 @@ private fun InfoCard(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.weight(1f) .weight(1f)
){ ) {
Text( Text(
text = label, text = label,
style = MaterialTheme.typography.labelLarge, style = MaterialTheme.typography.labelLarge,
@@ -731,7 +737,12 @@ private fun InfoCard(
when (signatureIndex) { when (signatureIndex) {
1 -> "(${stringResource(R.string.default_signature)})" 1 -> "(${stringResource(R.string.default_signature)})"
2 -> "(${stringResource(R.string.dynamic_signature)})" 2 -> "(${stringResource(R.string.dynamic_signature)})"
else -> if (signatureIndex >= 0) "(${stringResource(R.string.signature_index, signatureIndex)})" else "(${stringResource(R.string.unknown_signature)})" else -> if (signatureIndex >= 0) "(${
stringResource(
R.string.signature_index,
signatureIndex
)
})" else "(${stringResource(R.string.unknown_signature)})"
} }
) )
append(" | ") append(" | ")
@@ -751,19 +762,28 @@ private fun InfoCard(
icon = Icons.Default.Security, icon = Icons.Default.Security,
) )
if (!isSimpleMode && systemInfo.zygiskImplement != "None") {
InfoCardItem(
stringResource(R.string.home_zygisk_implement),
systemInfo.zygiskImplement,
icon = Icons.Default.Adb,
)
}
if (!isSimpleMode) { if (!isSimpleMode) {
// 根据showKpmInfo决定是否显示KPM信息 // 根据showKpmInfo决定是否显示KPM信息
if (lkmMode != true && !showKpmInfo) { if (lkmMode != true && !showKpmInfo) {
val displayVersion = if (systemInfo.kpmVersion.isEmpty() || systemInfo.kpmVersion.startsWith("Error")) { val displayVersion =
val statusText = if (Natives.isKPMEnabled()) { if (systemInfo.kpmVersion.isEmpty() || systemInfo.kpmVersion.startsWith("Error")) {
stringResource(R.string.kernel_patched) val statusText = if (Natives.isKPMEnabled()) {
stringResource(R.string.kernel_patched)
} else {
stringResource(R.string.kernel_not_enabled)
}
"${stringResource(R.string.not_supported)} ($statusText)"
} else { } else {
stringResource(R.string.kernel_not_enabled) "${stringResource(R.string.supported)} (${systemInfo.kpmVersion})"
} }
"${stringResource(R.string.not_supported)} ($statusText)"
} else {
"${stringResource(R.string.supported)} (${systemInfo.kpmVersion})"
}
InfoCardItem( InfoCardItem(
stringResource(R.string.home_kpm_version), stringResource(R.string.home_kpm_version),
@@ -775,7 +795,8 @@ private fun InfoCard(
if (!isSimpleMode && !isHideSusfsStatus && if (!isSimpleMode && !isHideSusfsStatus &&
systemInfo.suSFSStatus == "Supported" && systemInfo.suSFSStatus == "Supported" &&
systemInfo.suSFSVersion.isNotEmpty()) { systemInfo.suSFSVersion.isNotEmpty()
) {
val infoText = SuSFSInfoText(systemInfo) val infoText = SuSFSInfoText(systemInfo)
@@ -804,9 +825,11 @@ private fun SuSFSInfoText(systemInfo: HomeViewModel.SystemInfo): String = buildS
append(" ${stringResource(R.string.sus_su_mode)} ${systemInfo.susSUMode}") append(" ${stringResource(R.string.sus_su_mode)} ${systemInfo.susSUMode}")
} }
} }
Natives.getHookType() == "Manual" -> { Natives.getHookType() == "Manual" -> {
append(" (${stringResource(R.string.manual_hook)})") append(" (${stringResource(R.string.manual_hook)})")
} }
else -> { else -> {
append(" (${Natives.getHookType()})") append(" (${Natives.getHookType()})")
} }

View File

@@ -223,7 +223,11 @@ fun restoreBoot(
onFinish: (Boolean, Int) -> Unit, onStdout: (String) -> Unit, onStderr: (String) -> Unit onFinish: (Boolean, Int) -> Unit, onStdout: (String) -> Unit, onStderr: (String) -> Unit
): Boolean { ): Boolean {
val magiskboot = File(ksuApp.applicationInfo.nativeLibraryDir, "libzakoboot.so") val magiskboot = File(ksuApp.applicationInfo.nativeLibraryDir, "libzakoboot.so")
val result = flashWithIO("${getKsuDaemonPath()} boot-restore -f --magiskboot $magiskboot", onStdout, onStderr) val result = flashWithIO(
"${getKsuDaemonPath()} boot-restore -f --magiskboot $magiskboot",
onStdout,
onStderr
)
onFinish(result.isSuccess, result.code) onFinish(result.isSuccess, result.code)
return result.isSuccess return result.isSuccess
} }
@@ -232,7 +236,8 @@ fun uninstallPermanently(
onFinish: (Boolean, Int) -> Unit, onStdout: (String) -> Unit, onStderr: (String) -> Unit onFinish: (Boolean, Int) -> Unit, onStdout: (String) -> Unit, onStderr: (String) -> Unit
): Boolean { ): Boolean {
val magiskboot = File(ksuApp.applicationInfo.nativeLibraryDir, "libzakoboot.so") val magiskboot = File(ksuApp.applicationInfo.nativeLibraryDir, "libzakoboot.so")
val result = flashWithIO("${getKsuDaemonPath()} uninstall --magiskboot $magiskboot", onStdout, onStderr) val result =
flashWithIO("${getKsuDaemonPath()} uninstall --magiskboot $magiskboot", onStdout, onStderr)
onFinish(result.isSuccess, result.code) onFinish(result.isSuccess, result.code)
return result.isSuccess return result.isSuccess
} }
@@ -457,6 +462,7 @@ fun getSuSFSVariant(): String {
val result = ShellUtils.fastCmd(shell, "${getSuSFSDaemonPath()} variant") val result = ShellUtils.fastCmd(shell, "${getSuSFSDaemonPath()} variant")
return result return result
} }
fun getSuSFSFeatures(): String { fun getSuSFSFeatures(): String {
val shell = getRootShell() val shell = getRootShell()
val result = ShellUtils.fastCmd(shell, "${getSuSFSDaemonPath()} features") val result = ShellUtils.fastCmd(shell, "${getSuSFSDaemonPath()} features")
@@ -505,7 +511,7 @@ fun getKpmModuleCount(): Int {
return result.trim().toIntOrNull() ?: 0 return result.trim().toIntOrNull() ?: 0
} }
fun runCmd(shell : Shell, cmd : String) : String { fun runCmd(shell: Shell, cmd: String): String {
return shell.newJob() return shell.newJob()
.add(cmd) .add(cmd)
.to(mutableListOf<String>(), null) .to(mutableListOf<String>(), null)
@@ -548,3 +554,13 @@ fun getKpmVersion(): String {
val result = ShellUtils.fastCmd(shell, cmd) val result = ShellUtils.fastCmd(shell, cmd)
return result.trim() return result.trim()
} }
fun getZygiskImplement(): String {
val shell = getRootShell()
val zygiskPath = "/data/adb/modules/zygisksu"
val result = if (ShellUtils.fastCmdResult(shell, "test -f $zygiskPath/module.prop")) {
ShellUtils.fastCmd(shell, "grep '^name=' $zygiskPath/module.prop | cut -d'=' -f2")
} else "None"
Log.i(TAG, "Zygisk implement: $result")
return result
}

View File

@@ -62,7 +62,8 @@ class HomeViewModel : ViewModel() {
val moduleCount: Int = 0, val moduleCount: Int = 0,
val kpmModuleCount: Int = 0, val kpmModuleCount: Int = 0,
val managersList: Natives.ManagersList? = null, val managersList: Natives.ManagersList? = null,
val isDynamicSignEnabled: Boolean = false val isDynamicSignEnabled: Boolean = false,
val zygiskImplement: String = ""
) )
private val gson = Gson() private val gson = Gson()
@@ -280,7 +281,8 @@ class HomeViewModel : ViewModel() {
moduleCount = getModuleCount(), moduleCount = getModuleCount(),
kpmModuleCount = getKpmModuleCount(), kpmModuleCount = getKpmModuleCount(),
managersList = managersList, managersList = managersList,
isDynamicSignEnabled = isDynamicSignEnabled isDynamicSignEnabled = isDynamicSignEnabled,
zygiskImplement = getZygiskImplement()
) )
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Error fetching system info", e) Log.e(TAG, "Error fetching system info", e)

View File

@@ -583,4 +583,5 @@
<string name="unknown_signature">未知</string> <string name="unknown_signature">未知</string>
<string name="multi_manager_list">活跃管理器</string> <string name="multi_manager_list">活跃管理器</string>
<string name="no_active_manager">无活跃管理器</string> <string name="no_active_manager">无活跃管理器</string>
<string name="home_zygisk_implement">Zygisk 实现</string>
</resources> </resources>

View File

@@ -586,4 +586,5 @@
<string name="multi_manager_list">Active Manager</string> <string name="multi_manager_list">Active Manager</string>
<string name="no_active_manager">No active manager</string> <string name="no_active_manager">No active manager</string>
<string name="default_signature">SukiSU</string> <string name="default_signature">SukiSU</string>
<string name="home_zygisk_implement">Zygisk implement</string>
</resources> </resources>