fix: find the signed-in Steam account when loginusers.vdf has no MostRecent

droiddeck-steam-shortcuts and AddedGames.accountConfig took the account
marked "MostRecent" in loginusers.vdf, else the only userdata folder.
The arm64 client here writes no MostRecent, so with two accounts in one
install nothing was picked: no added or store game reached
shortcuts.vdf ("no signed-in account yet; nothing written") and Steam
answered their launch with "App configuration unavailable".

Without MostRecent, take the account marked AutoLogin, then the one with
the latest timestamp. Both sides use the same order so the app reads the
config the guest script writes.
This commit is contained in:
Nikolay Nadorichev authored and MaxsTechReview committed 2026-10-24 01:42:20 -04:00
1 parent 473ac666b3
commit 8c86b718a0
4 files changed
+86 -7

No files matched your search

@@ -0,0 +1,43 @@
package com.droiddeck.launcher.frontend
import java.io.File
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
class AddedGamesAccountTest {
@get:Rule val tmp = TemporaryFolder()
private fun steamRoot(vararg blocks: Pair<Long, Map<String, String>>): File = tmp.newFolder("Steam").also { root ->
File(root, "config").mkdirs()
File(root, "userdata/123/config").mkdirs()
File(root, "userdata/456/config").mkdirs()
val body = blocks.joinToString("") { (account, keys) ->
"\t\"${76561197960265728L + account}\"\n\t{\n" + keys.entries.joinToString("") { "\t\t\"${it.key}\"\t\t\"${it.value}\"\n" } + "\t}\n"
}
File(root, "config/loginusers.vdf").writeText("\"users\"\n{\n$body}\n")
}
@Test fun theAccountMarkedMostRecentIsUsed() {
val root = steamRoot(123L to mapOf("MostRecent" to "1", "AutoLogin" to "0", "timestamp" to "100"),
456L to mapOf("MostRecent" to "0", "AutoLogin" to "1", "timestamp" to "200"))
assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root))
}
@Test fun withoutMostRecentTheAccountThatSignsInIsUsed() {
val root = steamRoot(123L to mapOf("AutoLogin" to "1", "timestamp" to "100"), 456L to mapOf("AutoLogin" to "0", "timestamp" to "200"))
assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root))
}
@Test fun withoutEitherMarkTheAccountUsedLastIsUsed() {
val root = steamRoot(456L to mapOf("AutoLogin" to "0", "timestamp" to "100"), 123L to mapOf("AutoLogin" to "0", "timestamp" to "200"))
assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root))
}
@Test fun twoAccountsWithoutAnyMarkGiveNoAccount() {
val root = steamRoot(123L to mapOf("AccountName" to "a"), 456L to mapOf("AccountName" to "b"))
assertNull(AddedGames.accountConfig(root))
}
}