manager: fix misleading tips when grant root failed.

This commit is contained in:
weishu
2024-02-02 12:25:30 +08:00
parent 60d2685f7e
commit 5db51b0715
5 changed files with 16 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ import me.weishu.kernelsu.ui.screen.NavGraphs
import me.weishu.kernelsu.ui.theme.KernelSUTheme
import me.weishu.kernelsu.ui.util.LocalDialogHost
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
import me.weishu.kernelsu.ui.util.rootAvailable
class MainActivity : ComponentActivity() {
@@ -66,7 +67,7 @@ class MainActivity : ComponentActivity() {
@Composable
private fun BottomBar(navController: NavHostController) {
val isManager = Natives.becomeManager(ksuApp.packageName)
val fullFeatured = isManager && !Natives.requireNewKernel()
val fullFeatured = isManager && !Natives.requireNewKernel() && rootAvailable()
NavigationBar(tonalElevation = 8.dp) {
BottomBarDestination.values().forEach { destination ->
if (!fullFeatured && destination.rootRequired) return@forEach

View File

@@ -69,6 +69,11 @@ fun HomeScreen(navigator: DestinationsNavigator) {
)
)
}
if (!rootAvailable()) {
WarningCard(
stringResource(id = R.string.grant_root_failed)
)
}
val checkUpdate =
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("check_update", true)

View File

@@ -140,6 +140,11 @@ fun reboot(reason: String = "") {
ShellUtils.fastCmd(shell, "/system/bin/svc power reboot $reason || /system/bin/reboot $reason")
}
fun rootAvailable(): Boolean {
val shell = getRootShell()
return shell.isRoot
}
fun overlayFsAvailable(): Boolean {
val shell = getRootShell()
// check /proc/filesystems

View File

@@ -102,4 +102,7 @@
<string name="app_profile_template_save_failed">模版保存失败!</string>
<string name="app_profile_template_import_empty">剪切板为空!</string>
<string name="module_changelog_failed">获取更新日志失败:%s</string>
<string name="settings_check_update">检查更新</string>
<string name="settings_check_update_summary">在应用启动后自动检查是否有最新版</string>
<string name="grant_root_failed">获取 root 失败!</string>
</resources>

View File

@@ -106,4 +106,5 @@
<string name="module_changelog_failed">Fetch changelog failed: %s</string>
<string name="settings_check_update">Check update</string>
<string name="settings_check_update_summary">Automatically check for updates when opening the app</string>
<string name="grant_root_failed">Failed to grant root!</string>
</resources>