manager: hide install button when magisk installed.

This commit is contained in:
tiann
2023-03-01 12:51:04 +08:00
parent 9f6e9f5db6
commit 203dc42e75
2 changed files with 7 additions and 3 deletions

View File

@@ -53,10 +53,13 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
} }
val isSafeMode = Natives.isSafeMode() val isSafeMode = Natives.isSafeMode()
val hasMagisk = hasMagisk()
val showInstallButton = !(isSafeMode || hasMagisk)
Scaffold(topBar = { Scaffold(topBar = {
TopBar() TopBar()
}, floatingActionButton = if (isSafeMode) { }, floatingActionButton = if (showInstallButton) {
{ /* Empty */ } { /* Empty */ }
} else { } else {
{ {
@@ -103,8 +106,8 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
} }
return@Scaffold return@Scaffold
} }
if (hasMagisk()) { if (hasMagisk) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { Box(modifier = Modifier.fillMaxSize().padding(24.dp), contentAlignment = Alignment.Center) {
Text(stringResource(R.string.module_magisk_conflict)) Text(stringResource(R.string.module_magisk_conflict))
} }
return@Scaffold return@Scaffold

View File

@@ -113,5 +113,6 @@ fun overlayFsAvailable(): Boolean {
fun hasMagisk(): Boolean { fun hasMagisk(): Boolean {
val shell = createRootShell() val shell = createRootShell()
val result = shell.newJob().add("nsenter --mount=/proc/1/ns/mnt which magisk").exec() val result = shell.newJob().add("nsenter --mount=/proc/1/ns/mnt which magisk").exec()
Log.i(TAG, "has magisk: ${result.isSuccess}")
return result.isSuccess return result.isSuccess
} }