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_DENY_SU 4
|
||||||
#define CMD_GET_ALLOW_LIST 5
|
#define CMD_GET_ALLOW_LIST 5
|
||||||
#define CMD_GET_DENY_LIST 6
|
#define CMD_GET_DENY_LIST 6
|
||||||
|
#define CMD_CHECK_SAFEMODE 9
|
||||||
|
|
||||||
static bool ksuctl(int cmd, void* arg1, void* arg2) {
|
static bool ksuctl(int cmd, void* arg1, void* arg2) {
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
@@ -52,3 +53,7 @@ bool get_allow_list(int *uids, int *size) {
|
|||||||
bool get_deny_list(int *uids, int *size) {
|
bool get_deny_list(int *uids, int *size) {
|
||||||
return ksuctl(CMD_GET_DENY_LIST, uids, 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 get_deny_list(int *uids, int *size);
|
||||||
|
|
||||||
|
bool is_safe_mode();
|
||||||
|
|
||||||
#endif //KERNELSU_KSU_H
|
#endif //KERNELSU_KSU_H
|
||||||
|
|||||||
@@ -21,4 +21,6 @@ public final class Natives {
|
|||||||
public static native int[] getDenyList();
|
public static native int[] getDenyList();
|
||||||
|
|
||||||
public static native boolean allowRoot(int uid, boolean allow);
|
public static native boolean allowRoot(int uid, boolean allow);
|
||||||
|
|
||||||
|
public static native boolean isSafeMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,36 +52,42 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isSafeMode = Natives.isSafeMode()
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopBar()
|
TopBar()
|
||||||
},
|
},
|
||||||
floatingActionButton = {
|
floatingActionButton = if (isSafeMode) {
|
||||||
val moduleInstall = stringResource(id = R.string.module_install)
|
{ /* Empty */ }
|
||||||
val selectZipLauncher = rememberLauncherForActivityResult(
|
} else {
|
||||||
contract = ActivityResultContracts.StartActivityForResult()
|
{
|
||||||
) {
|
val moduleInstall = stringResource(id = R.string.module_install)
|
||||||
if (it.resultCode != RESULT_OK) {
|
val selectZipLauncher = rememberLauncherForActivityResult(
|
||||||
return@rememberLauncherForActivityResult
|
contract = ActivityResultContracts.StartActivityForResult()
|
||||||
|
) {
|
||||||
|
if (it.resultCode != RESULT_OK) {
|
||||||
|
return@rememberLauncherForActivityResult
|
||||||
|
}
|
||||||
|
val data = it.data ?: return@rememberLauncherForActivityResult
|
||||||
|
val uri = data.data ?: return@rememberLauncherForActivityResult
|
||||||
|
|
||||||
|
navigator.navigate(InstallScreenDestination(uri))
|
||||||
|
|
||||||
|
Log.i("ModuleScreen", "select zip result: ${it.data}")
|
||||||
}
|
}
|
||||||
val data = it.data ?: return@rememberLauncherForActivityResult
|
|
||||||
val uri = data.data ?: return@rememberLauncherForActivityResult
|
|
||||||
|
|
||||||
navigator.navigate(InstallScreenDestination(uri))
|
ExtendedFloatingActionButton(
|
||||||
|
onClick = {
|
||||||
Log.i("ModuleScreen", "select zip result: ${it.data}")
|
// select the zip file to install
|
||||||
|
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||||
|
intent.type = "application/zip"
|
||||||
|
selectZipLauncher.launch(intent)
|
||||||
|
},
|
||||||
|
icon = { Icon(Icons.Filled.Add, moduleInstall) },
|
||||||
|
text = { Text(text = moduleInstall) },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedFloatingActionButton(
|
|
||||||
onClick = {
|
|
||||||
// select the zip file to install
|
|
||||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
|
||||||
intent.type = "application/zip"
|
|
||||||
selectZipLauncher.launch(intent)
|
|
||||||
},
|
|
||||||
icon = { Icon(Icons.Filled.Add, moduleInstall) },
|
|
||||||
text = { Text(text = moduleInstall) },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
val failedEnable = stringResource(R.string.module_failed_to_enable)
|
val failedEnable = stringResource(R.string.module_failed_to_enable)
|
||||||
@@ -96,6 +102,12 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
return@Scaffold
|
return@Scaffold
|
||||||
}
|
}
|
||||||
|
if (isSafeMode) {
|
||||||
|
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||||
|
Text(stringResource(R.string.safe_mode_disable_module))
|
||||||
|
}
|
||||||
|
return@Scaffold
|
||||||
|
}
|
||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
state = swipeState,
|
state = swipeState,
|
||||||
onRefresh = {
|
onRefresh = {
|
||||||
@@ -123,7 +135,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
} else {
|
} else {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
verticalArrangement = Arrangement.spacedBy(15.dp),
|
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 ->
|
items(viewModel.moduleList) { module ->
|
||||||
var isChecked by rememberSaveable(module) { mutableStateOf(module.enabled) }
|
var isChecked by rememberSaveable(module) { mutableStateOf(module.enabled) }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name" translatable="false">KernelSU</string>
|
<string name="safe_mode_disable_module">セーフモード、すべてのモッドが無効になっています!</string>
|
||||||
|
<string name="app_name" translatable="false">KernelSU</string>
|
||||||
<string name="home">ホーム</string>
|
<string name="home">ホーム</string>
|
||||||
<string name="home_not_installed">未インストール</string>
|
<string name="home_not_installed">未インストール</string>
|
||||||
<string name="home_click_to_install">タップでインストール</string>
|
<string name="home_click_to_install">タップでインストール</string>
|
||||||
|
|||||||
@@ -52,5 +52,6 @@
|
|||||||
<string name="show_system_apps">Показать системные приложения</string>
|
<string name="show_system_apps">Показать системные приложения</string>
|
||||||
<string name="hide_system_apps">Скрыть системные приложения</string>
|
<string name="hide_system_apps">Скрыть системные приложения</string>
|
||||||
<string name="send_log">Отправить лог</string>
|
<string name="send_log">Отправить лог</string>
|
||||||
|
<string name="safe_mode_disable_module">Безопасный режим, все моды отключены!</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -48,4 +48,5 @@
|
|||||||
<string name="refresh">Làm mới</string>
|
<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="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="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>
|
</resources>
|
||||||
|
|||||||
@@ -50,4 +50,5 @@
|
|||||||
<string name="show_system_apps">显示系统应用</string>
|
<string name="show_system_apps">显示系统应用</string>
|
||||||
<string name="hide_system_apps">隐藏系统应用</string>
|
<string name="hide_system_apps">隐藏系统应用</string>
|
||||||
<string name="send_log">发送日志</string>
|
<string name="send_log">发送日志</string>
|
||||||
|
<string name="safe_mode_disable_module">安全模式,所有模块已被禁用!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -46,4 +46,5 @@
|
|||||||
<string name="module_version">版本</string>
|
<string name="module_version">版本</string>
|
||||||
<string name="module_author">作者</string>
|
<string name="module_author">作者</string>
|
||||||
<string name="module_overlay_fs_not_available">內核不支持 overlayfs,模塊功能無法運作!</string>
|
<string name="module_overlay_fs_not_available">內核不支持 overlayfs,模塊功能無法運作!</string>
|
||||||
|
<string name="safe_mode_disable_module">安全模式,所有模塊已被禁用!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -49,4 +49,5 @@
|
|||||||
<string name="refresh">重新整理</string>
|
<string name="refresh">重新整理</string>
|
||||||
<string name="show_system_apps">顯示系統應用程式</string>
|
<string name="show_system_apps">顯示系統應用程式</string>
|
||||||
<string name="hide_system_apps">隱藏系統應用程式</string>
|
<string name="hide_system_apps">隱藏系統應用程式</string>
|
||||||
|
<string name="safe_mode_disable_module">安全模式,所有模塊已被禁用!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -54,5 +54,6 @@
|
|||||||
<string name="show_system_apps">Show system apps</string>
|
<string name="show_system_apps">Show system apps</string>
|
||||||
<string name="hide_system_apps">Hide system apps</string>
|
<string name="hide_system_apps">Hide system apps</string>
|
||||||
<string name="send_log">Send Log</string>
|
<string name="send_log">Send Log</string>
|
||||||
|
<string name="safe_mode_disable_module">Safe mode, all module are disabled</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user