manager: fix misleading tips when grant root failed.
This commit is contained in:
@@ -32,6 +32,7 @@ import me.weishu.kernelsu.ui.screen.NavGraphs
|
|||||||
import me.weishu.kernelsu.ui.theme.KernelSUTheme
|
import me.weishu.kernelsu.ui.theme.KernelSUTheme
|
||||||
import me.weishu.kernelsu.ui.util.LocalDialogHost
|
import me.weishu.kernelsu.ui.util.LocalDialogHost
|
||||||
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
|
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
|
||||||
|
import me.weishu.kernelsu.ui.util.rootAvailable
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun BottomBar(navController: NavHostController) {
|
private fun BottomBar(navController: NavHostController) {
|
||||||
val isManager = Natives.becomeManager(ksuApp.packageName)
|
val isManager = Natives.becomeManager(ksuApp.packageName)
|
||||||
val fullFeatured = isManager && !Natives.requireNewKernel()
|
val fullFeatured = isManager && !Natives.requireNewKernel() && rootAvailable()
|
||||||
NavigationBar(tonalElevation = 8.dp) {
|
NavigationBar(tonalElevation = 8.dp) {
|
||||||
BottomBarDestination.values().forEach { destination ->
|
BottomBarDestination.values().forEach { destination ->
|
||||||
if (!fullFeatured && destination.rootRequired) return@forEach
|
if (!fullFeatured && destination.rootRequired) return@forEach
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (!rootAvailable()) {
|
||||||
|
WarningCard(
|
||||||
|
stringResource(id = R.string.grant_root_failed)
|
||||||
|
)
|
||||||
|
}
|
||||||
val checkUpdate =
|
val checkUpdate =
|
||||||
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
.getBoolean("check_update", true)
|
.getBoolean("check_update", true)
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ fun reboot(reason: String = "") {
|
|||||||
ShellUtils.fastCmd(shell, "/system/bin/svc power reboot $reason || /system/bin/reboot $reason")
|
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 {
|
fun overlayFsAvailable(): Boolean {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
// check /proc/filesystems
|
// check /proc/filesystems
|
||||||
|
|||||||
@@ -102,4 +102,7 @@
|
|||||||
<string name="app_profile_template_save_failed">模版保存失败!</string>
|
<string name="app_profile_template_save_failed">模版保存失败!</string>
|
||||||
<string name="app_profile_template_import_empty">剪切板为空!</string>
|
<string name="app_profile_template_import_empty">剪切板为空!</string>
|
||||||
<string name="module_changelog_failed">获取更新日志失败:%s</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>
|
</resources>
|
||||||
@@ -106,4 +106,5 @@
|
|||||||
<string name="module_changelog_failed">Fetch changelog failed: %s</string>
|
<string name="module_changelog_failed">Fetch changelog failed: %s</string>
|
||||||
<string name="settings_check_update">Check update</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="settings_check_update_summary">Automatically check for updates when opening the app</string>
|
||||||
|
<string name="grant_root_failed">Failed to grant root!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user