manager: ui state for safemode

This commit is contained in:
tiann
2023-02-13 22:41:32 +08:00
parent 42428345ff
commit 55602f1f16
12 changed files with 59 additions and 25 deletions

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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 = {
@@ -123,7 +135,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
} else {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(15.dp),
contentPadding = remember { PaddingValues(bottom = 16.dp + 56.dp /* Scaffold Fab Spacing + Fab container height */ ) }
contentPadding = remember { PaddingValues(bottom = 16.dp + 56.dp /* Scaffold Fab Spacing + Fab container height */) }
) {
items(viewModel.moduleList) { module ->
var isChecked by rememberSaveable(module) { mutableStateOf(module.enabled) }

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>