manager: ui state for safemode
This commit is contained in:
@@ -61,3 +61,9 @@ Java_me_weishu_kernelsu_Natives_allowRoot(JNIEnv *env, jclass clazz, jint uid, j
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_me_weishu_kernelsu_Natives_isSafeMode(JNIEnv *env, jclass clazz) {
|
||||
return is_safe_mode();
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
#define CMD_DENY_SU 4
|
||||
#define CMD_GET_ALLOW_LIST 5
|
||||
#define CMD_GET_DENY_LIST 6
|
||||
#define CMD_CHECK_SAFEMODE 9
|
||||
|
||||
static bool ksuctl(int cmd, void* arg1, void* arg2) {
|
||||
int32_t result = 0;
|
||||
@@ -52,3 +53,7 @@ bool get_allow_list(int *uids, int *size) {
|
||||
bool get_deny_list(int *uids, int *size) {
|
||||
return ksuctl(CMD_GET_DENY_LIST, uids, size);
|
||||
}
|
||||
|
||||
bool is_safe_mode() {
|
||||
return ksuctl(CMD_CHECK_SAFEMODE, nullptr, nullptr);
|
||||
}
|
||||
@@ -15,4 +15,6 @@ bool get_allow_list(int *uids, int *size);
|
||||
|
||||
bool get_deny_list(int *uids, int *size);
|
||||
|
||||
bool is_safe_mode();
|
||||
|
||||
#endif //KERNELSU_KSU_H
|
||||
|
||||
@@ -21,4 +21,6 @@ public final class Natives {
|
||||
public static native int[] getDenyList();
|
||||
|
||||
public static native boolean allowRoot(int uid, boolean allow);
|
||||
|
||||
public static native boolean isSafeMode();
|
||||
}
|
||||
|
||||
@@ -52,11 +52,16 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
}
|
||||
}
|
||||
|
||||
val isSafeMode = Natives.isSafeMode()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopBar()
|
||||
},
|
||||
floatingActionButton = {
|
||||
floatingActionButton = if (isSafeMode) {
|
||||
{ /* Empty */ }
|
||||
} else {
|
||||
{
|
||||
val moduleInstall = stringResource(id = R.string.module_install)
|
||||
val selectZipLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.StartActivityForResult()
|
||||
@@ -83,6 +88,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
text = { Text(text = moduleInstall) },
|
||||
)
|
||||
}
|
||||
}
|
||||
) { innerPadding ->
|
||||
val failedEnable = stringResource(R.string.module_failed_to_enable)
|
||||
val failedDisable = stringResource(R.string.module_failed_to_disable)
|
||||
@@ -96,6 +102,12 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
}
|
||||
return@Scaffold
|
||||
}
|
||||
if (isSafeMode) {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Text(stringResource(R.string.safe_mode_disable_module))
|
||||
}
|
||||
return@Scaffold
|
||||
}
|
||||
SwipeRefresh(
|
||||
state = swipeState,
|
||||
onRefresh = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="safe_mode_disable_module">セーフモード、すべてのモッドが無効になっています!</string>
|
||||
<string name="app_name" translatable="false">KernelSU</string>
|
||||
<string name="home">ホーム</string>
|
||||
<string name="home_not_installed">未インストール</string>
|
||||
|
||||
@@ -52,5 +52,6 @@
|
||||
<string name="show_system_apps">Показать системные приложения</string>
|
||||
<string name="hide_system_apps">Скрыть системные приложения</string>
|
||||
<string name="send_log">Отправить лог</string>
|
||||
<string name="safe_mode_disable_module">Безопасный режим, все моды отключены!</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -48,4 +48,5 @@
|
||||
<string name="refresh">Làm mới</string>
|
||||
<string name="show_system_apps">Hiển thị ứng dụng hệ thống</string>
|
||||
<string name="hide_system_apps">Ẩn ứng dụng hệ thống</string>
|
||||
<string name="safe_mode_disable_module">Chế độ an toàn, tất cả các mod đều bị tắt!</string>
|
||||
</resources>
|
||||
|
||||
@@ -50,4 +50,5 @@
|
||||
<string name="show_system_apps">显示系统应用</string>
|
||||
<string name="hide_system_apps">隐藏系统应用</string>
|
||||
<string name="send_log">发送日志</string>
|
||||
<string name="safe_mode_disable_module">安全模式,所有模块已被禁用!</string>
|
||||
</resources>
|
||||
|
||||
@@ -46,4 +46,5 @@
|
||||
<string name="module_version">版本</string>
|
||||
<string name="module_author">作者</string>
|
||||
<string name="module_overlay_fs_not_available">內核不支持 overlayfs,模塊功能無法運作!</string>
|
||||
<string name="safe_mode_disable_module">安全模式,所有模塊已被禁用!</string>
|
||||
</resources>
|
||||
|
||||
@@ -49,4 +49,5 @@
|
||||
<string name="refresh">重新整理</string>
|
||||
<string name="show_system_apps">顯示系統應用程式</string>
|
||||
<string name="hide_system_apps">隱藏系統應用程式</string>
|
||||
<string name="safe_mode_disable_module">安全模式,所有模塊已被禁用!</string>
|
||||
</resources>
|
||||
|
||||
@@ -54,5 +54,6 @@
|
||||
<string name="show_system_apps">Show system apps</string>
|
||||
<string name="hide_system_apps">Hide system apps</string>
|
||||
<string name="send_log">Send Log</string>
|
||||
<string name="safe_mode_disable_module">Safe mode, all module are disabled</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user