mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
fix(loading): show the arm64 Steam client's update progress in every language (#2651)
* fix(loading): show the arm64 Steam client's update progress in every language The arm64 bootstrapper writes its progress straight into session.log in the client's language and with thousands separators, e.g. "正在下载更新 (已下载 184,557,共 573,070 KB)" or "Downloading update (184,557 of 573,070 KB)". UPDATE_PROGRESS only matched the forwarded x86-64 form without separators, so the loading screen stayed on "Waiting for Steam's first frame" with no percentage for the whole ~570 MB first update. Users took that for a hang and cancelled; after two starts the installer's repair wiped the partial download, so it started over each time. Accept separators, and fall back to the bootstrapper's language-independent "Set percent complete: N" line. * chore: drop the added comment * fix(loading): a zero or post-extract percent line no longer reads as a download * fix(loading): an unknown percent ends the earlier download percent * fix(session): ignore out-of-range percents and clear a percent after an unknown one --------- Co-authored-by: guohaomin1995-dev <321670510+guohaomin1995-dev@users.noreply.github.com> Co-authored-by: maxjivi05 <maxjividen@gmail.com>
This commit is contained in:
2 files changed
+102
-7
No files matched your search
@@ -67,6 +67,8 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
|
||||
|
||||
private class Line(val line: String, val percent: Int, val topic: Topic, val readable: Boolean)
|
||||
|
||||
private var scriptStep: Line? = null
|
||||
|
||||
private fun read(context: Context, log: File?): Line? {
|
||||
if (log == null || !log.isFile) return null
|
||||
val text = try {
|
||||
@@ -89,6 +91,7 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
|
||||
var clientDownloadAt = -1
|
||||
var clientDownload: String? = null
|
||||
var clientPercent = -1
|
||||
var unknownAt = -1
|
||||
var offset = 0
|
||||
for (line in text.split('\n')) {
|
||||
val at = offset
|
||||
@@ -103,16 +106,34 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
|
||||
}
|
||||
} else {
|
||||
val m = UPDATE_PROGRESS.find(line)
|
||||
val p = if (m == null && steam) UPDATE_PERCENT.find(line) else null
|
||||
if (m != null) {
|
||||
downloadAt = at
|
||||
val done = m.groupValues[1].toLong()
|
||||
val total = maxOf(1L, m.groupValues[2].toLong())
|
||||
val done = m.groupValues[1].replace(",", "").toLong()
|
||||
val total = maxOf(1L, m.groupValues[2].replace(",", "").toLong())
|
||||
downloadPercent = (done * 100 / total).toInt()
|
||||
} else if (p != null) {
|
||||
val percent = p.groupValues[1].toIntOrNull() ?: continue
|
||||
if (percent < 0) {
|
||||
downloadAt = -1
|
||||
unknownAt = at
|
||||
} else if (percent > 0 && applyingAt <= stepAt) {
|
||||
downloadAt = at
|
||||
downloadPercent = percent.coerceAtMost(100)
|
||||
}
|
||||
} else if (steam && UPDATE_APPLYING.matches(line)) {
|
||||
applyingAt = at
|
||||
}
|
||||
}
|
||||
}
|
||||
val stepLine = when {
|
||||
clientDownloadAt == stepAt && clientDownload != null -> Line(
|
||||
context.getString(com.droiddeck.launcher.R.string.loadstate_steam_client, clientDownload), clientPercent,
|
||||
Topic.STEAM, readable = true,
|
||||
)
|
||||
stepText != null -> Line(stepText, -1, topicOf(stepText, steam), readableScriptStep(stepText))
|
||||
else -> null
|
||||
}?.also { scriptStep = it }
|
||||
return when {
|
||||
applyingAt > stepAt && applyingAt > downloadAt -> Line(
|
||||
context.getString(com.droiddeck.launcher.R.string.loadstate_steam_update_applying), -1,
|
||||
@@ -122,11 +143,10 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
|
||||
context.getString(com.droiddeck.launcher.R.string.loadstate_steam_update, downloadPercent), downloadPercent,
|
||||
Topic.STEAM, readable = true,
|
||||
)
|
||||
clientDownloadAt == stepAt && clientDownload != null -> Line(
|
||||
context.getString(com.droiddeck.launcher.R.string.loadstate_steam_client, clientDownload), clientPercent,
|
||||
Topic.STEAM, readable = true,
|
||||
stepLine != null -> stepLine
|
||||
unknownAt >= 0 -> scriptStep ?: Line(
|
||||
context.getString(com.droiddeck.launcher.R.string.loadstate_starting), -1, Topic.SESSION, readable = false,
|
||||
)
|
||||
stepText != null -> Line(stepText, -1, topicOf(stepText, steam), readableScriptStep(stepText))
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -166,7 +186,8 @@ class LoadingState(context: Context, private val steam: Boolean = true) {
|
||||
}
|
||||
|
||||
private const val TAIL_BYTES = 48L * 1024
|
||||
private val UPDATE_PROGRESS = Regex("""Downloading update \((\d+) of (\d+) KB\)""")
|
||||
private val UPDATE_PROGRESS = Regex("""Downloading update \(([\d,]+) of ([\d,]+) KB\)""")
|
||||
private val UPDATE_PERCENT = Regex("""^\[[^\]]+\] Set percent complete: (-?\d+)\s*$""")
|
||||
private val UPDATE_APPLYING = Regex("""^\s*(?:\[[^\]]+\]\s*)*(?:Extracting package|Installing update)\.\.\.\s*$""")
|
||||
private val INSTALL_COUNT = Regex("""downloading Steam: (\S+) \((\d+)/(\d+)\)""")
|
||||
private val INSTALL_MEGABYTES = Regex("""^, (\d+) of (\d+) MB""")
|
||||
|
||||
Reference in new issue
Block a user