You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
src: bring back LKM patching
This commit is contained in:
18
.github/workflows/ksud.yml
vendored
18
.github/workflows/ksud.yml
vendored
@@ -9,10 +9,10 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: ubuntu-latest
|
default: ubuntu-latest
|
||||||
# pack_lkm:
|
pack_lkm:
|
||||||
# required: false
|
required: false
|
||||||
# type: boolean
|
type: boolean
|
||||||
# default: true
|
default: true
|
||||||
use_cache:
|
use_cache:
|
||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -29,11 +29,11 @@ jobs:
|
|||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|
||||||
# - name: Prepare LKM Files
|
- name: Prepare LKM Files
|
||||||
# if: ${{ inputs.pack_lkm }}
|
if: ${{ inputs.pack_lkm }}
|
||||||
# run: |
|
run: |
|
||||||
# cp android*-lkm/*_kernelsu.ko ./userspace/ksud_overlayfs/bin/aarch64/
|
cp android*-lkm/*_kernelsu.ko ./userspace/ksud_overlayfs/bin/aarch64/
|
||||||
# cp android*-lkm/*_kernelsu.ko ./userspace/ksud_magic/bin/aarch64/ // DISBAND LKM MODE
|
cp android*-lkm/*_kernelsu.ko ./userspace/ksud_magic/bin/aarch64/
|
||||||
|
|
||||||
- name: Import susfsd Libraries
|
- name: Import susfsd Libraries
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import com.dergoogler.mmrl.ui.component.LabelItemDefaults
|
|||||||
import com.dergoogler.mmrl.ui.component.text.TextRow
|
import com.dergoogler.mmrl.ui.component.text.TextRow
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootGraph
|
import com.ramcosta.composedestinations.annotation.RootGraph
|
||||||
// import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination // DISBAND LKM MODE
|
import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination
|
||||||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -66,9 +66,9 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||||||
TopBar(
|
TopBar(
|
||||||
kernelVersion,
|
kernelVersion,
|
||||||
ksuVersion,
|
ksuVersion,
|
||||||
// onInstallClick = {
|
onInstallClick = {
|
||||||
// navigator.navigate(InstallScreenDestination)
|
navigator.navigate(InstallScreenDestination)
|
||||||
// }, // DISBAND LKM MODE
|
},
|
||||||
scrollBehavior = scrollBehavior
|
scrollBehavior = scrollBehavior
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -87,7 +87,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StatusCard(kernelVersion, ksuVersion, lkmMode) {
|
StatusCard(kernelVersion, ksuVersion, lkmMode) {
|
||||||
// navigator.navigate(InstallScreenDestination) // DISBAND LKM MODE
|
navigator.navigate(InstallScreenDestination)
|
||||||
}
|
}
|
||||||
if (isManager && Natives.requireNewKernel()) {
|
if (isManager && Natives.requireNewKernel()) {
|
||||||
WarningCard(
|
WarningCard(
|
||||||
@@ -173,20 +173,22 @@ fun RebootDropdownItem(@StringRes id: Int, reason: String = "") {
|
|||||||
private fun TopBar(
|
private fun TopBar(
|
||||||
kernelVersion: KernelVersion,
|
kernelVersion: KernelVersion,
|
||||||
ksuVersion: Int?,
|
ksuVersion: Int?,
|
||||||
// onInstallClick: () -> Unit, // DISBAND LKM MODE
|
onInstallClick: () -> Unit,
|
||||||
scrollBehavior: TopAppBarScrollBehavior? = null
|
scrollBehavior: TopAppBarScrollBehavior? = null
|
||||||
) {
|
) {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(stringResource(R.string.app_name)) },
|
title = { Text(stringResource(R.string.app_name)) },
|
||||||
actions = {
|
actions = {
|
||||||
// if (kernelVersion.isGKI()) {
|
if (ksuVersion != null) {
|
||||||
// IconButton(onClick = onInstallClick) {
|
if (kernelVersion.isGKI()) {
|
||||||
// Icon(
|
IconButton(onClick = onInstallClick) {
|
||||||
// imageVector = Icons.Filled.Archive,
|
Icon(
|
||||||
// contentDescription = stringResource(id = R.string.install)
|
imageVector = Icons.Filled.Archive,
|
||||||
// )
|
contentDescription = stringResource(id = R.string.install)
|
||||||
// }
|
)
|
||||||
// } // DISBAND LKM MODE
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ksuVersion != null) {
|
if (ksuVersion != null) {
|
||||||
var showDropdown by remember { mutableStateOf(false) }
|
var showDropdown by remember { mutableStateOf(false) }
|
||||||
@@ -257,16 +259,17 @@ private fun StatusCard(
|
|||||||
tapCount++
|
tapCount++
|
||||||
if (tapCount == 10) {
|
if (tapCount == 10) {
|
||||||
Toast.makeText(context, "Never gonna give you up! 💜", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "Never gonna give you up! 💜", Toast.LENGTH_SHORT).show()
|
||||||
// tapCount = 0
|
|
||||||
val url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
val url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
||||||
val intent = android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url))
|
val intent = android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url))
|
||||||
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
context.startActivity(intent)
|
if (ksuVersion != null) {
|
||||||
|
context.startActivity(intent)
|
||||||
|
} else {
|
||||||
|
onClickInstall()
|
||||||
|
}
|
||||||
|
} else if (ksuVersion == null && kernelVersion.isGKI()) {
|
||||||
|
onClickInstall()
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (kernelVersion.isGKI()) {
|
|
||||||
// onClickInstall()
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
.padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
|
.padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
when {
|
when {
|
||||||
@@ -344,20 +347,20 @@ private fun StatusCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// kernelVersion.isGKI() -> {
|
kernelVersion.isGKI() -> {
|
||||||
// Icon(Icons.Filled.Report, stringResource(R.string.lkm_mode_deprecated))
|
Icon(Icons.Filled.Report, stringResource(R.string.home_not_installed))
|
||||||
// Column(Modifier.padding(start = 20.dp)) {
|
Column(Modifier.padding(start = 20.dp)) {
|
||||||
// Text(
|
Text(
|
||||||
// text = stringResource(R.string.lkm_mode_deprecated),
|
text = stringResource(R.string.home_not_installed),
|
||||||
// style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
// )
|
)
|
||||||
// Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
// Text(
|
Text(
|
||||||
// text = stringResource(R.string.lkm_alternative_suggestion),
|
text = stringResource(R.string.home_click_to_install),
|
||||||
// style = MaterialTheme.typography.bodyMedium
|
style = MaterialTheme.typography.bodyMedium
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
Icon(Icons.Filled.Dangerous, stringResource(R.string.home_failure))
|
Icon(Icons.Filled.Dangerous, stringResource(R.string.home_failure))
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.FileUpload
|
import androidx.compose.material.icons.filled.FileUpload
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -30,6 +31,7 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.RadioButton
|
import androidx.compose.material3.RadioButton
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||||
@@ -77,6 +79,32 @@ import com.rifsxd.ksunext.ui.util.rootAvailable
|
|||||||
@Destination<RootGraph>
|
@Destination<RootGraph>
|
||||||
@Composable
|
@Composable
|
||||||
fun InstallScreen(navigator: DestinationsNavigator) {
|
fun InstallScreen(navigator: DestinationsNavigator) {
|
||||||
|
var showLkmWarning by remember { mutableStateOf(true) }
|
||||||
|
|
||||||
|
if (showLkmWarning) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = {
|
||||||
|
showLkmWarning = false
|
||||||
|
navigator.popBackStack()
|
||||||
|
},
|
||||||
|
title = { Text(stringResource(R.string.warning)) },
|
||||||
|
text = { Text(stringResource(R.string.lkm_warning_message)) },
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = { showLkmWarning = false }) {
|
||||||
|
Text(stringResource(R.string.proceed))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
showLkmWarning = false
|
||||||
|
navigator.popBackStack()
|
||||||
|
}) {
|
||||||
|
Text(stringResource(R.string.cancel))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
var installMethod by remember {
|
var installMethod by remember {
|
||||||
mutableStateOf<InstallMethod?>(null)
|
mutableStateOf<InstallMethod?>(null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,12 +399,12 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// val lkmMode = Natives.version >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && Natives.isLkmMode
|
val lkmMode = Natives.version >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && Natives.isLkmMode
|
||||||
// if (lkmMode) {
|
if (lkmMode) {
|
||||||
// UninstallItem(navigator) {
|
UninstallItem(navigator) {
|
||||||
// loadingDialog.withLoading(it)
|
loadingDialog.withLoading(it)
|
||||||
// }
|
}
|
||||||
// } // DISBAND LKM MODE
|
}
|
||||||
|
|
||||||
var showBottomsheet by remember { mutableStateOf(false) }
|
var showBottomsheet by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
@@ -532,107 +532,107 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Composable
|
@Composable
|
||||||
// fun UninstallItem(
|
fun UninstallItem(
|
||||||
// navigator: DestinationsNavigator,
|
navigator: DestinationsNavigator,
|
||||||
// withLoading: suspend (suspend () -> Unit) -> Unit,
|
withLoading: suspend (suspend () -> Unit) -> Unit,
|
||||||
// ) {
|
) {
|
||||||
// val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
// val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
// val uninstallConfirmDialog = rememberConfirmDialog()
|
val uninstallConfirmDialog = rememberConfirmDialog()
|
||||||
// val showTodo = {
|
val showTodo = {
|
||||||
// Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show()
|
||||||
// }
|
}
|
||||||
// val uninstallDialog = rememberUninstallDialog { uninstallType ->
|
val uninstallDialog = rememberUninstallDialog { uninstallType ->
|
||||||
// scope.launch {
|
scope.launch {
|
||||||
// val result = uninstallConfirmDialog.awaitConfirm(
|
val result = uninstallConfirmDialog.awaitConfirm(
|
||||||
// title = context.getString(uninstallType.title),
|
title = context.getString(uninstallType.title),
|
||||||
// content = context.getString(uninstallType.message)
|
content = context.getString(uninstallType.message)
|
||||||
// )
|
)
|
||||||
// if (result == ConfirmResult.Confirmed) {
|
if (result == ConfirmResult.Confirmed) {
|
||||||
// withLoading {
|
withLoading {
|
||||||
// when (uninstallType) {
|
when (uninstallType) {
|
||||||
// UninstallType.TEMPORARY -> showTodo()
|
UninstallType.TEMPORARY -> showTodo()
|
||||||
// UninstallType.PERMANENT -> navigator.navigate(
|
UninstallType.PERMANENT -> navigator.navigate(
|
||||||
// FlashScreenDestination(FlashIt.FlashUninstall)
|
FlashScreenDestination(FlashIt.FlashUninstall)
|
||||||
// )
|
)
|
||||||
// UninstallType.RESTORE_STOCK_IMAGE -> navigator.navigate(
|
UninstallType.RESTORE_STOCK_IMAGE -> navigator.navigate(
|
||||||
// FlashScreenDestination(FlashIt.FlashRestore)
|
FlashScreenDestination(FlashIt.FlashRestore)
|
||||||
// )
|
)
|
||||||
// UninstallType.NONE -> Unit
|
UninstallType.NONE -> Unit
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// val uninstall = stringResource(id = R.string.settings_uninstall)
|
val uninstall = stringResource(id = R.string.settings_uninstall)
|
||||||
// ListItem(
|
ListItem(
|
||||||
// leadingContent = {
|
leadingContent = {
|
||||||
// Icon(
|
Icon(
|
||||||
// Icons.Filled.Delete,
|
Icons.Filled.Delete,
|
||||||
// uninstall
|
uninstall
|
||||||
// )
|
)
|
||||||
// },
|
},
|
||||||
// headlineContent = { Text(uninstall) },
|
headlineContent = { Text(uninstall) },
|
||||||
// modifier = Modifier.clickable {
|
modifier = Modifier.clickable {
|
||||||
// uninstallDialog.show()
|
uninstallDialog.show()
|
||||||
// }
|
}
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// enum class UninstallType(val title: Int, val message: Int, val icon: ImageVector) {
|
enum class UninstallType(val title: Int, val message: Int, val icon: ImageVector) {
|
||||||
// TEMPORARY(
|
TEMPORARY(
|
||||||
// R.string.settings_uninstall_temporary,
|
R.string.settings_uninstall_temporary,
|
||||||
// R.string.settings_uninstall_temporary_message,
|
R.string.settings_uninstall_temporary_message,
|
||||||
// Icons.Filled.Delete
|
Icons.Filled.Delete
|
||||||
// ),
|
),
|
||||||
// PERMANENT(
|
PERMANENT(
|
||||||
// R.string.settings_uninstall_permanent,
|
R.string.settings_uninstall_permanent,
|
||||||
// R.string.settings_uninstall_permanent_message,
|
R.string.settings_uninstall_permanent_message,
|
||||||
// Icons.Filled.DeleteForever
|
Icons.Filled.DeleteForever
|
||||||
// ),
|
),
|
||||||
// RESTORE_STOCK_IMAGE(
|
RESTORE_STOCK_IMAGE(
|
||||||
// R.string.settings_restore_stock_image,
|
R.string.settings_restore_stock_image,
|
||||||
// R.string.settings_restore_stock_image_message,
|
R.string.settings_restore_stock_image_message,
|
||||||
// Icons.AutoMirrored.Filled.Undo
|
Icons.AutoMirrored.Filled.Undo
|
||||||
// ),
|
),
|
||||||
// NONE(0, 0, Icons.Filled.Delete)
|
NONE(0, 0, Icons.Filled.Delete)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// @OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
// @Composable
|
@Composable
|
||||||
// fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
|
fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
|
||||||
// return rememberCustomDialog { dismiss ->
|
return rememberCustomDialog { dismiss ->
|
||||||
// val options = listOf(
|
val options = listOf(
|
||||||
// // UninstallType.TEMPORARY,
|
// UninstallType.TEMPORARY,
|
||||||
// UninstallType.PERMANENT,
|
UninstallType.PERMANENT,
|
||||||
// UninstallType.RESTORE_STOCK_IMAGE
|
UninstallType.RESTORE_STOCK_IMAGE
|
||||||
// )
|
)
|
||||||
// val listOptions = options.map {
|
val listOptions = options.map {
|
||||||
// ListOption(
|
ListOption(
|
||||||
// titleText = stringResource(it.title),
|
titleText = stringResource(it.title),
|
||||||
// subtitleText = if (it.message != 0) stringResource(it.message) else null,
|
subtitleText = if (it.message != 0) stringResource(it.message) else null,
|
||||||
// icon = IconSource(it.icon)
|
icon = IconSource(it.icon)
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// var selection = UninstallType.NONE
|
var selection = UninstallType.NONE
|
||||||
// ListDialog(state = rememberUseCaseState(visible = true, onFinishedRequest = {
|
ListDialog(state = rememberUseCaseState(visible = true, onFinishedRequest = {
|
||||||
// if (selection != UninstallType.NONE) {
|
if (selection != UninstallType.NONE) {
|
||||||
// onSelected(selection)
|
onSelected(selection)
|
||||||
// }
|
}
|
||||||
// }, onCloseRequest = {
|
}, onCloseRequest = {
|
||||||
// dismiss()
|
dismiss()
|
||||||
// }), header = Header.Default(
|
}), header = Header.Default(
|
||||||
// title = stringResource(R.string.settings_uninstall),
|
title = stringResource(R.string.settings_uninstall),
|
||||||
// ), selection = ListSelection.Single(
|
), selection = ListSelection.Single(
|
||||||
// showRadioButtons = false,
|
showRadioButtons = false,
|
||||||
// options = listOptions,
|
options = listOptions,
|
||||||
// ) { index, _ ->
|
) { index, _ ->
|
||||||
// selection = options[index]
|
selection = options[index]
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
// } // DISBAND LKM MODE
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
BIN
manager/app/src/main/jniLibs/arm64-v8a/libmagiskboot.so
Normal file
BIN
manager/app/src/main/jniLibs/arm64-v8a/libmagiskboot.so
Normal file
Binary file not shown.
BIN
manager/app/src/main/jniLibs/armeabi-v7a/libmagiskboot.so
Normal file
BIN
manager/app/src/main/jniLibs/armeabi-v7a/libmagiskboot.so
Normal file
Binary file not shown.
BIN
manager/app/src/main/jniLibs/x86_64/libmagiskboot.so
Normal file
BIN
manager/app/src/main/jniLibs/x86_64/libmagiskboot.so
Normal file
Binary file not shown.
@@ -100,6 +100,7 @@
|
|||||||
<string name="proceed">Proceed</string>
|
<string name="proceed">Proceed</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="later">Later</string>
|
<string name="later">Later</string>
|
||||||
|
<string name="lkm_warning_message">The LKM patch relies on closed source components. Do you want to continue?</string>
|
||||||
<string name="home_next_kernelsu">🔥 Next build</string>
|
<string name="home_next_kernelsu">🔥 Next build</string>
|
||||||
<string name="home_next_kernelsu_repo">https://github.com/KernelSU-Next/KernelSU-Next</string>
|
<string name="home_next_kernelsu_repo">https://github.com/KernelSU-Next/KernelSU-Next</string>
|
||||||
<string name="home_next_kernelsu_body">Next experimental branch. Check it out on GitHub!</string>
|
<string name="home_next_kernelsu_body">Next experimental branch. Check it out on GitHub!</string>
|
||||||
|
|||||||
BIN
userspace/ksud_magic/bin/aarch64/bootctl
Normal file
BIN
userspace/ksud_magic/bin/aarch64/bootctl
Normal file
Binary file not shown.
BIN
userspace/ksud_magic/bin/aarch64/ksuinit
Normal file
BIN
userspace/ksud_magic/bin/aarch64/ksuinit
Normal file
Binary file not shown.
@@ -7,7 +7,7 @@ use crate::{defs::BINARY_DIR, utils};
|
|||||||
|
|
||||||
pub const RESETPROP_PATH: &str = concatcp!(BINARY_DIR, "resetprop");
|
pub const RESETPROP_PATH: &str = concatcp!(BINARY_DIR, "resetprop");
|
||||||
pub const BUSYBOX_PATH: &str = concatcp!(BINARY_DIR, "busybox");
|
pub const BUSYBOX_PATH: &str = concatcp!(BINARY_DIR, "busybox");
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const BOOTCTL_PATH: &str = concatcp!(BINARY_DIR, "bootctl");
|
pub const BOOTCTL_PATH: &str = concatcp!(BINARY_DIR, "bootctl");
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ use crate::defs::{KSU_BACKUP_DIR, KSU_BACKUP_FILE_PREFIX};
|
|||||||
use crate::{assets, utils};
|
use crate::{assets, utils};
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn ensure_gki_kernel() -> Result<()> {
|
fn ensure_gki_kernel() -> Result<()> {
|
||||||
let version = get_kernel_version()?;
|
let version = get_kernel_version()?;
|
||||||
let is_gki = version.0 == 5 && version.1 >= 10 || version.2 > 5;
|
let is_gki = version.0 == 5 && version.1 >= 10 || version.2 > 5;
|
||||||
@@ -28,7 +27,6 @@ fn ensure_gki_kernel() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_kernel_version() -> Result<(i32, i32, i32)> {
|
pub fn get_kernel_version() -> Result<(i32, i32, i32)> {
|
||||||
let uname = rustix::system::uname();
|
let uname = rustix::system::uname();
|
||||||
let version = uname.release().to_string_lossy();
|
let version = uname.release().to_string_lossy();
|
||||||
@@ -53,7 +51,6 @@ pub fn get_kernel_version() -> Result<(i32, i32, i32)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi(version: &str) -> Result<String> {
|
fn parse_kmi(version: &str) -> Result<String> {
|
||||||
let re = Regex::new(r"(.* )?(\d+\.\d+)(\S+)?(android\d+)(.*)")?;
|
let re = Regex::new(r"(.* )?(\d+\.\d+)(\S+)?(android\d+)(.*)")?;
|
||||||
let cap = re
|
let cap = re
|
||||||
@@ -65,7 +62,6 @@ fn parse_kmi(version: &str) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi_from_uname() -> Result<String> {
|
fn parse_kmi_from_uname() -> Result<String> {
|
||||||
let uname = rustix::system::uname();
|
let uname = rustix::system::uname();
|
||||||
let version = uname.release().to_string_lossy();
|
let version = uname.release().to_string_lossy();
|
||||||
@@ -73,7 +69,6 @@ fn parse_kmi_from_uname() -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi_from_modules() -> Result<String> {
|
fn parse_kmi_from_modules() -> Result<String> {
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
// find a *.ko in /vendor/lib/modules
|
// find a *.ko in /vendor/lib/modules
|
||||||
@@ -92,18 +87,15 @@ fn parse_kmi_from_modules() -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_current_kmi() -> Result<String> {
|
pub fn get_current_kmi() -> Result<String> {
|
||||||
parse_kmi_from_uname().or_else(|_| parse_kmi_from_modules())
|
parse_kmi_from_uname().or_else(|_| parse_kmi_from_modules())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_current_kmi() -> Result<String> {
|
pub fn get_current_kmi() -> Result<String> {
|
||||||
bail!("Unsupported platform")
|
bail!("Unsupported platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
|
fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
|
||||||
use std::fs::{File, copy};
|
use std::fs::{File, copy};
|
||||||
use std::io::{BufReader, Read};
|
use std::io::{BufReader, Read};
|
||||||
@@ -137,7 +129,6 @@ fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
|
|||||||
bail!("Try to choose LKM manually")
|
bail!("Try to choose LKM manually")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Result<String> {
|
fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Result<String> {
|
||||||
let image_path = workdir.join("image");
|
let image_path = workdir.join("image");
|
||||||
|
|
||||||
@@ -162,7 +153,6 @@ fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Re
|
|||||||
parse_kmi_from_kernel(&image_path, workdir)
|
parse_kmi_from_kernel(&image_path, workdir)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn do_cpio_cmd(magiskboot: &Path, workdir: &Path, cmd: &str) -> Result<()> {
|
fn do_cpio_cmd(magiskboot: &Path, workdir: &Path, cmd: &str) -> Result<()> {
|
||||||
let status = Command::new(magiskboot)
|
let status = Command::new(magiskboot)
|
||||||
.current_dir(workdir)
|
.current_dir(workdir)
|
||||||
@@ -177,7 +167,6 @@ fn do_cpio_cmd(magiskboot: &Path, workdir: &Path, cmd: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn is_magisk_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
fn is_magisk_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
||||||
let status = Command::new(magiskboot)
|
let status = Command::new(magiskboot)
|
||||||
.current_dir(workdir)
|
.current_dir(workdir)
|
||||||
@@ -190,7 +179,6 @@ fn is_magisk_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
|||||||
Ok(status.code() == Some(1))
|
Ok(status.code() == Some(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn is_kernelsu_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
fn is_kernelsu_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
||||||
let status = Command::new(magiskboot)
|
let status = Command::new(magiskboot)
|
||||||
.current_dir(workdir)
|
.current_dir(workdir)
|
||||||
@@ -202,7 +190,6 @@ fn is_kernelsu_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
|||||||
Ok(status.success())
|
Ok(status.success())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn dd<P: AsRef<Path>, Q: AsRef<Path>>(ifile: P, ofile: Q) -> Result<()> {
|
fn dd<P: AsRef<Path>, Q: AsRef<Path>>(ifile: P, ofile: Q) -> Result<()> {
|
||||||
let status = Command::new("dd")
|
let status = Command::new("dd")
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
@@ -219,7 +206,6 @@ fn dd<P: AsRef<Path>, Q: AsRef<Path>>(ifile: P, ofile: Q) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn restore(
|
pub fn restore(
|
||||||
image: Option<PathBuf>,
|
image: Option<PathBuf>,
|
||||||
magiskboot_path: Option<PathBuf>,
|
magiskboot_path: Option<PathBuf>,
|
||||||
@@ -337,7 +323,6 @@ pub fn restore(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn patch(
|
pub fn patch(
|
||||||
image: Option<PathBuf>,
|
image: Option<PathBuf>,
|
||||||
@@ -357,7 +342,6 @@ pub fn patch(
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn do_patch(
|
fn do_patch(
|
||||||
image: Option<PathBuf>,
|
image: Option<PathBuf>,
|
||||||
@@ -544,7 +528,6 @@ fn do_patch(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
||||||
use sha1::Digest;
|
use sha1::Digest;
|
||||||
@@ -565,7 +548,6 @@ fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
|||||||
Ok(format!("{:x}", result))
|
Ok(format!("{:x}", result))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
||||||
let sha1 = calculate_sha1(image)?;
|
let sha1 = calculate_sha1(image)?;
|
||||||
@@ -586,7 +568,6 @@ fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn clean_backup(sha1: &str) -> Result<()> {
|
fn clean_backup(sha1: &str) -> Result<()> {
|
||||||
println!("- Clean up backup");
|
println!("- Clean up backup");
|
||||||
@@ -610,7 +591,6 @@ fn clean_backup(sha1: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn flash_boot(bootdevice: &Option<String>, new_boot: PathBuf) -> Result<()> {
|
fn flash_boot(bootdevice: &Option<String>, new_boot: PathBuf) -> Result<()> {
|
||||||
let Some(bootdevice) = bootdevice else {
|
let Some(bootdevice) = bootdevice else {
|
||||||
bail!("boot device not found")
|
bail!("boot device not found")
|
||||||
@@ -624,7 +604,6 @@ fn flash_boot(bootdevice: &Option<String>, new_boot: PathBuf) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn find_magiskboot(magiskboot_path: Option<PathBuf>, workdir: &Path) -> Result<PathBuf> {
|
fn find_magiskboot(magiskboot_path: Option<PathBuf>, workdir: &Path) -> Result<PathBuf> {
|
||||||
let magiskboot = {
|
let magiskboot = {
|
||||||
if which("magiskboot").is_ok() {
|
if which("magiskboot").is_ok() {
|
||||||
@@ -649,7 +628,6 @@ fn find_magiskboot(magiskboot_path: Option<PathBuf>, workdir: &Path) -> Result<P
|
|||||||
Ok(magiskboot)
|
Ok(magiskboot)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn find_boot_image(
|
fn find_boot_image(
|
||||||
image: &Option<PathBuf>,
|
image: &Option<PathBuf>,
|
||||||
skip_init: bool,
|
skip_init: bool,
|
||||||
|
|||||||
@@ -62,65 +62,67 @@ enum Commands {
|
|||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Profile,
|
command: Profile,
|
||||||
},
|
},
|
||||||
//
|
|
||||||
// /// Patch boot or init_boot images to apply KernelSU Next
|
/// Patch boot or init_boot images to apply KernelSU Next
|
||||||
// BootPatch {
|
BootPatch {
|
||||||
// /// boot image path, if not specified, will try to find the boot image automatically
|
/// boot image path, if not specified, will try to find the boot image automatically
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// boot: Option<PathBuf>,
|
boot: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// kernel image path to replace
|
/// kernel image path to replace
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// kernel: Option<PathBuf>,
|
kernel: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// LKM module path to replace, if not specified, will use the builtin one
|
/// LKM module path to replace, if not specified, will use the builtin one
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// module: Option<PathBuf>,
|
module: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// init to be replaced
|
/// init to be replaced
|
||||||
// #[arg(short, long, requires("module"))]
|
#[arg(short, long, requires("module"))]
|
||||||
// init: Option<PathBuf>,
|
init: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// will use another slot when boot image is not specified
|
/// will use another slot when boot image is not specified
|
||||||
// #[arg(short = 'u', long, default_value = "false")]
|
#[arg(short = 'u', long, default_value = "false")]
|
||||||
// ota: bool,
|
ota: bool,
|
||||||
//
|
|
||||||
// /// Flash it to boot partition after patch
|
/// Flash it to boot partition after patch
|
||||||
// #[arg(short, long, default_value = "false")]
|
#[arg(short, long, default_value = "false")]
|
||||||
// flash: bool,
|
flash: bool,
|
||||||
//
|
|
||||||
// /// output path, if not specified, will use current directory
|
/// output path, if not specified, will use current directory
|
||||||
// #[arg(short, long, default_value = None)]
|
#[arg(short, long, default_value = None)]
|
||||||
// out: Option<PathBuf>,
|
out: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// magiskboot path, if not specified, will search from $PATH
|
/// magiskboot path, if not specified, will search from $PATH
|
||||||
// #[arg(long, default_value = None)]
|
#[arg(long, default_value = None)]
|
||||||
// magiskboot: Option<PathBuf>,
|
magiskboot: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// KMI version, if specified, will use the specified KMI
|
/// KMI version, if specified, will use the specified KMI
|
||||||
// #[arg(long, default_value = None)]
|
#[arg(long, default_value = None)]
|
||||||
// kmi: Option<String>,
|
kmi: Option<String>,
|
||||||
// },
|
},
|
||||||
//
|
|
||||||
// /// Restore boot or init_boot images patched by KernelSU Next
|
/// Restore boot or init_boot images patched by KernelSU Next
|
||||||
// BootRestore {
|
BootRestore {
|
||||||
// /// boot image path, if not specified, will try to find the boot image automatically
|
/// boot image path, if not specified, will try to find the boot image automatically
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// boot: Option<PathBuf>,
|
boot: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// Flash it to boot partition after patch
|
/// Flash it to boot partition after patch
|
||||||
// #[arg(short, long, default_value = "false")]
|
#[arg(short, long, default_value = "false")]
|
||||||
// flash: bool,
|
flash: bool,
|
||||||
//
|
|
||||||
// /// magiskboot path, if not specified, will search from $PATH
|
/// magiskboot path, if not specified, will search from $PATH
|
||||||
// #[arg(long, default_value = None)]
|
#[arg(long, default_value = None)]
|
||||||
// magiskboot: Option<PathBuf>,
|
magiskboot: Option<PathBuf>,
|
||||||
// },
|
},
|
||||||
|
|
||||||
/// Show boot information
|
/// Show boot information
|
||||||
BootInfo {
|
BootInfo {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: BootInfo,
|
command: BootInfo,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// For developers
|
/// For developers
|
||||||
Debug {
|
Debug {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@@ -354,17 +356,17 @@ pub fn run() -> Result<()> {
|
|||||||
Debug::Test => assets::ensure_binaries(false),
|
Debug::Test => assets::ensure_binaries(false),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Commands::BootPatch {
|
Commands::BootPatch {
|
||||||
// boot,
|
boot,
|
||||||
// init,
|
init,
|
||||||
// kernel,
|
kernel,
|
||||||
// module,
|
module,
|
||||||
// ota,
|
ota,
|
||||||
// flash,
|
flash,
|
||||||
// out,
|
out,
|
||||||
// magiskboot,
|
magiskboot,
|
||||||
// kmi,
|
kmi,
|
||||||
// } => crate::boot_patch::patch(boot, kernel, module, init, ota, flash, out, magiskboot, kmi), // DISBAND LKM MODE
|
} => crate::boot_patch::patch(boot, kernel, module, init, ota, flash, out, magiskboot, kmi),
|
||||||
Commands::BootInfo { command } => match command {
|
Commands::BootInfo { command } => match command {
|
||||||
BootInfo::CurrentKmi => {
|
BootInfo::CurrentKmi => {
|
||||||
let kmi = crate::boot_patch::get_current_kmi()?;
|
let kmi = crate::boot_patch::get_current_kmi()?;
|
||||||
@@ -378,11 +380,11 @@ pub fn run() -> Result<()> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Commands::BootRestore {
|
Commands::BootRestore {
|
||||||
// boot,
|
boot,
|
||||||
// magiskboot,
|
magiskboot,
|
||||||
// flash,
|
flash,
|
||||||
// } => crate::boot_patch::restore(boot, magiskboot, flash),
|
} => crate::boot_patch::restore(boot, magiskboot, flash),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = &result {
|
if let Err(e) = &result {
|
||||||
|
|||||||
BIN
userspace/ksud_overlayfs/bin/aarch64/bootctl
Normal file
BIN
userspace/ksud_overlayfs/bin/aarch64/bootctl
Normal file
Binary file not shown.
BIN
userspace/ksud_overlayfs/bin/aarch64/ksuinit
Normal file
BIN
userspace/ksud_overlayfs/bin/aarch64/ksuinit
Normal file
Binary file not shown.
@@ -8,7 +8,6 @@ use crate::{defs::BINARY_DIR, utils};
|
|||||||
pub const RESETPROP_PATH: &str = concatcp!(BINARY_DIR, "resetprop");
|
pub const RESETPROP_PATH: &str = concatcp!(BINARY_DIR, "resetprop");
|
||||||
pub const BUSYBOX_PATH: &str = concatcp!(BINARY_DIR, "busybox");
|
pub const BUSYBOX_PATH: &str = concatcp!(BINARY_DIR, "busybox");
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const BOOTCTL_PATH: &str = concatcp!(BINARY_DIR, "bootctl");
|
pub const BOOTCTL_PATH: &str = concatcp!(BINARY_DIR, "bootctl");
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ use crate::defs::{KSU_BACKUP_DIR, KSU_BACKUP_FILE_PREFIX};
|
|||||||
use crate::{assets, utils};
|
use crate::{assets, utils};
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn ensure_gki_kernel() -> Result<()> {
|
fn ensure_gki_kernel() -> Result<()> {
|
||||||
let version = get_kernel_version()?;
|
let version = get_kernel_version()?;
|
||||||
let is_gki = version.0 == 5 && version.1 >= 10 || version.2 > 5;
|
let is_gki = version.0 == 5 && version.1 >= 10 || version.2 > 5;
|
||||||
@@ -28,7 +27,6 @@ fn ensure_gki_kernel() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_kernel_version() -> Result<(i32, i32, i32)> {
|
pub fn get_kernel_version() -> Result<(i32, i32, i32)> {
|
||||||
let uname = rustix::system::uname();
|
let uname = rustix::system::uname();
|
||||||
let version = uname.release().to_string_lossy();
|
let version = uname.release().to_string_lossy();
|
||||||
@@ -94,12 +92,10 @@ pub fn get_current_kmi() -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_current_kmi() -> Result<String> {
|
pub fn get_current_kmi() -> Result<String> {
|
||||||
bail!("Unsupported platform")
|
bail!("Unsupported platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
|
fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
|
||||||
use std::fs::{File, copy};
|
use std::fs::{File, copy};
|
||||||
use std::io::{BufReader, Read};
|
use std::io::{BufReader, Read};
|
||||||
@@ -133,7 +129,6 @@ fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
|
|||||||
bail!("Try to choose LKM manually")
|
bail!("Try to choose LKM manually")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Result<String> {
|
fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Result<String> {
|
||||||
let image_path = workdir.join("image");
|
let image_path = workdir.join("image");
|
||||||
|
|
||||||
@@ -158,7 +153,6 @@ fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Re
|
|||||||
parse_kmi_from_kernel(&image_path, workdir)
|
parse_kmi_from_kernel(&image_path, workdir)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn do_cpio_cmd(magiskboot: &Path, workdir: &Path, cmd: &str) -> Result<()> {
|
fn do_cpio_cmd(magiskboot: &Path, workdir: &Path, cmd: &str) -> Result<()> {
|
||||||
let status = Command::new(magiskboot)
|
let status = Command::new(magiskboot)
|
||||||
.current_dir(workdir)
|
.current_dir(workdir)
|
||||||
@@ -173,7 +167,6 @@ fn do_cpio_cmd(magiskboot: &Path, workdir: &Path, cmd: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn is_magisk_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
fn is_magisk_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
||||||
let status = Command::new(magiskboot)
|
let status = Command::new(magiskboot)
|
||||||
.current_dir(workdir)
|
.current_dir(workdir)
|
||||||
@@ -186,7 +179,6 @@ fn is_magisk_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
|||||||
Ok(status.code() == Some(1))
|
Ok(status.code() == Some(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn is_kernelsu_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
fn is_kernelsu_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
||||||
let status = Command::new(magiskboot)
|
let status = Command::new(magiskboot)
|
||||||
.current_dir(workdir)
|
.current_dir(workdir)
|
||||||
@@ -198,7 +190,6 @@ fn is_kernelsu_patched(magiskboot: &Path, workdir: &Path) -> Result<bool> {
|
|||||||
Ok(status.success())
|
Ok(status.success())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn dd<P: AsRef<Path>, Q: AsRef<Path>>(ifile: P, ofile: Q) -> Result<()> {
|
fn dd<P: AsRef<Path>, Q: AsRef<Path>>(ifile: P, ofile: Q) -> Result<()> {
|
||||||
let status = Command::new("dd")
|
let status = Command::new("dd")
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
@@ -332,7 +323,6 @@ pub fn restore(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn patch(
|
pub fn patch(
|
||||||
image: Option<PathBuf>,
|
image: Option<PathBuf>,
|
||||||
@@ -352,7 +342,6 @@ pub fn patch(
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn do_patch(
|
fn do_patch(
|
||||||
image: Option<PathBuf>,
|
image: Option<PathBuf>,
|
||||||
@@ -540,7 +529,6 @@ fn do_patch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
||||||
use sha1::Digest;
|
use sha1::Digest;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
@@ -561,7 +549,6 @@ fn calculate_sha1(file_path: impl AsRef<Path>) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
||||||
let sha1 = calculate_sha1(image)?;
|
let sha1 = calculate_sha1(image)?;
|
||||||
let filename = format!("{KSU_BACKUP_FILE_PREFIX}{sha1}");
|
let filename = format!("{KSU_BACKUP_FILE_PREFIX}{sha1}");
|
||||||
@@ -582,7 +569,6 @@ fn do_backup(magiskboot: &Path, workdir: &Path, image: &str) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[allow(dead_code)]
|
|
||||||
fn clean_backup(sha1: &str) -> Result<()> {
|
fn clean_backup(sha1: &str) -> Result<()> {
|
||||||
println!("- Clean up backup");
|
println!("- Clean up backup");
|
||||||
let backup_name = format!("{}{}", KSU_BACKUP_FILE_PREFIX, sha1);
|
let backup_name = format!("{}{}", KSU_BACKUP_FILE_PREFIX, sha1);
|
||||||
@@ -605,7 +591,6 @@ fn clean_backup(sha1: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn flash_boot(bootdevice: &Option<String>, new_boot: PathBuf) -> Result<()> {
|
fn flash_boot(bootdevice: &Option<String>, new_boot: PathBuf) -> Result<()> {
|
||||||
let Some(bootdevice) = bootdevice else {
|
let Some(bootdevice) = bootdevice else {
|
||||||
bail!("boot device not found")
|
bail!("boot device not found")
|
||||||
@@ -619,7 +604,6 @@ fn flash_boot(bootdevice: &Option<String>, new_boot: PathBuf) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn find_magiskboot(magiskboot_path: Option<PathBuf>, workdir: &Path) -> Result<PathBuf> {
|
fn find_magiskboot(magiskboot_path: Option<PathBuf>, workdir: &Path) -> Result<PathBuf> {
|
||||||
let magiskboot = {
|
let magiskboot = {
|
||||||
if which("magiskboot").is_ok() {
|
if which("magiskboot").is_ok() {
|
||||||
@@ -644,7 +628,6 @@ fn find_magiskboot(magiskboot_path: Option<PathBuf>, workdir: &Path) -> Result<P
|
|||||||
Ok(magiskboot)
|
Ok(magiskboot)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn find_boot_image(
|
fn find_boot_image(
|
||||||
image: &Option<PathBuf>,
|
image: &Option<PathBuf>,
|
||||||
skip_init: bool,
|
skip_init: bool,
|
||||||
@@ -694,7 +677,6 @@ fn find_boot_image(
|
|||||||
Ok((bootimage, bootdevice))
|
Ok((bootimage, bootdevice))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn post_ota() -> Result<()> {
|
fn post_ota() -> Result<()> {
|
||||||
use crate::defs::ADB_DIR;
|
use crate::defs::ADB_DIR;
|
||||||
use assets::BOOTCTL_PATH;
|
use assets::BOOTCTL_PATH;
|
||||||
|
|||||||
@@ -58,65 +58,67 @@ enum Commands {
|
|||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Profile,
|
command: Profile,
|
||||||
},
|
},
|
||||||
//
|
|
||||||
// /// Patch boot or init_boot images to apply KernelSU Next
|
/// Patch boot or init_boot images to apply KernelSU Next
|
||||||
// BootPatch {
|
BootPatch {
|
||||||
// /// boot image path, if not specified, will try to find the boot image automatically
|
/// boot image path, if not specified, will try to find the boot image automatically
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// boot: Option<PathBuf>,
|
boot: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// kernel image path to replace
|
/// kernel image path to replace
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// kernel: Option<PathBuf>,
|
kernel: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// LKM module path to replace, if not specified, will use the builtin one
|
/// LKM module path to replace, if not specified, will use the builtin one
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// module: Option<PathBuf>,
|
module: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// init to be replaced
|
/// init to be replaced
|
||||||
// #[arg(short, long, requires("module"))]
|
#[arg(short, long, requires("module"))]
|
||||||
// init: Option<PathBuf>,
|
init: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// will use another slot when boot image is not specified
|
/// will use another slot when boot image is not specified
|
||||||
// #[arg(short = 'u', long, default_value = "false")]
|
#[arg(short = 'u', long, default_value = "false")]
|
||||||
// ota: bool,
|
ota: bool,
|
||||||
//
|
|
||||||
// /// Flash it to boot partition after patch
|
/// Flash it to boot partition after patch
|
||||||
// #[arg(short, long, default_value = "false")]
|
#[arg(short, long, default_value = "false")]
|
||||||
// flash: bool,
|
flash: bool,
|
||||||
//
|
|
||||||
// /// output path, if not specified, will use current directory
|
/// output path, if not specified, will use current directory
|
||||||
// #[arg(short, long, default_value = None)]
|
#[arg(short, long, default_value = None)]
|
||||||
// out: Option<PathBuf>,
|
out: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// magiskboot path, if not specified, will search from $PATH
|
/// magiskboot path, if not specified, will search from $PATH
|
||||||
// #[arg(long, default_value = None)]
|
#[arg(long, default_value = None)]
|
||||||
// magiskboot: Option<PathBuf>,
|
magiskboot: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// KMI version, if specified, will use the specified KMI
|
/// KMI version, if specified, will use the specified KMI
|
||||||
// #[arg(long, default_value = None)]
|
#[arg(long, default_value = None)]
|
||||||
// kmi: Option<String>,
|
kmi: Option<String>,
|
||||||
// }, // DISBAND LKM MODE
|
},
|
||||||
//
|
|
||||||
// /// Restore boot or init_boot images patched by KernelSU Next
|
/// Restore boot or init_boot images patched by KernelSU Next
|
||||||
// BootRestore {
|
BootRestore {
|
||||||
// /// boot image path, if not specified, will try to find the boot image automatically
|
/// boot image path, if not specified, will try to find the boot image automatically
|
||||||
// #[arg(short, long)]
|
#[arg(short, long)]
|
||||||
// boot: Option<PathBuf>,
|
boot: Option<PathBuf>,
|
||||||
//
|
|
||||||
// /// Flash it to boot partition after patch
|
/// Flash it to boot partition after patch
|
||||||
// #[arg(short, long, default_value = "false")]
|
#[arg(short, long, default_value = "false")]
|
||||||
// flash: bool,
|
flash: bool,
|
||||||
//
|
|
||||||
// /// magiskboot path, if not specified, will search from $PATH
|
/// magiskboot path, if not specified, will search from $PATH
|
||||||
// #[arg(long, default_value = None)]
|
#[arg(long, default_value = None)]
|
||||||
// magiskboot: Option<PathBuf>,
|
magiskboot: Option<PathBuf>,
|
||||||
// },
|
},
|
||||||
|
|
||||||
/// Show boot information
|
/// Show boot information
|
||||||
BootInfo {
|
BootInfo {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: BootInfo,
|
command: BootInfo,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// For developers
|
/// For developers
|
||||||
Debug {
|
Debug {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@@ -326,7 +328,7 @@ pub fn run() -> Result<()> {
|
|||||||
Module::Shrink => module::shrink_ksu_images(),
|
Module::Shrink => module::shrink_ksu_images(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Commands::Install { magiskboot } => utils::install(magiskboot), // DISBAND LKM MODE
|
Commands::Install { magiskboot } => utils::install(magiskboot),
|
||||||
Commands::Uninstall { magiskboot } => utils::uninstall(magiskboot),
|
Commands::Uninstall { magiskboot } => utils::uninstall(magiskboot),
|
||||||
Commands::Sepolicy { command } => match command {
|
Commands::Sepolicy { command } => match command {
|
||||||
Sepolicy::Patch { sepolicy } => crate::sepolicy::live_patch(&sepolicy),
|
Sepolicy::Patch { sepolicy } => crate::sepolicy::live_patch(&sepolicy),
|
||||||
@@ -369,17 +371,17 @@ pub fn run() -> Result<()> {
|
|||||||
Debug::Test => assets::ensure_binaries(false),
|
Debug::Test => assets::ensure_binaries(false),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Commands::BootPatch {
|
Commands::BootPatch {
|
||||||
// boot,
|
boot,
|
||||||
// init,
|
init,
|
||||||
// kernel,
|
kernel,
|
||||||
// module,
|
module,
|
||||||
// ota,
|
ota,
|
||||||
// flash,
|
flash,
|
||||||
// out,
|
out,
|
||||||
// magiskboot,
|
magiskboot,
|
||||||
// kmi,
|
kmi,
|
||||||
// } => crate::boot_patch::patch(boot, kernel, module, init, ota, flash, out, magiskboot, kmi), // DISBAND LKM MODE
|
} => crate::boot_patch::patch(boot, kernel, module, init, ota, flash, out, magiskboot, kmi),
|
||||||
Commands::BootInfo { command } => match command {
|
Commands::BootInfo { command } => match command {
|
||||||
BootInfo::CurrentKmi => {
|
BootInfo::CurrentKmi => {
|
||||||
let kmi = crate::boot_patch::get_current_kmi()?;
|
let kmi = crate::boot_patch::get_current_kmi()?;
|
||||||
@@ -393,11 +395,11 @@ pub fn run() -> Result<()> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Commands::BootRestore {
|
Commands::BootRestore {
|
||||||
// boot,
|
boot,
|
||||||
// magiskboot,
|
magiskboot,
|
||||||
// flash,
|
flash,
|
||||||
// } => crate::boot_patch::restore(boot, magiskboot, flash),
|
} => crate::boot_patch::restore(boot, magiskboot, flash),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = &result {
|
if let Err(e) = &result {
|
||||||
|
|||||||
Reference in New Issue
Block a user