manager: Implement version restrictions for certain features

This commit is contained in:
ShirkNeko
2025-11-03 14:59:12 +08:00
parent 7051b22536
commit 4350d309da
4 changed files with 25 additions and 19 deletions

View File

@@ -214,7 +214,7 @@ bool is_kernel_umount_enabled() {
} }
return value != 0; return value != 0;
} }
// 1. 获取完整版本名称
void get_full_version(char* buff) { void get_full_version(char* buff) {
struct ksu_get_full_version_cmd cmd = {0}; struct ksu_get_full_version_cmd cmd = {0};
if (ksuctl(KSU_IOCTL_GET_FULL_VERSION, &cmd) == 0) { if (ksuctl(KSU_IOCTL_GET_FULL_VERSION, &cmd) == 0) {
@@ -225,7 +225,6 @@ void get_full_version(char* buff) {
} }
} }
// 2. 获取KPM启用状态
bool is_KPM_enable(void) { bool is_KPM_enable(void) {
struct ksu_enable_kpm_cmd cmd = {}; struct ksu_enable_kpm_cmd cmd = {};
if (ksuctl(KSU_IOCTL_ENABLE_KPM, &cmd) == 0 && cmd.enabled) { if (ksuctl(KSU_IOCTL_ENABLE_KPM, &cmd) == 0 && cmd.enabled) {
@@ -234,7 +233,6 @@ bool is_KPM_enable(void) {
return legacy_is_KPM_enable(); return legacy_is_KPM_enable();
} }
// 3. 获取钩子类型
void get_hook_type(char *buff) { void get_hook_type(char *buff) {
struct ksu_hook_type_cmd cmd = {0}; struct ksu_hook_type_cmd cmd = {0};
if (ksuctl(KSU_IOCTL_HOOK_TYPE, &cmd) == 0) { if (ksuctl(KSU_IOCTL_HOOK_TYPE, &cmd) == 0) {

View File

@@ -23,7 +23,7 @@ object Natives {
const val MINIMAL_SUPPORTED_SU_COMPAT = 12040 const val MINIMAL_SUPPORTED_SU_COMPAT = 12040
const val KERNEL_SU_DOMAIN = "u:r:su:s0" const val KERNEL_SU_DOMAIN = "u:r:su:s0"
const val MINIMAL_SUPPORTED_KERNEL_FULL = "v3.1.8" const val MINIMAL_SUPPORTED_KERNEL_FULL = "v3.1.8"
const val MINIMAL_SUPPORTED_KPM = 12800 const val MINIMAL_SUPPORTED_KPM = 12800
@@ -31,6 +31,8 @@ object Natives {
const val MINIMAL_SUPPORTED_UID_SCANNER = 13347 const val MINIMAL_SUPPORTED_UID_SCANNER = 13347
const val MINIMAL_NEW_IOCTL_KERNEL = 13490
const val ROOT_UID = 0 const val ROOT_UID = 0
const val ROOT_GID = 0 const val ROOT_GID = 0

View File

@@ -152,6 +152,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
var isSuDisabled by rememberSaveable { var isSuDisabled by rememberSaveable {
mutableStateOf(!Natives.isSuEnabled()) mutableStateOf(!Natives.isSuEnabled())
} }
SwitchItem( SwitchItem(
icon = Icons.Filled.RemoveModerator, icon = Icons.Filled.RemoveModerator,
title = stringResource(R.string.settings_disable_su), title = stringResource(R.string.settings_disable_su),
@@ -166,21 +167,26 @@ fun SettingScreen(navigator: DestinationsNavigator) {
) )
} }
var isKernelUmountDisabled by rememberSaveable { // 禁用内核卸载开关
mutableStateOf(!Natives.isKernelUmountEnabled()) if (Natives.version >= Natives.MINIMAL_NEW_IOCTL_KERNEL) {
} var isKernelUmountDisabled by rememberSaveable {
SwitchItem( mutableStateOf(!Natives.isKernelUmountEnabled())
icon = Icons.Rounded.FolderDelete,
title = stringResource(id = R.string.settings_disable_kernel_umount),
summary = stringResource(id = R.string.settings_disable_kernel_umount_summary),
checked = isKernelUmountDisabled,
onCheckedChange = { checked: Boolean ->
val shouldEnable = !checked
if (Natives.setKernelUmountEnabled(shouldEnable)) {
isKernelUmountDisabled = !shouldEnable
}
} }
)
SwitchItem(
icon = Icons.Rounded.FolderDelete,
title = stringResource(id = R.string.settings_disable_kernel_umount),
summary = stringResource(id = R.string.settings_disable_kernel_umount_summary),
checked = isKernelUmountDisabled,
onCheckedChange = { checked: Boolean ->
val shouldEnable = !checked
if (Natives.setKernelUmountEnabled(shouldEnable)) {
isKernelUmountDisabled = !shouldEnable
}
}
)
}
// 强制签名验证开关 // 强制签名验证开关
var forceSignatureVerification by rememberSaveable { var forceSignatureVerification by rememberSaveable {

View File

@@ -357,7 +357,7 @@ private fun AdvancedSettings(
SusFSSettings(state = state, handlers = handlers) SusFSSettings(state = state, handlers = handlers)
// 动态管理器设置 // 动态管理器设置
if (Natives.version >= Natives.MINIMAL_SUPPORTED_DYNAMIC_MANAGER) { if (Natives.version >= Natives.MINIMAL_SUPPORTED_DYNAMIC_MANAGER && Natives.version >= Natives.MINIMAL_NEW_IOCTL_KERNEL) {
SettingItem( SettingItem(
icon = Icons.Filled.Security, icon = Icons.Filled.Security,
title = stringResource(R.string.dynamic_manager_title), title = stringResource(R.string.dynamic_manager_title),