Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75d79fc14d |
No files matched your search
@@ -1038,14 +1038,18 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onHandled()
|
||||
return
|
||||
}
|
||||
val files = game.gameFiles
|
||||
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
|
||||
val files = game.gameFiles?.takeIf { game.source == com.droiddeck.launcher.stores.Store.XBOX.id }
|
||||
val steamClient = Library.fromSteamClient(game)
|
||||
if (files == null && !steamClient) {
|
||||
if (startGame(game, returnHome, onHandled, request)) onSettled()
|
||||
else launchCoordinator.releaseHandling(request)
|
||||
return
|
||||
}
|
||||
val app = applicationContext
|
||||
Thread({
|
||||
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
||||
val refused = files != null && com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
||||
val uncached = steamClient && !com.droiddeck.launcher.session.NoSteamLaunch.enabled(app, game) &&
|
||||
com.droiddeck.launcher.session.OfflineMode.lacksAppInfo(app, game.appId)
|
||||
ui.post {
|
||||
when {
|
||||
!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed -> {
|
||||
@@ -1057,11 +1061,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
|
||||
onSettled()
|
||||
}
|
||||
startGame(game, returnHome, onHandled, request) -> onSettled()
|
||||
else -> launchCoordinator.releaseHandling(request)
|
||||
else -> {
|
||||
if (uncached) android.widget.Toast.makeText(this, getString(R.string.game_steam_offline_uncached, game.name), android.widget.Toast.LENGTH_LONG).show()
|
||||
if (startGame(game, returnHome, onHandled, request)) onSettled()
|
||||
else launchCoordinator.releaseHandling(request)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "xbox-app-model").start()
|
||||
}, "game-launch-check").start()
|
||||
}
|
||||
|
||||
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit, ticket: LaunchTicket): Boolean {
|
||||
|
||||
@@ -80,20 +80,38 @@ object SteamAppInfo {
|
||||
|
||||
private fun JSONArray?.strings(): List<String> = if (this == null) emptyList() else (0 until length()).map { optString(it) }
|
||||
|
||||
internal fun read(file: File, appId: Int): Info? {
|
||||
if (!file.isFile) return null
|
||||
internal fun read(file: File, appId: Int): Info? = scan(file, appId, unreadable = null, missing = null) { raf, entry ->
|
||||
if (entry.size > 64L * 1024 * 1024) return@scan null
|
||||
val body = ByteArray(entry.size.toInt())
|
||||
raf.readFully(body)
|
||||
val strings = entry.tableAt?.let { readStrings(raf, it) }
|
||||
val kv = ByteBuffer.wrap(body, entry.fixed, body.size - entry.fixed).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val tree = readMap(kv, strings)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
|
||||
infoOf(app)
|
||||
}
|
||||
|
||||
fun cached(file: File, appId: Int): Boolean? =
|
||||
runCatching { scan(file, appId, unreadable = null, missing = false) { _, _ -> true } }
|
||||
.onFailure { Log.w(TAG, "appinfo: ${it.javaClass.simpleName}") }
|
||||
.getOrNull()
|
||||
|
||||
private class Entry(val fixed: Int, val tableAt: Long?, val size: Long)
|
||||
|
||||
private fun <T> scan(file: File, appId: Int, unreadable: T, missing: T, found: (RandomAccessFile, Entry) -> T): T {
|
||||
if (!file.isFile) return unreadable
|
||||
RandomAccessFile(file, "r").use { raf ->
|
||||
val head = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
|
||||
raf.readFully(head.array(), 0, 8)
|
||||
val magic = head.getInt(0)
|
||||
val version = magic and 0xFF
|
||||
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return null
|
||||
var strings: List<String>? = null
|
||||
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return unreadable
|
||||
var tableAt: Long? = null
|
||||
var pos = 8L
|
||||
if (version >= 0x29) {
|
||||
raf.readFully(head.array(), 8, 8)
|
||||
val tableAt = head.getLong(8)
|
||||
strings = readStrings(raf, tableAt)
|
||||
tableAt = head.getLong(8)
|
||||
pos = 16L
|
||||
}
|
||||
val fixed = if (version >= 0x28) 4 + 4 + 8 + 20 + 4 + 20 else 4 + 4 + 8 + 20 + 4
|
||||
@@ -103,20 +121,11 @@ object SteamAppInfo {
|
||||
raf.readFully(entry.array(), 0, 8)
|
||||
val id = entry.getInt(0)
|
||||
val size = entry.getInt(4).toLong() and 0xFFFFFFFFL
|
||||
if (id == 0) return null
|
||||
if (id == appId) {
|
||||
if (size > 64L * 1024 * 1024) return null
|
||||
val body = ByteArray(size.toInt())
|
||||
raf.readFully(body)
|
||||
val kv = ByteBuffer.wrap(body, fixed, body.size - fixed).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val tree = readMap(kv, strings)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
|
||||
return infoOf(app)
|
||||
}
|
||||
if (id == 0) return missing
|
||||
if (id == appId) return found(raf, Entry(fixed, tableAt, size))
|
||||
pos += 8 + size
|
||||
}
|
||||
return null
|
||||
return missing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.session
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.agent.AgentGuest
|
||||
import com.droiddeck.launcher.frontend.SteamAppInfo
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import java.io.File
|
||||
|
||||
@@ -63,6 +64,9 @@ object OfflineMode {
|
||||
fun active(context: Context): Boolean =
|
||||
offline(enabled(context), isOnline(context), auto(context))
|
||||
|
||||
fun lacksAppInfo(context: Context, appId: Int): Boolean =
|
||||
active(context) && SteamAppInfo.cached(SteamAppInfo.appinfoFile(context), appId) == false
|
||||
|
||||
@Synchronized
|
||||
fun setEnabled(context: Context, on: Boolean) {
|
||||
write(context, LinuxRuntime.rootDir(context), on)
|
||||
|
||||
@@ -4310,4 +4310,5 @@
|
||||
<string name="steam_store_linux_build">تثبّت هذه اللعبة إصدار Linux الخاص بها. ثبّتها من Steam.</string>
|
||||
<string name="game_zoom_title">تكبير اللعبة</string>
|
||||
<string name="game_zoom_hint">اضبط تكبير اللعبة من 100% إلى 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam في وضع عدم الاتصال ولم يحمّل %1$s بعد. اتصل بالإنترنت في Steam مرة واحدة لتشغيلها.</string>
|
||||
</resources>
|
||||
@@ -4188,4 +4188,5 @@
|
||||
<string name="steam_store_close_steam">Cierra Steam primero</string>
|
||||
<string name="steam_store_session_wait">Pausa primero la descarga de Steam</string>
|
||||
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
|
||||
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y todavía no cargó %1$s. Conéctate en Steam una vez para jugarlo.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Тази игра инсталира версията си за Linux. Инсталирайте я от Steam.</string>
|
||||
<string name="game_zoom_title">Мащабиране на играта</string>
|
||||
<string name="game_zoom_hint">Регулирайте увеличението на играта от 100% до 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam е в офлайн режим и още не е заредил %1$s. Свържете Steam онлайн веднъж, за да я играете.</string>
|
||||
</resources>
|
||||
@@ -4230,4 +4230,5 @@
|
||||
<string name="steam_store_linux_build">Tato hra instaluje svou verzi pro Linux. Nainstalujte ji ze Steamu.</string>
|
||||
<string name="game_zoom_title">Přiblížení hry</string>
|
||||
<string name="game_zoom_hint">Nastavte zvětšení hry od 100 % do 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam je v režimu offline a %1$s ještě nenačetl. Jednou se ve Steamu připojte online, abyste ji mohli hrát.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Dette spil installerer sin Linux-version. Installer det fra Steam.</string>
|
||||
<string name="game_zoom_title">Spilzoom</string>
|
||||
<string name="game_zoom_hint">Juster spillets forstørrelse fra 100 % til 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam er i offlinetilstand og har ikke indlæst %1$s endnu. Gå online i Steam én gang for at spille det.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Dieses Spiel installiert seine Linux-Version. Installiere es über Steam.</string>
|
||||
<string name="game_zoom_title">Spielzoom</string>
|
||||
<string name="game_zoom_hint">Spielvergrößerung von 100 % bis 300 % anpassen</string>
|
||||
<string name="game_steam_offline_uncached">Steam ist im Offlinemodus und hat %1$s noch nicht geladen. Gehe einmal in Steam online, um es zu spielen.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Αυτό το παιχνίδι εγκαθιστά την έκδοσή του για Linux. Εγκαταστήστε το από το Steam.</string>
|
||||
<string name="game_zoom_title">Ζουμ παιχνιδιού</string>
|
||||
<string name="game_zoom_hint">Ρυθμίστε τη μεγέθυνση του παιχνιδιού από 100% έως 300%</string>
|
||||
<string name="game_steam_offline_uncached">Το Steam είναι σε λειτουργία εκτός σύνδεσης και δεν έχει φορτώσει ακόμη το %1$s. Συνδεθείτε μία φορά στο Steam για να το παίξετε.</string>
|
||||
</resources>
|
||||
@@ -4190,4 +4190,5 @@
|
||||
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
|
||||
<string name="game_zoom_title">Zoom del juego</string>
|
||||
<string name="game_zoom_hint">Ajusta la ampliación del juego del 100 % al 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y aún no ha cargado %1$s. Conéctate en Steam una vez para jugarlo.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Tämä peli asentaa Linux-versionsa. Asenna se Steamista.</string>
|
||||
<string name="game_zoom_title">Pelin zoomaus</string>
|
||||
<string name="game_zoom_hint">Säädä pelin suurennusta välillä 100–300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam on offline-tilassa eikä ole vielä ladannut peliä %1$s. Siirry Steamissa kerran online-tilaan pelataksesi sitä.</string>
|
||||
</resources>
|
||||
@@ -4189,4 +4189,5 @@
|
||||
<string name="steam_store_linux_build">Ce jeu installe sa version Linux. Installez-le depuis Steam.</string>
|
||||
<string name="game_zoom_title">Zoom du jeu</string>
|
||||
<string name="game_zoom_hint">Réglez le grossissement du jeu de 100 % à 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam est en mode hors ligne et n\'a pas encore chargé %1$s. Passez en ligne une fois dans Steam pour y jouer.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">यह गेम अपना Linux संस्करण इंस्टॉल करता है। इसे Steam से इंस्टॉल करें।</string>
|
||||
<string name="game_zoom_title">गेम ज़ूम</string>
|
||||
<string name="game_zoom_hint">गेम का ज़ूम 100% से 300% तक समायोजित करें</string>
|
||||
<string name="game_steam_offline_uncached">Steam ऑफ़लाइन मोड में है और उसने अभी तक %1$s लोड नहीं किया है। इसे खेलने के लिए Steam में एक बार ऑनलाइन जाएँ।</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Ez a játék a Linux-verzióját telepíti. Telepítsd a Steamből.</string>
|
||||
<string name="game_zoom_title">Játék nagyítása</string>
|
||||
<string name="game_zoom_hint">A játék nagyításának beállítása 100% és 300% között</string>
|
||||
<string name="game_steam_offline_uncached">A Steam offline módban van, és még nem töltötte be ezt: %1$s. A játékhoz egyszer lépj online módba a Steamben.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">Game ini memasang versi Linux-nya. Pasang dari Steam.</string>
|
||||
<string name="game_zoom_title">Zoom game</string>
|
||||
<string name="game_zoom_hint">Sesuaikan pembesaran game dari 100% hingga 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam dalam mode luring dan belum memuat %1$s. Hubungkan Steam secara daring sekali untuk memainkannya.</string>
|
||||
</resources>
|
||||
@@ -4189,4 +4189,5 @@
|
||||
<string name="steam_store_linux_build">Questo gioco installa la sua versione Linux. Installalo da Steam.</string>
|
||||
<string name="game_zoom_title">Zoom del gioco</string>
|
||||
<string name="game_zoom_hint">Regola l\'ingrandimento del gioco dal 100% al 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam è in modalità offline e non ha ancora caricato %1$s. Vai online in Steam una volta per giocarci.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">このゲームは Linux 版をインストールします。Steam からインストールしてください。</string>
|
||||
<string name="game_zoom_title">ゲームズーム</string>
|
||||
<string name="game_zoom_hint">ゲームの拡大率を100%から300%の間で調整します</string>
|
||||
<string name="game_steam_offline_uncached">Steam はオフラインモードのため、%1$s をまだ読み込んでいません。プレイするには Steam で一度オンラインにしてください。</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">이 게임은 Linux 버전을 설치합니다. Steam에서 설치하세요.</string>
|
||||
<string name="game_zoom_title">게임 확대</string>
|
||||
<string name="game_zoom_hint">게임 확대율을 100%에서 300%까지 조정합니다</string>
|
||||
<string name="game_steam_offline_uncached">Steam이 오프라인 모드이며 아직 %1$s을(를) 불러오지 않았습니다. 플레이하려면 Steam에서 한 번 온라인으로 전환하세요.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">Permainan ini memasang versi Linuxnya. Pasang daripada Steam.</string>
|
||||
<string name="game_zoom_title">Zum permainan</string>
|
||||
<string name="game_zoom_hint">Laraskan pembesaran permainan daripada 100% hingga 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam dalam mod luar talian dan belum memuatkan %1$s. Pergi dalam talian dalam Steam sekali untuk memainkannya.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Dette spillet installerer Linux-versjonen sin. Installer det fra Steam.</string>
|
||||
<string name="game_zoom_title">Spillzoom</string>
|
||||
<string name="game_zoom_hint">Juster spillforstørrelsen fra 100 % til 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam er i frakoblet modus og har ikke lastet inn %1$s ennå. Gå tilkoblet i Steam én gang for å spille det.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Deze game installeert zijn Linux-versie. Installeer hem via Steam.</string>
|
||||
<string name="game_zoom_title">Gamezoom</string>
|
||||
<string name="game_zoom_hint">Pas de spelvergroting aan van 100% tot 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam staat in offlinemodus en heeft %1$s nog niet geladen. Ga één keer online in Steam om het te spelen.</string>
|
||||
</resources>
|
||||
@@ -4230,4 +4230,5 @@
|
||||
<string name="steam_store_linux_build">Ta gra instaluje swoją wersję dla Linuksa. Zainstaluj ją ze Steama.</string>
|
||||
<string name="game_zoom_title">Powiększenie gry</string>
|
||||
<string name="game_zoom_hint">Dostosuj powiększenie gry w zakresie od 100% do 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam jest w trybie offline i nie wczytał jeszcze %1$s. Przejdź raz do trybu online w Steamie, aby w to zagrać.</string>
|
||||
</resources>
|
||||
@@ -4189,4 +4189,5 @@
|
||||
<string name="steam_store_linux_build">Este jogo instala a sua versão para Linux. Instale-o a partir do Steam.</string>
|
||||
<string name="game_zoom_title">Zoom do jogo</string>
|
||||
<string name="game_zoom_hint">Ajuste a ampliação do jogo de 100% a 300%</string>
|
||||
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
|
||||
</resources>
|
||||
@@ -4197,4 +4197,5 @@
|
||||
<string name="steam_store_close_steam">Feche o Steam primeiro</string>
|
||||
<string name="steam_store_session_wait">Pause o download do Steam primeiro</string>
|
||||
<string name="steam_store_linux_build">Este jogo instala sua versão para Linux. Instale-o pelo Steam.</string>
|
||||
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
|
||||
</resources>
|
||||
@@ -4190,4 +4190,5 @@
|
||||
<string name="steam_store_linux_build">Acest joc își instalează versiunea pentru Linux. Instalează-l din Steam.</string>
|
||||
<string name="game_zoom_title">Zoom joc</string>
|
||||
<string name="game_zoom_hint">Reglați mărirea jocului între 100% și 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam este în modul offline și nu a încărcat încă %1$s. Treci o dată online în Steam ca să îl joci.</string>
|
||||
</resources>
|
||||
@@ -4231,4 +4231,5 @@
|
||||
<string name="steam_store_linux_build">Эта игра устанавливает свою версию для Linux. Установите её из Steam.</string>
|
||||
<string name="game_zoom_title">Масштаб игры</string>
|
||||
<string name="game_zoom_hint">Настройте увеличение игры от 100% до 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam в автономном режиме и ещё не загрузил %1$s. Чтобы играть, один раз переведите Steam в сеть.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Det här spelet installerar sin Linux-version. Installera det från Steam.</string>
|
||||
<string name="game_zoom_title">Spelzoom</string>
|
||||
<string name="game_zoom_hint">Justera spelförstoringen från 100 % till 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam är i offlineläge och har inte läst in %1$s än. Gå online i Steam en gång för att spela det.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">เกมนี้ติดตั้งเวอร์ชัน Linux ของตัวเอง ให้ติดตั้งจาก Steam</string>
|
||||
<string name="game_zoom_title">ซูมเกม</string>
|
||||
<string name="game_zoom_hint">ปรับการขยายเกมตั้งแต่ 100% ถึง 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam อยู่ในโหมดออฟไลน์และยังไม่ได้โหลด %1$s ออนไลน์ใน Steam หนึ่งครั้งเพื่อเล่นเกมนี้</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Bu oyun Linux sürümünü yükler. Steam\'den yükleyin.</string>
|
||||
<string name="game_zoom_title">Oyun yakınlaştırma</string>
|
||||
<string name="game_zoom_hint">Oyun yakınlaştırmasını %100 ile %300 arasında ayarlayın</string>
|
||||
<string name="game_steam_offline_uncached">Steam çevrimdışı modda ve %1$s henüz yüklenmedi. Oynamak için Steam\'de bir kez çevrimiçi olun.</string>
|
||||
</resources>
|
||||
@@ -4230,4 +4230,5 @@
|
||||
<string name="steam_store_linux_build">Ця гра встановлює свою версію для Linux. Установіть її зі Steam.</string>
|
||||
<string name="game_zoom_title">Масштаб гри</string>
|
||||
<string name="game_zoom_hint">Налаштуйте збільшення гри від 100% до 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam в офлайн-режимі й ще не завантажив %1$s. Щоб грати, один раз перейдіть у Steam онлайн.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">Trò chơi này cài bản dành cho Linux. Hãy cài từ Steam.</string>
|
||||
<string name="game_zoom_title">Thu phóng trò chơi</string>
|
||||
<string name="game_zoom_hint">Điều chỉnh độ phóng đại trò chơi từ 100% đến 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam đang ở chế độ ngoại tuyến và chưa tải %1$s. Hãy trực tuyến trong Steam một lần để chơi.</string>
|
||||
</resources>
|
||||
@@ -4118,4 +4118,5 @@
|
||||
<string name="steam_store_close_steam">请先关闭 Steam</string>
|
||||
<string name="steam_store_session_wait">请先暂停 Steam 下载</string>
|
||||
<string name="steam_store_linux_build">此游戏会安装其 Linux 版本。请通过 Steam 安装。</string>
|
||||
<string name="game_steam_offline_uncached">Steam 处于离线模式,尚未加载 %1$s。请在 Steam 中联网一次后再玩。</string>
|
||||
</resources>
|
||||
@@ -4118,4 +4118,5 @@
|
||||
<string name="steam_store_close_steam">請先關閉 Steam</string>
|
||||
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
|
||||
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
|
||||
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
|
||||
</resources>
|
||||
@@ -4118,4 +4118,5 @@
|
||||
<string name="steam_store_close_steam">請先關閉 Steam</string>
|
||||
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
|
||||
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
|
||||
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
|
||||
</resources>
|
||||
@@ -1755,6 +1755,7 @@
|
||||
<string name="game_link_session_busy">Stop the current session before launching a Steam game.</string>
|
||||
<string name="game_link_failed">Could not send the game to Steam. Try launching it again.</string>
|
||||
<string name="game_needs_app_model">%1$s is a UWP app. This runtime has no Windows app-model host to start it.</string>
|
||||
<string name="game_steam_offline_uncached">Steam is in offline mode and has not loaded %1$s yet. Go online in Steam once to play it.</string>
|
||||
<string name="setup_retry_removal">Retry removal</string>
|
||||
<string name="runtime_removing">Removing</string>
|
||||
<string name="runtime_removal_incomplete">Removal incomplete</string>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.droiddeck.launcher.frontend
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
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 SteamAppInfoTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun file() = File(tmp.newFolder(), "appinfo.vdf")
|
||||
|
||||
private fun le(size: Int) = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
private fun writeV28(file: File, appId: Int, name: String) {
|
||||
val kv = ByteArrayOutputStream().apply {
|
||||
fun cstring(s: String) { write(s.toByteArray()); write(0) }
|
||||
write(0x00); cstring("appinfo")
|
||||
write(0x00); cstring("common")
|
||||
write(0x01); cstring("name"); cstring(name)
|
||||
write(0x08); write(0x08); write(0x08)
|
||||
}.toByteArray()
|
||||
val body = ByteArray(60) + kv
|
||||
val out = le(8 + 8 + body.size + 4).putInt(0x07564428).putInt(1).putInt(appId).putInt(body.size).put(body).putInt(0)
|
||||
file.writeBytes(out.array())
|
||||
}
|
||||
|
||||
@Test fun anAppInTheClientsCacheIsToldApartFromOneMissingFromIt() {
|
||||
val file = file()
|
||||
WinCompSourcesTest.writeAppinfo(file, 17470)
|
||||
assertEquals(true, SteamAppInfo.cached(file, 17470))
|
||||
assertEquals(false, SteamAppInfo.cached(file, 1145360))
|
||||
}
|
||||
|
||||
@Test fun theOlderFormatWithoutAStringTableIsReadToo() {
|
||||
val file = file()
|
||||
writeV28(file, 17470, "Some Game")
|
||||
assertTrue(SteamAppInfo.cached(file, 17470)!!)
|
||||
assertFalse(SteamAppInfo.cached(file, 22330)!!)
|
||||
assertEquals("Some Game", SteamAppInfo.read(file, 17470)!!.name)
|
||||
assertNull(SteamAppInfo.read(file, 22330))
|
||||
}
|
||||
|
||||
@Test fun aMissingOrUnknownCacheIsNotTakenAsMissingTheApp() {
|
||||
val missing = file()
|
||||
assertNull(SteamAppInfo.cached(missing, 17470))
|
||||
val newer = file().apply { writeBytes(le(16).putInt(0x0756442A).putInt(1).array()) }
|
||||
assertNull(SteamAppInfo.cached(newer, 17470))
|
||||
val garbage = file().apply { writeBytes(byteArrayOf(1, 2, 3)) }
|
||||
assertNull(SteamAppInfo.cached(garbage, 17470))
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,32 @@ class OfflineModeTest {
|
||||
shadowOf(cm).setNetworkCapabilities(cm.activeNetwork, caps)
|
||||
}
|
||||
|
||||
private fun clientCache(appId: Int) =
|
||||
com.droiddeck.launcher.frontend.WinCompSourcesTest.writeAppinfo(com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context), appId)
|
||||
|
||||
@Test
|
||||
fun offlineSteamReportsAGameMissingFromItsCache() {
|
||||
writeSteam("1")
|
||||
clientCache(220)
|
||||
assertTrue(OfflineMode.active(context))
|
||||
assertTrue(OfflineMode.lacksAppInfo(context, 17470))
|
||||
assertFalse(OfflineMode.lacksAppInfo(context, 220))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlineSteamNeverReportsAMissingGame() {
|
||||
clientCache(220)
|
||||
assertFalse(OfflineMode.active(context))
|
||||
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun offlineSteamWithoutAReadableCacheReportsNothing() {
|
||||
writeSteam("1")
|
||||
com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context).delete()
|
||||
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun offlineWhenChosenOrWithoutInternet() {
|
||||
assertFalse(OfflineMode.offline(manual = false, online = true))
|
||||
|
||||
Reference in new issue
Block a user