mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cf0a7e43f |
No files matched your search
@@ -329,8 +329,8 @@ object BwrapSpawner {
|
||||
|
||||
private fun zypakShims(binds: List<Bind>, root: File, dir: File): List<Bind> {
|
||||
val wrappers = listOf("/app/bin/zypak-wrapper.sh", "/app/bin/zypak-wrapper").filter { guest ->
|
||||
val host = File(hostPath(binds, root.path, guest))
|
||||
host.isFile && !Files.isSymbolicLink(host.toPath())
|
||||
val host = File(hostPath(binds, root.path, guest)).toPath()
|
||||
Files.isRegularFile(host, java.nio.file.LinkOption.NOFOLLOW_LINKS) || Files.isSymbolicLink(host)
|
||||
}
|
||||
if (wrappers.isEmpty()) return emptyList()
|
||||
val shim = File(dir, "zypak-wrapper")
|
||||
|
||||
@@ -117,20 +117,19 @@ object EaApi {
|
||||
return list to next
|
||||
}
|
||||
|
||||
internal fun ownedVariables(next: String): JSONObject = JSONObject()
|
||||
.put("isMac", false)
|
||||
.put("limit", 100)
|
||||
.put("next", next)
|
||||
.put("type", JSONArray().put("DIGITAL_FULL_GAME").put("PACKAGED_FULL_GAME"))
|
||||
.put("storefronts", JSONArray().put("EA").put("EPIC"))
|
||||
.put("platforms", JSONArray().put("PC"))
|
||||
|
||||
fun owned(token: String): List<OwnedProduct> {
|
||||
val out = ArrayList<OwnedProduct>()
|
||||
var next: String? = "0"
|
||||
var guard = 0
|
||||
while (next != null && guard++ < 50) {
|
||||
val (items, after) = parseOwned(call(token, "getPreloadedOwnedGames", ownedVariables(next)))
|
||||
val variables = JSONObject()
|
||||
.put("isMac", false)
|
||||
.put("limit", 100)
|
||||
.put("next", next)
|
||||
.put("type", JSONArray().put("DIGITAL_FULL_GAME").put("PACKAGED_FULL_GAME"))
|
||||
.put("storefronts", JSONArray().put("EA"))
|
||||
.put("platforms", JSONArray().put("PC"))
|
||||
val (items, after) = parseOwned(call(token, "getPreloadedOwnedGames", variables))
|
||||
out += items
|
||||
next = after?.takeIf { it != next && items.isNotEmpty() }
|
||||
}
|
||||
|
||||
@@ -263,8 +263,26 @@ class BwrapSpawnerPlanTest {
|
||||
val shim = plan.binds.single { it.guest == "/app/bin/zypak-wrapper.sh" }
|
||||
assertTrue(shim.host.startsWith(dir.path))
|
||||
assertTrue(File(shim.host).readText().contains("exec \"\$program\" --no-sandbox \"\$@\""))
|
||||
assertFalse(plan.binds.any { it.guest == "/app/bin/zypak-wrapper" })
|
||||
assertEquals(shim.host, plan.binds.single { it.guest == "/app/bin/zypak-wrapper" }.host)
|
||||
assertTrue(File(app, "bin/zypak-wrapper.sh").readText().contains("zypak-helper"))
|
||||
assertEquals("/app/bin/zypak-wrapper.sh", Files.readSymbolicLink(File(app, "bin/zypak-wrapper").toPath()).toString())
|
||||
}
|
||||
|
||||
@Test fun zypakWrapperLinkThatDoesNotResolveOnTheHostGetsTheShim() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val app = File(runtime, "app").apply { File(this, "bin").mkdirs() }
|
||||
File(app, "bin/zypak-wrapper.sh").writeText("#!/usr/bin/bash\nexec zypak-helper host - \"\$@\"\n")
|
||||
val dangling = java.nio.file.Paths.get(LinuxRuntime.rootDir(context).path, "app/bin/zypak-wrapper.sh")
|
||||
Files.createSymbolicLink(File(app, "bin/zypak-wrapper").toPath(), dangling)
|
||||
val plan = BwrapSpawner.plan(context, request(
|
||||
op("t" to "bind", "src" to "/runtime-files/app", "dest" to "/app", "ro" to true),
|
||||
), dir)
|
||||
|
||||
assertFalse(Files.exists(dangling))
|
||||
val shim = plan.binds.single { it.guest == "/app/bin/zypak-wrapper" }
|
||||
assertTrue(shim.host.startsWith(dir.path))
|
||||
assertTrue(File(shim.host).readText().contains("exec \"\$program\" --no-sandbox \"\$@\""))
|
||||
assertEquals(shim.host, plan.binds.single { it.guest == "/app/bin/zypak-wrapper.sh" }.host)
|
||||
}
|
||||
|
||||
@Test fun appsWithoutZypakKeepTheirFiles() {
|
||||
|
||||
@@ -298,14 +298,6 @@ class EaTest {
|
||||
assertNotNull(EaApi.query("getPreloadedOwnedGames"))
|
||||
}
|
||||
|
||||
@Test fun ownedGamesIncludeEpicCopiesTheEaAppInstallsButNotSteamCopies() {
|
||||
val variables = EaApi.ownedVariables("0")
|
||||
val storefronts = variables.getJSONArray("storefronts").let { a -> (0 until a.length()).map { a.getString(it) } }
|
||||
assertEquals(listOf("EA", "EPIC"), storefronts)
|
||||
assertEquals("0", variables.getString("next"))
|
||||
assertEquals("PC", variables.getJSONArray("platforms").getString(0))
|
||||
}
|
||||
|
||||
@Test fun launcherReadsTheSessionFileOnce() {
|
||||
val text = StoreLaunch.launcherText(StoreGameSidecar(Store.EA, "Origin.OFR.1", "Game", exe = "bin/Game.exe", args = listOf("-dx12")))
|
||||
assertTrue(text.contains("for /f \"usebackq tokens=1,* delims==\" %%a in (\"%~dp0.droiddeck-ea-env\") do set \"%%a=%%b\""))
|
||||
|
||||
Reference in new issue
Block a user