Updating the KPM configuration

- We don't know if KPM can run on arm32-bit devices, so to avoid some problems, add a dependency on 64-bit architectures

Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-05-17 22:22:13 +08:00
parent 0701967bab
commit 28aa34c0b6
4 changed files with 243 additions and 192 deletions

View File

@@ -16,20 +16,13 @@ config KSU_DEBUG
help help
Enable KernelSU debug mode. Enable KernelSU debug mode.
config KSU_HOOK
bool "Enable KernelSU Hook"
default n
help
This option enables the KernelSU Hook feature. If enabled, it will
override the kernel version check and enable the hook functionality.
config KPM config KPM
bool "Enable SukiSU KPM" bool "Enable SukiSU KPM"
depends on KSU && 64BIT
default n default n
help help
Enabling this option will activate the KPM feature of SukiSU. Enabling this option will activate the KPM feature of SukiSU.
This option is suitable for scenarios where you need to force KPM to be enabled. This option is suitable for scenarios where you need to force KPM to be enabled.
but it may affect system stability. but it may affect system stability.
endmenu endmenu

View File

@@ -206,28 +206,36 @@ fun GroupsPanel(selected: List<Groups>, closeSelection: (selection: Set<Groups>)
} }
val selection = HashSet(selected) val selection = HashSet(selected)
ListDialog( val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest
state = rememberUseCaseState(visible = true, onFinishedRequest = {
closeSelection(selection) MaterialTheme(
}, onCloseRequest = { colorScheme = MaterialTheme.colorScheme.copy(
dismiss() surface = backgroundColor
}), )
header = Header.Default( ) {
title = stringResource(R.string.profile_groups), ListDialog(
), state = rememberUseCaseState(visible = true, onFinishedRequest = {
selection = ListSelection.Multiple( closeSelection(selection)
showCheckBoxes = true, }, onCloseRequest = {
options = options, dismiss()
maxChoices = 32, // Kernel only supports 32 groups at most }),
) { indecies, _ -> header = Header.Default(
// Handle selection title = stringResource(R.string.profile_groups),
selection.clear() ),
indecies.forEach { index -> selection = ListSelection.Multiple(
val group = groups[index] showCheckBoxes = true,
selection.add(group) options = options,
maxChoices = 32, // Kernel only supports 32 groups at most
) { indecies, _ ->
// Handle selection
selection.clear()
indecies.forEach { index ->
val group = groups[index]
selection.add(group)
}
} }
} )
) }
} }
OutlinedCard( OutlinedCard(
@@ -278,27 +286,35 @@ fun CapsPanel(
} }
val selection = HashSet(selected) val selection = HashSet(selected)
ListDialog( val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest
state = rememberUseCaseState(visible = true, onFinishedRequest = {
closeSelection(selection) MaterialTheme(
}, onCloseRequest = { colorScheme = MaterialTheme.colorScheme.copy(
dismiss() surface = backgroundColor
}), )
header = Header.Default( ) {
title = stringResource(R.string.profile_capabilities), ListDialog(
), state = rememberUseCaseState(visible = true, onFinishedRequest = {
selection = ListSelection.Multiple( closeSelection(selection)
showCheckBoxes = true, }, onCloseRequest = {
options = options dismiss()
) { indecies, _ -> }),
// Handle selection header = Header.Default(
selection.clear() title = stringResource(R.string.profile_capabilities),
indecies.forEach { index -> ),
val group = caps[index] selection = ListSelection.Multiple(
selection.add(group) showCheckBoxes = true,
options = options
) { indecies, _ ->
// Handle selection
selection.clear()
indecies.forEach { index ->
val group = caps[index]
selection.add(group)
}
} }
} )
) }
} }
OutlinedCard( OutlinedCard(
@@ -425,24 +441,33 @@ private fun SELinuxPanel(
) )
) )
InputDialog( val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest
state = rememberUseCaseState(visible = true,
onFinishedRequest = { MaterialTheme(
onSELinuxChange(domain, rules) colorScheme = MaterialTheme.colorScheme.copy(
}, surface = backgroundColor
onCloseRequest = {
dismiss()
}),
header = Header.Default(
title = stringResource(R.string.profile_selinux_context),
),
selection = InputSelection(
input = inputOptions,
onPositiveClick = { result ->
// Handle selection
},
) )
) ) {
InputDialog(
state = rememberUseCaseState(
visible = true,
onFinishedRequest = {
onSELinuxChange(domain, rules)
},
onCloseRequest = {
dismiss()
}),
header = Header.Default(
title = stringResource(R.string.profile_selinux_context),
),
selection = InputSelection(
input = inputOptions,
onPositiveClick = { result ->
// Handle selection
},
)
)
}
} }
ListItem(headlineContent = { ListItem(headlineContent = {

View File

@@ -359,7 +359,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
var isCustomizeExpanded by remember { mutableStateOf(false) } var isCustomizeExpanded by remember { mutableStateOf(false) }
var isAppearanceExpanded by remember { mutableStateOf(true) } var isAppearanceExpanded by remember { mutableStateOf(true) }
var isAdvancedExpanded by remember { mutableStateOf(false) } var isAdvancedExpanded by remember { mutableStateOf(false) }
var isDpiExpanded by remember { mutableStateOf(false) }
// DPI 设置 // DPI 设置
val systemDpi = remember { context.resources.displayMetrics.densityDpi } val systemDpi = remember { context.resources.displayMetrics.densityDpi }
@@ -680,6 +679,99 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
} }
// DPI 设置
ListItem(
headlineContent = { Text(stringResource(R.string.app_dpi_title)) },
supportingContent = { Text(stringResource(R.string.app_dpi_summary)) },
leadingContent = {
Icon(
Icons.Default.AcUnit,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary
)
},
trailingContent = {
Text(
text = getDpiFriendlyName(tempDpi),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary
)
},
colors = ListItemDefaults.colors(
containerColor = Color.Transparent
)
)
// DPI 滑动条
Column(modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp)) {
Slider(
value = tempDpi.toFloat(),
onValueChange = {
tempDpi = it.toInt()
isDpiCustom = !dpiPresets.containsValue(tempDpi)
},
valueRange = 160f..600f,
steps = 11,
colors = SliderDefaults.colors(
thumbColor = MaterialTheme.colorScheme.primary,
activeTrackColor = MaterialTheme.colorScheme.primary,
inactiveTrackColor = MaterialTheme.colorScheme.surfaceVariant
)
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp),
) {
dpiPresets.forEach { (name, dpi) ->
TextButton(
onClick = {
tempDpi = dpi
isDpiCustom = false
},
modifier = Modifier.weight(1f)
) {
Text(
text = name,
color = if (tempDpi == dpi)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
TextButton(
onClick = {
if (tempDpi != currentDpi) {
showDpiConfirmDialog = true
}
},
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
) {
Text(stringResource(R.string.dpi_apply_settings))
}
Text(
text = if (isDpiCustom)
"${stringResource(R.string.dpi_size_custom)}: $tempDpi"
else
"${getDpiFriendlyName(tempDpi)}: $tempDpi",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 4.dp)
)
}
HorizontalDivider(
modifier = Modifier.padding(horizontal = 16.dp),
color = MaterialTheme.colorScheme.outlineVariant
)
// 自定义背景开关 // 自定义背景开关
ListItem( ListItem(
headlineContent = { Text(stringResource(id = R.string.settings_custom_background)) }, headlineContent = { Text(stringResource(id = R.string.settings_custom_background)) },
@@ -850,114 +942,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
} }
// DPI 设置部分
SectionHeader(
title = stringResource(R.string.dpi_settings),
expanded = isDpiExpanded,
onToggle = { isDpiExpanded = !isDpiExpanded }
)
AnimatedVisibility(
visible = isDpiExpanded,
enter = fadeIn() + expandVertically(),
exit = fadeOut() + shrinkVertically()
) {
Surface(
shape = RoundedCornerShape(16.dp),
tonalElevation = 1.dp,
modifier = Modifier.padding(bottom = 16.dp)
) {
Column {
ListItem(
headlineContent = { Text(stringResource(R.string.app_dpi_title)) },
supportingContent = { Text(stringResource(R.string.app_dpi_summary)) },
leadingContent = {
Icon(
Icons.Default.AcUnit,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary
)
},
trailingContent = {
Text(
text = getDpiFriendlyName(tempDpi),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary
)
},
colors = ListItemDefaults.colors(
containerColor = Color.Transparent
)
)
// DPI 滑动条
Column(modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp)) {
Slider(
value = tempDpi.toFloat(),
onValueChange = {
tempDpi = it.toInt()
isDpiCustom = !dpiPresets.containsValue(tempDpi)
},
valueRange = 160f..600f,
steps = 11,
colors = SliderDefaults.colors(
thumbColor = MaterialTheme.colorScheme.primary,
activeTrackColor = MaterialTheme.colorScheme.primary,
inactiveTrackColor = MaterialTheme.colorScheme.surfaceVariant
)
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp),
) {
dpiPresets.forEach { (name, dpi) ->
TextButton(
onClick = {
tempDpi = dpi
isDpiCustom = false
},
modifier = Modifier.weight(1f)
) {
Text(
text = name,
color = if (tempDpi == dpi)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
TextButton(
onClick = {
if (tempDpi != currentDpi) {
showDpiConfirmDialog = true
}
},
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
) {
Text(stringResource(R.string.dpi_apply_settings))
}
Text(
text = if (isDpiCustom)
"${stringResource(R.string.dpi_size_custom)}: $tempDpi"
else
"${getDpiFriendlyName(tempDpi)}: $tempDpi",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 4.dp)
)
}
}
}
}
// 自定义设置部分 // 自定义设置部分
SectionHeader( SectionHeader(
title = stringResource(R.string.custom_settings), title = stringResource(R.string.custom_settings),

View File

@@ -12,6 +12,7 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
@@ -32,6 +33,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@@ -645,7 +647,7 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
) )
} }
var selection = UninstallType.NONE var selectedOption by remember { mutableStateOf<UninstallType?>(null) }
val cardColor = if (!ThemeConfig.useDynamicColor) { val cardColor = if (!ThemeConfig.useDynamicColor) {
ThemeConfig.currentTheme.ButtonContrast ThemeConfig.currentTheme.ButtonContrast
} else { } else {
@@ -668,55 +670,102 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
modifier = Modifier.padding(vertical = 8.dp), modifier = Modifier.padding(vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(16.dp) verticalArrangement = Arrangement.spacedBy(16.dp)
) { ) {
listOptions.forEachIndexed { index, option -> options.forEachIndexed { index, option ->
val isSelected = selectedOption == option
val backgroundColor = if (isSelected)
MaterialTheme.colorScheme.primaryContainer
else
Color.Transparent
val borderColor = if (isSelected)
MaterialTheme.colorScheme.primary
else
Color.Transparent
val contentColor = if (isSelected)
MaterialTheme.colorScheme.onPrimaryContainer
else
MaterialTheme.colorScheme.onSurface
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clip(MaterialTheme.shapes.medium) .clip(MaterialTheme.shapes.medium)
.background(backgroundColor)
.border(
width = 1.dp,
color = borderColor,
shape = MaterialTheme.shapes.medium
)
.clickable { .clickable {
selection = options[index] selectedOption = option
} }
.padding(vertical = 12.dp, horizontal = 8.dp), .padding(vertical = 12.dp, horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Icon( Icon(
imageVector = options[index].icon, imageVector = option.icon,
contentDescription = null, contentDescription = null,
tint = MaterialTheme.colorScheme.primary, tint = if (isSelected)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.primary,
modifier = Modifier modifier = Modifier
.padding(end = 16.dp) .padding(end = 16.dp)
.size(24.dp) .size(24.dp)
) )
Column { Column(
modifier = Modifier.weight(1f)
) {
Text( Text(
text = option.titleText, text = listOptions[index].titleText,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface color = contentColor
) )
option.subtitleText?.let { listOptions[index].subtitleText?.let {
Text( Text(
text = it, text = it,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant color = if (isSelected)
contentColor.copy(alpha = 0.8f)
else
MaterialTheme.colorScheme.onSurfaceVariant
) )
} }
} }
if (isSelected) {
Icon(
imageVector = Icons.Default.RadioButtonChecked,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(24.dp)
)
} else {
Icon(
imageVector = Icons.Default.RadioButtonUnchecked,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(24.dp)
)
}
} }
} }
} }
}, },
confirmButton = { confirmButton = {
TextButton( Button(
onClick = { onClick = {
if (selection != UninstallType.NONE) { selectedOption?.let { onSelected(it) }
onSelected(selection)
}
dismiss() dismiss()
} },
enabled = selectedOption != null,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary,
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant,
disabledContentColor = MaterialTheme.colorScheme.onSurfaceVariant
)
) { ) {
Text( Text(
text = stringResource(android.R.string.ok), text = stringResource(android.R.string.ok)
color = MaterialTheme.colorScheme.primary
) )
} }
}, },