manager:Optimize the path configuration to automatically configure the corresponding value as long as the self-boot is enabled
This commit is contained in:
@@ -349,14 +349,14 @@ object SuSFSManager {
|
||||
val scripts = mapOf(
|
||||
"service.sh" to ScriptGenerator.generateServiceScript(
|
||||
targetPath, config["unameValue"] as String, config["buildTimeValue"] as String,
|
||||
config.getSetSafe<String>("susPaths"), config["androidDataPath"] as String,
|
||||
config["sdcardPath"] as String, config["enableLog"] as Boolean,
|
||||
config.getSetSafe<String>("susPaths"), config["enableLog"] as Boolean,
|
||||
config["executeInPostFsData"] as Boolean, config.getSetSafe<String>("kstatConfigs"),
|
||||
config.getSetSafe<String>("addKstatPaths")
|
||||
),
|
||||
"post-fs-data.sh" to ScriptGenerator.generatePostFsDataScript(
|
||||
targetPath, config["unameValue"] as String, config["buildTimeValue"] as String,
|
||||
config["executeInPostFsData"] as Boolean
|
||||
config["executeInPostFsData"] as Boolean, config["androidDataPath"] as String,
|
||||
config["sdcardPath"] as String
|
||||
),
|
||||
"post-mount.sh" to ScriptGenerator.generatePostMountScript(
|
||||
targetPath, config.getSetSafe<String>("susMounts"), config.getSetSafe<String>("tryUmounts")
|
||||
@@ -596,7 +596,13 @@ object SuSFSManager {
|
||||
val success = executeSusfsCommand(context, "set_android_data_root_path '$path'")
|
||||
if (success) {
|
||||
saveAndroidDataPath(context, path)
|
||||
if (isAutoStartEnabled(context)) createMagiskModule(context)
|
||||
// 如果开机自启动已启用,立即更新模块脚本
|
||||
if (isAutoStartEnabled(context)) {
|
||||
kotlinx.coroutines.CoroutineScope(Dispatchers.Default).launch {
|
||||
removeMagiskModule()
|
||||
createMagiskModule(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return success
|
||||
}
|
||||
@@ -606,7 +612,13 @@ object SuSFSManager {
|
||||
val success = executeSusfsCommand(context, "set_sdcard_root_path '$path'")
|
||||
if (success) {
|
||||
saveSdcardPath(context, path)
|
||||
if (isAutoStartEnabled(context)) createMagiskModule(context)
|
||||
// 如果开机自启动已启用,立即更新模块脚本
|
||||
if (isAutoStartEnabled(context)) {
|
||||
kotlinx.coroutines.CoroutineScope(Dispatchers.Default).launch {
|
||||
removeMagiskModule()
|
||||
createMagiskModule(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return success
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ object ScriptGenerator {
|
||||
unameValue: String,
|
||||
buildTimeValue: String,
|
||||
susPaths: Set<String>,
|
||||
androidDataPath: String,
|
||||
sdcardPath: String,
|
||||
enableLog: Boolean,
|
||||
executeInPostFsData: Boolean = false,
|
||||
kstatConfigs: Set<String> = emptySet(),
|
||||
@@ -71,9 +69,6 @@ object ScriptGenerator {
|
||||
// 设置日志启用状态
|
||||
generateLogSettingSection(enableLog)
|
||||
|
||||
// 设置路径
|
||||
generatePathSettingSection(androidDataPath, sdcardPath)
|
||||
|
||||
// 添加SUS路径
|
||||
generateSusPathsSection(susPaths)
|
||||
|
||||
@@ -98,27 +93,6 @@ object ScriptGenerator {
|
||||
appendLine()
|
||||
}
|
||||
|
||||
private fun StringBuilder.generatePathSettingSection(
|
||||
androidDataPath: String,
|
||||
sdcardPath: String
|
||||
) {
|
||||
// 设置Android Data路径
|
||||
if (androidDataPath != DEFAULT_ANDROID_DATA_PATH) {
|
||||
appendLine("# 设置Android Data路径")
|
||||
appendLine("\"${'$'}SUSFS_BIN\" set_android_data_root_path '$androidDataPath'")
|
||||
appendLine("echo \"$(get_current_time): Android Data路径设置为: $androidDataPath\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
|
||||
// 设置SD卡路径
|
||||
if (sdcardPath != DEFAULT_SDCARD_PATH) {
|
||||
appendLine("# 设置SD卡路径")
|
||||
appendLine("\"${'$'}SUSFS_BIN\" set_sdcard_root_path '$sdcardPath'")
|
||||
appendLine("echo \"$(get_current_time): SD卡路径设置为: $sdcardPath\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine()
|
||||
}
|
||||
}
|
||||
|
||||
private fun StringBuilder.generateSusPathsSection(susPaths: Set<String>) {
|
||||
if (susPaths.isNotEmpty()) {
|
||||
appendLine("# 添加SUS路径")
|
||||
@@ -276,12 +250,15 @@ object ScriptGenerator {
|
||||
targetPath: String,
|
||||
unameValue: String,
|
||||
buildTimeValue: String,
|
||||
executeInPostFsData: Boolean = false
|
||||
executeInPostFsData: Boolean = false,
|
||||
androidDataPath: String = DEFAULT_ANDROID_DATA_PATH,
|
||||
sdcardPath: String = DEFAULT_SDCARD_PATH
|
||||
): String {
|
||||
return buildString {
|
||||
appendLine("#!/system/bin/sh")
|
||||
appendLine("# SuSFS Post-FS-Data Script")
|
||||
appendLine("# 在文件系统挂载后但在系统完全启动前执行")
|
||||
appendLine("# 优先级最高的配置项")
|
||||
appendLine()
|
||||
appendLine(generateLogSetup("susfs_post_fs_data.log"))
|
||||
appendLine()
|
||||
@@ -290,6 +267,18 @@ object ScriptGenerator {
|
||||
appendLine("echo \"$(get_current_time): Post-FS-Data脚本开始执行\" >> \"${'$'}LOG_FILE\"")
|
||||
appendLine()
|
||||
|
||||
// 路径设置
|
||||
appendLine("# 设置路径配置(优先级最高)")
|
||||
appendLine("# 设置Android Data路径")
|
||||
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()
|
||||
|
||||
// 设置uname和构建时间 - 只有在选择在post-fs-data中执行时才执行
|
||||
if (executeInPostFsData && (unameValue != DEFAULT_UNAME || buildTimeValue != DEFAULT_BUILD_TIME)) {
|
||||
appendLine("# 设置uname和构建时间")
|
||||
|
||||
Reference in New Issue
Block a user