From df146d011f8c788c078deb9a0fe0f63555cc8af1 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sun, 18 Oct 2026 19:11:30 -0400 Subject: [PATCH] fix: keep hidden and private Steam games off the Steam home art wall (#1097) --- .../droiddeck/launcher/frontend/Library.kt | 27 ++++++++++- .../frontend/LibraryConcealedAppsTest.kt | 46 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/frontend/LibraryConcealedAppsTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt index 8fbb19b7cb..743fea5d9e 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -72,6 +72,7 @@ object Library { private val NAME = Regex("^\\s*\"name\"\\s*\"([^\"]*)\"", RegexOption.MULTILINE) private val STATE = Regex("^\\s*\"StateFlags\"\\s*\"(\\d+)\"", RegexOption.MULTILINE) private val LAST_PLAYED = Regex("^\\s*\"LastPlayed\"\\s*\"(\\d+)\"", RegexOption.MULTILINE) + private val PRIVATE_APPS = Regex("\"PrivateApps_\\d+\"\\s*\"\\[([^\\]]*)\\]\"") private val INSTALL_DIR = Regex("^\\s*\"installdir\"\\s*\"([^\"]*)\"", RegexOption.MULTILINE) internal fun steamLibraries(context: Context, arch: String = SessionPrefs.activeSteamClientArch(context)): List> { @@ -137,13 +138,35 @@ object Library { } fun steamLibraryArt(context: Context): List> { - val cache = File(SessionPrefs.activeSteamRoot(context), "appcache/librarycache") + val root = SessionPrefs.activeSteamRoot(context) + val cache = File(root, "appcache/librarycache") + val concealed = concealedSteamApps(root) return cache.listFiles().orEmpty().mapNotNull { dir -> - val appId = dir.name.toIntOrNull()?.takeIf { it !in NOT_GAMES } ?: return@mapNotNull null + val appId = dir.name.toIntOrNull()?.takeIf { it !in NOT_GAMES && it.toLong() !in concealed } ?: return@mapNotNull null steamCacheImage(cache, appId, STEAM_CAPSULES)?.let { appId to it } } } + /** Apps the user hid (the "hidden" collection) or marked private in Steam. */ + internal fun concealedSteamApps(root: File): Set { + val config = AddedGames.accountConfig(root) ?: return emptySet() + val hidden = runCatching { + val entries = org.json.JSONArray(File(config, "cloudstorage/cloud-storage-namespace-1.json").readText()) + val entry = (0 until entries.length()).map { entries.getJSONArray(it) } + .firstOrNull { it.optString(0) == "user-collections.hidden" }?.optJSONObject(1) + if (entry == null || entry.optBoolean("is_deleted")) emptySet() else { + val collection = org.json.JSONObject(entry.optString("value")) + fun ids(key: String) = collection.optJSONArray(key)?.let { a -> (0 until a.length()).map { a.optLong(it) } }.orEmpty() + ids("added").toSet() - ids("removed").toSet() + } + }.getOrDefault(emptySet()) + val private = runCatching { + PRIVATE_APPS.find(File(config, "localconfig.vdf").readText())?.groupValues?.get(1) + ?.split(',')?.mapNotNull { it.trim().toLongOrNull() }?.toSet() + }.getOrNull().orEmpty() + return hidden + private + } + fun fromSteamClient(g: SteamGame): Boolean = g.library != ADDED && g.source == SOURCE_STEAM fun launchableGames( diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/LibraryConcealedAppsTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/LibraryConcealedAppsTest.kt new file mode 100644 index 0000000000..8d00784ccd --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/frontend/LibraryConcealedAppsTest.kt @@ -0,0 +1,46 @@ +package com.droiddeck.launcher.frontend + +import java.io.File +import org.junit.Assert.assertEquals +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33]) +class LibraryConcealedAppsTest { + @get:Rule val tmp = TemporaryFolder() + + private fun steamRoot(): File = tmp.newFolder("Steam").also { root -> + File(root, "config").mkdirs() + File(root, "config/loginusers.vdf").writeText( + "\"users\"\n{\n\t\"76561198352563669\"\n\t{\n\t\t\"AccountName\"\t\t\"a\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t}\n}\n") + } + + private fun config(root: File) = File(root, "userdata/392297941/config").apply { mkdirs() } + + @Test fun hiddenCollectionAndPrivateAppsAreBothConcealed() { + val root = steamRoot() + val config = config(root) + File(config, "cloudstorage").mkdirs() + File(config, "cloudstorage/cloud-storage-namespace-1.json").writeText( + """[["user-collections.favorite",{"key":"user-collections.favorite","value":"{\"id\":\"favorite\",\"added\":[620],\"removed\":[]}"}],""" + + """["user-collections.hidden",{"key":"user-collections.hidden","value":"{\"id\":\"hidden\",\"name\":\"Hidden\",\"added\":[223470,2931908220,400],\"removed\":[400]}"}]]""") + File(config, "localconfig.vdf").writeText( + "\"UserLocalConfigStore\"\n{\n\t\"WebStorage\"\n\t{\n\t\t\"PrivateApps_392297941\"\t\t\"[339800,567090]\"\n\t}\n}\n") + assertEquals(setOf(223470L, 2931908220L, 339800L, 567090L), Library.concealedSteamApps(root)) + } + + @Test fun deletedHiddenCollectionAndMissingFilesConcealNothing() { + val root = steamRoot() + assertEquals(emptySet(), Library.concealedSteamApps(root)) + val config = config(root) + File(config, "cloudstorage").mkdirs() + File(config, "cloudstorage/cloud-storage-namespace-1.json").writeText( + """[["user-collections.hidden",{"key":"user-collections.hidden","is_deleted":true}]]""") + assertEquals(emptySet(), Library.concealedSteamApps(root)) + } +}