manager: Modifying the getHookType function to return a string type

Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: rifsxd <rifat.44.azad.rifs@gmail.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-06-13 15:36:15 +08:00
parent 2d9783e3d4
commit d7a5e80d34
5 changed files with 47 additions and 33 deletions

View File

@@ -312,7 +312,8 @@ Java_com_sukisu_ultra_Natives_isKPMEnabled(JNIEnv *env, jobject) {
return is_KPM_enable();
}
extern "C" JNIEXPORT jboolean JNICALL
extern "C" JNIEXPORT jstring JNICALL
Java_com_sukisu_ultra_Natives_getHookType(JNIEnv *env, jobject) {
return get_hook_type();
const char* hook_type = get_hook_type();
return env->NewStringUTF(hook_type);
}

View File

@@ -105,7 +105,13 @@ bool is_KPM_enable() {
return ksuctl(CMD_ENABLE_KPM, &enabled, nullptr), enabled;
}
bool get_hook_type() {
bool enabled = false;
return ksuctl(CMD_HOOK_TYPE, &enabled, nullptr), enabled;
const char* get_hook_type() {
static char hook_type[16] = {0};
if (hook_type[0] == '\0') {
if (ksuctl(CMD_HOOK_TYPE, hook_type, nullptr)) {
return hook_type;
}
strcpy(hook_type, "Unknown");
}
return hook_type;
}

View File

@@ -85,6 +85,6 @@ bool is_su_enabled();
bool is_KPM_enable();
bool get_hook_type();
const char* get_hook_type();
#endif //KERNELSU_KSU_H

View File

@@ -69,7 +69,7 @@ object Natives {
external fun isSuEnabled(): Boolean
external fun setSuEnabled(enabled: Boolean): Boolean
external fun isKPMEnabled(): Boolean
external fun getHookType(): Boolean
external fun getHookType(): String
private const val NON_ROOT_DEFAULT_PROFILE_KEY = "$"
private const val NOBODY_UID = 9999

View File

@@ -725,25 +725,11 @@ private fun InfoCard(
}
}
if ((!isSimpleMode) && (!isHideSusfsStatus)) {
if (systemInfo.suSFSStatus == "Supported") {
if (systemInfo.suSFSVersion.isNotEmpty()) {
val isSUS_SU = systemInfo.suSFSFeatures == "CONFIG_KSU_SUSFS_SUS_SU"
val infoText = buildString {
append(systemInfo.suSFSVersion)
append(if (isSUS_SU && !Natives.getHookType()) " (${systemInfo.suSFSVariant})" else {
if (Natives.getHookType()) {
" (${stringResource(R.string.manual_hook)})"
} else {
"Unknown"
}
})
if (isSUS_SU) {
if (systemInfo.susSUMode.isNotEmpty()) {
append(" ${stringResource(R.string.sus_su_mode)} ${systemInfo.susSUMode}")
}
}
}
if (!isSimpleMode && !isHideSusfsStatus &&
systemInfo.suSFSStatus == "Supported" &&
systemInfo.suSFSVersion.isNotEmpty()) {
val infoText = SuSFSInfoText(systemInfo)
InfoCardItem(
stringResource(R.string.home_susfs_version),
@@ -753,6 +739,27 @@ private fun InfoCard(
}
}
}
}
@Composable
private fun SuSFSInfoText(systemInfo: HomeViewModel.SystemInfo): String = buildString {
append(systemInfo.suSFSVersion)
val isSUS_SU = systemInfo.suSFSFeatures == "CONFIG_KSU_SUSFS_SUS_SU"
val isKprobesHook = Natives.getHookType() == "Kprobes"
when {
isSUS_SU && isKprobesHook -> {
append(" (${systemInfo.suSFSVariant})")
if (systemInfo.susSUMode.isNotEmpty()) {
append(" ${stringResource(R.string.sus_su_mode)} ${systemInfo.susSUMode}")
}
}
Natives.getHookType() == "Manual" -> {
append(" (${stringResource(R.string.manual_hook)})")
}
else -> {
append(" (${Natives.getHookType()})")
}
}
}