diff --git a/README.md b/README.md index 76a02242b7..794e272cc2 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Compatibility and performance vary by device; hardware validation is limited. De ## Credits and licence -GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. Battle.net support is [@kayakyakr](https://github.com/kayakyakr)'s: it runs Blizzard's own Battle.net client, downloaded from Blizzard and not included, in Proton, and shows the key art from each game's [Battle.net Shop](https://shop.battle.net) page; without the Steam client its games see DroidDeck's pad as an Xbox 360 controller through `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`. The registry entries a GOG game's install script (`goggame-.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc//mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. Games render with [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's own per-render-pass choice between tile memory and system memory, while the Steam client keeps `TU_DEBUG=sysmem`; [FEX](https://github.com/FEX-Emu/FEX)'s code disk cache was checked in its source and is already on through Proton. The proot fast path picks the guest name of a host file bound under several names in the order [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later) sorts its bindings, so links and `/proc/self/fd` read back as they do through proot. The session's [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) opens its sockets with the per-socket access settings documented in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions through its `access.rules`. Wine write watches use the userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later): libblsession gives it the arm64 syscall number and answers its `PAGEMAP_SCAN` from `/proc/self/pagemap` where Android refuses the ioctl. Wine on arm64 sets a thread's full context by raising `SIGUSR2` from `syscall_dispatcher_return_slowpath` in [Wine](https://gitlab.winehq.org/wine/wine)'s `dlls/ntdll/unix/signal_arm64.c` (LGPL-2.1-or-later); libblsession runs that handler in place on a frame laid out as the [Linux](https://github.com/torvalds/linux) kernel's `arch/arm64/kernel/signal.c` builds it and returns through `rt_sigreturn`, so proot does not stop the thread for it. Wine's process list reads each process's memory counters from `/proc//status` in `fill_vm_counters` ([Wine](https://gitlab.winehq.org/wine/wine) `dlls/ntdll/unix/process.c`, LGPL-2.1-or-later), so libblsession gives those reads the kernel's file instead of a copy with `TracerPid` cleared. droiddeck-ntsync is checked against the object, wait and error semantics documented for the [Linux](https://github.com/torvalds/linux) ntsync driver in `Documentation/userspace-api/ntsync.rst` (GPL-2.0). Xbox games load the Windows modules of [@domsvoboda](https://github.com/domsvoboda)'s [xodus-nexus](https://github.com/domsvoboda/xodus-nexus) runtime (LGPL-2.1-or-later), including its `wintypes.dll`, whose `ApiInformation` answer Minecraft for Windows needs to start; how Minecraft installs GameInput under Wine was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT). See [LICENSE](LICENSE). Steam and Proton belong to Valve Corporation; this project is not affiliated with Valve. +GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. Battle.net support is [@kayakyakr](https://github.com/kayakyakr)'s: it runs Blizzard's own Battle.net client, downloaded from Blizzard and not included, in Proton, and shows the key art from each game's [Battle.net Shop](https://shop.battle.net) page; without the Steam client its games see DroidDeck's pad as an Xbox 360 controller through `PROTON_SPOOF_STEAMINPUT_VIDPID` in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/winebus.sys`. Its games install from Stores through Blizzard's own Agent and the local HTTP API it serves, driven the way [@barncastle](https://github.com/barncastle)'s [Battle.Net-Installer](https://github.com/barncastle/Battle.Net-Installer) drives it, with the requests described on [wowdev.wiki](https://wowdev.wiki/Agent); how other launchers find, install and start Blizzard games was read in [@mubaraknumann](https://github.com/mubaraknumann)'s [unifideck](https://github.com/mubaraknumann/unifideck), [@djmittens](https://github.com/djmittens)'s [neo-mittens](https://github.com/djmittens/neo-mittens) `bnetswitch`, [@BCD1210](https://github.com/BCD1210)'s [soju](https://github.com/BCD1210/soju) and [Lutris](https://github.com/lutris/lutris)'s `product.db` reader, without taking their code. The registry entries a GOG game's install script (`goggame-.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc//mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. Games render with [Mesa](https://gitlab.freedesktop.org/mesa/mesa) Turnip's own per-render-pass choice between tile memory and system memory, while the Steam client keeps `TU_DEBUG=sysmem`; [FEX](https://github.com/FEX-Emu/FEX)'s code disk cache was checked in its source and is already on through Proton. The proot fast path picks the guest name of a host file bound under several names in the order [PRoot](https://github.com/proot-me/proot)'s `path/binding.c` (GPL-2.0-or-later) sorts its bindings, so links and `/proc/self/fd` read back as they do through proot. The session's [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) opens its sockets with the per-socket access settings documented in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions through its `access.rules`. Wine write watches use the userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later): libblsession gives it the arm64 syscall number and answers its `PAGEMAP_SCAN` from `/proc/self/pagemap` where Android refuses the ioctl. Wine on arm64 sets a thread's full context by raising `SIGUSR2` from `syscall_dispatcher_return_slowpath` in [Wine](https://gitlab.winehq.org/wine/wine)'s `dlls/ntdll/unix/signal_arm64.c` (LGPL-2.1-or-later); libblsession runs that handler in place on a frame laid out as the [Linux](https://github.com/torvalds/linux) kernel's `arch/arm64/kernel/signal.c` builds it and returns through `rt_sigreturn`, so proot does not stop the thread for it. Wine's process list reads each process's memory counters from `/proc//status` in `fill_vm_counters` ([Wine](https://gitlab.winehq.org/wine/wine) `dlls/ntdll/unix/process.c`, LGPL-2.1-or-later), so libblsession gives those reads the kernel's file instead of a copy with `TracerPid` cleared. droiddeck-ntsync is checked against the object, wait and error semantics documented for the [Linux](https://github.com/torvalds/linux) ntsync driver in `Documentation/userspace-api/ntsync.rst` (GPL-2.0). Xbox games load the Windows modules of [@domsvoboda](https://github.com/domsvoboda)'s [xodus-nexus](https://github.com/domsvoboda/xodus-nexus) runtime (LGPL-2.1-or-later), including its `wintypes.dll`, whose `ApiInformation` answer Minecraft for Windows needs to start; how Minecraft installs GameInput under Wine was checked against [@Wyze3306](https://github.com/Wyze3306)'s [BedrockOnLinux](https://github.com/Wyze3306/BedrockOnLinux) (MIT). See [LICENSE](LICENSE). Steam and Proton belong to Valve Corporation; this project is not affiliated with Valve. XR glasses support builds on WinNative's VITURE glasses work. VITURE protocol details were checked against [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) by [@wheaney](https://github.com/wheaney), including the VITURE protocol header it ships, [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) by [@badicsalex](https://github.com/badicsalex) and the [go-macos/iokit VITURE package](https://pkg.go.dev/github.com/go-macos/iokit/viture); the optional VITURE SDK belongs to VITURE and is not included. RayNeo support adapts [@informalTechCode](https://github.com/informalTechCode)'s [RayNeo-Air-Series-3DoF-Scaffold](https://github.com/informalTechCode/RayNeo-Air-Series-3DoF-Scaffold) (Apache-2.0) and references [@verncat](https://github.com/verncat)'s [RayNeo-Air-3S-Pro-OpenVR](https://github.com/verncat/RayNeo-Air-3S-Pro-OpenVR) (MIT) and [Monado](https://gitlab.freedesktop.org/monado/monado) (BSL-1.0); see [docs/third-party/rayneo](docs/third-party/rayneo/README.md). XREAL 1S support references [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) and [xrealOneDeviceKit](https://github.com/wheaney/xrealOneDeviceKit) by @wheaney, [xreal_one_driver](https://github.com/rohitsangwan01/xreal_one_driver) by [@rohitsangwan01](https://github.com/rohitsangwan01) (MIT) and [xr-tools](https://github.com/0xcaff/xr-tools) by [@0xcaff](https://github.com/0xcaff). Rokid support follows the Rokid protocol notes in [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) and @badicsalex's [Void Computing write-ups](https://voidcomputing.hu/blog/worse-better-prettier/), and [Monado](https://gitlab.freedesktop.org/monado/monado)'s Rokid driver. The REDMAGIC glasses-display findings draw on [@mekhontsev](https://github.com/mekhontsev)'s [MagicDesk investigation](https://github.com/mekhontsev/magicdesk/blob/main/docs/xr-resolution-fix.md) and [@Coding-BR](https://github.com/Coding-BR)'s [decompiled Nubia kernel](https://github.com/Coding-BR/android_kernel_nubia_sm8850_qwjujube). VITURE, RayNeo, XREAL, Rokid and REDMAGIC are trademarks of their owners; this project is not affiliated with them. diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt b/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt index 5cd766a7b8..f753585b17 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt @@ -17,45 +17,45 @@ object BattleNet { const val PROGRAM = "/usr/local/bin/droiddeck-battlenet" - class Title(val uid: String, val name: String, val code: String, val steam: Int? = null, val shop: String? = null) + class Title(val uid: String, val name: String, val code: String, val steam: Int? = null, val shop: String? = null, val product: String? = null) internal val TITLES = listOf( - Title("wow", "World of Warcraft", "WoW", shop = "world-of-warcraft-midnight"), - Title("wow_classic", "World of Warcraft Classic", "WoWC", shop = "world-of-warcraft-burning-crusade-classic-anniversary-edition-upgrades"), - Title("wow_classic_era", "World of Warcraft Classic", "WoWC"), - Title("wow_classic_anniversary", "World of Warcraft Classic", "WoWC"), - Title("diablo3", "Diablo III", "D3", shop = "diablo-iii"), + Title("wow", "World of Warcraft", "WoW", shop = "world-of-warcraft-midnight", product = "wow"), + Title("wow_classic", "World of Warcraft Classic", "WoWC", shop = "world-of-warcraft-burning-crusade-classic-anniversary-edition-upgrades", product = "wow_classic"), + Title("wow_classic_era", "World of Warcraft Classic", "WoWC", product = "wow_classic_era"), + Title("wow_classic_anniversary", "World of Warcraft Classic", "WoWC", product = "wow_anniversary"), + Title("diablo3", "Diablo III", "D3", shop = "diablo-iii", product = "d3"), Title("d3cn", "Diablo III", "D3CN", shop = "diablo-iii"), - Title("s2", "StarCraft II", "S2", shop = "starcraft-ii"), - Title("s1", "StarCraft", "S1", shop = "starcraft-remastered"), - Title("hs_beta", "Hearthstone", "WTCG", shop = "hearthstone"), - Title("heroes", "Heroes of the Storm", "Hero", shop = "heroes-of-the-storm"), - Title("prometheus", "Overwatch 2", "Pro", 2357570, shop = "overwatch"), - Title("w3", "Warcraft III: Reforged", "W3", shop = "warcraft-3-reforged"), - Title("viper", "Call of Duty: Black Ops 4", "VIPR", shop = "call-of-duty-black-ops-4"), - Title("odin", "Call of Duty: Modern Warfare", "ODIN", 2000950, shop = "call-of-duty-modern-warfare"), - Title("lazarus", "Call of Duty: Modern Warfare 2 Campaign Remastered", "LAZR", shop = "call-of-duty-modern-warfare-2-campaign-remastered"), - Title("zeus", "Call of Duty: Black Ops Cold War", "ZEUS", shop = "call-of-duty-black-ops-cold-war"), - Title("fore", "Call of Duty: Vanguard", "FORE", shop = "call-of-duty-vanguard"), - Title("auks", "Call of Duty: Modern Warfare II", "AUKS", shop = "call-of-duty-modern-warfare-ii"), - Title("pinta", "Call of Duty: Modern Warfare III", "PNTA", 2519060, shop = "call-of-duty-modern-warfare-iii"), - Title("wlby", "Crash Bandicoot 4: It's About Time", "WLBY", 1378990, shop = "crash-bandicoot-4"), - Title("osi", "Diablo II: Resurrected", "OSI"), - Title("rtro", "Blizzard Arcade Collection", "RTRO", shop = "blizzard-arcade-collection"), - Title("anbs", "Diablo Immortal", "ANBS", shop = "diablo-immortal"), - Title("fenris", "Diablo IV", "Fen", 2344520, shop = "diablo-iv"), - Title("fen", "Diablo IV", "Fen", 2344520, shop = "diablo-iv"), - Title("d1", "Diablo", "D1", shop = "diablo"), - Title("w1", "Warcraft: Orcs & Humans", "W1", shop = "warcraft-orcs-and-humans"), - Title("w2", "Warcraft II: Battle.net Edition", "W2", shop = "warcraft-2-battle-net-edition"), - Title("w1r", "Warcraft: Remastered", "W1R", shop = "warcraft-1-remastered"), - Title("w2r", "Warcraft II: Remastered", "W2R", shop = "warcraft-2-remastered"), - Title("gryphon", "Warcraft Rumble", "GRY", shop = "warcraft-rumble"), - Title("aris", "Doom: The Dark Ages", "ARIS", 3017860, shop = "doom-the-dark-ages"), - Title("scorpio", "Sea of Thieves", "SCOR", 1172620, shop = "sea-of-thieves"), - Title("arkansas", "The Outer Worlds 2", "ARK", 1449110, shop = "the-outer-worlds-2"), - Title("libra", "Tony Hawk's Pro Skater 3 + 4", "LBRA", 2545710), - Title("aqua", "Avowed", "AQUA", 2457220, shop = "avowed"), + Title("s2", "StarCraft II", "S2", shop = "starcraft-ii", product = "s2"), + Title("s1", "StarCraft", "S1", shop = "starcraft-remastered", product = "s1"), + Title("hs_beta", "Hearthstone", "WTCG", shop = "hearthstone", product = "hsb"), + Title("heroes", "Heroes of the Storm", "Hero", shop = "heroes-of-the-storm", product = "hero"), + Title("prometheus", "Overwatch 2", "Pro", 2357570, shop = "overwatch", product = "pro"), + Title("w3", "Warcraft III: Reforged", "W3", shop = "warcraft-3-reforged", product = "w3"), + Title("viper", "Call of Duty: Black Ops 4", "VIPR", shop = "call-of-duty-black-ops-4", product = "viper"), + Title("odin", "Call of Duty: Modern Warfare", "ODIN", 2000950, shop = "call-of-duty-modern-warfare", product = "odin"), + Title("lazarus", "Call of Duty: Modern Warfare 2 Campaign Remastered", "LAZR", shop = "call-of-duty-modern-warfare-2-campaign-remastered", product = "lazr"), + Title("zeus", "Call of Duty: Black Ops Cold War", "ZEUS", shop = "call-of-duty-black-ops-cold-war", product = "zeus"), + Title("fore", "Call of Duty: Vanguard", "FORE", shop = "call-of-duty-vanguard", product = "fore"), + Title("auks", "Call of Duty: Modern Warfare II", "AUKS", shop = "call-of-duty-modern-warfare-ii", product = "auks"), + Title("pinta", "Call of Duty: Modern Warfare III", "PNTA", 2519060, shop = "call-of-duty-modern-warfare-iii", product = "pinta"), + Title("wlby", "Crash Bandicoot 4: It's About Time", "WLBY", 1378990, shop = "crash-bandicoot-4", product = "wlby"), + Title("osi", "Diablo II: Resurrected", "OSI", product = "osi"), + Title("rtro", "Blizzard Arcade Collection", "RTRO", shop = "blizzard-arcade-collection", product = "rtro"), + Title("anbs", "Diablo Immortal", "ANBS", shop = "diablo-immortal", product = "anbs"), + Title("fenris", "Diablo IV", "Fen", 2344520, shop = "diablo-iv", product = "fenris"), + Title("fen", "Diablo IV", "Fen", 2344520, shop = "diablo-iv", product = "fenris"), + Title("d1", "Diablo", "D1", shop = "diablo", product = "drtl"), + Title("w1", "Warcraft: Orcs & Humans", "W1", shop = "warcraft-orcs-and-humans", product = "war1"), + Title("w2", "Warcraft II: Battle.net Edition", "W2", shop = "warcraft-2-battle-net-edition", product = "w2bn"), + Title("w1r", "Warcraft: Remastered", "W1R", shop = "warcraft-1-remastered", product = "w1r"), + Title("w2r", "Warcraft II: Remastered", "W2R", shop = "warcraft-2-remastered", product = "w2r"), + Title("gryphon", "Warcraft Rumble", "GRY", shop = "warcraft-rumble", product = "gryphon"), + Title("aris", "Doom: The Dark Ages", "ARIS", 3017860, shop = "doom-the-dark-ages", product = "aris"), + Title("scorpio", "Sea of Thieves", "SCOR", 1172620, shop = "sea-of-thieves", product = "scor"), + Title("arkansas", "The Outer Worlds 2", "ARK", 1449110, shop = "the-outer-worlds-2", product = "ark"), + Title("libra", "Tony Hawk's Pro Skater 3 + 4", "LBRA", 2545710, product = "lbra"), + Title("aqua", "Avowed", "AQUA", 2457220, shop = "avowed", product = "aqua"), ) val STORE: List get() = TITLES.distinctBy { it.code }.filter { it.uid != "d3cn" && it.code != "WoWC" } @@ -104,7 +104,7 @@ object BattleNet { private val NOT_GAMES = setOf("agent", "bna", "battle.net") - class Game(val uid: String, val name: String, val code: String, val folder: File) { + class Game(val uid: String, val name: String, val code: String, val folder: File, val installUid: String = uid) { val title: Title get() = title(uid) ?: Title(uid, name, code) } @@ -172,7 +172,7 @@ object BattleNet { } if (title.code in found) continue val folder = hostFolder(context, path)?.takeIf { it.isDirectory } ?: continue - found[title.code] = Game(title.uid, title.name, title.code, folder) + found[title.code] = Game(title.uid, title.name, title.code, folder, uid) } return found.values.toList() } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt index e15f19dd48..3488bf05a4 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt @@ -236,7 +236,7 @@ object StoresState { fun install(context: Context, item: CatalogItem, root: java.io.File? = null, language: String? = null) { val app = context.applicationContext val targetRoot = root ?: StoreInstallRoot.defaultTarget(app)?.root ?: StoreInstallRoot.installRoot(app) - if (item.store == Store.BATTLENET) { + if (item.store == Store.BATTLENET && !com.droiddeck.launcher.stores.battlenet.BattleNetInstall.headless(item)) { backends[item.store]?.install(app, item, targetRoot) return } @@ -273,7 +273,7 @@ object StoresState { uninstalling[key] = 0f background("stores-uninstall", onFailure = { main.post { uninstalling.remove(key); onDone() } }) { runCatching { backends[game.sidecar.store]?.uninstall(app, game) } - if (game.sidecar.store == Store.BATTLENET) { + if (game.sidecar.store == Store.BATTLENET && com.droiddeck.launcher.runtime.BattleNet.games(app).any { it.folder.absolutePath == game.folder.absolutePath }) { main.post { uninstalling.remove(key); onDone() } return@background } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetInstall.kt b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetInstall.kt new file mode 100644 index 0000000000..925f113b14 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetInstall.kt @@ -0,0 +1,283 @@ +package com.droiddeck.launcher.stores.battlenet + +import android.content.Context +import android.util.Log +import androidx.compose.runtime.mutableStateMapOf +import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.AddedGames +import com.droiddeck.launcher.runtime.BattleNet +import com.droiddeck.launcher.runtime.GuestCommand +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameStorage +import com.droiddeck.launcher.session.SecondaryLibrary +import com.droiddeck.launcher.stores.CatalogItem +import com.droiddeck.launcher.stores.InstalledStoreGame +import com.droiddeck.launcher.stores.Store +import com.droiddeck.launcher.stores.StoreInstallRoot +import com.droiddeck.launcher.stores.StoreLanguage +import com.droiddeck.launcher.stores.StoresState +import com.droiddeck.launcher.stores.download.DownloadEntry +import com.droiddeck.launcher.stores.download.DownloadQueue +import com.droiddeck.launcher.stores.download.DownloadStage +import org.json.JSONObject +import java.io.File +import java.net.HttpURLConnection +import java.net.URL +import java.util.Locale +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicBoolean + +object BattleNetInstall { + private const val TAG = "BattleNetInstall" + internal const val PROGRESS = "BNET_PROGRESS " + internal const val STATE = "BNET_STATE " + internal const val DONE = "BNET_DONE " + internal const val ERROR = "BNET_ERROR " + private const val LIBRARY_GUEST = "/mnt/droiddeck-sd" + private const val VERSIONS = "https://%s.version.battle.net/v2/products/%s/versions" + private const val BUILD_INFO = ".build.info" + private const val CHECK_AGAIN_MS = 30 * 60_000L + + internal val LOCALES = listOf( + "enUS", "enGB", "esMX", "esES", "ptBR", "ptPT", "frFR", "deDE", "itIT", "ruRU", "jaJP", "koKR", "plPL", "trTR", + "zhTW", "zhCN", "thTH", "arSA", + ) + + private val checks = Executors.newSingleThreadExecutor { r -> Thread(r, "battlenet-updates") } + private val checkedAt = HashMap<String, Long>() + + val updates = mutableStateMapOf<String, Boolean>() + + fun product(id: String): String? = BattleNet.title(id)?.product + + fun headless(item: CatalogItem): Boolean = item.store == Store.BATTLENET && product(item.id) != null + + internal fun locale(locale: Locale): String { + val language = locale.language.lowercase(Locale.ROOT) + if (language == "zh") { + val traditional = locale.script.equals("Hant", true) || locale.country.uppercase(Locale.ROOT) in setOf("TW", "HK", "MO") + return if (traditional) "zhTW" else "zhCN" + } + val exact = language + locale.country.uppercase(Locale.ROOT) + return LOCALES.firstOrNull { it == exact } ?: LOCALES.firstOrNull { it.startsWith(language) } ?: "enUS" + } + + internal fun country(locale: Locale): Pair<String, String> { + val two = locale.country.uppercase(Locale.ROOT) + val three = runCatching { locale.isO3Country.uppercase(Locale.ROOT) }.getOrDefault("") + return if (two.matches(Regex("[A-Z]{2}")) && three.matches(Regex("[A-Z]{3}"))) three to two else "USA" to "US" + } + + internal fun binds(context: Context, guest: String): List<String> { + val out = ArrayList<String>() + if (guest.startsWith(StoreInstallRoot.GUEST_EXTERNAL + "/")) out += StoreInstallRoot.externalBindSpecs(context) + if (guest == LIBRARY_GUEST || guest.startsWith("$LIBRARY_GUEST/")) { + GameStorage.effective(context)?.let { library -> + File(LinuxRuntime.rootDir(context), LIBRARY_GUEST.removePrefix("/")).mkdirs() + out += SecondaryLibrary.contentPath(File(library.path)).path + ":" + LIBRARY_GUEST + } + } + return out + } + + internal fun run(context: Context, args: List<String>, guest: String?, cancelled: AtomicBoolean?, onLine: (String) -> Unit): Int = + GuestCommand.run( + context, listOf(BattleNet.PROGRAM) + args, logName = "battlenet-agent", + extraBinds = guest?.let { binds(context, it) }, fastPath = true, cancelled = cancelled, onLine = onLine, + ) + + fun enqueue(context: Context, item: CatalogItem, folder: File, update: Boolean = false) { + val app = context.applicationContext + val entry = DownloadEntry( + Store.BATTLENET, item.id, item.title, cover = item.tallImageUrl ?: item.imageUrl, + location = StoreInstallRoot.labelFor(app, folder), + ) + DownloadQueue.enqueue(app, entry) { BattleNetInstaller(app, item, folder, update) } + } + + fun update(context: Context, game: InstalledStoreGame) { + val app = context.applicationContext + Thread({ + val item = CatalogItem( + Store.BATTLENET, game.sidecar.id, game.sidecar.title, game.sidecar.hero, tallImageUrl = game.sidecar.cover, owned = true, + extra = mapOf(INSTALL_UID to installUid(app, game)), + ) + game.folder.parentFile?.parentFile?.let { com.droiddeck.launcher.stores.download.SavedQueue.remember(app, item, it) } + enqueue(app, item, game.folder, update = true) + }, "battlenet-update").start() + } + + internal const val INSTALL_UID = "installUid" + + internal fun installUid(context: Context, game: InstalledStoreGame): String = + runCatching { BattleNet.games(context).firstOrNull { it.uid == game.sidecar.id }?.installUid }.getOrNull() ?: game.sidecar.id + + fun uninstall(context: Context, game: InstalledStoreGame): Boolean { + if (product(game.sidecar.id) == null || !BattleNet.installed(context)) return false + val uid = installUid(context, game) + var done = false + val code = runCatching { + run(context, listOf("agent-uninstall", uid), AddedGames.guestPath(context, game.folder), null) { line -> + if (line.startsWith(DONE)) done = true + } + }.onFailure { Log.w(TAG, "uninstall $uid", it) }.getOrDefault(-1) + Log.i(TAG, "uninstall $uid: ${if (done) "done" else "exit $code"}") + if (done) StoresState.post { StoresState.notifyLibraryChanged(context.applicationContext) } + return done + } + + internal fun buildKey(text: String): Pair<String, String>? { + val rows = text.lines().filter { it.isNotBlank() } + if (rows.size < 2) return null + val head = rows[0].split('|').map { it.substringBefore('!') } + val branch = head.indexOf("Branch") + val active = head.indexOf("Active") + val key = head.indexOf("Build Key") + if (branch < 0 || key < 0) return null + val row = rows.drop(1).map { it.split('|') }.firstOrNull { active < 0 || it.getOrNull(active) == "1" } ?: return null + val region = row.getOrNull(branch)?.takeIf { it.matches(Regex("[a-z]{2}")) } ?: return null + val build = row.getOrNull(key)?.takeIf { it.matches(Regex("[0-9a-f]{32}")) } ?: return null + return region to build + } + + internal fun latestBuild(text: String, region: String): String? { + val rows = text.lines().filter { it.isNotBlank() && !it.startsWith("##") } + if (rows.isEmpty()) return null + val head = rows[0].split('|').map { it.substringBefore('!') } + val at = head.indexOf("Region") + val key = head.indexOf("BuildConfig") + if (at < 0 || key < 0) return null + return rows.drop(1).map { it.split('|') }.firstOrNull { it.getOrNull(at) == region }?.getOrNull(key) + ?.takeIf { it.matches(Regex("[0-9a-f]{32}")) } + } + + fun checkUpdate(context: Context, game: InstalledStoreGame, force: Boolean = false) = check(game.sidecar.id, game.folder, force) + + internal fun check(id: String, folder: File, force: Boolean) { + val product = product(id) ?: return + val now = System.currentTimeMillis() + synchronized(checkedAt) { + if (!force && now - (checkedAt[id] ?: 0L) < CHECK_AGAIN_MS) return + checkedAt[id] = now + } + checks.execute { + val local = runCatching { buildKey(File(folder, BUILD_INFO).readText()) }.getOrNull() ?: return@execute + val latest = runCatching { latestBuild(fetch(VERSIONS.format(Locale.ROOT, local.first, product)), local.first) } + .onFailure { Log.w(TAG, "versions of $product: ${it.javaClass.simpleName}") }.getOrNull() ?: return@execute + val behind = latest != local.second + Log.i(TAG, "$id: ${if (behind) "update available" else "up to date"}") + StoresState.post { if (behind) updates[id] = true else updates.remove(id) } + } + } + + private fun fetch(url: String): String { + val conn = (URL(url).openConnection() as HttpURLConnection).apply { + connectTimeout = 15_000 + readTimeout = 15_000 + setRequestProperty("User-Agent", "DroidDeck") + } + try { + if (conn.responseCode != 200) throw java.io.IOException("HTTP ${conn.responseCode}") + return conn.inputStream.bufferedReader().use { it.readText() } + } finally { + conn.disconnect() + } + } + + internal fun failure(context: Context, reason: String?, code: Int): String { + val detail = when { + reason == null -> "exit $code" + reason == "client" -> return context.getString(R.string.bnet_dl_client_first) + reason.startsWith("agent ") -> context.getString(R.string.bnet_dl_agent_error, reason.removePrefix("agent ")) + else -> reason.removePrefix("stopped ") + } + return context.getString(R.string.bnet_dl_failed, detail) + } + + internal fun localeTag(context: Context): String = locale(StoreLanguage.localeFor(null, context)) + + internal enum class Step { PREPARING, DOWNLOADING, APPLYING } + + internal fun step(state: Int, phase: Int, current: Long, total: Long): Step = when { + state == DONE_STATE || phase == APPLY_PHASE || total > 0L && current >= total -> Step.APPLYING + total > 0L -> Step.DOWNLOADING + else -> Step.PREPARING + } + + private const val DONE_STATE = 1004 + private const val APPLY_PHASE = 2000 +} + +internal class BattleNetInstaller( + private val app: Context, + private val item: CatalogItem, + private val folder: File, + private val update: Boolean, +) : DownloadQueue.DownloadJob { + private val cancelled = AtomicBoolean(false) + private var before = 0L + private var kept = -1L + + override fun run(handle: DownloadQueue.JobHandle): String? { + before = DownloadQueue.entry(handle.key)?.bytesTotal ?: 0L + handle.stage(DownloadStage.MANIFEST, app.getString(R.string.bnet_dl_starting)) + if (!BattleNet.installed(app)) throw IllegalStateException(app.getString(R.string.bnet_dl_client_first)) + val title = BattleNet.title(item.id) + val product = title?.product ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, item.id)) + val uid = item.extra[BattleNetInstall.INSTALL_UID] ?: title.uid + if (!update) folder.mkdirs() + val guest = AddedGames.guestPath(app, folder) ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, folder.path)) + val (country, region) = BattleNetInstall.country(Locale.getDefault()) + val args = if (update) listOf("agent-update", uid) + else listOf("agent-install", uid, product, guest, BattleNetInstall.localeTag(app), country, region) + var done: JSONObject? = null + var reason: String? = null + val code = BattleNetInstall.run(app, args, guest, cancelled) { line -> + when { + line.startsWith(BattleNetInstall.PROGRESS) -> + runCatching { JSONObject(line.removePrefix(BattleNetInstall.PROGRESS)) }.getOrNull()?.let { progress(handle, it) } + line == BattleNetInstall.STATE + "waiting" -> handle.stage(DownloadStage.MANIFEST, app.getString(R.string.bnet_dl_waiting)) + line == BattleNetInstall.STATE + "queued" -> handle.stage(DownloadStage.MANIFEST, app.getString(R.string.bnet_dl_queued)) + line == BattleNetInstall.STATE + "starting" -> handle.stage(DownloadStage.MANIFEST, app.getString(R.string.bnet_dl_starting)) + line.startsWith(BattleNetInstall.DONE) -> done = runCatching { JSONObject(line.removePrefix(BattleNetInstall.DONE)) }.getOrNull() + line.startsWith(BattleNetInstall.ERROR) -> reason = line.removePrefix(BattleNetInstall.ERROR) + } + } + if (cancelled.get()) return null + if (done == null) throw IllegalStateException(BattleNetInstall.failure(app, reason, code)) + handle.log("Battle.net: ${item.title} ${if (update) "updated" else "installed"} ${done?.optString("version").orEmpty()}".trimEnd()) + StoresState.post { + BattleNetInstall.updates.remove(item.id) + StoresState.notifyLibraryChanged(app) + } + BattleNetInstall.check(item.id, folder, force = true) + return folder.absolutePath + } + + private fun progress(handle: DownloadQueue.JobHandle, status: JSONObject) { + val current = status.optLong("download_current", 0L) + val total = status.optLong("download_total", 0L) + when (BattleNetInstall.step(status.optInt("state", 0), status.optInt("phase", 0), current, total)) { + BattleNetInstall.Step.PREPARING -> handle.stage(DownloadStage.MANIFEST, app.getString(R.string.stores_stage_checking)) + BattleNetInstall.Step.DOWNLOADING -> { + if (kept < 0L) kept = (before - total).coerceAtLeast(0L) + handle.progress(kept + current, kept + total) + } + BattleNetInstall.Step.APPLYING -> handle.stage(DownloadStage.INSTALL) + } + } + + override fun cancel(deleteFiles: Boolean) { + cancelled.set(true) + if (!deleteFiles || update) return + val uid = item.extra[BattleNetInstall.INSTALL_UID] ?: BattleNet.title(item.id)?.uid ?: return + Thread({ + Thread.sleep(2_000) + val gone = runCatching { + BattleNetInstall.run(app, listOf("agent-uninstall", uid), AddedGames.guestPath(app, folder), null) {} + }.getOrDefault(-1) + if (folder.isDirectory) com.droiddeck.launcher.core.FileUtils.delete(folder) + Log.i("BattleNetInstall", "cancelled install of $uid cleaned up (exit $gone)") + }, "battlenet-cancel").start() + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt index 945c75c7a6..737ba3b4ff 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt @@ -189,9 +189,15 @@ object BattleNetBackend : StoreBackend { override fun search(context: Context, query: String): List<CatalogItem> = BattleNet.STORE.filter { it.name.contains(query, ignoreCase = true) }.map { item(context, it) } - override fun install(context: Context, item: CatalogItem, root: File) = BattleNetClient.installGame(context, item.id, root) + override fun install(context: Context, item: CatalogItem, root: File) { + if (!BattleNetInstall.headless(item)) return BattleNetClient.installGame(context, item.id, root) + val app = context.applicationContext + BattleNetInstall.enqueue(app, item, StoreInstallRoot.folderFor(app, store, item.id, item.title, root)) + } - override fun uninstall(context: Context, game: InstalledStoreGame) = BattleNetClient.open(emptyList()) + override fun uninstall(context: Context, game: InstalledStoreGame) { + if (!BattleNetInstall.uninstall(context, game)) BattleNetClient.open(emptyList()) + } fun installed(context: Context): List<BattleNet.Game> = if (BattleNet.installed(context)) BattleNet.games(context) else emptyList() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt b/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt index 53b5c953bb..ac8ecffcce 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt @@ -56,6 +56,7 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.boundsInRoot import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.layout.positionInRoot import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalConfiguration @@ -86,6 +87,7 @@ import com.droiddeck.launcher.stores.StoreInstallRoot import com.droiddeck.launcher.stores.StoreLanguage import com.droiddeck.launcher.stores.StoreSizes import com.droiddeck.launcher.stores.StoresState +import com.droiddeck.launcher.stores.battlenet.BattleNetInstall import com.droiddeck.launcher.stores.download.DownloadQueue import com.droiddeck.launcher.stores.download.DownloadState import com.droiddeck.launcher.stores.formatBytes @@ -267,13 +269,15 @@ private fun GameHero( ) } Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0f to colors.background.copy(alpha = 0.94f), 0.55f to colors.background.copy(alpha = 0.58f), 1f to Color.Transparent))) + var scoresWidth by remember { mutableStateOf(0) } if (scores != null) { Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0.45f to Color.Transparent, 1f to colors.background.copy(alpha = 0.75f)))) - HeroScores(scores, Modifier.align(Alignment.BottomEnd).padding(end = 16.dp, bottom = 18.dp)) + HeroScores(scores, Modifier.align(Alignment.BottomEnd).padding(end = 16.dp, bottom = 18.dp).onSizeChanged { scoresWidth = it.width }) } + val scoresSpace = with(LocalDensity.current) { if (scores != null && scoresWidth > 0) scoresWidth.toDp() + 16.dp else 0.dp } Column( verticalArrangement = Arrangement.spacedBy(6.dp), - modifier = Modifier.align(Alignment.BottomStart).padding(horizontal = 22.dp, vertical = 18.dp), + modifier = Modifier.align(Alignment.BottomStart).padding(start = 22.dp, end = 22.dp + scoresSpace, top = 18.dp, bottom = 18.dp), content = content, ) Box(Modifier.align(Alignment.TopEnd).padding(12.dp), content = corner) @@ -358,7 +362,19 @@ internal fun GameActions( } SecondaryButton(stringResource(R.string.stores_xbox_manage), enabled = download == null) { XboxContent.manage(ctx, installed) } } - if (store == Store.BATTLENET) SecondaryButton(stringResource(R.string.bnet_open)) { a.onBattleNet() } + if (store == Store.BATTLENET) { + if (installed != null && id != null) { + LaunchedEffect(id) { BattleNetInstall.checkUpdate(ctx, installed) } + if (download != null) { + ActionChip(downloadLabel(download), ok = false) + if (download.state != DownloadState.PAUSED) SecondaryButton(stringResource(R.string.stores_dl_pause)) { DownloadQueue.pause(download.key) } + else SecondaryButton(stringResource(R.string.stores_dl_resume)) { DownloadQueue.resume(ctx, download.key) } + } else if (BattleNetInstall.updates[id] == true) { + SecondaryButton(stringResource(R.string.bnet_update)) { BattleNetInstall.update(ctx, installed) } + } + } + SecondaryButton(stringResource(R.string.bnet_open)) { a.onBattleNet() } + } } download != null -> { ActionChip(downloadLabel(download), ok = false) @@ -534,7 +550,7 @@ private fun IconAction(icon: androidx.compose.ui.graphics.vector.ImageVector, la private fun RemoveButton(title: String, game: Library.SteamGame?, installed: InstalledStoreGame?, a: FrontEndActions) { val ctx = LocalContext.current val colors = MaterialTheme.colorScheme - if ((installed?.sidecar?.store?.id ?: game?.source) == Store.BATTLENET.id) return + if ((installed?.sidecar?.store?.id ?: game?.source) == Store.BATTLENET.id && installed?.sidecar?.id?.let(BattleNetInstall::product) == null) return if (installed != null) { val key = installed.key val gone = StoresState.uninstalling[key] diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt index d3e3b8b0aa..a4e8bdaf76 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt @@ -1392,7 +1392,11 @@ internal fun downloadLabel(d: com.droiddeck.launcher.stores.download.DownloadEnt @Composable internal fun activeStageLabel(d: com.droiddeck.launcher.stores.download.DownloadEntry): String = when (d.stage) { - DownloadStage.MANIFEST -> if (d.stageItemsTotal > 0) stringResource(R.string.stores_stage_checking) else stringResource(R.string.stores_stage_manifest) + DownloadStage.MANIFEST -> when { + d.store == Store.BATTLENET && d.detail.isNotBlank() -> d.detail + d.stageItemsTotal > 0 -> stringResource(R.string.stores_stage_checking) + else -> stringResource(R.string.stores_stage_manifest) + } DownloadStage.DOWNLOAD -> stringResource(R.string.stores_stage_downloading) DownloadStage.VERIFY -> stringResource(R.string.stores_stage_verifying) DownloadStage.INSTALL -> stringResource(R.string.stores_stage_installing) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index fa1c13e5e5..0d17340d69 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -2081,6 +2081,13 @@ <string name="stores_play">تشغيل</string> <string name="stores_install">تثبيت</string> <string name="bnet_open">فتح Battle.net</string> + <string name="bnet_dl_starting">جارٍ تشغيل أداة التنزيل من Blizzard…</string> + <string name="bnet_dl_waiting">في انتظار إغلاق Battle.net…</string> + <string name="bnet_dl_queued">في انتظار تنزيل Battle.net الآخر…</string> + <string name="bnet_dl_client_first">افتح Battle.net وسجّل الدخول مرة واحدة، ثم ثبّت ألعابه من هنا.</string> + <string name="bnet_dl_failed">توقفت أداة التنزيل من Blizzard: %1$s</string> + <string name="bnet_dl_agent_error">خطأ Blizzard %1$s</string> + <string name="bnet_update">تحديث</string> <string name="bnet_store">ألعاب Blizzard</string> <string name="stores_resume_install">استئناف التثبيت</string> <string name="stores_dl_interrupted">منقطع</string> diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml index acbf053f10..35abfeb415 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -2049,6 +2049,13 @@ <string name="stores_play">Jugar</string> <string name="stores_install">Instalar</string> <string name="bnet_open">Abrir Battle.net</string> + <string name="bnet_dl_starting">Iniciando el descargador de Blizzard…</string> + <string name="bnet_dl_waiting">Esperando a que se cierre Battle.net…</string> + <string name="bnet_dl_queued">Esperando la otra descarga de Battle.net…</string> + <string name="bnet_dl_client_first">Abre Battle.net e inicia sesión una vez; luego instala sus juegos desde aquí.</string> + <string name="bnet_dl_failed">El descargador de Blizzard se detuvo: %1$s</string> + <string name="bnet_dl_agent_error">Error de Blizzard %1$s</string> + <string name="bnet_update">Actualizar</string> <string name="bnet_store">Juegos de Blizzard</string> <string name="stores_resume_install">Reanudar instalación</string> <string name="stores_dl_interrupted">Interrumpida</string> diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 137b761f8b..e4eda5acf1 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Играй</string> <string name="stores_install">Инсталирай</string> <string name="bnet_open">Отвори Battle.net</string> + <string name="bnet_dl_starting">Стартиране на програмата за изтегляне на Blizzard…</string> + <string name="bnet_dl_waiting">Изчакване Battle.net да се затвори…</string> + <string name="bnet_dl_queued">Изчакване на другото изтегляне от Battle.net…</string> + <string name="bnet_dl_client_first">Отворете Battle.net и влезте веднъж, след това инсталирайте игрите му оттук.</string> + <string name="bnet_dl_failed">Програмата за изтегляне на Blizzard спря: %1$s</string> + <string name="bnet_dl_agent_error">Грешка на Blizzard %1$s</string> + <string name="bnet_update">Актуализиране</string> <string name="bnet_store">Игри на Blizzard</string> <string name="stores_resume_install">Продължи инсталацията</string> <string name="stores_dl_interrupted">Прекъснато</string> diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index d12e8ff408..f3c5a4b8fb 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -2039,6 +2039,13 @@ <string name="stores_play">Hrát</string> <string name="stores_install">Instalovat</string> <string name="bnet_open">Otevřít Battle.net</string> + <string name="bnet_dl_starting">Spouštění stahovače Blizzardu…</string> + <string name="bnet_dl_waiting">Čekání na zavření Battle.net…</string> + <string name="bnet_dl_queued">Čekání na druhé stahování z Battle.net…</string> + <string name="bnet_dl_client_first">Otevřete Battle.net a jednou se přihlaste, pak instalujte jeho hry odsud.</string> + <string name="bnet_dl_failed">Stahovač Blizzardu se zastavil: %1$s</string> + <string name="bnet_dl_agent_error">Chyba Blizzardu %1$s</string> + <string name="bnet_update">Aktualizovat</string> <string name="bnet_store">Hry od Blizzardu</string> <string name="stores_resume_install">Pokračovat v instalaci</string> <string name="stores_dl_interrupted">Přerušeno</string> diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index caf758e572..f34cad2490 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Spil</string> <string name="stores_install">Installer</string> <string name="bnet_open">Åbn Battle.net</string> + <string name="bnet_dl_starting">Starter Blizzards downloader…</string> + <string name="bnet_dl_waiting">Venter på, at Battle.net lukker…</string> + <string name="bnet_dl_queued">Venter på den anden Battle.net-download…</string> + <string name="bnet_dl_client_first">Åbn Battle.net, og log ind én gang, og installer derefter dets spil herfra.</string> + <string name="bnet_dl_failed">Blizzards downloader stoppede: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-fejl %1$s</string> + <string name="bnet_update">Opdater</string> <string name="bnet_store">Blizzard-spil</string> <string name="stores_resume_install">Genoptag installation</string> <string name="stores_dl_interrupted">Afbrudt</string> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index fbdf383abb..db80fbc596 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1989,6 +1989,13 @@ <string name="stores_play">Spielen</string> <string name="stores_install">Installieren</string> <string name="bnet_open">Battle.net öffnen</string> + <string name="bnet_dl_starting">Blizzards Downloader wird gestartet…</string> + <string name="bnet_dl_waiting">Warten, bis Battle.net geschlossen ist…</string> + <string name="bnet_dl_queued">Warten auf den anderen Battle.net-Download…</string> + <string name="bnet_dl_client_first">Öffne Battle.net und melde dich einmal an, dann installiere seine Spiele hier.</string> + <string name="bnet_dl_failed">Blizzards Downloader wurde beendet: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-Fehler %1$s</string> + <string name="bnet_update">Aktualisieren</string> <string name="bnet_store">Blizzard-Spiele</string> <string name="stores_resume_install">Installation fortsetzen</string> <string name="stores_dl_interrupted">Unterbrochen</string> diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 7e21ae76cd..0fb72f3a33 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Αναπαραγωγή</string> <string name="stores_install">Εγκατάσταση</string> <string name="bnet_open">Άνοιγμα του Battle.net</string> + <string name="bnet_dl_starting">Εκκίνηση του προγράμματος λήψης της Blizzard…</string> + <string name="bnet_dl_waiting">Αναμονή για κλείσιμο του Battle.net…</string> + <string name="bnet_dl_queued">Αναμονή για την άλλη λήψη από το Battle.net…</string> + <string name="bnet_dl_client_first">Ανοίξτε το Battle.net και συνδεθείτε μία φορά, έπειτα εγκαταστήστε τα παιχνίδια του από εδώ.</string> + <string name="bnet_dl_failed">Το πρόγραμμα λήψης της Blizzard σταμάτησε: %1$s</string> + <string name="bnet_dl_agent_error">Σφάλμα Blizzard %1$s</string> + <string name="bnet_update">Ενημέρωση</string> <string name="bnet_store">Παιχνίδια της Blizzard</string> <string name="stores_resume_install">Συνέχιση εγκατάστασης</string> <string name="stores_dl_interrupted">Διακόπηκε</string> diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1e3859f582..e599874c81 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -2020,6 +2020,13 @@ <string name="stores_play">Jugar</string> <string name="stores_install">Instalar</string> <string name="bnet_open">Abrir Battle.net</string> + <string name="bnet_dl_starting">Iniciando el descargador de Blizzard…</string> + <string name="bnet_dl_waiting">Esperando a que se cierre Battle.net…</string> + <string name="bnet_dl_queued">Esperando a la otra descarga de Battle.net…</string> + <string name="bnet_dl_client_first">Abre Battle.net e inicia sesión una vez; después instala sus juegos desde aquí.</string> + <string name="bnet_dl_failed">El descargador de Blizzard se ha detenido: %1$s</string> + <string name="bnet_dl_agent_error">Error de Blizzard %1$s</string> + <string name="bnet_update">Actualizar</string> <string name="bnet_store">Juegos de Blizzard</string> <string name="stores_resume_install">Reanudar instalación</string> <string name="stores_dl_interrupted">Interrumpida</string> diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 30f3341610..0fc0768a86 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Pelaa</string> <string name="stores_install">Asenna</string> <string name="bnet_open">Avaa Battle.net</string> + <string name="bnet_dl_starting">Käynnistetään Blizzardin latausohjelmaa…</string> + <string name="bnet_dl_waiting">Odotetaan Battle.netin sulkeutumista…</string> + <string name="bnet_dl_queued">Odotetaan toista Battle.net-latausta…</string> + <string name="bnet_dl_client_first">Avaa Battle.net ja kirjaudu sisään kerran, asenna sitten sen pelit täältä.</string> + <string name="bnet_dl_failed">Blizzardin latausohjelma pysähtyi: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-virhe %1$s</string> + <string name="bnet_update">Päivitä</string> <string name="bnet_store">Blizzardin pelit</string> <string name="stores_resume_install">Jatka asennusta</string> <string name="stores_dl_interrupted">Keskeytynyt</string> diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 76bf5abc2c..ceaad3f8ae 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -2020,6 +2020,13 @@ <string name="stores_play">Jouer</string> <string name="stores_install">Installer</string> <string name="bnet_open">Ouvrir Battle.net</string> + <string name="bnet_dl_starting">Démarrage du téléchargeur de Blizzard…</string> + <string name="bnet_dl_waiting">En attente de la fermeture de Battle.net…</string> + <string name="bnet_dl_queued">En attente de l\'autre téléchargement Battle.net…</string> + <string name="bnet_dl_client_first">Ouvrez Battle.net et connectez-vous une fois, puis installez ses jeux ici.</string> + <string name="bnet_dl_failed">Le téléchargeur de Blizzard s\'est arrêté : %1$s</string> + <string name="bnet_dl_agent_error">Erreur Blizzard %1$s</string> + <string name="bnet_update">Mettre à jour</string> <string name="bnet_store">Jeux Blizzard</string> <string name="stores_resume_install">Reprendre l\'installation</string> <string name="stores_dl_interrupted">Interrompu</string> diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 68cb4c185a..72455444e1 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Play</string> <string name="stores_install">इंस्टॉल करें</string> <string name="bnet_open">Battle.net खोलें</string> + <string name="bnet_dl_starting">Blizzard का डाउनलोडर शुरू हो रहा है…</string> + <string name="bnet_dl_waiting">Battle.net के बंद होने का इंतज़ार…</string> + <string name="bnet_dl_queued">दूसरे Battle.net डाउनलोड का इंतज़ार…</string> + <string name="bnet_dl_client_first">Battle.net खोलें और एक बार साइन इन करें, फिर इसके गेम यहाँ से इंस्टॉल करें।</string> + <string name="bnet_dl_failed">Blizzard का डाउनलोडर रुक गया: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard त्रुटि %1$s</string> + <string name="bnet_update">अपडेट करें</string> <string name="bnet_store">Blizzard के गेम</string> <string name="stores_resume_install">इंस्टॉल फिर से शुरू करें</string> <string name="stores_dl_interrupted">बाधित</string> diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index a7e0ca9754..fd309f9ad6 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Játék</string> <string name="stores_install">Telepítés</string> <string name="bnet_open">Battle.net megnyitása</string> + <string name="bnet_dl_starting">A Blizzard letöltőjének indítása…</string> + <string name="bnet_dl_waiting">Várakozás a Battle.net bezárására…</string> + <string name="bnet_dl_queued">Várakozás a másik Battle.net-letöltésre…</string> + <string name="bnet_dl_client_first">Nyisd meg a Battle.netet, és jelentkezz be egyszer, majd innen telepítsd a játékait.</string> + <string name="bnet_dl_failed">A Blizzard letöltője leállt: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-hiba: %1$s</string> + <string name="bnet_update">Frissítés</string> <string name="bnet_store">Blizzard-játékok</string> <string name="stores_resume_install">Telepítés folytatása</string> <string name="stores_dl_interrupted">Megszakítva</string> diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index d5fc612c3f..6f8d35ffcd 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -1976,6 +1976,13 @@ <string name="stores_play">Mainkan</string> <string name="stores_install">Instal</string> <string name="bnet_open">Buka Battle.net</string> + <string name="bnet_dl_starting">Memulai pengunduh Blizzard…</string> + <string name="bnet_dl_waiting">Menunggu Battle.net ditutup…</string> + <string name="bnet_dl_queued">Menunggu unduhan Battle.net lainnya…</string> + <string name="bnet_dl_client_first">Buka Battle.net dan masuk sekali, lalu instal gamenya dari sini.</string> + <string name="bnet_dl_failed">Pengunduh Blizzard berhenti: %1$s</string> + <string name="bnet_dl_agent_error">Kesalahan Blizzard %1$s</string> + <string name="bnet_update">Perbarui</string> <string name="bnet_store">Game Blizzard</string> <string name="stores_resume_install">Lanjutkan instalasi</string> <string name="stores_dl_interrupted">Terhenti</string> diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d070b01e32..f410007078 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -2010,6 +2010,13 @@ <string name="stores_play">Gioca</string> <string name="stores_install">Installa</string> <string name="bnet_open">Apri Battle.net</string> + <string name="bnet_dl_starting">Avvio del downloader di Blizzard…</string> + <string name="bnet_dl_waiting">In attesa della chiusura di Battle.net…</string> + <string name="bnet_dl_queued">In attesa dell\'altro download di Battle.net…</string> + <string name="bnet_dl_client_first">Apri Battle.net ed esegui l\'accesso una volta, poi installa qui i suoi giochi.</string> + <string name="bnet_dl_failed">Il downloader di Blizzard si è fermato: %1$s</string> + <string name="bnet_dl_agent_error">Errore Blizzard %1$s</string> + <string name="bnet_update">Aggiorna</string> <string name="bnet_store">Giochi Blizzard</string> <string name="stores_resume_install">Riprendi installazione</string> <string name="stores_dl_interrupted">Interrotto</string> diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 9bb40dcd11..5de521b824 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -1978,6 +1978,13 @@ <string name="stores_play">プレイ</string> <string name="stores_install">インストール</string> <string name="bnet_open">Battle.net を開く</string> + <string name="bnet_dl_starting">Blizzard のダウンローダーを起動しています…</string> + <string name="bnet_dl_waiting">Battle.net が閉じるのを待っています…</string> + <string name="bnet_dl_queued">もう一つの Battle.net のダウンロードを待っています…</string> + <string name="bnet_dl_client_first">Battle.net を開いて一度サインインしてから、ここでゲームをインストールしてください。</string> + <string name="bnet_dl_failed">Blizzard のダウンローダーが停止しました: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard エラー %1$s</string> + <string name="bnet_update">アップデート</string> <string name="bnet_store">Blizzard のゲーム</string> <string name="stores_resume_install">インストールを再開</string> <string name="stores_dl_interrupted">中断</string> diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index b76da8d131..5c87b95a3c 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1978,6 +1978,13 @@ <string name="stores_play">플레이</string> <string name="stores_install">설치</string> <string name="bnet_open">Battle.net 열기</string> + <string name="bnet_dl_starting">Blizzard 다운로더를 시작하는 중…</string> + <string name="bnet_dl_waiting">Battle.net이 닫히기를 기다리는 중…</string> + <string name="bnet_dl_queued">다른 Battle.net 다운로드를 기다리는 중…</string> + <string name="bnet_dl_client_first">Battle.net을 열고 한 번 로그인한 다음 여기에서 게임을 설치하세요.</string> + <string name="bnet_dl_failed">Blizzard 다운로더가 중지됨: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard 오류 %1$s</string> + <string name="bnet_update">업데이트</string> <string name="bnet_store">Blizzard 게임</string> <string name="stores_resume_install">설치 재개</string> <string name="stores_dl_interrupted">중단됨</string> diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index e036753b5d..562683f18a 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -1976,6 +1976,13 @@ <string name="stores_play">Main</string> <string name="stores_install">Pasang</string> <string name="bnet_open">Buka Battle.net</string> + <string name="bnet_dl_starting">Memulakan pemuat turun Blizzard…</string> + <string name="bnet_dl_waiting">Menunggu Battle.net ditutup…</string> + <string name="bnet_dl_queued">Menunggu muat turun Battle.net yang lain…</string> + <string name="bnet_dl_client_first">Buka Battle.net dan log masuk sekali, kemudian pasang permainannya dari sini.</string> + <string name="bnet_dl_failed">Pemuat turun Blizzard berhenti: %1$s</string> + <string name="bnet_dl_agent_error">Ralat Blizzard %1$s</string> + <string name="bnet_update">Kemas kini</string> <string name="bnet_store">Permainan Blizzard</string> <string name="stores_resume_install">Sambung pemasangan</string> <string name="stores_dl_interrupted">Terganggu</string> diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index a9f9489c15..a979f2c44d 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Spill</string> <string name="stores_install">Installer</string> <string name="bnet_open">Åpne Battle.net</string> + <string name="bnet_dl_starting">Starter Blizzards nedlaster…</string> + <string name="bnet_dl_waiting">Venter på at Battle.net lukkes…</string> + <string name="bnet_dl_queued">Venter på den andre Battle.net-nedlastingen…</string> + <string name="bnet_dl_client_first">Åpne Battle.net og logg på én gang, og installer deretter spillene herfra.</string> + <string name="bnet_dl_failed">Blizzards nedlaster stoppet: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-feil %1$s</string> + <string name="bnet_update">Oppdater</string> <string name="bnet_store">Blizzard-spill</string> <string name="stores_resume_install">Gjenoppta installasjon</string> <string name="stores_dl_interrupted">Avbrutt</string> diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index d74633be94..ccef5c5df3 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Spelen</string> <string name="stores_install">Installeren</string> <string name="bnet_open">Battle.net openen</string> + <string name="bnet_dl_starting">Blizzards downloader wordt gestart…</string> + <string name="bnet_dl_waiting">Wachten tot Battle.net is gesloten…</string> + <string name="bnet_dl_queued">Wachten op de andere Battle.net-download…</string> + <string name="bnet_dl_client_first">Open Battle.net en meld je één keer aan, installeer daarna de games hier.</string> + <string name="bnet_dl_failed">Blizzards downloader is gestopt: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-fout %1$s</string> + <string name="bnet_update">Bijwerken</string> <string name="bnet_store">Blizzard-games</string> <string name="stores_resume_install">Installatie hervatten</string> <string name="stores_dl_interrupted">Onderbroken</string> diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 121d781649..145d207a30 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -2039,6 +2039,13 @@ <string name="stores_play">Graj</string> <string name="stores_install">Zainstaluj</string> <string name="bnet_open">Otwórz Battle.net</string> + <string name="bnet_dl_starting">Uruchamianie programu pobierającego Blizzarda…</string> + <string name="bnet_dl_waiting">Oczekiwanie na zamknięcie Battle.net…</string> + <string name="bnet_dl_queued">Oczekiwanie na drugie pobieranie z Battle.net…</string> + <string name="bnet_dl_client_first">Otwórz Battle.net i zaloguj się raz, a potem instaluj jego gry tutaj.</string> + <string name="bnet_dl_failed">Program pobierający Blizzarda zatrzymał się: %1$s</string> + <string name="bnet_dl_agent_error">Błąd Blizzarda %1$s</string> + <string name="bnet_update">Aktualizuj</string> <string name="bnet_store">Gry Blizzarda</string> <string name="stores_resume_install">Wznów instalację</string> <string name="stores_dl_interrupted">Przerwano</string> diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 61fe3b5ff4..ab9b323b70 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -2010,6 +2010,13 @@ <string name="stores_play">Jogar</string> <string name="stores_install">Instalar</string> <string name="bnet_open">Abrir o Battle.net</string> + <string name="bnet_dl_starting">A iniciar o transferidor da Blizzard…</string> + <string name="bnet_dl_waiting">A aguardar que o Battle.net feche…</string> + <string name="bnet_dl_queued">A aguardar a outra transferência do Battle.net…</string> + <string name="bnet_dl_client_first">Abra o Battle.net e inicie sessão uma vez; depois instale os jogos dele aqui.</string> + <string name="bnet_dl_failed">O transferidor da Blizzard parou: %1$s</string> + <string name="bnet_dl_agent_error">Erro da Blizzard %1$s</string> + <string name="bnet_update">Atualizar</string> <string name="bnet_store">Jogos da Blizzard</string> <string name="stores_resume_install">Retomar instalação</string> <string name="stores_dl_interrupted">Interrompida</string> diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index c9e1e7b1b7..c5b7bd327d 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -2010,6 +2010,13 @@ <string name="stores_play">Jogar</string> <string name="stores_install">Instalar</string> <string name="bnet_open">Abrir o Battle.net</string> + <string name="bnet_dl_starting">Iniciando o downloader da Blizzard…</string> + <string name="bnet_dl_waiting">Aguardando o Battle.net fechar…</string> + <string name="bnet_dl_queued">Aguardando o outro download do Battle.net…</string> + <string name="bnet_dl_client_first">Abra o Battle.net e entre uma vez; depois instale os jogos dele aqui.</string> + <string name="bnet_dl_failed">O downloader da Blizzard parou: %1$s</string> + <string name="bnet_dl_agent_error">Erro da Blizzard %1$s</string> + <string name="bnet_update">Atualizar</string> <string name="bnet_store">Jogos da Blizzard</string> <string name="stores_resume_install">Retomar instalação</string> <string name="stores_dl_interrupted">Interrompido</string> diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index b8e3b4954c..d4aa16f9d8 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -2018,6 +2018,13 @@ <string name="stores_play">Joacă</string> <string name="stores_install">Instalează</string> <string name="bnet_open">Deschide Battle.net</string> + <string name="bnet_dl_starting">Se pornește programul de descărcare Blizzard…</string> + <string name="bnet_dl_waiting">Se așteaptă închiderea Battle.net…</string> + <string name="bnet_dl_queued">Se așteaptă cealaltă descărcare Battle.net…</string> + <string name="bnet_dl_client_first">Deschide Battle.net și conectează-te o dată, apoi instalează jocurile de aici.</string> + <string name="bnet_dl_failed">Programul de descărcare Blizzard s-a oprit: %1$s</string> + <string name="bnet_dl_agent_error">Eroare Blizzard %1$s</string> + <string name="bnet_update">Actualizează</string> <string name="bnet_store">Jocuri Blizzard</string> <string name="stores_resume_install">Reia instalarea</string> <string name="stores_dl_interrupted">Întreruptă</string> diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 59e74118e7..0de18cd365 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -2041,6 +2041,13 @@ <string name="stores_play">Играть</string> <string name="stores_install">Установить</string> <string name="bnet_open">Открыть Battle.net</string> + <string name="bnet_dl_starting">Запуск загрузчика Blizzard…</string> + <string name="bnet_dl_waiting">Ожидание закрытия Battle.net…</string> + <string name="bnet_dl_queued">Ожидание другой загрузки Battle.net…</string> + <string name="bnet_dl_client_first">Откройте Battle.net и войдите один раз, затем устанавливайте его игры здесь.</string> + <string name="bnet_dl_failed">Загрузчик Blizzard остановился: %1$s</string> + <string name="bnet_dl_agent_error">Ошибка Blizzard %1$s</string> + <string name="bnet_update">Обновить</string> <string name="bnet_store">Игры Blizzard</string> <string name="stores_resume_install">Продолжить установку</string> <string name="stores_dl_interrupted">Прервано</string> diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 2c62e8b139..7e5ccf7d66 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -1997,6 +1997,13 @@ <string name="stores_play">Spela</string> <string name="stores_install">Installera</string> <string name="bnet_open">Öppna Battle.net</string> + <string name="bnet_dl_starting">Startar Blizzards nedladdare…</string> + <string name="bnet_dl_waiting">Väntar på att Battle.net stängs…</string> + <string name="bnet_dl_queued">Väntar på den andra Battle.net-nedladdningen…</string> + <string name="bnet_dl_client_first">Öppna Battle.net och logga in en gång, installera sedan dess spel här.</string> + <string name="bnet_dl_failed">Blizzards nedladdare stoppades: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard-fel %1$s</string> + <string name="bnet_update">Uppdatera</string> <string name="bnet_store">Blizzard-spel</string> <string name="stores_resume_install">Återuppta installation</string> <string name="stores_dl_interrupted">Avbruten</string> diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 38337b0fda..762cb944dd 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -1976,6 +1976,13 @@ <string name="stores_play">เล่น</string> <string name="stores_install">ติดตั้ง</string> <string name="bnet_open">เปิด Battle.net</string> + <string name="bnet_dl_starting">กำลังเริ่มตัวดาวน์โหลดของ Blizzard…</string> + <string name="bnet_dl_waiting">กำลังรอให้ Battle.net ปิด…</string> + <string name="bnet_dl_queued">กำลังรอการดาวน์โหลด Battle.net อีกรายการ…</string> + <string name="bnet_dl_client_first">เปิด Battle.net และลงชื่อเข้าใช้หนึ่งครั้ง แล้วติดตั้งเกมจากที่นี่</string> + <string name="bnet_dl_failed">ตัวดาวน์โหลดของ Blizzard หยุดทำงาน: %1$s</string> + <string name="bnet_dl_agent_error">ข้อผิดพลาดของ Blizzard %1$s</string> + <string name="bnet_update">อัปเดต</string> <string name="bnet_store">เกมของ Blizzard</string> <string name="stores_resume_install">ดำเนินการติดตั้งต่อ</string> <string name="stores_dl_interrupted">ถูกขัดจังหวะ</string> diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index c1bbb9d33d..693747e851 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -1991,6 +1991,13 @@ <string name="stores_play">Oyna</string> <string name="stores_install">Yükle</string> <string name="bnet_open">Battle.net\'i aç</string> + <string name="bnet_dl_starting">Blizzard indiricisi başlatılıyor…</string> + <string name="bnet_dl_waiting">Battle.net\'in kapanması bekleniyor…</string> + <string name="bnet_dl_queued">Diğer Battle.net indirmesi bekleniyor…</string> + <string name="bnet_dl_client_first">Battle.net\'i açıp bir kez oturum açın, ardından oyunlarını buradan yükleyin.</string> + <string name="bnet_dl_failed">Blizzard indiricisi durdu: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard hatası %1$s</string> + <string name="bnet_update">Güncelle</string> <string name="bnet_store">Blizzard oyunları</string> <string name="stores_resume_install">Yüklemeyi sürdür</string> <string name="stores_dl_interrupted">Kesintiye uğradı</string> diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 2cadb53c52..44e0418ddc 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -2039,6 +2039,13 @@ <string name="stores_play">Грати</string> <string name="stores_install">Встановити</string> <string name="bnet_open">Відкрити Battle.net</string> + <string name="bnet_dl_starting">Запуск завантажувача Blizzard…</string> + <string name="bnet_dl_waiting">Очікування закриття Battle.net…</string> + <string name="bnet_dl_queued">Очікування іншого завантаження Battle.net…</string> + <string name="bnet_dl_client_first">Відкрийте Battle.net і увійдіть один раз, потім встановлюйте його ігри тут.</string> + <string name="bnet_dl_failed">Завантажувач Blizzard зупинився: %1$s</string> + <string name="bnet_dl_agent_error">Помилка Blizzard %1$s</string> + <string name="bnet_update">Оновити</string> <string name="bnet_store">Ігри Blizzard</string> <string name="stores_resume_install">Продовжити встановлення</string> <string name="stores_dl_interrupted">Перервано</string> diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index b8a7da87a9..7a8194842c 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1976,6 +1976,13 @@ <string name="stores_play">Chơi</string> <string name="stores_install">Cài</string> <string name="bnet_open">Mở Battle.net</string> + <string name="bnet_dl_starting">Đang khởi động trình tải xuống của Blizzard…</string> + <string name="bnet_dl_waiting">Đang chờ Battle.net đóng…</string> + <string name="bnet_dl_queued">Đang chờ lượt tải Battle.net khác…</string> + <string name="bnet_dl_client_first">Mở Battle.net và đăng nhập một lần, sau đó cài trò chơi của nó tại đây.</string> + <string name="bnet_dl_failed">Trình tải xuống của Blizzard đã dừng: %1$s</string> + <string name="bnet_dl_agent_error">Lỗi Blizzard %1$s</string> + <string name="bnet_update">Cập nhật</string> <string name="bnet_store">Trò chơi Blizzard</string> <string name="stores_resume_install">Tiếp tục cài</string> <string name="stores_dl_interrupted">Bị gián đoạn</string> diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 2726014a0b..5e16b21607 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -2056,6 +2056,13 @@ <string name="stores_play">游玩</string> <string name="stores_install">安装</string> <string name="bnet_open">打开 Battle.net</string> + <string name="bnet_dl_starting">正在启动暴雪下载器…</string> + <string name="bnet_dl_waiting">正在等待 Battle.net 关闭…</string> + <string name="bnet_dl_queued">正在等待另一个 Battle.net 下载…</string> + <string name="bnet_dl_client_first">请先打开 Battle.net 并登录一次,然后在这里安装其游戏。</string> + <string name="bnet_dl_failed">暴雪下载器已停止:%1$s</string> + <string name="bnet_dl_agent_error">暴雪错误 %1$s</string> + <string name="bnet_update">更新</string> <string name="bnet_store">暴雪游戏</string> <string name="stores_resume_install">继续安装</string> <string name="stores_dl_interrupted">已中断</string> diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index cdcc40b76a..6ca43c17f2 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1979,6 +1979,13 @@ <string name="stores_play">開啟遊戲</string> <string name="stores_install">安裝</string> <string name="bnet_open">開啟 Battle.net</string> + <string name="bnet_dl_starting">正在啟動暴雪下載器…</string> + <string name="bnet_dl_waiting">正在等待 Battle.net 關閉…</string> + <string name="bnet_dl_queued">正在等待另一個 Battle.net 下載…</string> + <string name="bnet_dl_client_first">請先開啟 Battle.net 並登入一次,然後在這裡安裝其遊戲。</string> + <string name="bnet_dl_failed">暴雪下載器已停止:%1$s</string> + <string name="bnet_dl_agent_error">暴雪錯誤 %1$s</string> + <string name="bnet_update">更新</string> <string name="bnet_store">Blizzard 遊戲</string> <string name="stores_resume_install">繼續安裝</string> <string name="stores_dl_interrupted">已中斷</string> diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 43fb5e4434..77156849a5 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1979,6 +1979,13 @@ <string name="stores_play">執行</string> <string name="stores_install">安裝</string> <string name="bnet_open">開啟 Battle.net</string> + <string name="bnet_dl_starting">正在啟動暴雪下載器…</string> + <string name="bnet_dl_waiting">正在等待 Battle.net 關閉…</string> + <string name="bnet_dl_queued">正在等待另一個 Battle.net 下載…</string> + <string name="bnet_dl_client_first">請先開啟 Battle.net 並登入一次,然後在這裡安裝其遊戲。</string> + <string name="bnet_dl_failed">暴雪下載器已停止:%1$s</string> + <string name="bnet_dl_agent_error">暴雪錯誤 %1$s</string> + <string name="bnet_update">更新</string> <string name="bnet_store">Blizzard 遊戲</string> <string name="stores_resume_install">繼續安裝</string> <string name="stores_dl_interrupted">已中斷</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9fa3fe8caf..d260c3da88 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2094,6 +2094,13 @@ <string name="stores_play">Play</string> <string name="stores_install">Install</string> <string name="bnet_open">Open Battle.net</string> + <string name="bnet_dl_starting">Starting Blizzard\'s downloader…</string> + <string name="bnet_dl_waiting">Waiting for Battle.net to close…</string> + <string name="bnet_dl_queued">Waiting for the other Battle.net download…</string> + <string name="bnet_dl_client_first">Open Battle.net and sign in once, then install its games here.</string> + <string name="bnet_dl_failed">Blizzard\'s downloader stopped: %1$s</string> + <string name="bnet_dl_agent_error">Blizzard error %1$s</string> + <string name="bnet_update">Update</string> <string name="bnet_store">Blizzard games</string> <string name="stores_resume_install">Resume install</string> <string name="stores_dl_interrupted">Interrupted</string> diff --git a/app/src/test/java/com/droiddeck/launcher/stores/battlenet/BattleNetInstallTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/battlenet/BattleNetInstallTest.kt new file mode 100644 index 0000000000..9a907b3720 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/battlenet/BattleNetInstallTest.kt @@ -0,0 +1,75 @@ +package com.droiddeck.launcher.stores.battlenet + +import com.droiddeck.launcher.runtime.BattleNet +import com.droiddeck.launcher.stores.CatalogItem +import com.droiddeck.launcher.stores.Store +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import java.util.Locale + +class BattleNetInstallTest { + private val buildInfo = """ + Branch!STRING:0|Active!DEC:1|Build Key!HEX:16|CDN Key!HEX:16|Install Key!HEX:16|IM Size!DEC:4|Version!STRING:0|Product!STRING:0 + eu|0|11111111111111111111111111111111|db0583272ed15286569b5f24ce516876|||16.1.1.1|gryphon + us|1|e474008a3535d8ea978949a90d9873e6|db0583272ed15286569b5f24ce516876|||16.1.2.119725|gryphon + """.trimIndent() + + private val versions = """ + Region!STRING:0|BuildConfig!HEX:16|CDNConfig!HEX:16|KeyRing!HEX:16|BuildId!DEC:4|VersionsName!String:0|ProductConfig!HEX:16 + ## seqn = 4048130 + us|f00d008a3535d8ea978949a90d9873e6|db0583272ed15286569b5f24ce516876||119800|16.1.3.119800|f6a454799d25791e5a37a7547d75ce49 + eu|e474008a3535d8ea978949a90d9873e6|db0583272ed15286569b5f24ce516876||119725|16.1.2.119725|f6a454799d25791e5a37a7547d75ce49 + """.trimIndent() + + @Test fun theActiveRowGivesTheRegionAndBuildOnDisk() { + assertEquals("us" to "e474008a3535d8ea978949a90d9873e6", BattleNetInstall.buildKey(buildInfo)) + assertNull(BattleNetInstall.buildKey("Branch!STRING:0|Active!DEC:1\n")) + assertNull(BattleNetInstall.buildKey("Branch!STRING:0|Active!DEC:1|Build Key!HEX:16\nus|1|not-a-key\n")) + } + + @Test fun theLiveBuildIsReadForTheSameRegion() { + assertEquals("f00d008a3535d8ea978949a90d9873e6", BattleNetInstall.latestBuild(versions, "us")) + assertEquals("e474008a3535d8ea978949a90d9873e6", BattleNetInstall.latestBuild(versions, "eu")) + assertNull(BattleNetInstall.latestBuild(versions, "kr")) + assertNull(BattleNetInstall.latestBuild("", "us")) + } + + @Test fun theDeviceLanguagePicksABlizzardLocale() { + assertEquals("enUS", BattleNetInstall.locale(Locale.US)) + assertEquals("enGB", BattleNetInstall.locale(Locale.UK)) + assertEquals("enUS", BattleNetInstall.locale(Locale("en", "AU"))) + assertEquals("deDE", BattleNetInstall.locale(Locale.GERMANY)) + assertEquals("ptBR", BattleNetInstall.locale(Locale("pt", "BR"))) + assertEquals("ptPT", BattleNetInstall.locale(Locale("pt", "PT"))) + assertEquals("zhTW", BattleNetInstall.locale(Locale.forLanguageTag("zh-Hant-HK"))) + assertEquals("zhCN", BattleNetInstall.locale(Locale.SIMPLIFIED_CHINESE)) + assertEquals("enUS", BattleNetInstall.locale(Locale("nl", "NL"))) + } + + @Test fun theCountryIsSentInBothForms() { + assertEquals("DEU" to "DE", BattleNetInstall.country(Locale.GERMANY)) + assertEquals("USA" to "US", BattleNetInstall.country(Locale("en"))) + } + + @Test fun everyStoreTitleWithAProductInstallsHeadless() { + val products = BattleNet.TITLES.mapNotNull { it.product } + assertTrue(products.all { Regex("[a-z0-9_]{1,32}").matches(it) }) + assertTrue(BattleNetInstall.headless(CatalogItem(Store.BATTLENET, "gryphon", "Warcraft Rumble", null))) + assertEquals("hsb", BattleNetInstall.product("hs_beta")) + assertEquals("d3", BattleNetInstall.product("diablo3_enus")) + assertFalse(BattleNetInstall.headless(CatalogItem(Store.BATTLENET, "d3cn", "Diablo III", null))) + assertFalse(BattleNetInstall.headless(CatalogItem(Store.EPIC, "gryphon", "Warcraft Rumble", null))) + } + + @Test fun theAgentStatusPicksTheDownloadStep() { + assertEquals(BattleNetInstall.Step.PREPARING, BattleNetInstall.step(1008, 0, 0, 0)) + assertEquals(BattleNetInstall.Step.PREPARING, BattleNetInstall.step(1003, 500, 0, 0)) + assertEquals(BattleNetInstall.Step.DOWNLOADING, BattleNetInstall.step(1003, 500, 31405777, 6746574227)) + assertEquals(BattleNetInstall.Step.APPLYING, BattleNetInstall.step(1003, 500, 6746574227, 6746574227)) + assertEquals(BattleNetInstall.Step.APPLYING, BattleNetInstall.step(1003, 2000, 1, 9)) + assertEquals(BattleNetInstall.Step.APPLYING, BattleNetInstall.step(1004, 1000, 0, 0)) + } +} diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet index cf3e6ae85d..0552642b8e 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet @@ -67,6 +67,110 @@ GX_API_SETTING = re.compile(r"(?im)^[ \t]*SET[ \t]+gxApi[ \t].*$") GX_API_MARK = ".droiddeck-d3d11" STEAM_CLIENT = {"steam", "steamwebhelper"} LOG = os.path.join(CACHE, "battlenet.log") +AGENT_DIR = ("ProgramData", "Battle.net", "Agent") +AGENT_BUILD = re.compile(r"Agent\.(\d+)") +AGENT_PORT = re.compile(r"\d{2,5}") +AGENT_START = 90 +AGENT_HELPER = "agent.js" +AGENT_RUNTIME = "agent-runtime" +AGENT_LOG = "agent.log" +AGENT_LOG_LIMIT = 4 << 20 +HEADLESS = ["--backend", "headless", "-w", "640", "-h", "480"] +PRODUCT = re.compile(r"[a-z0-9_]{1,32}") +LOCALE = re.compile(r"[a-z]{2}[A-Z]{2}") +COUNTRY = re.compile(r"[A-Z]{3}") +REGION = re.compile(r"[A-Z]{2}") +REPORT = "BNET" +ETA_LIMIT = 30 * 86400 +DONE_STATE = 1004 +REPORTED = ("progress", "playable_progress", "download_rate", "download_remaining", "estimated_time_in_sec", "state", + "playable", "paused", "download_complete", "installed", "error") +AGENT_SCRIPT = r"""var a = WScript.Arguments, port = a(0), action = a(1), uid = a(2), product = a(3), dir = a(4); +var lang = a(5), country = a(6), region = a(7), out = a(8), token = ""; +var fso = new ActiveXObject("Scripting.FileSystemObject"); + +function save(name, text) { + var f = fso.CreateTextFile(out + name + ".tmp", true, true); + f.Write(text); + f.Close(); + if (fso.FileExists(out + name)) fso.DeleteFile(out + name); + fso.MoveFile(out + name + ".tmp", out + name); +} + +function call(method, path, body) { + var r = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); + r.SetTimeouts(10000, 10000, 30000, 30000); + r.Open(method, "http://127.0.0.1:" + port + path, false); + r.SetRequestHeader("User-Agent", "phoenix-agent/1.0"); + if (token) r.SetRequestHeader("Authorization", token); + r.Send(body || ""); + return r.ResponseText; +} + +function field(text, name) { + var m = new RegExp('"' + name + '"\\s*:\\s*"([^"]*)"').exec(text); + return m ? m[1] : ""; +} + +function install() { + var form = call("POST", "/install", '{"uid":"' + uid + '","instructions_patch_url":"http://' + zone + '.patch.battle.net:1119/' + + product + '","instructions_product":"NGDP","monitor_pid":12345,"priority":{"insert_at_head":true,"value":900}}'); + save(".form", form); + if (form.indexOf('"' + lang + '"') < 0) lang = "enUS"; + var locale = lang.toLowerCase(); + call("POST", "/install/" + uid, '{"account_country":"' + country + '","finalized":true,"game_dir":"' + dir + '","geo_ip_country":"' + + region + '","language":["' + locale + '"],"selected_asset_locale":"' + locale + '","selected_locale":"' + locale + + '","shortcut":"none","tome_torrent":""}'); + watch("/install/" + uid); +} + +function watch(path) { + var started = false; + for (var i = 0; ; i++) { + var s = call("GET", path); + save(".json", s); + if (/"error"\s*:\s*[1-9]/.test(s)) break; + var state = /"state"\s*:\s*(\d+)/.exec(s.replace(/"extended_status"\s*:\s*\{[^}]*\}/, "")), complete = /"download_complete"\s*:\s*true/.test(s); + state = state ? +state[1] : 0; + if (state == 1000 || state == 1003 || !complete) started = true; + if (started && (state == 1004 || complete && /"playable"\s*:\s*true/.test(s))) break; + if (!started && state == 1004 && i >= 20) break; + if (!started && i >= 180) { + if (/"playable"\s*:\s*true/.test(call("GET", "/game/" + uid))) break; + throw new Error("the agent did not start the " + action); + } + WScript.Sleep(1000); + } + save(".game", call("GET", "/game/" + uid)); +} + +function update() { + save(".form", call("POST", "/update", '{"uid":"' + uid + '","priority":{"insert_at_head":true,"value":900}}')); + watch("/update/" + uid); +} + +function uninstall() { + save(".json", call("POST", "/uninstall", '{"uid":"' + uid + '","run_compaction":true}')); + for (var i = 0; i < 900; i++) { + var s = call("GET", "/game/" + uid); + save(".game", s); + if (!/"installed"\s*:\s*true/.test(s)) break; + WScript.Sleep(1000); + } +} + +var zone = "us"; +try { + var agent = call("GET", "/agent"); + token = field(agent, "authorization"); + zone = field(agent, "region") || "us"; + if (!token) throw new Error("no authorization from the agent"); + if (action == "install") install(); else if (action == "update") update(); else uninstall(); +} catch (e) { + save(".error", e.message || "the agent stopped answering"); + WScript.Quit(1); +} +""" LOG_LIMIT = 512 << 10 @@ -933,6 +1037,227 @@ def install_game(root, uid): return open_client(root) +def agent_exe(root): + folder = os.path.join(drive_c(root), *AGENT_DIR) + try: + names = os.listdir(folder) + except OSError: + return None + builds = sorted(((int(m.group(1)), name) for name in names for m in [AGENT_BUILD.fullmatch(name)] if m), reverse=True) + for _, name in builds: + exe = os.path.join(folder, name, "Agent.exe") + if os.path.isfile(exe): + return exe + return None + + +def agent_port(root): + try: + with open(os.path.join(drive_c(root), *AGENT_DIR, "Agent.dat"), encoding="ascii", errors="replace") as f: + text = f.read().strip() + except OSError: + return None + return int(text) if AGENT_PORT.fullmatch(text) else None + + +def answers(port, timeout=2): + try: + conn = http.client.HTTPConnection("127.0.0.1", port, timeout=timeout) + try: + conn.request("GET", "/agent", headers={"User-Agent": "phoenix-agent/1.0"}) + conn.getresponse().read() + finally: + conn.close() + return True + except (OSError, http.client.HTTPException): + return False + + +def agent_env(): + env = proton_env() + env["PROTON_USE_XALIA"] = "0" + return env + + +def agent_failed(status, reason): + say(reason) + try: + with open(status.replace("\\", "/")[2:] + ".error", "w", encoding="utf-8") as f: + f.write(reason) + except OSError: + pass + + +def agent_serve(root, args, wait=None, poll=None): + exe = agent_exe(root) + if exe is None: + agent_failed(args[-1], "no Blizzard Agent in the Battle.net prefix") + return 3 + cmd = [PROTON_RUN, "--prefix", APP_ID, "--verb", "run"] + say("starting Blizzard's Agent on its own: %s" % exe) + try: + agent = subprocess.Popen(cmd + [exe, "--internalclienttools"], stdin=subprocess.DEVNULL, env=agent_env()) + except OSError as error: + say("%s: %s" % (PROTON_RUN, error)) + return 127 + deadline = time.monotonic() + (AGENT_START if wait is None else wait) + port = None + while time.monotonic() < deadline: + port = agent_port(root) + if port and answers(port): + break + if agent.poll() is not None and not any(program(argv) == AGENT for _, argv in wine_processes(os.path.join(prefix(root), "pfx"))): + agent_failed(args[-1], "the Agent exited before it answered") + return 4 + port = None + time.sleep(POLL if poll is None else poll) + if port is None: + agent_failed(args[-1], "the Agent did not answer in time") + return 4 + helper = os.path.join(CACHE, AGENT_HELPER) + with open(helper, "w", encoding="utf-8") as f: + f.write(AGENT_SCRIPT) + cscript = os.path.join(drive_c(root), "windows", "system32", "cscript.exe") + say("the Agent answers on port %d; %s %s" % (port, args[0], args[1])) + return subprocess.call(cmd + [cscript, "//nologo", "Z:" + helper.replace("/", "\\"), str(port)] + list(args), env=agent_env()) + + +def emit(kind, value=""): + print(("%s_%s %s" % (REPORT, kind, value)).rstrip(), flush=True) + + +def read_status(path): + try: + with open(path, "rb") as f: + data = f.read() + except OSError: + return None + for encoding in ("utf-16", "utf-8-sig"): + try: + return json.loads(data.decode(encoding)) + except (UnicodeDecodeError, ValueError): + continue + return None + + +def summary(status): + out = {key: status[key] for key in REPORTED if key in status} + for key in ("download_current", "download_total"): + value = status.get(key) + if isinstance(value, list) and value and isinstance(value[0], (int, float)): + out[key] = value[0] + phase = (status.get("extended_status") or {}).get("state") + if isinstance(phase, int): + out["phase"] = phase + eta = out.get("estimated_time_in_sec") + if not isinstance(eta, int) or not 0 <= eta <= ETA_LIMIT: + out.pop("estimated_time_in_sec", None) + return out + + +def agent_job(root, action, uid, product="", folder="", locale="enUS", country="USA", region="US", poll=None, wait=None): + pfx = os.path.join(prefix(root), "pfx") + if not installed(root) or agent_exe(root) is None: + emit("ERROR", "client") + return 3 + windows = "" + if action == "install": + if not folder.startswith("/") or any(c in folder for c in '"\\\n'): + emit("ERROR", "folder") + return 2 + try: + os.makedirs(folder, exist_ok=True) + except OSError as error: + say("%s not made: %s" % (folder, error)) + emit("ERROR", "folder") + return 2 + windows = "Z:" + folder + told = None + while True: + processes = wine_processes(pfx) + busy = bool(processes) and not idle(processes) + lock = None if busy else acquire() + if lock is not None: + break + state = "waiting" if busy else "queued" + if told != state: + say("%s; the %s of %s waits for it" % ("Battle.net or a game is open" if busy else "another Battle.net job holds the prefix", + action, uid)) + emit("STATE", state) + told = state + time.sleep(POLL if poll is None else poll) + with lock: + stop_leftovers(pfx) + emit("STATE", "starting") + base = os.path.join(CACHE, "agent-%s" % uid) + for suffix in (".json", ".game", ".form", ".error"): + try: + os.unlink(base + suffix) + except OSError: + pass + runtime = os.path.join(CACHE, AGENT_RUNTIME) + os.makedirs(runtime, mode=0o700, exist_ok=True) + env = agent_env() + for name in ("DISPLAY", "WAYLAND_DISPLAY"): + env.pop(name, None) + env["XDG_RUNTIME_DIR"] = runtime + cmd = ["gamescope"] + HEADLESS + ["--", os.path.abspath(sys.argv[0]), "agent-serve", action, uid, product or "-", + windows or "-", locale, country, region, "Z:" + base.replace("/", "\\")] + say("%s %s through the Agent: %s" % (action, uid, " ".join(cmd))) + output = os.path.join(CACHE, AGENT_LOG) + try: + if os.path.getsize(output) > AGENT_LOG_LIMIT: + os.replace(output, output + ".1") + except OSError: + pass + with open(output, "ab") as log: + child = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=log, stderr=log, env=env) + seen = None + while True: + done = child.poll() is not None + status = read_status(base + ".json") + if status is not None and action != "uninstall": + brief = summary(status) + if brief != seen: + emit("PROGRESS", json.dumps(brief, sort_keys=True)) + seen = brief + if done: + break + time.sleep(POLL if poll is None else poll) + leftovers = wine_processes(pfx) + if leftovers and idle(leftovers): + stop(leftovers) + game = read_status(base + ".game") or {} + status = read_status(base + ".json") or {} + try: + with open(base + ".error", "rb") as f: + data = f.read() + reason = data.decode("utf-16" if data[:2] in (b"\xff\xfe", b"\xfe\xff") else "utf-8", "replace").strip() \ + or "the agent stopped answering" + except OSError: + reason = None + code = status.get("error") + if reason is None and isinstance(code, int) and code > 0: + emit("ERROR", "agent %d" % code) + say("the %s of %s stopped: Agent error %d" % (action, uid, code)) + return 5 + if reason is None and action != "uninstall" and game.get("installed") is True \ + and (game.get("playable") is True or status.get("state") == DONE_STATE): + binary = ((game.get("binaries") or {}).get("game") or {}).get("relative_path", "") + emit("DONE", json.dumps({"install_dir": game.get("install_dir", windows), "exe": binary, + "version": game.get("local_version", "")}, sort_keys=True)) + say("%s %s in %s" % (uid, "updated" if action == "update" else "installed", game.get("install_dir", windows))) + return 0 + if reason is None and action == "uninstall" and game.get("installed") is not True: + emit("DONE", json.dumps({"uninstalled": uid})) + say("%s uninstalled" % uid) + return 0 + reason = reason or "exit %d" % child.returncode + say("the %s of %s stopped: %s" % (action, uid, reason)) + emit("ERROR", "stopped %s" % reason.replace("\n", " ")) + return 1 + + def main(argv): global LIBRARY argv = list(argv) @@ -943,10 +1268,18 @@ def main(argv): LIBRARY = os.path.normpath(argv[1]) argv = argv[2:] action = argv[0] if argv else "open" + if action == "agent-serve" and len(argv) == 9: + return agent_serve(steam_root(), argv[1:]) + if action == "agent-install" and len(argv) == 7 and GAME_UID.fullmatch(argv[1]) and PRODUCT.fullmatch(argv[2]) and argv[3].startswith("/") \ + and LOCALE.fullmatch(argv[4]) and COUNTRY.fullmatch(argv[5]) and REGION.fullmatch(argv[6]): + return agent_job(steam_root(), "install", argv[1], argv[2], os.path.normpath(argv[3]), argv[4], argv[5], argv[6]) + if action in ("agent-update", "agent-uninstall") and len(argv) == 2 and GAME_UID.fullmatch(argv[1]): + return agent_job(steam_root(), action[len("agent-"):], argv[1]) launching = action == "launch" and len(argv) == 2 and CODE.fullmatch(argv[1]) getting = action == "install-game" and len(argv) == 2 and GAME_UID.fullmatch(argv[1]) if not (launching or getting) and (action not in ("open", "install", "status") or len(argv) > 1): - say("usage: droiddeck-battlenet [--library DIR] [open | install | status | launch CODE | install-game ID]") + say("usage: droiddeck-battlenet [--library DIR] [open | install | status | launch CODE | install-game ID | " + "agent-install ID PRODUCT DIR LOCALE COUNTRY REGION | agent-update ID | agent-uninstall ID]") return 2 root = steam_root() if action == "status": diff --git a/tools/tests/test_battlenet.py b/tools/tests/test_battlenet.py index 2a953dfe7f..b44d7b424a 100644 --- a/tools/tests/test_battlenet.py +++ b/tools/tests/test_battlenet.py @@ -1,3 +1,4 @@ +import contextlib import json import os from pathlib import Path @@ -1064,5 +1065,183 @@ class HandOverTest(Harness): self.assertEqual(self.calls, []) +class AgentTest(Temp): + def test_the_newest_agent_build_and_its_port_are_found(self): + root = str(self.tmp / "Steam") + agent = "Steam/steamapps/compatdata/%s/pfx/drive_c/ProgramData/Battle.net/Agent" % BNET["APP_ID"] + self.write(agent + "/Agent.9100/Agent.exe", b"MZ") + self.write(agent + "/Agent.9824/Agent.exe", b"MZ") + os.makedirs(self.tmp / agent / "Agent.9999") + self.write(agent + "/Agent.dat", "39211\n") + self.assertTrue(BNET["agent_exe"](root).endswith("Agent.9824/Agent.exe")) + self.assertEqual(BNET["agent_port"](root), 39211) + self.write(agent + "/Agent.dat", "not a port") + self.assertIsNone(BNET["agent_port"](root)) + + def test_progress_keeps_the_fields_the_app_reads(self): + status = {"progress": 0.35, "download_current": [2397, 0, 0], "download_total": [6746, 0, 0], "download_rate": 34076920, + "state": 1003, "build_config_kv_pairs": {"x": "y"}, "regional_version_info": {}, "estimated_time_in_sec": 120, + "extended_status": {"current": 1, "state": 500, "total": 2, "unit_type": "bytes"}} + self.assertEqual(BNET["summary"](status), {"progress": 0.35, "download_current": 2397, "download_total": 6746, + "download_rate": 34076920, "state": 1003, "estimated_time_in_sec": 120, "phase": 500}) + + def test_an_unknown_time_left_is_not_reported(self): + for eta in (18446744073709551615, -1, 1.5): + with self.subTest(eta): + self.assertNotIn("estimated_time_in_sec", BNET["summary"]({"estimated_time_in_sec": eta})) + + def test_the_driver_script_reads_its_arguments_in_the_order_they_are_passed(self): + script = BNET["AGENT_SCRIPT"] + self.assertIn("port = a(0), action = a(1), uid = a(2), product = a(3), dir = a(4)", script) + self.assertIn("lang = a(5), country = a(6), region = a(7), out = a(8)", script) + self.assertIn('"--internalclienttools"', (BIN / "droiddeck-battlenet").read_text()) + + +class AgentJobTest(Harness): + def setUp(self): + super().setUp() + self.lines = [] + self.files = {} + self.started = [] + self.envs = [] + test = self + + class Child: + def __init__(self, cmd, **kwargs): + test.started.append(cmd) + test.envs.append(kwargs.get("env") or {}) + base = cmd[-1][2:].replace("\\", "/") + for suffix, value in test.files.items(): + with open(base + suffix, "wb") as f: + f.write(value.encode("utf-16")) + self.returncode = 0 + + def poll(self): + return 0 + + patcher = mock.patch.dict(BNET, {"emit": lambda kind, value="": self.lines.append((kind, value)), + "stop_leftovers": lambda pfx: True, "CACHE": str(self.tmp / "cache")}) + patcher.start() + self.addCleanup(patcher.stop) + popen = mock.patch.object(BNET["subprocess"], "Popen", Child) + popen.start() + self.addCleanup(popen.stop) + + def install(self): + super().install() + self.write("Steam/steamapps/compatdata/%s/pfx/drive_c/ProgramData/Battle.net/Agent/Agent.9824/Agent.exe" % BNET["APP_ID"], b"MZ") + + def test_a_game_downloads_headless_and_reports_where_it_landed(self): + self.install() + folder = str(self.tmp / "Games/Battle.net/Warcraft Rumble") + self.files = { + ".json": json.dumps({"progress": 1.0, "download_complete": True, "state": 1004, "download_current": [6746, 0, 0], + "download_total": [6746, 0, 0]}), + ".game": json.dumps({"installed": True, "install_dir": "Z:" + folder, "local_version": "16.1.2.119725", + "binaries": {"game": {"relative_path": "WarcraftRumble.exe"}}}), + } + code = BNET["agent_job"](self.root, "install", "gryphon", "gryphon", folder, "enUS", "USA", "US", poll=0) + self.assertEqual(code, 0) + self.assertTrue(os.path.isdir(folder)) + cmd = self.started[0] + self.assertEqual(cmd[:6], ["gamescope", "--backend", "headless", "-w", "640", "-h"]) + self.assertEqual(cmd[cmd.index("--") + 2:-1], ["agent-serve", "install", "gryphon", "gryphon", "Z:" + folder, "enUS", "USA", "US"]) + self.assertEqual([kind for kind, _ in self.lines], ["STATE", "PROGRESS", "DONE"]) + self.assertEqual(json.loads(self.lines[-1][1]), {"install_dir": "Z:" + folder, "exe": "WarcraftRumble.exe", "version": "16.1.2.119725"}) + + def test_an_agent_error_is_reported_with_its_code(self): + self.install() + self.files = {".json": json.dumps({"error": 2421, "progress": 0.0})} + self.assertEqual(BNET["agent_job"](self.root, "install", "fenris", "fenris", str(self.tmp / "D4"), "enUS", "USA", "US", poll=0), 5) + self.assertEqual(self.lines[-1], ("ERROR", "agent 2421")) + + def test_a_driver_failure_is_reported_with_its_reason(self): + self.install() + self.files = {".error": "the agent stopped answering"} + self.assertEqual(BNET["agent_job"](self.root, "update", "wow", poll=0), 1) + self.assertEqual(self.lines[-1], ("ERROR", "stopped the agent stopped answering")) + + def test_an_update_reports_the_new_version(self): + self.install() + self.files = {".json": json.dumps({"progress": 1.0}), + ".game": json.dumps({"installed": True, "playable": True, "install_dir": "Z:/g", "local_version": "2"})} + self.assertEqual(BNET["agent_job"](self.root, "update", "gryphon", poll=0), 0) + self.assertIn("agent-serve", self.started[0]) + self.assertEqual(json.loads(self.lines[-1][1])["version"], "2") + + def test_a_game_left_unplayable_is_not_reported_as_done(self): + self.install() + self.files = {".json": json.dumps({"state": 1008, "download_complete": True, "progress": 0.0}), + ".game": json.dumps({"installed": True, "playable": False, "install_dir": "Z:/g", "local_version": "2"})} + self.assertEqual(BNET["agent_job"](self.root, "update", "gryphon", poll=0), 1) + self.assertEqual(self.lines[-1][0], "ERROR") + + def test_the_driver_only_stops_once_the_agent_has_really_run(self): + script = BNET["AGENT_SCRIPT"] + self.assertIn("if (started && (state == 1004 || complete && /\"playable\"\\s*:\\s*true/.test(s))) break;", script) + self.assertNotIn('"progress"', script) + + def test_an_uninstall_is_done_once_the_agent_no_longer_lists_it(self): + self.install() + self.files = {".json": json.dumps({}), ".game": json.dumps({"installed": False})} + self.assertEqual(BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0), 0) + self.assertEqual(self.lines[-1], ("DONE", json.dumps({"uninstalled": "gryphon"}))) + + def test_a_large_agent_log_is_rotated_before_a_job(self): + self.install() + os.makedirs(self.tmp / "cache") + log = self.tmp / "cache" / "agent.log" + log.write_bytes(b"x" * (BNET["AGENT_LOG_LIMIT"] + 1)) + self.files = {".game": json.dumps({"installed": False})} + BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0) + self.assertEqual((self.tmp / "cache" / "agent.log.1").stat().st_size, BNET["AGENT_LOG_LIMIT"] + 1) + self.assertEqual(log.stat().st_size, 0) + + def test_it_queues_behind_another_battle_net_job(self): + self.install() + self.files = {".game": json.dumps({"installed": False})} + locks = iter([None, contextlib.nullcontext()]) + with mock.patch.dict(BNET, {"acquire": lambda *a: next(locks)}): + self.assertEqual(BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0), 0) + self.assertEqual(self.lines[:2], [("STATE", "queued"), ("STATE", "starting")]) + + def test_without_battle_net_nothing_starts(self): + self.assertEqual(BNET["agent_job"](self.root, "install", "gryphon", "gryphon", str(self.tmp / "g"), "enUS", "USA", "US", poll=0), 3) + self.assertEqual(self.lines, [("ERROR", "client")]) + self.assertEqual(self.started, []) + + def test_it_waits_while_battle_net_or_a_game_is_open(self): + self.install() + self.states = [self.clients() + [(40, self.GAME)], [(40, self.GAME)], []] + self.files = {".game": json.dumps({"installed": False})} + self.assertEqual(BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0), 0) + self.assertEqual(self.lines[0], ("STATE", "waiting")) + self.assertEqual(self.lines[1], ("STATE", "starting")) + + def test_gamescope_gets_no_display_but_the_agent_keeps_the_one_gamescope_gives_it(self): + self.install() + os.environ.update(DISPLAY=":5", WAYLAND_DISPLAY="wayland-1") + self.files = {".game": json.dumps({"installed": False})} + BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0) + self.assertNotIn("DISPLAY", self.envs[0]) + self.assertNotIn("WAYLAND_DISPLAY", self.envs[0]) + self.assertEqual(self.envs[0]["PROTON_USE_XALIA"], "0") + os.environ["DISPLAY"] = ":0" + self.assertEqual(BNET["agent_env"]()["DISPLAY"], ":0") + + def test_only_valid_arguments_start_a_job(self): + calls = [] + with mock.patch.dict(BNET, {"agent_job": lambda *a, **k: calls.append(a[1:]) or 0}): + for argv in (["agent-install", "gryphon", "gryphon", "relative/dir", "enUS", "USA", "US"], + ["agent-install", "gryphon", "Gry phon", "/g", "enUS", "USA", "US"], + ["agent-install", "gryphon", "gryphon", "/g", "english", "USA", "US"], + ["agent-update"], ["agent-uninstall", "Gryphon"]): + with self.subTest(argv): + self.assertEqual(BNET["main"](argv), 2) + self.assertEqual(BNET["main"](["agent-install", "gryphon", "gryphon", "/g/../g/Rumble", "enUS", "USA", "US"]), 0) + self.assertEqual(BNET["main"](["agent-update", "wow_classic"]), 0) + self.assertEqual(calls, [("install", "gryphon", "gryphon", "/g/Rumble", "enUS", "USA", "US"), ("update", "wow_classic")]) + + if __name__ == "__main__": unittest.main()