Skip to content

Commit

Permalink
manager: fix misleading tips when grant root failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Feb 2, 2024
1 parent 60d2685 commit 5db51b0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions manager/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
1 change: 1 addition & 0 deletions manager/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 5db51b0

Please sign in to comment.