You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: improved module mount system & fixed bug for module installation file name error
This commit is contained in:
@@ -354,6 +354,10 @@ private fun InfoCard() {
|
||||
mutableStateOf(prefs.getBoolean("use_overlay_fs", false))
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
useOverlayFs = prefs.getBoolean("use_overlay_fs", false)
|
||||
}
|
||||
|
||||
ElevatedCard {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -429,10 +433,8 @@ private fun InfoCard() {
|
||||
InfoCardItem(
|
||||
label = stringResource(R.string.home_module_mount),
|
||||
content = if (useOverlayFs) {
|
||||
// Show different content if OverlayFS is enabled
|
||||
stringResource(R.string.home_overlayfs_mount)
|
||||
} else {
|
||||
// Default content when OverlayFS is not enabled
|
||||
stringResource(R.string.home_magic_mount)
|
||||
},
|
||||
icon = Icons.Filled.SettingsSuggest,
|
||||
|
||||
@@ -96,6 +96,7 @@ import com.rifsxd.ksunext.R
|
||||
import com.rifsxd.ksunext.ui.component.ConfirmResult
|
||||
import com.rifsxd.ksunext.ui.component.rememberConfirmDialog
|
||||
import com.rifsxd.ksunext.ui.component.rememberLoadingDialog
|
||||
import com.rifsxd.ksunext.ui.util.*
|
||||
import com.rifsxd.ksunext.ui.util.DownloadListener
|
||||
import com.rifsxd.ksunext.ui.util.LocalSnackbarHost
|
||||
import com.rifsxd.ksunext.ui.util.download
|
||||
@@ -240,8 +241,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
) { innerPadding ->
|
||||
// confirmation dialog
|
||||
if (showConfirmDialog && zipUri != null) {
|
||||
// extract the module name from the zipUri
|
||||
val moduleName = zipUri?.lastPathSegment?.substringAfterLast('/') ?: "Unknown Module"
|
||||
val moduleName = getFileName(context, zipUri!!)
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { showConfirmDialog = false },
|
||||
@@ -251,7 +251,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModule(zipUri!!)))
|
||||
|
||||
viewModel.markNeedRefresh()
|
||||
|
||||
}) {
|
||||
Text(stringResource(R.string.confirm))
|
||||
}
|
||||
@@ -261,7 +260,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
Text(stringResource(android.R.string.cancel))
|
||||
}
|
||||
},
|
||||
title = { Text(stringResource(R.string.confirm_module_installation)) },
|
||||
title = { Text(stringResource(R.string.module)) },
|
||||
text = {
|
||||
Text(
|
||||
stringResource(R.string.module_install_prompt_with_name, moduleName)
|
||||
@@ -270,6 +269,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
when {
|
||||
hasMagisk -> {
|
||||
Box(
|
||||
|
||||
@@ -70,6 +70,7 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import com.rifsxd.ksunext.BuildConfig
|
||||
import com.rifsxd.ksunext.Natives
|
||||
import com.rifsxd.ksunext.ksuApp
|
||||
import com.rifsxd.ksunext.R
|
||||
import com.rifsxd.ksunext.ui.component.AboutDialog
|
||||
import com.rifsxd.ksunext.ui.component.ConfirmResult
|
||||
@@ -168,7 +169,9 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
)
|
||||
}
|
||||
|
||||
var showRestartDialog by remember { mutableStateOf(false) }
|
||||
val isManager = Natives.becomeManager(ksuApp.packageName)
|
||||
|
||||
var showRebootDialog by remember { mutableStateOf(false) }
|
||||
|
||||
SwitchItem(
|
||||
icon = Icons.Filled.Build,
|
||||
@@ -178,24 +181,25 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
) {
|
||||
prefs.edit().putBoolean("use_overlay_fs", it).apply()
|
||||
useOverlayFs = it
|
||||
showRestartDialog = true
|
||||
if (isManager) install()
|
||||
showRebootDialog = true
|
||||
}
|
||||
|
||||
if (showRestartDialog) {
|
||||
if (showRebootDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showRestartDialog = false },
|
||||
title = { Text(stringResource(R.string.restart_required)) },
|
||||
text = { Text(stringResource(R.string.restart_message)) },
|
||||
onDismissRequest = { showRebootDialog = false },
|
||||
title = { Text(stringResource(R.string.reboot_required)) },
|
||||
text = { Text(stringResource(R.string.reboot_message)) },
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showRestartDialog = false
|
||||
restartKsuNext(context)
|
||||
showRebootDialog = false
|
||||
reboot()
|
||||
}) {
|
||||
Text(stringResource(R.string.restart_now))
|
||||
Text(stringResource(R.string.reboot))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showRestartDialog = false }) {
|
||||
TextButton(onClick = { showRebootDialog = false }) {
|
||||
Text(stringResource(R.string.later))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,6 +427,21 @@ fun getAppProfileTemplate(id: String): String {
|
||||
.to(ArrayList(), null).exec().out.joinToString("\n")
|
||||
}
|
||||
|
||||
fun getFileName(context: Context, uri: Uri): String {
|
||||
var name = "Unknown Module"
|
||||
if (uri.scheme == ContentResolver.SCHEME_CONTENT) {
|
||||
val cursor: Cursor? = context.contentResolver.query(uri, null, null, null, null)
|
||||
cursor?.use {
|
||||
if (it.moveToFirst()) {
|
||||
name = it.getString(it.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME))
|
||||
}
|
||||
}
|
||||
} else if (uri.scheme == "file") {
|
||||
name = uri.lastPathSegment ?: "Unknown Module"
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
fun setAppProfileTemplate(id: String, template: String): Boolean {
|
||||
val shell = getRootShell()
|
||||
val escapedTemplate = template.replace("\"", "\\\"")
|
||||
@@ -461,10 +476,3 @@ fun restartApp(packageName: String) {
|
||||
forceStopApp(packageName)
|
||||
launchApp(packageName)
|
||||
}
|
||||
|
||||
fun restartKsuNext(context: Context) {
|
||||
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
||||
intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<string name="module_failed_to_disable">Gagal menonaktifkan modul: %s</string>
|
||||
<string name="module_empty">Tidak ada modul</string>
|
||||
<string name="module">Modul</string>
|
||||
<string name="confirm_module_installation">Yakin instal</string>
|
||||
<string name="module_install_prompt_with_name">Anda ingin melanjutkan pemasangan modul %1$s?</string>
|
||||
<string name="module_sort_a_to_z">Menyortir (A - Z)</string>
|
||||
<string name="module_sort_z_to_a">Menyortir (Z - A)</string>
|
||||
@@ -68,10 +67,6 @@
|
||||
<string name="home_overlayfs_mount">OverlayFS</string>
|
||||
<string name="use_overlay_fs">Use OverlayFS</string>
|
||||
<string name="use_overlay_fs_summary">Toggle between using OverlayFS or Magic for KernelSU Next\'s mount system.</string>
|
||||
<string name="restart_required">Restart Required</string>
|
||||
<string name="restart_message">Changes will take effect after restarting the app. Would you like to restart now?</string>
|
||||
<string name="restart_now">Restart Now</string>
|
||||
<string name="later">Later</string>
|
||||
<string name="home_next_kernelsu">🔥 Pembangunan Next</string>
|
||||
<string name="home_next_kernelsu_repo">https://github.com/rifsxd/KernelSU-Next</string>
|
||||
<string name="home_next_kernelsu_body">Next cabang eksperimental. Lihat di GitHub!</string>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<string name="module_failed_to_disable">Falha ao desativar o módulo %s</string>
|
||||
<string name="module_empty">Nenhum módulo instalado</string>
|
||||
<string name="module">Módulo</string>
|
||||
<string name="confirm_module_installation">Confirmação de instalação</string>
|
||||
<string name="module_install_prompt_with_name">Deseja continuar instalando o módulo %1$s?</string>
|
||||
<string name="module_sort_a_to_z">Ordenar (A-Z)</string>
|
||||
<string name="module_sort_z_to_a">Ordenar (Z-A)</string>
|
||||
@@ -68,10 +67,6 @@
|
||||
<string name="home_overlayfs_mount">OverlayFS</string>
|
||||
<string name="use_overlay_fs">Use OverlayFS</string>
|
||||
<string name="use_overlay_fs_summary">Toggle between using OverlayFS or Magic for KernelSU Next\'s mount system.</string>
|
||||
<string name="restart_required">Restart Required</string>
|
||||
<string name="restart_message">Changes will take effect after restarting the app. Would you like to restart now?</string>
|
||||
<string name="restart_now">Restart Now</string>
|
||||
<string name="later">Later</string>
|
||||
<string name="home_next_kernelsu">🔥 Compilação next</string>
|
||||
<string name="home_next_kernelsu_repo">https://github.com/rifsxd/KernelSU-Next</string>
|
||||
<string name="home_next_kernelsu_body">Branch next experimental. Confira no GitHub!</string>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<string name="module_failed_to_disable">无法禁用模块: %s</string>
|
||||
<string name="module_empty">没有安装模块</string>
|
||||
<string name="module">模块</string>
|
||||
<string name="confirm_module_installation">确认安装</string>
|
||||
<string name="module_install_prompt_with_name">是否要继续安装模块 %1$s ?</string>
|
||||
<string name="module_sort_a_to_z">种类 (A - Z)</string>
|
||||
<string name="module_sort_z_to_a">种类 (Z - A)</string>
|
||||
@@ -67,10 +66,6 @@
|
||||
<string name="home_overlayfs_mount">OverlayFS</string>
|
||||
<string name="use_overlay_fs">Use OverlayFS</string>
|
||||
<string name="use_overlay_fs_summary">Toggle between using OverlayFS or Magic for KernelSU Next\'s mount system.</string>
|
||||
<string name="restart_required">Restart Required</string>
|
||||
<string name="restart_message">Changes will take effect after restarting the app. Would you like to restart now?</string>
|
||||
<string name="restart_now">Restart Now</string>
|
||||
<string name="later">Later</string>
|
||||
<string name="module_magisk_conflict">因与 Magisk 有冲突,所有模块不可用!</string>
|
||||
<string name="home_next_kernelsu">🔥 Next 构建</string>
|
||||
<string name="home_next_kernelsu_repo">https://github.com/rifsxd/KernelSU-Next</string>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<string name="module_failed_to_disable">Failed to disable module: %s</string>
|
||||
<string name="module_empty">No module installed</string>
|
||||
<string name="module">Module</string>
|
||||
<string name="confirm_module_installation">Install confirmation</string>
|
||||
<string name="module_install_prompt_with_name">Do you want to continue installing module %1$s?</string>
|
||||
<string name="module_sort_a_to_z">Sort (A-Z)</string>
|
||||
<string name="module_sort_z_to_a">Sort (Z-A)</string>
|
||||
@@ -68,9 +67,8 @@
|
||||
<string name="home_overlayfs_mount">OverlayFS</string>
|
||||
<string name="use_overlay_fs">Use OverlayFS</string>
|
||||
<string name="use_overlay_fs_summary">Toggle between using OverlayFS or Magic for KernelSU Next\'s mount system.</string>
|
||||
<string name="restart_required">Restart Required</string>
|
||||
<string name="restart_message">Changes will take effect after restarting the app. Would you like to restart now?</string>
|
||||
<string name="restart_now">Restart Now</string>
|
||||
<string name="reboot_required">Reboot Required</string>
|
||||
<string name="reboot_message">Changes will take effect after rebooting the system. Would you like to reboot now?</string>
|
||||
<string name="later">Later</string>
|
||||
<string name="home_next_kernelsu">🔥 Next build</string>
|
||||
<string name="home_next_kernelsu_repo">https://github.com/rifsxd/KernelSU-Next</string>
|
||||
|
||||
Reference in New Issue
Block a user