diff --git a/manager/app/src/main/cpp/jni.cc b/manager/app/src/main/cpp/jni.cc index 725a5827..65e37638 100644 --- a/manager/app/src/main/cpp/jni.cc +++ b/manager/app/src/main/cpp/jni.cc @@ -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); } \ No newline at end of file diff --git a/manager/app/src/main/cpp/ksu.cc b/manager/app/src/main/cpp/ksu.cc index 3d2a5bc4..ab9069e4 100644 --- a/manager/app/src/main/cpp/ksu.cc +++ b/manager/app/src/main/cpp/ksu.cc @@ -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; } \ No newline at end of file diff --git a/manager/app/src/main/cpp/ksu.h b/manager/app/src/main/cpp/ksu.h index 7a9dfddc..715c5aef 100644 --- a/manager/app/src/main/cpp/ksu.h +++ b/manager/app/src/main/cpp/ksu.h @@ -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 \ No newline at end of file diff --git a/manager/app/src/main/java/com/sukisu/ultra/Natives.kt b/manager/app/src/main/java/com/sukisu/ultra/Natives.kt index 5ac9deb0..72302f2f 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/Natives.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/Natives.kt @@ -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 diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt index de7ef071..2fe5a973 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt @@ -725,38 +725,45 @@ 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()) { - InfoCardItem( - stringResource(R.string.home_susfs_version), - infoText, - icon = Icons.Default.Storage - ) - } - } + val infoText = SuSFSInfoText(systemInfo) + + InfoCardItem( + stringResource(R.string.home_susfs_version), + infoText, + icon = Icons.Default.Storage + ) } } } } +@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()})") + } + } +} + fun getManagerVersion(context: Context): Pair { val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)!! val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)