mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Merge branch 'main' into fix/mali-g615-venus-shader-crash
This commit is contained in:
23 files changed
+330
-64
No files matched your search
@@ -55,7 +55,7 @@ jobs:
|
||||
jq -r --arg n "$2" '.assets // [] | .[] | select(.name == $n) | .digest // empty'
|
||||
}
|
||||
commit=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$BUILD_RUN" --jq .head_sha 2>/dev/null || echo "$GITHUB_SHA")
|
||||
for name in proot directaudio tracking xbox comet butler powervr ubisoft; do
|
||||
for name in proot directaudio tracking xbox comet butler powervr ubisoft rockstar dirt; do
|
||||
file="packs/$name.tar.zst"
|
||||
[ -f "$file" ] || { echo "::error::$name.tar.zst is missing from Build APK run $BUILD_RUN"; exit 1; }
|
||||
sha=$(sha256sum "$file" | cut -d' ' -f1)
|
||||
|
||||
+1
-1
@@ -36,4 +36,4 @@ __pycache__/
|
||||
app/src/main/assets/directaudio/
|
||||
app/src/main/assets/hybris/
|
||||
/tools/vr/out/
|
||||
app/src/main/resources/rockstar/helpers/
|
||||
app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar/
|
||||
+2
-2
@@ -93,7 +93,7 @@ def trackingPack = rootProject.file('tools/packs/tracking/release.env').readLine
|
||||
def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines()
|
||||
.findAll { it.contains('=') && !it.startsWith('#') }
|
||||
.collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] }
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft'].collectEntries { name ->
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt'].collectEntries { name ->
|
||||
def pack = file("build/packs/${name}.tar.zst")
|
||||
if (!pack.isFile()) {
|
||||
if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
@@ -206,7 +206,7 @@ android {
|
||||
}
|
||||
|
||||
androidResources {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<dir>directaudio:<dir>hybris'
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>droiddeck-xbox:<dir>droiddeck-comet:<dir>droiddeck-ubisoft:<dir>droiddeck-rockstar:<dir>droiddeck-dirt:<dir>directaudio:<dir>hybris'
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
|
||||
@@ -84,12 +84,15 @@ class App : Application() {
|
||||
if (com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app).isDirectory) {
|
||||
com.droiddeck.launcher.core.AddonPack.PROOT.ensure(app)
|
||||
com.droiddeck.launcher.core.AddonPack.DIRECTAUDIO.ensure(app)
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureDirtStandIn(app)
|
||||
}
|
||||
if (com.droiddeck.launcher.stores.gog.GogComet.enabled(app)) com.droiddeck.launcher.core.AddonPack.COMET.ensure(app)
|
||||
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.XBOX) != null)
|
||||
com.droiddeck.launcher.core.AddonPack.XBOX.ensure(app)
|
||||
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.UBISOFT) != null)
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureUbisoftService(app)
|
||||
if (com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, com.droiddeck.launcher.stores.Store.ROCKSTAR) != null)
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureRockstarService(app)
|
||||
com.droiddeck.launcher.handtracking.HandTracking.load(app)
|
||||
}.onFailure { android.util.Log.w("App", "add-on pack prefetch failed", it) }
|
||||
}, "addon-packs").start()
|
||||
|
||||
@@ -2589,7 +2589,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
runCatching { com.droiddeck.launcher.runtime.RuntimeInstallService.start(this, release) }
|
||||
val ok = com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.install(this, release,
|
||||
progressFor(RUNTIME_LINES, release.size / 1_000_000))
|
||||
if (ok) return null
|
||||
if (ok) {
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureDirtStandIn(this)
|
||||
return null
|
||||
}
|
||||
SessionEvents.record("runtime.failed", mapOf("step" to "install", "reason" to com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.installError()))
|
||||
return getString(R.string.session_runtime_install_failed)
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ object AgentChats {
|
||||
internal fun encode(entry: Entry): String = when (entry) {
|
||||
is Entry.Asked -> JSONObject().put("asked", entry.text).apply { if (entry.files.isNotEmpty()) put("files", JSONArray(entry.files)) }
|
||||
is Entry.Said -> JSONObject().put("said", entry.text)
|
||||
is Entry.Notice -> JSONObject().put("notice", entry.text)
|
||||
is Entry.Thought -> JSONObject().put("thought", entry.text)
|
||||
is Entry.Result -> JSONObject().put("result", entry.id).put("output", entry.output).put("failed", entry.failed)
|
||||
is Entry.Used -> JSONObject().put("used", entry.tool).put("detail", entry.detail).put("id", entry.id).put("input", entry.input)
|
||||
@@ -119,6 +120,7 @@ object AgentChats {
|
||||
private fun decode(o: JSONObject): Entry? = when {
|
||||
o.has("asked") -> Entry.Asked(o.getString("asked"), o.optJSONArray("files")?.let { a -> (0 until a.length()).map { a.getString(it) } }.orEmpty())
|
||||
o.has("said") -> Entry.Said(o.getString("said"))
|
||||
o.has("notice") -> Entry.Notice(o.getString("notice"))
|
||||
o.has("thought") -> Entry.Thought(o.getString("thought"))
|
||||
o.has("used") -> Entry.Used(o.optString("id"), o.getString("used"), o.optString("detail"), o.optString("input"),
|
||||
if (o.has("output")) o.optString("output") else null, o.optBoolean("failed"), o.optString("parent"))
|
||||
|
||||
@@ -29,6 +29,7 @@ object AgentHost {
|
||||
sealed interface Entry {
|
||||
data class Asked(val text: String, val files: List<String> = emptyList()) : Entry
|
||||
data class Said(val text: String) : Entry
|
||||
data class Notice(val text: String) : Entry
|
||||
data class Thought(val text: String) : Entry
|
||||
/**
|
||||
* A tool call; [output] stays null until its result arrives. [parent] is the subagent call it was made under, if any.
|
||||
@@ -130,7 +131,12 @@ object AgentHost {
|
||||
var lab by mutableStateOf<LabProgress?>(null)
|
||||
private set
|
||||
|
||||
private class Turn(val process: Process, val pid: Int, val stdin: java.io.OutputStream? = null)
|
||||
private class Turn(val process: Process, val pid: Int, val stdin: java.io.OutputStream? = null) {
|
||||
var writingGeneration: Int? = null
|
||||
var exitStatus: Int? = null
|
||||
var costs: AgentCostTracker? = null
|
||||
var clearingCosts = false
|
||||
}
|
||||
|
||||
private val main = Handler(Looper.getMainLooper())
|
||||
private var turn: Turn? = null
|
||||
@@ -301,7 +307,7 @@ object AgentHost {
|
||||
live = ""
|
||||
liveThinking = ""
|
||||
turnStarted = SystemClock.elapsedRealtime()
|
||||
AgentHostService.start(app)
|
||||
AgentHostService.start(app)?.let { serviceWarning(app, it) }
|
||||
val current = harness
|
||||
val prompt = AgentAttachments.prompt(message, attached)
|
||||
turnPlanned = plan && current.plans
|
||||
@@ -314,14 +320,19 @@ object AgentHost {
|
||||
if (kept != null && line != null && sessionKey == key && kept.process.isAlive) {
|
||||
main.removeCallbacks(reap)
|
||||
turn = kept
|
||||
kept.writingGeneration = gen
|
||||
kept.clearingCosts = prompt == "/clear"
|
||||
Thread({
|
||||
val written = runCatching { synchronized(kept) { kept.stdin?.apply { write((line + "\n").toByteArray()); flush() } != null } }.getOrDefault(false)
|
||||
// The process died between turns: the same message goes to a new one, which resumes the conversation.
|
||||
if (!written) main.post {
|
||||
main.post {
|
||||
if (kept.writingGeneration == gen) kept.writingGeneration = null
|
||||
if (generation == gen && session === kept) {
|
||||
dropSession()
|
||||
turn = null
|
||||
spawn(app, gen, current, current.turn(prompt, conversation, options), line, key)
|
||||
if (!written) {
|
||||
dropSession()
|
||||
turn = null
|
||||
spawn(app, gen, current, current.turn(prompt, conversation, options), line, key)
|
||||
} else kept.exitStatus?.let { processExited(app, kept, current, it) }
|
||||
}
|
||||
}
|
||||
}, "agent-input").start()
|
||||
@@ -346,7 +357,9 @@ object AgentHost {
|
||||
main.post { if (generation == gen) finish(app, e.message ?: "could not start") }
|
||||
return@Thread
|
||||
}
|
||||
val started = Turn(child, AgentProcesses.pidOf(child), if (line != null) child.outputStream else null)
|
||||
val started = Turn(child, AgentProcesses.pidOf(child), if (line != null) child.outputStream else null).apply {
|
||||
if (current === ClaudeCode && line != null) costs = AgentCostTracker()
|
||||
}
|
||||
OrphanReaper.keep(started.pid)
|
||||
main.post {
|
||||
if (generation == gen && state == State.WORKING && turn == null) {
|
||||
@@ -375,20 +388,34 @@ object AgentHost {
|
||||
val status = runCatching { child.waitFor() }.getOrDefault(-1)
|
||||
OrphanReaper.release(started.pid)
|
||||
main.post {
|
||||
if (session === started) { session = null; main.removeCallbacks(reap) }
|
||||
if (turn === started) {
|
||||
turn = null
|
||||
if (state == State.WORKING) finish(app, app.getString(R.string.agent_exited, current.name, status))
|
||||
}
|
||||
if (started.writingGeneration != null) started.exitStatus = status
|
||||
else processExited(app, started, current, status)
|
||||
}
|
||||
}, "agent-output").start()
|
||||
}
|
||||
|
||||
private fun processExited(app: Context, exited: Turn, current: AgentHarness, status: Int) {
|
||||
if (session === exited) {
|
||||
session = null
|
||||
launchedBackground = false
|
||||
main.removeCallbacks(reap)
|
||||
AgentHostService.backgroundDone(app)
|
||||
}
|
||||
if (turn === exited) {
|
||||
turn = null
|
||||
if (state == State.WORKING) finish(app, app.getString(R.string.agent_exited, current.name, status))
|
||||
}
|
||||
}
|
||||
|
||||
private fun serviceWarning(app: Context, error: Throwable) {
|
||||
record(app, Entry.Notice("Unable to keep the agent running in the background: ${error.message ?: error.javaClass.simpleName}"))
|
||||
}
|
||||
|
||||
/** One event from the CLI, which may belong to a turn it started on its own once the user's has ended. */
|
||||
private fun handle(app: Context, from: Turn, event: AgentEvent) {
|
||||
if (event.background) {
|
||||
// A leftover task answered before the user's message is not the user's turn; one the CLI started is its own.
|
||||
if (background && state == State.WORKING) finish(app, event.backgroundError, usage = event.usage)
|
||||
if (background && state == State.WORKING) finish(app, event.backgroundError, usage = event.usage?.let { from.costs?.perTurn(it) ?: it })
|
||||
return
|
||||
}
|
||||
val content = event.text != null || event.thinking != null || event.entries.any { it !is Entry.Finished }
|
||||
@@ -401,9 +428,16 @@ object AgentHost {
|
||||
live = ""
|
||||
liveThinking = ""
|
||||
turnStarted = SystemClock.elapsedRealtime()
|
||||
AgentHostService.start(app)
|
||||
AgentHostService.start(app)?.let { serviceWarning(app, it) }
|
||||
}
|
||||
apply(app, event)
|
||||
val finished = event.entries.filterIsInstance<Entry.Finished>().firstOrNull()
|
||||
if (finished != null && state == State.WORKING && from.clearingCosts) {
|
||||
if (finished.error == null) from.costs?.reset()
|
||||
from.clearingCosts = false
|
||||
}
|
||||
val applied = if (finished != null && state == State.WORKING && event.usage != null)
|
||||
event.copy(usage = from.costs?.perTurn(event.usage) ?: event.usage) else event
|
||||
apply(app, applied)
|
||||
}
|
||||
|
||||
/** Ends the CLI process kept between turns, and with it whatever it still runs in the background. */
|
||||
@@ -531,11 +565,13 @@ object AgentHost {
|
||||
live = ""
|
||||
liveThinking = ""
|
||||
val held = if (context > 0) (usage ?: Usage(0, 0.0, 0, 0)).copy(context = context, window = window) else usage
|
||||
record(app, Entry.Finished(error, stopped, held, planned = turnPlanned && !stopped && error == null))
|
||||
state = State.IDLE
|
||||
unseen = true
|
||||
failed = error != null
|
||||
if (session != null && launchedBackground) AgentHostService.waitForBackground(app) else AgentHostService.stop(app)
|
||||
if (session != null && launchedBackground) {
|
||||
AgentHostService.waitForBackground(app)?.let { serviceWarning(app, it) }
|
||||
} else AgentHostService.stop(app)
|
||||
record(app, Entry.Finished(error, stopped, held, planned = turnPlanned && !stopped && error == null))
|
||||
// Claude Code now and then ends a resumed turn at once without reading the message; nothing
|
||||
// happened, so the message is sent once more.
|
||||
val asked = entries.lastOrNull { it is Entry.Asked } as? Entry.Asked
|
||||
@@ -781,3 +817,17 @@ internal fun choices(reply: String): Choices {
|
||||
val options = lines.subList(found.first + 1, found.last).map { it.trim().removePrefix("- ").removePrefix("* ").trim() }.filter { it.isNotEmpty() }
|
||||
return Choices(lines.subList(0, found.first).joinToString("\n").trimEnd(), options)
|
||||
}
|
||||
|
||||
internal class AgentCostTracker {
|
||||
private var previous = 0.0
|
||||
|
||||
fun reset() { previous = 0.0 }
|
||||
|
||||
fun perTurn(usage: AgentHost.Usage): AgentHost.Usage {
|
||||
val total = usage.costUsd
|
||||
if (total == 0.0 && previous > 0.0) return usage
|
||||
val delta = if (total >= previous) total - previous else total
|
||||
previous = total
|
||||
return usage.copy(costUsd = delta)
|
||||
}
|
||||
}
|
||||
@@ -42,15 +42,16 @@ class AgentHostService : Service() {
|
||||
/** Setup steps that keep the app alive while they run, besides the agent's turn. */
|
||||
private var setupSteps = 0
|
||||
|
||||
fun start(context: Context) {
|
||||
fun start(context: Context): Throwable? {
|
||||
if (started) { update(context); return null }
|
||||
lastText = null
|
||||
started = true
|
||||
runCatching { context.startForegroundService(Intent(context, AgentHostService::class.java)) }
|
||||
.onSuccess { awaiting++ }
|
||||
return runCatching { context.startForegroundService(Intent(context, AgentHostService::class.java)) }
|
||||
.onSuccess { started = true; awaiting++ }
|
||||
.exceptionOrNull()
|
||||
}
|
||||
|
||||
fun stop(context: Context) {
|
||||
if (setupSteps > 0) return
|
||||
if (setupSteps > 0 || waiting) return
|
||||
started = false
|
||||
if (awaiting == 0) context.stopService(Intent(context, AgentHostService::class.java))
|
||||
}
|
||||
@@ -61,9 +62,9 @@ class AgentHostService : Service() {
|
||||
*/
|
||||
@Volatile private var waiting = false
|
||||
|
||||
fun waitForBackground(context: Context) {
|
||||
fun waitForBackground(context: Context): Throwable? {
|
||||
waiting = true
|
||||
if (started) update(context) else start(context)
|
||||
return if (started) { update(context); null } else start(context)
|
||||
}
|
||||
|
||||
fun backgroundDone(context: Context) {
|
||||
|
||||
@@ -172,5 +172,8 @@ internal class AddonPack(
|
||||
listOf("runtime.tzst", "version.txt"))
|
||||
val UBISOFT = AddonPack("ubisoft", BuildConfig.PACK_UBISOFT_SHA256, BuildConfig.PACK_UBISOFT_SIZE,
|
||||
listOf("droiddeck-upc.exe"))
|
||||
val ROCKSTAR = AddonPack("rockstar", BuildConfig.PACK_ROCKSTAR_SHA256, BuildConfig.PACK_ROCKSTAR_SIZE,
|
||||
listOf("Launcher32.exe", "Launcher64.exe"))
|
||||
val DIRT = AddonPack("dirt", BuildConfig.PACK_DIRT_SHA256, BuildConfig.PACK_DIRT_SIZE, listOf("ws2_32.dll"))
|
||||
}
|
||||
}
|
||||
@@ -36,35 +36,60 @@ object SessionFiles {
|
||||
"etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop",
|
||||
)
|
||||
|
||||
private const val UBISOFT_SERVICE = "usr/local/lib/droiddeck-ubisoft/droiddeck-upc.exe"
|
||||
private val SERVICE_PACKS = mapOf(
|
||||
AddonPack.UBISOFT to "usr/local/lib/droiddeck-ubisoft",
|
||||
AddonPack.ROCKSTAR to "usr/local/lib/droiddeck-rockstar",
|
||||
AddonPack.DIRT to "usr/local/lib/droiddeck-dirt",
|
||||
)
|
||||
|
||||
/** Fetches the Ubisoft pack and, once it lands, stages the service so a running session gets it without restarting. */
|
||||
fun ensureUbisoftService(context: Context) {
|
||||
AddonPack.UBISOFT.ensure(context) { app ->
|
||||
fun ensureUbisoftService(context: Context) = ensureStoreService(context, AddonPack.UBISOFT)
|
||||
|
||||
fun ensureRockstarService(context: Context) = ensureStoreService(context, AddonPack.ROCKSTAR)
|
||||
|
||||
/** The DiRT 3 / DiRT Showdown ws2_32 stand-in; droiddeck-game-env applies it only when it is staged. */
|
||||
fun ensureDirtStandIn(context: Context) = ensureStoreService(context, AddonPack.DIRT)
|
||||
|
||||
private fun ensureStoreService(context: Context, pack: AddonPack) {
|
||||
pack.ensure(context) { app ->
|
||||
com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app).takeIf { it.isDirectory }
|
||||
?.let { stageUbisoftService(app, it, null) }
|
||||
?.let { stageStoreService(app, it, pack, null) }
|
||||
}
|
||||
}
|
||||
|
||||
/** Blocks until the store's service pack is installed and staged in [root]; false when it could not be fetched. */
|
||||
fun awaitStoreService(context: Context, store: String, root: File): Boolean {
|
||||
val pack = SERVICE_PACKS.keys.firstOrNull { it.name == store } ?: return false
|
||||
if (!pack.await(context)) return false
|
||||
return stageStoreService(context, root, pack, null)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun stageUbisoftService(context: Context, root: File, ledger: StageLedger?) {
|
||||
val pack = AddonPack.UBISOFT.takeIf { it.installed(context) }?.dir(context) ?: return
|
||||
val target = File(root, UBISOFT_SERVICE)
|
||||
if (ledger?.current(UBISOFT_SERVICE, target) == true) return
|
||||
val staged = File(target.parentFile, target.name + ".staged")
|
||||
var installed = false
|
||||
try {
|
||||
target.parentFile?.mkdirs()
|
||||
File(pack, "droiddeck-upc.exe").inputStream().use { input ->
|
||||
staged.outputStream().use { output -> FileUtils.copy(input, output) }
|
||||
private fun stageStoreService(context: Context, root: File, pack: AddonPack, ledger: StageLedger?): Boolean {
|
||||
val dir = pack.takeIf { it.installed(context) }?.dir(context) ?: return false
|
||||
val base = SERVICE_PACKS.getValue(pack)
|
||||
var all = true
|
||||
for (file in dir.listFiles().orEmpty().filter { it.isFile && it.name != AddonPack.COMPLETE }.sortedBy { it.name }) {
|
||||
val relative = "$base/${file.name}"
|
||||
val target = File(root, relative)
|
||||
if (ledger?.current(relative, target) == true) continue
|
||||
val staged = File(target.parentFile, target.name + ".staged")
|
||||
var installed = false
|
||||
try {
|
||||
target.parentFile?.mkdirs()
|
||||
file.inputStream().use { input ->
|
||||
staged.outputStream().use { output -> FileUtils.copy(input, output) }
|
||||
}
|
||||
installed = staged.setExecutable(true, false) && staged.renameTo(target)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "could not stage the ${pack.name} pack", e)
|
||||
} finally {
|
||||
if (!installed) staged.delete()
|
||||
}
|
||||
installed = staged.setExecutable(true, false) && staged.renameTo(target)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "could not stage the Ubisoft launcher service", e)
|
||||
} finally {
|
||||
if (!installed) staged.delete()
|
||||
if (installed) ledger?.staged(relative, target) else Log.e(TAG, "$relative NOT staged")
|
||||
all = all && installed
|
||||
}
|
||||
if (installed) ledger?.staged(UBISOFT_SERVICE, target) else Log.e(TAG, "$UBISOFT_SERVICE NOT staged")
|
||||
return all
|
||||
}
|
||||
|
||||
fun stage(context: Context, root: File, startsSession: Boolean = false) {
|
||||
@@ -73,8 +98,6 @@ object SessionFiles {
|
||||
GameEnvironmentStore.publish(context)
|
||||
WinComponents.publish(context)
|
||||
val files = arrayOf(
|
||||
"rockstar/helpers/Launcher32.exe" to "usr/local/lib/droiddeck-rockstar/Launcher32.exe",
|
||||
"rockstar/helpers/Launcher64.exe" to "usr/local/lib/droiddeck-rockstar/Launcher64.exe",
|
||||
"usr/local/bin/droiddeck-game-env" to "usr/local/bin/droiddeck-game-env",
|
||||
"usr/local/bin/droiddeck-game-debug" to "usr/local/bin/droiddeck-game-debug",
|
||||
"usr/local/bin/droiddeck-game-gpu" to "usr/local/bin/droiddeck-game-gpu",
|
||||
@@ -234,7 +257,6 @@ object SessionFiles {
|
||||
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
|
||||
"usr/local/lib/droiddeck-pipewire.tzst" to "usr/local/lib/droiddeck-pipewire.tzst",
|
||||
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
|
||||
"usr/local/lib/droiddeck-dirt/ws2_32.dll" to "usr/local/lib/droiddeck-dirt/ws2_32.dll",
|
||||
) + mangoapp + xclipse.map { it to it } + maliCompat + msitools.map { it to it } + vr + gpuLoad + fexPreloads).filter { (asset, _) ->
|
||||
val dir = asset.substringBeforeLast('/')
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
@@ -248,7 +270,7 @@ object SessionFiles {
|
||||
var installed = false
|
||||
try {
|
||||
target.parentFile?.mkdirs()
|
||||
(if (asset.startsWith("rockstar/")) requireNotNull(javaClass.getResourceAsStream("/$asset")) else context.assets.open("linuxfs/$asset")).use { input ->
|
||||
context.assets.open("linuxfs/$asset").use { input ->
|
||||
staged.outputStream().use { output -> FileUtils.copy(input, output) }
|
||||
}
|
||||
installed = staged.setExecutable(true, false) && staged.renameTo(target)
|
||||
@@ -290,7 +312,7 @@ object SessionFiles {
|
||||
}
|
||||
if (installed) ledger.staged(key, target) else Log.e(TAG, "DirectAudio $set/$relative NOT staged")
|
||||
}
|
||||
stageUbisoftService(context, root, ledger)
|
||||
for (pack in SERVICE_PACKS.keys) stageStoreService(context, root, pack, ledger)
|
||||
ledger.save()
|
||||
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
|
||||
val preload = StringBuilder("/usr/local/lib/libblsession.so\n")
|
||||
|
||||
@@ -80,6 +80,11 @@ object StoreLaunchRequests {
|
||||
lastLaunched = Store.ROCKSTAR to request.optString("id")
|
||||
com.droiddeck.launcher.stores.rockstar.RockstarLaunch.prepare(app, request.optString("id"))
|
||||
}.getOrElse { JSONObject().put("ok", false).put("reason", "error-" + it.javaClass.simpleName) }
|
||||
"store-service" -> runCatching {
|
||||
val root = com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app)
|
||||
if (com.droiddeck.launcher.session.SessionFiles.awaitStoreService(app, request.optString("store"), root)) JSONObject().put("ok", true)
|
||||
else JSONObject().put("ok", false).put("reason", "service-unavailable")
|
||||
}.getOrElse { JSONObject().put("ok", false).put("reason", "error-" + it.javaClass.simpleName) }
|
||||
"rockstar-exited" -> {
|
||||
if (lastLaunched == (Store.ROCKSTAR to request.optString("id"))) lastLaunched = null
|
||||
JSONObject().put("ok", true)
|
||||
|
||||
@@ -141,6 +141,7 @@ object RockstarAuth {
|
||||
StoreAccounts.clear(context.applicationContext, Store.ROCKSTAR)
|
||||
return "ticket"
|
||||
}
|
||||
com.droiddeck.launcher.session.SessionFiles.ensureRockstarService(context)
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ internal fun AgentEntry(
|
||||
if (reply.options.isNotEmpty()) AgentChoices(reply.options, answerable, onSent)
|
||||
}
|
||||
}
|
||||
is Entry.Notice -> Text(entry.text, color = colors.error, modifier = Modifier.padding(horizontal = 4.dp))
|
||||
is Entry.Thought -> AgentThought(entry.text, live = false)
|
||||
is Entry.Used -> if (entry.tool == "TodoWrite") AgentTodos(entry.input) else AgentToolCall(entry, running, children)
|
||||
is Entry.Result -> Unit
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.ContextWrapper
|
||||
import android.content.Intent
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class AgentHostServiceTest {
|
||||
private class ServiceContext : ContextWrapper(RuntimeEnvironment.getApplication()) {
|
||||
var stops = 0
|
||||
var reject = false
|
||||
override fun startForegroundService(service: Intent): ComponentName {
|
||||
if (reject) throw IllegalStateException("start rejected")
|
||||
return ComponentName(packageName, AgentHostService::class.java.name)
|
||||
}
|
||||
override fun stopService(service: Intent): Boolean { stops++; return true }
|
||||
}
|
||||
|
||||
@Test fun setupCompletionKeepsBackgroundWaitUntilItEnds() {
|
||||
val context = ServiceContext()
|
||||
AgentHostService.setupStarted(context)
|
||||
val service = Robolectric.buildService(AgentHostService::class.java).create().get()
|
||||
service.onStartCommand(Intent(context, AgentHostService::class.java), 0, 1)
|
||||
assertNull(AgentHostService.waitForBackground(context))
|
||||
AgentHostService.setupEnded(context)
|
||||
assertEquals(0, context.stops)
|
||||
AgentHostService.backgroundDone(context)
|
||||
assertEquals(1, context.stops)
|
||||
}
|
||||
|
||||
@Test fun rejectedForegroundStartIsReportedAndCanBeRetried() {
|
||||
val context = ServiceContext()
|
||||
context.reject = true
|
||||
assertNotNull(AgentHostService.start(context))
|
||||
context.reject = false
|
||||
assertNull(AgentHostService.start(context))
|
||||
val service = Robolectric.buildService(AgentHostService::class.java).create().get()
|
||||
service.onStartCommand(Intent(context, AgentHostService::class.java), 0, 1)
|
||||
AgentHostService.stop(context)
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,19 @@ class AgentHostTest {
|
||||
assertNull(event.backgroundError)
|
||||
}
|
||||
|
||||
@Test fun retainedClaudeCostsAreRecordedOncePerProcess() {
|
||||
val costs = AgentCostTracker()
|
||||
fun usage(cost: Double) = AgentHost.Usage(1, cost, 1, 1)
|
||||
assertEquals(0.05, costs.perTurn(usage(0.05)).costUsd, 0.000001)
|
||||
assertEquals(0.02, costs.perTurn(usage(0.07)).costUsd, 0.000001)
|
||||
assertEquals(0.0, costs.perTurn(usage(0.07)).costUsd, 0.000001)
|
||||
costs.reset()
|
||||
assertEquals(0.0, costs.perTurn(usage(0.0)).costUsd, 0.000001)
|
||||
assertEquals(0.07, costs.perTurn(usage(0.07)).costUsd, 0.000001)
|
||||
assertEquals(0.01, costs.perTurn(usage(0.01)).costUsd, 0.000001)
|
||||
assertEquals(0.07, AgentCostTracker().perTurn(usage(0.07)).costUsd, 0.000001)
|
||||
}
|
||||
|
||||
@Test fun aFailedTaskNotificationResultKeepsItsError() {
|
||||
val event = ClaudeCode.parse("""{"type":"result","is_error":true,"result":"API Error: overloaded","session_id":"s","usage":{"input_tokens":0,"output_tokens":0},"origin":{"kind":"task-notification"}}""")!!
|
||||
assertTrue(event.background)
|
||||
@@ -212,7 +225,7 @@ class AgentHostTest {
|
||||
AgentChats.start(file, "claude")
|
||||
AgentChats.appendConversation(file, "abc")
|
||||
val written = listOf(
|
||||
Entry.Asked("hi", listOf("/root/x.png")), Entry.Said("hello"), Entry.Thought("hm"), Entry.Used("t1", "Read", "/root/x", "{}"),
|
||||
Entry.Asked("hi", listOf("/root/x.png")), Entry.Said("hello"), Entry.Notice("service unavailable"), Entry.Thought("hm"), Entry.Used("t1", "Read", "/root/x", "{}"),
|
||||
Entry.Result("t1", "contents", false), Entry.Finished(null, usage = AgentHost.Usage(1, 0.5, 2, 3)), Entry.Finished("boom", stopped = true),
|
||||
Entry.Finished(null, usage = AgentHost.Usage(1, 0.5, 2, 3, context = 40_000, window = 200_000), planned = true),
|
||||
)
|
||||
@@ -222,7 +235,7 @@ class AgentHostTest {
|
||||
assertEquals("claude", loaded.harness)
|
||||
assertEquals("abc", loaded.conversation)
|
||||
assertEquals(listOf(
|
||||
Entry.Asked("hi", listOf("/root/x.png")), Entry.Said("hello"), Entry.Thought("hm"), Entry.Used("t1", "Read", "/root/x", "{}", "contents", false),
|
||||
Entry.Asked("hi", listOf("/root/x.png")), Entry.Said("hello"), Entry.Notice("service unavailable"), Entry.Thought("hm"), Entry.Used("t1", "Read", "/root/x", "{}", "contents", false),
|
||||
Entry.Finished(null, usage = AgentHost.Usage(1, 0.5, 2, 3)), Entry.Finished("boom", stopped = true),
|
||||
Entry.Finished(null, usage = AgentHost.Usage(1, 0.5, 2, 3, context = 40_000, window = 200_000), planned = true),
|
||||
), loaded.entries)
|
||||
@@ -231,6 +244,7 @@ class AgentHostTest {
|
||||
|
||||
@Test fun aTurnThatEndsWithNothingIsAnswerless() {
|
||||
assertTrue(AgentHost.answerless(listOf(Entry.Said("x"), Entry.Asked("go on"), Entry.Finished(null))))
|
||||
assertTrue(AgentHost.answerless(listOf(Entry.Asked("go on"), Entry.Notice("service unavailable"), Entry.Finished(null))))
|
||||
assertFalse(AgentHost.answerless(listOf(Entry.Asked("go on"), Entry.Said("ok"), Entry.Finished(null))))
|
||||
assertFalse(AgentHost.answerless(listOf(Entry.Asked("go on"), Entry.Finished("boom"))))
|
||||
assertFalse(AgentHost.answerless(listOf(Entry.Asked("go on"), Entry.Finished(null, stopped = true))))
|
||||
|
||||
@@ -433,7 +433,7 @@ if [[ "${DROIDDECK_SKIP_RUST:-0}" != 1 ]]; then
|
||||
CARGO_TARGET_DIR="${cache_dir}/ubisoft-target" bash tools/ubisoft-launcher/build.sh "${upc_out}"
|
||||
save_step ubisoft "${upc_key}" "${upc_out}"
|
||||
fi
|
||||
rockstar_out="${repo_root}/app/src/main/resources/rockstar/helpers"
|
||||
rockstar_out="${linuxfs_dir}/usr/local/lib/droiddeck-rockstar"
|
||||
rockstar_key=$(inputs_hash "windows-gnu" tools/rockstar-launcher/src tools/rockstar-launcher/Cargo.toml tools/rockstar-launcher/Cargo.lock tools/rockstar-launcher/build.sh)
|
||||
if ! restore_step rockstar "${rockstar_key}" "${rockstar_out}"; then
|
||||
command -v i686-w64-mingw32-gcc >/dev/null 2>&1 || { echo "i686-w64-mingw32-gcc is required for the Rockstar launcher service." >&2; exit 1; }
|
||||
|
||||
@@ -314,6 +314,7 @@ UBISOFT_DIR = "drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher"
|
||||
UBISOFT_WINDOWS_DIR = "C:\\Program Files (x86)\\Ubisoft\\Ubisoft Game Launcher\\"
|
||||
UBISOFT_INSTALLER_URL = "https://static3.cdn.ubi.com/orbit/launcher_installer/UbisoftConnectInstaller.exe"
|
||||
ROCKSTAR_SERVICE = Path("/usr/local/lib/droiddeck-rockstar")
|
||||
SERVICE_WAIT = 300.0
|
||||
ROCKSTAR_FOLDER = "drive_c/Program Files/Rockstar Games/Launcher"
|
||||
ROCKSTAR_TITLES = {"gta3": "Grand Theft Auto III", "gtavc": "Grand Theft Auto: Vice City", "gtasa": "GTA: San Andreas",
|
||||
"gta4": "Grand Theft Auto IV", "lanoire": "LANoireMTL"}
|
||||
@@ -446,6 +447,15 @@ def rockstar_runtime(folder, exe, compat_data, arch):
|
||||
return "installed"
|
||||
|
||||
|
||||
def fetch_service(service, store, launch_dir, ask_app=None):
|
||||
if service.is_file():
|
||||
return True
|
||||
if not launch_dir:
|
||||
return False
|
||||
answer = (ask_app or ask)(Path(launch_dir) / "stores", {"op": "store-service", "store": store}, timeout=SERVICE_WAIT)
|
||||
return isinstance(answer, dict) and bool(answer.get("ok")) and service.is_file()
|
||||
|
||||
|
||||
def prepare_rockstar(folder, sidecar, compat_data, launch_dir, proton="", ask_app=None):
|
||||
if not compat_data:
|
||||
return "no-prefix"
|
||||
@@ -481,7 +491,7 @@ def prepare_rockstar(folder, sidecar, compat_data, launch_dir, proton="", ask_ap
|
||||
if len(signature) != 6 or signature[:4] != b"PE\0\0" or signature[4:] not in (b"\x4c\x01", b"\x64\x86"):
|
||||
return "invalid-game-exe"
|
||||
service = ROCKSTAR_SERVICE / ("Launcher32.exe" if signature[4:] == b"\x4c\x01" else "Launcher64.exe")
|
||||
if not service.is_file():
|
||||
if not fetch_service(service, "rockstar", launch_dir, ask_app):
|
||||
return "no-service"
|
||||
made = "present" if (Path(compat_data) / "pfx/user.reg").is_file() else create_prefix(compat_data, proton)
|
||||
if made not in ("created", "present"):
|
||||
@@ -723,7 +733,7 @@ def prepare_ubisoft(folder, sidecar, compat_data, launch_dir, proton="", ask_app
|
||||
product = ubisoft_product(sidecar)
|
||||
if product is None:
|
||||
return "no-product"
|
||||
if not UBISOFT_SERVICE.is_file():
|
||||
if not fetch_service(UBISOFT_SERVICE, "ubisoft", launch_dir, ask_app):
|
||||
return "no-service"
|
||||
made = create_prefix(compat_data, proton) if not (Path(compat_data) / "pfx/user.reg").is_file() else "present"
|
||||
if made not in ("present", "created"):
|
||||
|
||||
@@ -78,6 +78,8 @@ pack xbox "$linuxfs/droiddeck-xbox" version xodus-cli xodus-service
|
||||
pack comet "$linuxfs/droiddeck-comet" version comet
|
||||
pack powervr "$repo/app/src/main/assets/hybris" runtime.tzst version.txt
|
||||
[ ! -f "$linuxfs/droiddeck-ubisoft/droiddeck-upc.exe" ] || pack ubisoft "$linuxfs/droiddeck-ubisoft" droiddeck-upc.exe
|
||||
[ ! -f "$linuxfs/droiddeck-rockstar/Launcher64.exe" ] || pack rockstar "$linuxfs/droiddeck-rockstar" Launcher32.exe Launcher64.exe
|
||||
[ ! -f "$linuxfs/droiddeck-dirt/ws2_32.dll" ] || pack dirt "$linuxfs/droiddeck-dirt" ws2_32.dll
|
||||
|
||||
mkdir "$work/butler"
|
||||
fetch "https://broth.itch.zone/butler/linux-arm64/${BUTLER_VERSION}/archive/default" \
|
||||
|
||||
@@ -14,12 +14,13 @@ ROOT = Path(__file__).resolve().parents[2]
|
||||
MANIFEST = Path('app/build/runtime-inputs.json')
|
||||
PACKS = Path('app/build/packs')
|
||||
PACKED = {'assets/linuxfs/usr/local/lib/droiddeck-xbox/': 'xbox', 'assets/linuxfs/usr/local/lib/droiddeck-comet/': 'comet',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-ubisoft/': 'ubisoft',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-ubisoft/': 'ubisoft', 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/': 'rockstar',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-dirt/': 'dirt',
|
||||
'assets/directaudio/': 'directaudio', 'assets/hybris/': 'powervr'}
|
||||
PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so'),
|
||||
'lib/arm64-v8a/libproot-loader.so': ('proot', 'libproot-loader.so')}
|
||||
PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt']
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
@@ -211,12 +212,27 @@ def pack_digests(root, name):
|
||||
return digests
|
||||
|
||||
|
||||
def windows_binaries(package):
|
||||
found = []
|
||||
for info in package.infolist():
|
||||
if info.is_dir():
|
||||
continue
|
||||
with package.open(info) as entry:
|
||||
if entry.read(2) == b'MZ':
|
||||
found.append(info.filename)
|
||||
return found
|
||||
|
||||
|
||||
def check_apk(apk, root=ROOT):
|
||||
data = verify(root)
|
||||
packs = {name: pack_digests(root, name) for name in PACK_NAMES
|
||||
if name != 'ubisoft' or (root / PACKS / 'ubisoft.tar.zst').is_file()}
|
||||
if name not in ('ubisoft', 'rockstar', 'dirt') or (root / PACKS / (name + '.tar.zst')).is_file()}
|
||||
with ZipFile(apk) as package:
|
||||
names = set(package.namelist())
|
||||
for name in sorted(names):
|
||||
prefix = next((p for p in PACKED if name.startswith(p)), None)
|
||||
if prefix:
|
||||
raise ValueError('APK still carries ' + name + ', which the ' + PACKED[prefix] + ' pack provides')
|
||||
for library in PACKED_LIBRARIES:
|
||||
if library in names:
|
||||
raise ValueError('APK still carries ' + library + ', which the tracking pack provides')
|
||||
@@ -243,6 +259,9 @@ def check_apk(apk, root=ROOT):
|
||||
raise ValueError('APK missing ' + name)
|
||||
if hashlib.sha256(content).hexdigest() != output['sha256']:
|
||||
raise ValueError('APK has stale runtime input: ' + name)
|
||||
found = windows_binaries(package)
|
||||
if found:
|
||||
raise ValueError('APK carries Windows executables, which ship in add-on packs: ' + ', '.join(found))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -12,7 +12,7 @@ GTA III defaults to full x87 precision for FEX before Wine starts, because reduc
|
||||
|
||||
Raw launcher identity requests use `INIT:<nonce>:` with a terminating colon. Framed requests carry their payload length. The reply echoes the complete challenge after `TINI:launcher:`; partial reads do not complete a raw request.
|
||||
|
||||
`build.sh` builds 32-bit and 64-bit executables with the GNU Windows targets and stages them as APK resources. `legacy-cipher.bin` contains the fixed client protocol tables, not account credentials or APK signing keys.
|
||||
`build.sh` builds 32-bit and 64-bit executables with the GNU Windows targets for the `rockstar` add-on pack. The app downloads the pack after Rockstar sign-in, or when a launch finds the service missing, and stages it in the Linux runtime. `legacy-cipher.bin` contains the fixed client protocol tables, not account credentials or APK signing keys.
|
||||
|
||||
Run the protocol tests with:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
out=${1:-"$here/../../app/src/main/resources/rockstar/helpers"}
|
||||
out=${1:-"$here/../../app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar"}
|
||||
mkdir -p "$out"
|
||||
for target in i686-pc-windows-gnu x86_64-pc-windows-gnu; do
|
||||
rustup target add "$target" >/dev/null 2>&1 || true
|
||||
|
||||
@@ -36,6 +36,10 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
service = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-ubisoft/droiddeck-upc.exe'
|
||||
service.parent.mkdir(parents=True)
|
||||
service.write_bytes(b'MZ service')
|
||||
rockstar = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar'
|
||||
rockstar.mkdir(parents=True)
|
||||
(rockstar / 'Launcher32.exe').write_bytes(b'MZ launcher 32')
|
||||
(rockstar / 'Launcher64.exe').write_bytes(b'MZ launcher 64')
|
||||
self.audio(['pactl', 'modules/arm64/module-aaudio-sink.so', 'modules/arm64/module-directaudio-native-sink.so'])
|
||||
self.packs()
|
||||
|
||||
@@ -189,6 +193,46 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, 'ubisoft pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_rockstar_service_is_rejected(self):
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/Launcher32.exe'
|
||||
self.assertIn(name, runtime.outputs(self.root))
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'MZ launcher 32'})
|
||||
with self.assertRaisesRegex(ValueError, 'rockstar pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_a_packed_file_the_manifest_does_not_list_is_rejected(self):
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/Unlisted.bin'
|
||||
self.assertNotIn(name, runtime.outputs(self.root))
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'helper data'})
|
||||
with self.assertRaisesRegex(ValueError, 'Unlisted.bin, which the rockstar pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_a_stale_rockstar_pack_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'current.apk')
|
||||
self.pack('rockstar', {'Launcher32.exe': b'MZ older launcher', 'Launcher64.exe': b'MZ launcher 64'})
|
||||
with self.assertRaisesRegex(ValueError, 'rockstar is missing or has a stale'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_carrying_any_windows_executable_is_rejected(self):
|
||||
for name in ('assets/linuxfs/usr/local/lib/new-helper/helper.exe', 'assets/anything/renamed.bin', 'res/raw/x.dll'):
|
||||
with self.subTest(name=name):
|
||||
apk = self.current_apk(self.root / 'windows.apk', {name: b'MZ helper'})
|
||||
with self.assertRaisesRegex(ValueError, 'Windows executables.*' + name):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_dirt_stand_in_is_rejected(self):
|
||||
dirt = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-dirt'
|
||||
dirt.mkdir(parents=True)
|
||||
(dirt / 'ws2_32.dll').write_bytes(b'MZ droiddeck-dirt-ws2_32')
|
||||
self.packs()
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-dirt/ws2_32.dll'
|
||||
self.assertIn(name, runtime.outputs(self.root))
|
||||
self.assertEqual('dirt', runtime.PACKED['assets/linuxfs/usr/local/lib/droiddeck-dirt/'])
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'MZ droiddeck-dirt-ws2_32'})
|
||||
with self.assertRaisesRegex(ValueError, 'dirt pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
runtime.check_apk(self.current_apk(self.root / 'current.apk'), self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_powervr_runtime_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {'assets/hybris/runtime.tzst': b'runtime'})
|
||||
with self.assertRaisesRegex(ValueError, 'powervr pack provides'):
|
||||
|
||||
@@ -165,6 +165,41 @@ class RockstarLaunch(unittest.TestCase):
|
||||
self.assertEqual('rockstar-launch', requests[0]['op'])
|
||||
self.assertEqual(b'compiled-helper', path.with_name('Launcher.exe').read_bytes())
|
||||
|
||||
def test_a_missing_service_is_fetched_from_the_app_before_launch(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder, sidecar, prefix, service, answer = self.setup_game(root)
|
||||
helper = (service / 'Launcher32.exe').read_bytes()
|
||||
(service / 'Launcher32.exe').unlink()
|
||||
requests = []
|
||||
|
||||
def ask(channel, request, timeout):
|
||||
requests.append(request)
|
||||
if request['op'] == 'store-service':
|
||||
(service / 'Launcher32.exe').write_bytes(helper)
|
||||
return {'ok': True}
|
||||
return answer
|
||||
|
||||
with patch.object(store, 'ROCKSTAR_SERVICE', service), patch.object(store, 'rockstar_registry', return_value=True):
|
||||
result = store.prepare_rockstar(folder, sidecar, str(prefix), str(Path(root) / 'channel'), ask_app=ask)
|
||||
self.assertEqual('ready', result)
|
||||
self.assertEqual([{'op': 'store-service', 'store': 'rockstar'}], requests[:1])
|
||||
self.assertEqual('rockstar-launch', requests[1]['op'])
|
||||
|
||||
def test_an_unavailable_service_does_not_request_account_data(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder, sidecar, prefix, service, _ = self.setup_game(root)
|
||||
(service / 'Launcher32.exe').unlink()
|
||||
requests = []
|
||||
|
||||
def ask(channel, request, timeout):
|
||||
requests.append(request)
|
||||
return {'ok': False, 'reason': 'service-unavailable'}
|
||||
|
||||
with patch.object(store, 'ROCKSTAR_SERVICE', service), patch.object(store, 'rockstar_registry', return_value=True):
|
||||
result = store.prepare_rockstar(folder, sidecar, str(prefix), str(Path(root) / 'channel'), ask_app=ask)
|
||||
self.assertEqual('no-service', result)
|
||||
self.assertEqual(['store-service'], [request['op'] for request in requests])
|
||||
|
||||
def test_rejected_or_expired_sessions_cannot_reuse_stale_material(self):
|
||||
for update in ({'ok': False, 'reason': 'not-owned'}, {'material': 'A' * 641}, {'expiresAt': 1}):
|
||||
with self.subTest(update=update), tempfile.TemporaryDirectory() as root:
|
||||
|
||||
Reference in new issue
Block a user