diff --git a/manager/app/src/main/AndroidManifest.xml b/manager/app/src/main/AndroidManifest.xml index a893ed23..59a93490 100644 --- a/manager/app/src/main/AndroidManifest.xml +++ b/manager/app/src/main/AndroidManifest.xml @@ -3,8 +3,10 @@ xmlns:tools="http://schemas.android.com/tools"> - - + + "5_10" - else -> "5_15+" + val version = kernelVersion?.let { versionRegex.find(it) }?.value ?: "" + val toolName = if (version.isNotEmpty()) { + val parts = version.split('.') + if (parts.size >= 2) { + val major = parts[0].toIntOrNull() ?: 0 + val minor = parts[1].toIntOrNull() ?: 0 + if (major < 5 || (major == 5 && minor <= 10)) "5_10" else "5_15+" + } else { + "5_15+" + } + } else { + "5_15+" } val toolPath = "${context.filesDir.absolutePath}/mkbootfs" AssetsUtil.exportFiles(context, "$toolName-mkbootfs", toolPath) @@ -283,7 +298,7 @@ class HorizonKernelWorker( } } - private fun runCommandGetOutput(su: Boolean, cmd: String): String { + private fun runCommandGetOutput(su: Boolean, cmd: String): String? { val process = ProcessBuilder(if (su) "su" else "sh") .redirectErrorStream(true) .start() @@ -428,4 +443,4 @@ fun HorizonKernelFlashProgress(state: FlashState) { } } } -} +} \ No newline at end of file diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt index 8dbfadd3..3b32dbee 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt @@ -115,6 +115,7 @@ fun InstallScreen(navigator: DestinationsNavigator) { val summary = stringResource(R.string.horizon_kernel_summary) val kernelVersion = getKernelVersion() val isGKI = kernelVersion.isGKI() + val isAbDevice = isAbDevice() val onFlashComplete = { showRebootDialog = true @@ -169,7 +170,7 @@ fun InstallScreen(navigator: DestinationsNavigator) { // 槽位选择 SlotSelectionDialog( - show = showSlotSelectionDialog, + show = showSlotSelectionDialog && isAbDevice, onDismiss = { showSlotSelectionDialog = false }, onSlotSelected = { slot -> showSlotSelectionDialog = false @@ -240,10 +241,15 @@ fun InstallScreen(navigator: DestinationsNavigator) { ) { SelectInstallMethod( isGKI = isGKI, + isAbDevice = isAbDevice, onSelected = { method -> - if (method is InstallMethod.HorizonKernel && method.uri != null && method.slot == null) { - tempKernelUri = method.uri - showSlotSelectionDialog = true + if (method is InstallMethod.HorizonKernel && method.uri != null) { + if (isAbDevice) { + tempKernelUri = method.uri + showSlotSelectionDialog = true + } else { + installMethod = method + } } else { installMethod = method } @@ -395,6 +401,7 @@ sealed class InstallMethod { @Composable private fun SelectInstallMethod( isGKI: Boolean = false, + isAbDevice: Boolean = false, onSelected: (InstallMethod) -> Unit = {} ) { val rootAvailable = rootAvailable() @@ -488,7 +495,7 @@ private fun SelectInstallMethod( modifier = Modifier.padding(horizontal = 16.dp) ) { // LKM 安装/修补 - if (isGKI && rootAvailable) { + if (isGKI) { ElevatedCard( colors = getCardColors(MaterialTheme.colorScheme.surfaceVariant), elevation = CardDefaults.cardElevation(defaultElevation = cardElevation), @@ -698,43 +705,6 @@ private fun SelectInstallMethod( } } } - - // 没有root - if (!rootAvailable) { - ElevatedCard( - colors = getCardColors(MaterialTheme.colorScheme.errorContainer), - elevation = CardDefaults.cardElevation(defaultElevation = cardElevation), - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 12.dp) - .clip(MaterialTheme.shapes.large) - .shadow( - elevation = cardElevation, - shape = MaterialTheme.shapes.large, - spotColor = MaterialTheme.colorScheme.error.copy(alpha = 0.1f) - ) - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(24.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Icon( - imageVector = Icons.Filled.AutoFixHigh, - contentDescription = null, - tint = MaterialTheme.colorScheme.onErrorContainer, - modifier = Modifier - .padding(end = 16.dp) - ) - Text( - text = stringResource(R.string.root_require_for_install), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onErrorContainer - ) - } - } - } } }