manager: Deprecated AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT, the leftover add_sus_mount cli and umount_for_zygote_system_process
Reason: - AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT is also causing a bit more performance overheads and still it cannot catch all the sus mounts in all situations. Actually it can easily be done in boot-completed.sh, and it should be more accurate, see module templates for more details. - Official KernelSU also allows ksud to add custom path to try_umount list as well, users can use their own way to add only the desired sus mounts to try_umount list, but remember to disable susfs ADD_TRY_UMOUNT in kernel if users want to use the official one. - There are less use cases for umount_for_zygote_system_process, and sometimes enabling this may cause bootloop with some modules enabled, instead user can use busybox nsenter to umount the sus mounts for specific process later by themmselves.
This commit is contained in:
@@ -47,7 +47,6 @@ enum class SuSFSTab(val displayNameRes: Int) {
|
||||
SUS_PATHS(R.string.susfs_tab_sus_paths),
|
||||
SUS_LOOP_PATHS(R.string.susfs_tab_sus_loop_paths),
|
||||
SUS_MAPS(R.string.susfs_tab_sus_maps),
|
||||
SUS_MOUNTS(R.string.susfs_tab_sus_mounts),
|
||||
TRY_UMOUNT(R.string.susfs_tab_try_umount),
|
||||
KSTAT_CONFIG(R.string.susfs_tab_kstat_config),
|
||||
PATH_SETTINGS(R.string.susfs_tab_path_settings),
|
||||
@@ -99,7 +98,6 @@ fun SuSFSConfigScreen(
|
||||
var susPaths by remember { mutableStateOf(emptySet<String>()) }
|
||||
var susLoopPaths by remember { mutableStateOf(emptySet<String>()) }
|
||||
var susMaps by remember { mutableStateOf(emptySet<String>()) }
|
||||
var susMounts by remember { mutableStateOf(emptySet<String>()) }
|
||||
var tryUmounts by remember { mutableStateOf(emptySet<String>()) }
|
||||
var androidDataPath by remember { mutableStateOf("") }
|
||||
var sdcardPath by remember { mutableStateOf("") }
|
||||
@@ -125,7 +123,6 @@ fun SuSFSConfigScreen(
|
||||
var showAddLoopPathDialog by remember { mutableStateOf(false) }
|
||||
var showAddSusMapDialog by remember { mutableStateOf(false) }
|
||||
var showAddAppPathDialog by remember { mutableStateOf(false) }
|
||||
var showAddMountDialog by remember { mutableStateOf(false) }
|
||||
var showAddUmountDialog by remember { mutableStateOf(false) }
|
||||
var showAddKstatStaticallyDialog by remember { mutableStateOf(false) }
|
||||
var showAddKstatDialog by remember { mutableStateOf(false) }
|
||||
@@ -134,7 +131,6 @@ fun SuSFSConfigScreen(
|
||||
var editingPath by remember { mutableStateOf<String?>(null) }
|
||||
var editingLoopPath by remember { mutableStateOf<String?>(null) }
|
||||
var editingSusMap by remember { mutableStateOf<String?>(null) }
|
||||
var editingMount by remember { mutableStateOf<String?>(null) }
|
||||
var editingUmount by remember { mutableStateOf<String?>(null) }
|
||||
var editingKstatConfig by remember { mutableStateOf<String?>(null) }
|
||||
var editingKstatPath by remember { mutableStateOf<String?>(null) }
|
||||
@@ -143,7 +139,6 @@ fun SuSFSConfigScreen(
|
||||
var showResetPathsDialog by remember { mutableStateOf(false) }
|
||||
var showResetLoopPathsDialog by remember { mutableStateOf(false) }
|
||||
var showResetSusMapsDialog by remember { mutableStateOf(false) }
|
||||
var showResetMountsDialog by remember { mutableStateOf(false) }
|
||||
var showResetUmountsDialog by remember { mutableStateOf(false) }
|
||||
var showResetKstatDialog by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -304,7 +299,6 @@ fun SuSFSConfigScreen(
|
||||
susPaths = SuSFSManager.getSusPaths(context)
|
||||
susLoopPaths = SuSFSManager.getSusLoopPaths(context)
|
||||
susMaps = SuSFSManager.getSusMaps(context)
|
||||
susMounts = SuSFSManager.getSusMounts(context)
|
||||
tryUmounts = SuSFSManager.getTryUmounts(context)
|
||||
androidDataPath = SuSFSManager.getAndroidDataPath(context)
|
||||
sdcardPath = SuSFSManager.getSdcardPath(context)
|
||||
@@ -477,7 +471,6 @@ fun SuSFSConfigScreen(
|
||||
susPaths = SuSFSManager.getSusPaths(context)
|
||||
susLoopPaths = SuSFSManager.getSusLoopPaths(context)
|
||||
susMaps = SuSFSManager.getSusMaps(context)
|
||||
susMounts = SuSFSManager.getSusMounts(context)
|
||||
tryUmounts = SuSFSManager.getTryUmounts(context)
|
||||
androidDataPath = SuSFSManager.getAndroidDataPath(context)
|
||||
sdcardPath = SuSFSManager.getSdcardPath(context)
|
||||
@@ -649,35 +642,6 @@ fun SuSFSConfigScreen(
|
||||
existingSusPaths = susPaths
|
||||
)
|
||||
|
||||
AddPathDialog(
|
||||
showDialog = showAddMountDialog,
|
||||
onDismiss = {
|
||||
showAddMountDialog = false
|
||||
editingMount = null
|
||||
},
|
||||
onConfirm = { mount ->
|
||||
coroutineScope.launch {
|
||||
isLoading = true
|
||||
val success = if (editingMount != null) {
|
||||
SuSFSManager.editSusMount(context, editingMount!!, mount)
|
||||
} else {
|
||||
SuSFSManager.addSusMount(context, mount)
|
||||
}
|
||||
if (success) {
|
||||
susMounts = SuSFSManager.getSusMounts(context)
|
||||
}
|
||||
isLoading = false
|
||||
showAddMountDialog = false
|
||||
editingMount = null
|
||||
}
|
||||
},
|
||||
isLoading = isLoading,
|
||||
titleRes = if (editingMount != null) R.string.susfs_edit_sus_mount else R.string.susfs_add_sus_mount,
|
||||
labelRes = R.string.susfs_mount_path_label,
|
||||
placeholderRes = R.string.susfs_path_placeholder,
|
||||
initialValue = editingMount ?: ""
|
||||
)
|
||||
|
||||
AddTryUmountDialog(
|
||||
showDialog = showAddUmountDialog,
|
||||
onDismiss = {
|
||||
@@ -865,27 +829,6 @@ fun SuSFSConfigScreen(
|
||||
isDestructive = true
|
||||
)
|
||||
|
||||
ConfirmDialog(
|
||||
showDialog = showResetMountsDialog,
|
||||
onDismiss = { showResetMountsDialog = false },
|
||||
onConfirm = {
|
||||
coroutineScope.launch {
|
||||
isLoading = true
|
||||
SuSFSManager.saveSusMounts(context, emptySet())
|
||||
susMounts = emptySet()
|
||||
if (SuSFSManager.isAutoStartEnabled(context)) {
|
||||
SuSFSManager.configureAutoStart(context, true)
|
||||
}
|
||||
isLoading = false
|
||||
showResetMountsDialog = false
|
||||
}
|
||||
},
|
||||
titleRes = R.string.susfs_reset_mounts_title,
|
||||
messageRes = R.string.susfs_reset_mounts_message,
|
||||
isLoading = isLoading,
|
||||
isDestructive = true
|
||||
)
|
||||
|
||||
ConfirmDialog(
|
||||
showDialog = showResetUmountsDialog,
|
||||
onDismiss = { showResetUmountsDialog = false },
|
||||
@@ -1106,28 +1049,6 @@ fun SuSFSConfigScreen(
|
||||
}
|
||||
}
|
||||
|
||||
SuSFSTab.SUS_MOUNTS -> {
|
||||
OutlinedButton(
|
||||
onClick = { showResetMountsDialog = true },
|
||||
enabled = !isLoading && susMounts.isNotEmpty(),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(40.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.RestoreFromTrash,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
Text(
|
||||
stringResource(R.string.susfs_reset_mounts_title),
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SuSFSTab.TRY_UMOUNT -> {
|
||||
OutlinedButton(
|
||||
onClick = { showResetUmountsDialog = true },
|
||||
@@ -1325,6 +1246,20 @@ fun SuSFSConfigScreen(
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
},
|
||||
hideSusMountsForAllProcs = hideSusMountsForAllProcs,
|
||||
onHideSusMountsForAllProcsChange = { hideForAll ->
|
||||
coroutineScope.launch {
|
||||
isLoading = true
|
||||
if (SuSFSManager.setHideSusMountsForAllProcs(
|
||||
context,
|
||||
hideForAll
|
||||
)
|
||||
) {
|
||||
hideSusMountsForAllProcs = hideForAll
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1390,43 +1325,6 @@ fun SuSFSConfigScreen(
|
||||
}
|
||||
)
|
||||
}
|
||||
SuSFSTab.SUS_MOUNTS -> {
|
||||
val isSusVersion158 = remember { isSusVersion158() }
|
||||
|
||||
SusMountsContent(
|
||||
susMounts = susMounts,
|
||||
hideSusMountsForAllProcs = hideSusMountsForAllProcs,
|
||||
isSusVersion158 = isSusVersion158,
|
||||
isLoading = isLoading,
|
||||
onAddMount = { showAddMountDialog = true },
|
||||
onRemoveMount = { mount ->
|
||||
coroutineScope.launch {
|
||||
isLoading = true
|
||||
if (SuSFSManager.removeSusMount(context, mount)) {
|
||||
susMounts = SuSFSManager.getSusMounts(context)
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
},
|
||||
onEditMount = { mount ->
|
||||
editingMount = mount
|
||||
showAddMountDialog = true
|
||||
},
|
||||
onToggleHideSusMountsForAllProcs = { hideForAll ->
|
||||
coroutineScope.launch {
|
||||
isLoading = true
|
||||
if (SuSFSManager.setHideSusMountsForAllProcs(
|
||||
context,
|
||||
hideForAll
|
||||
)
|
||||
) {
|
||||
hideSusMountsForAllProcs = hideForAll
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
SuSFSTab.TRY_UMOUNT -> {
|
||||
TryUmountContent(
|
||||
@@ -1570,7 +1468,9 @@ private fun BasicSettingsContent(
|
||||
enableCleanupResidue: Boolean,
|
||||
onEnableCleanupResidueChange: (Boolean) -> Unit,
|
||||
enableAvcLogSpoofing: Boolean,
|
||||
onEnableAvcLogSpoofingChange: (Boolean) -> Unit
|
||||
onEnableAvcLogSpoofingChange: (Boolean) -> Unit,
|
||||
hideSusMountsForAllProcs: Boolean,
|
||||
onHideSusMountsForAllProcsChange: (Boolean) -> Unit
|
||||
) {
|
||||
var scriptLocationExpanded by remember { mutableStateOf(false) }
|
||||
val isAbDevice = produceState(initialValue = false) {
|
||||
@@ -1946,6 +1846,16 @@ private fun BasicSettingsContent(
|
||||
}
|
||||
}
|
||||
|
||||
// 对所有进程隐藏sus挂载开关(仅在1.5.8+版本显示)
|
||||
val isSusVersion158 = isSusVersion158()
|
||||
if (isSusVersion158) {
|
||||
SusMountHidingControlCard(
|
||||
hideSusMountsForAllProcs = hideSusMountsForAllProcs,
|
||||
isLoading = isLoading,
|
||||
onToggleHiding = onHideSusMountsForAllProcsChange
|
||||
)
|
||||
}
|
||||
|
||||
// 槽位信息按钮
|
||||
if (isAbDevice) {
|
||||
Card(
|
||||
|
||||
@@ -420,82 +420,6 @@ fun SusMapsContent(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SUS挂载内容组件
|
||||
*/
|
||||
@Composable
|
||||
fun SusMountsContent(
|
||||
susMounts: Set<String>,
|
||||
hideSusMountsForAllProcs: Boolean,
|
||||
isSusVersion158: Boolean,
|
||||
isLoading: Boolean,
|
||||
onAddMount: () -> Unit,
|
||||
onRemoveMount: (String) -> Unit,
|
||||
onEditMount: ((String) -> Unit)? = null,
|
||||
onToggleHideSusMountsForAllProcs: (Boolean) -> Unit
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
if (isSusVersion158) {
|
||||
item {
|
||||
SusMountHidingControlCard(
|
||||
hideSusMountsForAllProcs = hideSusMountsForAllProcs,
|
||||
isLoading = isLoading,
|
||||
onToggleHiding = onToggleHideSusMountsForAllProcs
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (susMounts.isEmpty()) {
|
||||
item {
|
||||
EmptyStateCard(
|
||||
message = stringResource(R.string.susfs_no_mounts_configured)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
items(susMounts.toList()) { mount ->
|
||||
PathItemCard(
|
||||
path = mount,
|
||||
icon = Icons.Default.Storage,
|
||||
onDelete = { onRemoveMount(mount) },
|
||||
onEdit = if (onEditMount != null) { { onEditMount(mount) } } else null,
|
||||
isLoading = isLoading
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Button(
|
||||
onClick = onAddMount,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(48.dp),
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(text = stringResource(R.string.add))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试卸载内容组件
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,6 @@ object SuSFSManager {
|
||||
private const val KEY_SUS_LOOP_PATHS = "sus_loop_paths"
|
||||
|
||||
private const val KEY_SUS_MAPS = "sus_maps"
|
||||
private const val KEY_SUS_MOUNTS = "sus_mounts"
|
||||
private const val KEY_TRY_UMOUNTS = "try_umounts"
|
||||
private const val KEY_ANDROID_DATA_PATH = "android_data_path"
|
||||
private const val KEY_SDCARD_PATH = "sdcard_path"
|
||||
@@ -157,7 +156,6 @@ object SuSFSManager {
|
||||
val susPaths: Set<String>,
|
||||
val susLoopPaths: Set<String>,
|
||||
val susMaps: Set<String>,
|
||||
val susMounts: Set<String>,
|
||||
val tryUmounts: Set<String>,
|
||||
val androidDataPath: String,
|
||||
val sdcardPath: String,
|
||||
@@ -180,7 +178,6 @@ object SuSFSManager {
|
||||
susPaths.isNotEmpty() ||
|
||||
susLoopPaths.isNotEmpty() ||
|
||||
susMaps.isNotEmpty() ||
|
||||
susMounts.isNotEmpty() ||
|
||||
tryUmounts.isNotEmpty() ||
|
||||
kstatConfigs.isNotEmpty() ||
|
||||
addKstatPaths.isNotEmpty()
|
||||
@@ -271,7 +268,6 @@ object SuSFSManager {
|
||||
susPaths = getSusPaths(context),
|
||||
susLoopPaths = getSusLoopPaths(context),
|
||||
susMaps = getSusMaps(context),
|
||||
susMounts = getSusMounts(context),
|
||||
tryUmounts = getTryUmounts(context),
|
||||
androidDataPath = getAndroidDataPath(context),
|
||||
sdcardPath = getSdcardPath(context),
|
||||
@@ -381,12 +377,6 @@ object SuSFSManager {
|
||||
fun getSusMaps(context: Context): Set<String> =
|
||||
getPrefs(context).getStringSet(KEY_SUS_MAPS, emptySet()) ?: emptySet()
|
||||
|
||||
fun saveSusMounts(context: Context, mounts: Set<String>) =
|
||||
getPrefs(context).edit { putStringSet(KEY_SUS_MOUNTS, mounts) }
|
||||
|
||||
fun getSusMounts(context: Context): Set<String> =
|
||||
getPrefs(context).getStringSet(KEY_SUS_MOUNTS, emptySet()) ?: emptySet()
|
||||
|
||||
fun saveTryUmounts(context: Context, umounts: Set<String>) =
|
||||
getPrefs(context).edit { putStringSet(KEY_TRY_UMOUNTS, umounts) }
|
||||
|
||||
@@ -547,7 +537,6 @@ object SuSFSManager {
|
||||
KEY_SUS_PATHS to getSusPaths(context),
|
||||
KEY_SUS_LOOP_PATHS to getSusLoopPaths(context),
|
||||
KEY_SUS_MAPS to getSusMaps(context),
|
||||
KEY_SUS_MOUNTS to getSusMounts(context),
|
||||
KEY_TRY_UMOUNTS to getTryUmounts(context),
|
||||
KEY_ANDROID_DATA_PATH to getAndroidDataPath(context),
|
||||
KEY_SDCARD_PATH to getSdcardPath(context),
|
||||
@@ -860,13 +849,11 @@ object SuSFSManager {
|
||||
|
||||
val featureMap = mapOf(
|
||||
"CONFIG_KSU_SUSFS_SUS_PATH" to context.getString(R.string.sus_path_feature_label),
|
||||
"CONFIG_KSU_SUSFS_SUS_MOUNT" to context.getString(R.string.sus_mount_feature_label),
|
||||
"CONFIG_KSU_SUSFS_TRY_UMOUNT" to context.getString(R.string.try_umount_feature_label),
|
||||
"CONFIG_KSU_SUSFS_SPOOF_UNAME" to context.getString(R.string.spoof_uname_feature_label),
|
||||
"CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG" to context.getString(R.string.spoof_cmdline_feature_label),
|
||||
"CONFIG_KSU_SUSFS_OPEN_REDIRECT" to context.getString(R.string.open_redirect_feature_label),
|
||||
"CONFIG_KSU_SUSFS_ENABLE_LOG" to context.getString(R.string.enable_log_feature_label),
|
||||
"CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT" to context.getString(R.string.auto_try_umount_bind_feature_label),
|
||||
"CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS" to context.getString(R.string.hide_symbols_feature_label),
|
||||
"CONFIG_KSU_SUSFS_SUS_KSTAT" to context.getString(R.string.sus_kstat_feature_label),
|
||||
)
|
||||
@@ -890,13 +877,11 @@ object SuSFSManager {
|
||||
private fun getDefaultDisabledFeatures(context: Context): List<EnabledFeature> {
|
||||
val defaultFeatures = listOf(
|
||||
"sus_path_feature_label" to context.getString(R.string.sus_path_feature_label),
|
||||
"sus_mount_feature_label" to context.getString(R.string.sus_mount_feature_label),
|
||||
"try_umount_feature_label" to context.getString(R.string.try_umount_feature_label),
|
||||
"spoof_uname_feature_label" to context.getString(R.string.spoof_uname_feature_label),
|
||||
"spoof_cmdline_feature_label" to context.getString(R.string.spoof_cmdline_feature_label),
|
||||
"open_redirect_feature_label" to context.getString(R.string.open_redirect_feature_label),
|
||||
"enable_log_feature_label" to context.getString(R.string.enable_log_feature_label),
|
||||
"auto_try_umount_bind_feature_label" to context.getString(R.string.auto_try_umount_bind_feature_label),
|
||||
"hide_symbols_feature_label" to context.getString(R.string.hide_symbols_feature_label),
|
||||
"sus_kstat_feature_label" to context.getString(R.string.sus_kstat_feature_label),
|
||||
)
|
||||
@@ -1182,54 +1167,6 @@ object SuSFSManager {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加SUS挂载
|
||||
suspend fun addSusMount(context: Context, mount: String): Boolean {
|
||||
val success = executeSusfsCommand(context, "add_sus_mount '$mount'")
|
||||
if (success) {
|
||||
saveSusMounts(context, getSusMounts(context) + mount)
|
||||
if (isAutoStartEnabled(context)) updateMagiskModule(context)
|
||||
}
|
||||
return success
|
||||
}
|
||||
|
||||
suspend fun removeSusMount(context: Context, mount: String): Boolean {
|
||||
saveSusMounts(context, getSusMounts(context) - mount)
|
||||
if (isAutoStartEnabled(context)) updateMagiskModule(context)
|
||||
showToast(context, "Removed SUS mount: $mount")
|
||||
return true
|
||||
}
|
||||
|
||||
// 编辑SUS挂载
|
||||
suspend fun editSusMount(context: Context, oldMount: String, newMount: String): Boolean {
|
||||
return try {
|
||||
val currentMounts = getSusMounts(context).toMutableSet()
|
||||
if (!currentMounts.remove(oldMount)) {
|
||||
showToast(context, "Original mount not found: $oldMount")
|
||||
return false
|
||||
}
|
||||
|
||||
saveSusMounts(context, currentMounts)
|
||||
|
||||
val success = addSusMount(context, newMount)
|
||||
|
||||
if (success) {
|
||||
showToast(context, "SUS mount updated: $oldMount -> $newMount")
|
||||
return true
|
||||
} else {
|
||||
// 如果添加新挂载点失败,恢复旧挂载点
|
||||
currentMounts.add(oldMount)
|
||||
saveSusMounts(context, currentMounts)
|
||||
if (isAutoStartEnabled(context)) updateMagiskModule(context)
|
||||
showToast(context, "Failed to update mount, reverted to original")
|
||||
return false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
showToast(context, "Error updating SUS mount: ${e.message}")
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// 添加尝试卸载
|
||||
suspend fun addTryUmount(context: Context, path: String, mode: Int): Boolean {
|
||||
val commandSuccess = executeSusfsCommand(context, "add_try_umount '$path' $mode")
|
||||
|
||||
@@ -26,13 +26,13 @@ object ScriptGenerator {
|
||||
}
|
||||
|
||||
// 日志相关的通用脚本片段
|
||||
private fun generateLogSetup(logFileName: String): String = """
|
||||
private fun generateLogSetup(logFileName: String): String = $$"""
|
||||
# 日志目录
|
||||
LOG_DIR="$LOG_DIR"
|
||||
LOG_FILE="${'$'}LOG_DIR/$logFileName"
|
||||
LOG_DIR="$$LOG_DIR"
|
||||
LOG_FILE="$LOG_DIR/$$logFileName"
|
||||
|
||||
# 创建日志目录
|
||||
mkdir -p "${'$'}LOG_DIR"
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
# 获取当前时间
|
||||
get_current_time() {
|
||||
@@ -41,11 +41,11 @@ object ScriptGenerator {
|
||||
""".trimIndent()
|
||||
|
||||
// 二进制文件检查的通用脚本片段
|
||||
private fun generateBinaryCheck(targetPath: String): String = """
|
||||
private fun generateBinaryCheck(targetPath: String): String = $$"""
|
||||
# 检查SuSFS二进制文件
|
||||
SUSFS_BIN="$targetPath"
|
||||
if [ ! -f "${'$'}SUSFS_BIN" ]; then
|
||||
echo "$(get_current_time): SuSFS二进制文件未找到: ${'$'}SUSFS_BIN" >> "${'$'}LOG_FILE"
|
||||
SUSFS_BIN="$$targetPath"
|
||||
if [ ! -f "$SUSFS_BIN" ]; then
|
||||
echo "$(get_current_time): SuSFS二进制文件未找到: $SUSFS_BIN" >> "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
""".trimIndent()
|
||||
@@ -94,7 +94,7 @@ object ScriptGenerator {
|
||||
generateCleanupResidueSection()
|
||||
}
|
||||
|
||||
appendLine("echo \"$(get_current_time): Service脚本执行完成\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Service脚本执行完成\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,16 +112,16 @@ object ScriptGenerator {
|
||||
private fun StringBuilder.generateLogSettingSection(enableLog: Boolean) {
|
||||
appendLine("# 设置日志启用状态")
|
||||
val logValue = if (enableLog) 1 else 0
|
||||
appendLine("\"${'$'}SUSFS_BIN\" enable_log $logValue")
|
||||
appendLine("echo \"$(get_current_time): 日志功能设置为: ${if (enableLog) "启用" else "禁用"}\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" enable_log $$logValue")
|
||||
appendLine($$"echo \"$(get_current_time): 日志功能设置为: $${if (enableLog) "启用" else "禁用"}\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
|
||||
private fun StringBuilder.generateAvcLogSpoofingSection(enableAvcLogSpoofing: Boolean) {
|
||||
appendLine("# 设置AVC日志欺骗状态")
|
||||
val avcLogValue = if (enableAvcLogSpoofing) 1 else 0
|
||||
appendLine("\"${'$'}SUSFS_BIN\" enable_avc_log_spoofing $avcLogValue")
|
||||
appendLine("echo \"$(get_current_time): AVC日志欺骗功能设置为: ${if (enableAvcLogSpoofing) "启用" else "禁用"}\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" enable_avc_log_spoofing $$avcLogValue")
|
||||
appendLine($$"echo \"$(get_current_time): AVC日志欺骗功能设置为: $${if (enableAvcLogSpoofing) "启用" else "禁用"}\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ object ScriptGenerator {
|
||||
if (susPaths.isNotEmpty()) {
|
||||
appendLine("# 添加SUS路径")
|
||||
susPaths.forEach { path ->
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_sus_path '$path'")
|
||||
appendLine("echo \"$(get_current_time): 添加SUS路径: $path\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" add_sus_path '$$path'")
|
||||
appendLine($$"echo \"$(get_current_time): 添加SUS路径: $$path\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
@@ -140,8 +140,8 @@ object ScriptGenerator {
|
||||
if (susLoopPaths.isNotEmpty()) {
|
||||
appendLine("# 添加SUS循环路径")
|
||||
susLoopPaths.forEach { path ->
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_sus_path_loop '$path'")
|
||||
appendLine("echo \"$(get_current_time): 添加SUS循环路径: $path\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" add_sus_path_loop '$$path'")
|
||||
appendLine($$"echo \"$(get_current_time): 添加SUS循环路径: $$path\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
@@ -156,8 +156,8 @@ object ScriptGenerator {
|
||||
if (addKstatPaths.isNotEmpty()) {
|
||||
appendLine("# 添加Kstat路径")
|
||||
addKstatPaths.forEach { path ->
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_sus_kstat '$path'")
|
||||
appendLine("echo \"$(get_current_time): 添加Kstat路径: $path\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" add_sus_kstat '$$path'")
|
||||
appendLine($$"echo \"$(get_current_time): 添加Kstat路径: $$path\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
@@ -171,11 +171,11 @@ object ScriptGenerator {
|
||||
val path = parts[0]
|
||||
val params = parts.drop(1).joinToString("' '", "'", "'")
|
||||
appendLine()
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_sus_kstat_statically '$path' $params")
|
||||
appendLine("echo \"$(get_current_time): 添加Kstat静态配置: $path\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" add_sus_kstat_statically '$$path' $$params")
|
||||
appendLine($$"echo \"$(get_current_time): 添加Kstat静态配置: $$path\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
appendLine("\"${'$'}SUSFS_BIN\" update_sus_kstat '$path'")
|
||||
appendLine("echo \"$(get_current_time): 更新Kstat配置: $path\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" update_sus_kstat '$$path'")
|
||||
appendLine($$"echo \"$(get_current_time): 更新Kstat配置: $$path\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
}
|
||||
appendLine()
|
||||
@@ -185,8 +185,8 @@ object ScriptGenerator {
|
||||
private fun StringBuilder.generateUnameSection(config: SuSFSManager.ModuleConfig) {
|
||||
if (!config.executeInPostFsData && (config.unameValue != DEFAULT_UNAME || config.buildTimeValue != DEFAULT_BUILD_TIME)) {
|
||||
appendLine("# 设置uname和构建时间")
|
||||
appendLine("\"${'$'}SUSFS_BIN\" set_uname '${config.unameValue}' '${config.buildTimeValue}'")
|
||||
appendLine("echo \"$(get_current_time): 设置uname为: ${config.unameValue}, 构建时间为: ${config.buildTimeValue}\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" set_uname '$${config.unameValue}' '$${config.buildTimeValue}'")
|
||||
appendLine($$"echo \"$(get_current_time): 设置uname为: $${config.unameValue}, 构建时间为: $${config.buildTimeValue}\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
}
|
||||
@@ -194,44 +194,44 @@ object ScriptGenerator {
|
||||
private fun StringBuilder.generateHideBlSection() {
|
||||
appendLine("# 隐藏BL 来自 Shamiko 脚本")
|
||||
appendLine(
|
||||
"""
|
||||
$$"""
|
||||
RESETPROP_BIN="/data/adb/ksu/bin/resetprop"
|
||||
|
||||
check_reset_prop() {
|
||||
local NAME=$1
|
||||
local EXPECTED=$2
|
||||
local VALUE=$("${'$'}RESETPROP_BIN" ${'$'}NAME)
|
||||
[ -z ${'$'}VALUE ] || [ ${'$'}VALUE = ${'$'}EXPECTED ] || "${'$'}RESETPROP_BIN" ${'$'}NAME ${'$'}EXPECTED
|
||||
local VALUE=$("$RESETPROP_BIN" $NAME)
|
||||
[ -z $VALUE ] || [ $VALUE = $EXPECTED ] || "$RESETPROP_BIN" $NAME $EXPECTED
|
||||
}
|
||||
|
||||
check_missing_prop() {
|
||||
local NAME=$1
|
||||
local EXPECTED=$2
|
||||
local VALUE=$("${'$'}RESETPROP_BIN" ${'$'}NAME)
|
||||
[ -z ${'$'}VALUE ] && "${'$'}RESETPROP_BIN" ${'$'}NAME ${'$'}EXPECTED
|
||||
local VALUE=$("$RESETPROP_BIN" $NAME)
|
||||
[ -z $VALUE ] && "$RESETPROP_BIN" $NAME $EXPECTED
|
||||
}
|
||||
|
||||
check_missing_match_prop() {
|
||||
local NAME=$1
|
||||
local EXPECTED=$2
|
||||
local VALUE=$("${'$'}RESETPROP_BIN" ${'$'}NAME)
|
||||
[ -z ${'$'}VALUE ] || [ ${'$'}VALUE = ${'$'}EXPECTED ] || "${'$'}RESETPROP_BIN" ${'$'}NAME ${'$'}EXPECTED
|
||||
[ -z ${'$'}VALUE ] && "${'$'}RESETPROP_BIN" ${'$'}NAME ${'$'}EXPECTED
|
||||
local VALUE=$("$RESETPROP_BIN" $NAME)
|
||||
[ -z $VALUE ] || [ $VALUE = $EXPECTED ] || "$RESETPROP_BIN" $NAME $EXPECTED
|
||||
[ -z $VALUE ] && "$RESETPROP_BIN" $NAME $EXPECTED
|
||||
}
|
||||
|
||||
contains_reset_prop() {
|
||||
local NAME=$1
|
||||
local CONTAINS=$2
|
||||
local NEWVAL=$3
|
||||
case "$("${'$'}RESETPROP_BIN" ${'$'}NAME)" in
|
||||
*"${'$'}CONTAINS"*) "${'$'}RESETPROP_BIN" ${'$'}NAME ${'$'}NEWVAL ;;
|
||||
case "$("$RESETPROP_BIN" $NAME)" in
|
||||
*"$CONTAINS"*) "$RESETPROP_BIN" $NAME $NEWVAL ;;
|
||||
esac
|
||||
}
|
||||
""".trimIndent())
|
||||
appendLine()
|
||||
appendLine("sleep 30")
|
||||
appendLine()
|
||||
appendLine("\"${'$'}RESETPROP_BIN\" -w sys.boot_completed 0")
|
||||
appendLine($$"\"$RESETPROP_BIN\" -w sys.boot_completed 0")
|
||||
|
||||
// 添加所有系统属性重置
|
||||
val systemProps = listOf(
|
||||
@@ -292,27 +292,28 @@ object ScriptGenerator {
|
||||
// 清理残留脚本生成
|
||||
private fun StringBuilder.generateCleanupResidueSection() {
|
||||
appendLine("# 清理工具残留文件")
|
||||
appendLine("echo \"$(get_current_time): 开始清理工具残留\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): 开始清理工具残留\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
|
||||
// 定义清理函数
|
||||
appendLine("""
|
||||
appendLine(
|
||||
$$"""
|
||||
cleanup_path() {
|
||||
local path="$1"
|
||||
local desc="$2"
|
||||
local current="$3"
|
||||
local total="$4"
|
||||
|
||||
if [ -n "${'$'}desc" ]; then
|
||||
echo "$(get_current_time): [${'$'}current/${'$'}total] 清理: ${'$'}path (${'$'}desc)" >> "${'$'}LOG_FILE"
|
||||
if [ -n "$desc" ]; then
|
||||
echo "$(get_current_time): [$current/$total] 清理: $path ($desc)" >> "$LOG_FILE"
|
||||
else
|
||||
echo "$(get_current_time): [${'$'}current/${'$'}total] 清理: ${'$'}path" >> "${'$'}LOG_FILE"
|
||||
echo "$(get_current_time): [$current/$total] 清理: $path" >> "$LOG_FILE"
|
||||
fi
|
||||
|
||||
if rm -rf "${'$'}path" 2>/dev/null; then
|
||||
echo "$(get_current_time): ✓ 成功清理: ${'$'}path" >> "${'$'}LOG_FILE"
|
||||
if rm -rf "$path" 2>/dev/null; then
|
||||
echo "$(get_current_time): ✓ 成功清理: $path" >> "$LOG_FILE"
|
||||
else
|
||||
echo "$(get_current_time): ✗ 清理失败或不存在: ${'$'}path" >> "${'$'}LOG_FILE"
|
||||
echo "$(get_current_time): ✗ 清理失败或不存在: $path" >> "$LOG_FILE"
|
||||
fi
|
||||
}
|
||||
""".trimIndent())
|
||||
@@ -360,11 +361,11 @@ object ScriptGenerator {
|
||||
|
||||
cleanupPaths.forEachIndexed { index, (path, desc) ->
|
||||
val current = index + 1
|
||||
appendLine("cleanup_path '$path' '$desc' $current \$TOTAL")
|
||||
appendLine($$"cleanup_path '$$path' '$$desc' $$current $TOTAL")
|
||||
}
|
||||
|
||||
appendLine()
|
||||
appendLine("echo \"$(get_current_time): 工具残留清理完成\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): 工具残留清理完成\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
|
||||
@@ -381,14 +382,14 @@ object ScriptGenerator {
|
||||
appendLine()
|
||||
appendLine(generateBinaryCheck(config.targetPath))
|
||||
appendLine()
|
||||
appendLine("echo \"$(get_current_time): Post-FS-Data脚本开始执行\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Post-FS-Data脚本开始执行\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
|
||||
// 设置uname和构建时间 - 只有在选择在post-fs-data中执行时才执行
|
||||
if (config.executeInPostFsData && (config.unameValue != DEFAULT_UNAME || config.buildTimeValue != DEFAULT_BUILD_TIME)) {
|
||||
appendLine("# 设置uname和构建时间")
|
||||
appendLine("\"${'$'}SUSFS_BIN\" set_uname '${config.unameValue}' '${config.buildTimeValue}'")
|
||||
appendLine("echo \"$(get_current_time): 设置uname为: ${config.unameValue}, 构建时间为: ${config.buildTimeValue}\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" set_uname '$${config.unameValue}' '$${config.buildTimeValue}'")
|
||||
appendLine($$"echo \"$(get_current_time): 设置uname为: $${config.unameValue}, 构建时间为: $${config.buildTimeValue}\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
|
||||
@@ -397,7 +398,7 @@ object ScriptGenerator {
|
||||
// 添加AVC日志欺骗设置
|
||||
generateAvcLogSpoofingSection(config.enableAvcLogSpoofing)
|
||||
|
||||
appendLine("echo \"$(get_current_time): Post-FS-Data脚本执行完成\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Post-FS-Data脚本执行完成\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,8 +407,8 @@ object ScriptGenerator {
|
||||
if (support158) {
|
||||
appendLine("# 设置Zygote隔离服务卸载状态")
|
||||
val umountValue = if (umountForZygoteIsoService) 1 else 0
|
||||
appendLine("\"${'$'}SUSFS_BIN\" umount_for_zygote_iso_service $umountValue")
|
||||
appendLine("echo \"$(get_current_time): Zygote隔离服务卸载设置为: ${if (umountForZygoteIsoService) "启用" else "禁用"}\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" umount_for_zygote_iso_service $$umountValue")
|
||||
appendLine($$"echo \"$(get_current_time): Zygote隔离服务卸载设置为: $${if (umountForZygoteIsoService) "启用" else "禁用"}\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
}
|
||||
@@ -423,21 +424,11 @@ object ScriptGenerator {
|
||||
appendLine()
|
||||
appendLine(generateLogSetup("susfs_post_mount.log"))
|
||||
appendLine()
|
||||
appendLine("echo \"$(get_current_time): Post-Mount脚本开始执行\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Post-Mount脚本开始执行\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
appendLine(generateBinaryCheck(config.targetPath))
|
||||
appendLine()
|
||||
|
||||
// 添加SUS挂载
|
||||
if (config.susMounts.isNotEmpty()) {
|
||||
appendLine("# 添加SUS挂载")
|
||||
config.susMounts.forEach { mount ->
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_sus_mount '$mount'")
|
||||
appendLine("echo \"$(get_current_time): 添加SUS挂载: $mount\" >> \"${'$'}LOG_FILE\"")
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
|
||||
// 添加尝试卸载
|
||||
if (config.tryUmounts.isNotEmpty()) {
|
||||
appendLine("# 添加尝试卸载")
|
||||
@@ -446,14 +437,14 @@ object ScriptGenerator {
|
||||
if (parts.size == 2) {
|
||||
val path = parts[0]
|
||||
val mode = parts[1]
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_try_umount '$path' $mode")
|
||||
appendLine("echo \"$(get_current_time): 添加尝试卸载: $path (模式: $mode)\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" add_try_umount '$$path' $$mode")
|
||||
appendLine($$"echo \"$(get_current_time): 添加尝试卸载: $$path (模式: $$mode)\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
|
||||
appendLine("echo \"$(get_current_time): Post-Mount脚本执行完成\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Post-Mount脚本执行完成\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +460,7 @@ object ScriptGenerator {
|
||||
appendLine()
|
||||
appendLine(generateLogSetup("susfs_boot_completed.log"))
|
||||
appendLine()
|
||||
appendLine("echo \"$(get_current_time): Boot-Completed脚本开始执行\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Boot-Completed脚本开始执行\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
appendLine(generateBinaryCheck(config.targetPath))
|
||||
appendLine()
|
||||
@@ -479,8 +470,8 @@ object ScriptGenerator {
|
||||
// SUS挂载隐藏控制
|
||||
val hideValue = if (config.hideSusMountsForAllProcs) 1 else 0
|
||||
appendLine("# 设置SUS挂载隐藏控制")
|
||||
appendLine("\"${'$'}SUSFS_BIN\" hide_sus_mnts_for_all_procs $hideValue")
|
||||
appendLine("echo \"$(get_current_time): SUS挂载隐藏控制设置为: ${if (config.hideSusMountsForAllProcs) "对所有进程隐藏" else "仅对非KSU进程隐藏"}\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" hide_sus_mnts_for_all_procs $$hideValue")
|
||||
appendLine($$"echo \"$(get_current_time): SUS挂载隐藏控制设置为: $${if (config.hideSusMountsForAllProcs) "对所有进程隐藏" else "仅对非KSU进程隐藏"}\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
|
||||
// 路径设置和SUS路径设置
|
||||
@@ -504,7 +495,7 @@ object ScriptGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
appendLine("echo \"$(get_current_time): Boot-Completed脚本执行完成\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"echo \"$(get_current_time): Boot-Completed脚本执行完成\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,8 +503,8 @@ object ScriptGenerator {
|
||||
if (susMaps.isNotEmpty()) {
|
||||
appendLine("# 添加SUS映射")
|
||||
susMaps.forEach { map ->
|
||||
appendLine("\"${'$'}SUSFS_BIN\" add_sus_map '$map'")
|
||||
appendLine("echo \"$(get_current_time): 添加SUS映射: $map\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" add_sus_map '$$map'")
|
||||
appendLine($$"echo \"$(get_current_time): 添加SUS映射: $$map\" >> \"$LOG_FILE\"")
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
@@ -526,12 +517,12 @@ object ScriptGenerator {
|
||||
appendLine("until [ -d \"/sdcard/Android\" ]; do sleep 1; done")
|
||||
appendLine("sleep 60")
|
||||
appendLine()
|
||||
appendLine("\"${'$'}SUSFS_BIN\" set_android_data_root_path '$androidDataPath'")
|
||||
appendLine("echo \"$(get_current_time): Android Data路径设置为: $androidDataPath\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" set_android_data_root_path '$$androidDataPath'")
|
||||
appendLine($$"echo \"$(get_current_time): Android Data路径设置为: $$androidDataPath\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
appendLine("# 设置SD卡路径")
|
||||
appendLine("\"${'$'}SUSFS_BIN\" set_sdcard_root_path '$sdcardPath'")
|
||||
appendLine("echo \"$(get_current_time): SD卡路径设置为: $sdcardPath\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine($$"\"$SUSFS_BIN\" set_sdcard_root_path '$$sdcardPath'")
|
||||
appendLine($$"echo \"$(get_current_time): SD卡路径设置为: $$sdcardPath\" >> \"$LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user