Restore Xbox launches from Steam (#1170)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-20 00:46:35 +00:00
1 parent 6bbcf3ad8b
commit 3dd0045874
6 files changed
+19 -36

No files matched your search

@@ -83,10 +83,6 @@ object StoreLaunch {
}
fun prepare(context: Context, store: Store, id: String, onReady: () -> Unit) {
if (store == Store.XBOX && !com.droiddeck.launcher.stores.xbox.XboxRuntime.authorize(context, id)) {
StoresState.problems[Store.XBOX] = "Xbox account is unavailable. Sign in again and retry."
return
}
if (store != Store.EPIC) { onReady(); return }
val app = context.applicationContext
Thread({
@@ -4,16 +4,11 @@ import java.io.Closeable
import java.util.UUID
internal class XboxLaunchLeases(private val now: () -> Long) {
private data class Permit(val account: String, val expires: Long)
private data class Lease(val id: String, val account: String, val session: String, var expires: Long, var child: Closeable? = null)
private val permits = HashMap<String, Permit>()
private val leases = HashMap<String, Lease>()
@Synchronized fun authorize(id: String, account: String) { permits[id] = Permit(account, now() + 180_000) }
@Synchronized fun active(id: String) = leases.values.any { it.id == id }
@Synchronized fun begin(id: String, account: String, session: String): String {
val permit = permits.remove(id)
check(permit != null && permit.account == account && permit.expires > now()) { "Start this Xbox game from DroidDeck." }
check(!active(id)) { "This Xbox game is already starting or running." }
val token = UUID.randomUUID().toString()
leases[token] = Lease(id, account, session, now() + 180_000)
@@ -38,7 +33,6 @@ internal class XboxLaunchLeases(private val now: () -> Long) {
return expired.mapNotNull { leases.remove(it)?.child }
}
@Synchronized fun clear(): List<Closeable> {
permits.clear()
return leases.values.mapNotNull { it.child }.also { leases.clear() }
}
}
@@ -16,13 +16,6 @@ internal object XboxRuntime {
private val views = XboxLaunchViews()
private val launches = XboxLaunchLeases { android.os.SystemClock.uptimeMillis() }
fun isActive(id: String): Boolean = launches.active(id)
fun authorize(app: Context, id: String): Boolean = runCatching {
XboxCredentials.lifecycle(app) {
val account = StoreAccounts.signedInAs(app, Store.XBOX) ?: return@lifecycle false
launches.authorize(id, account)
true
}
}.getOrDefault(false)
fun released(token: String) { runCatching { launches.release(token)?.close() } }
fun renew(app: Context, id: String, token: String): Boolean = launches.renew(token, id,
StoreAccounts.signedInAs(app, Store.XBOX), SessionState.sessionId.takeIf { SessionState.running })
@@ -9,19 +9,16 @@ class XboxLaunchLeasesTest {
private val leases = XboxLaunchLeases { time }
private var closed = 0
private fun launch(account: String = "account", session: String = "session"): String {
leases.authorize("game", account)
return leases.begin("game", account, session).also { leases.attach(it, Closeable { closed++ }) }
}
private fun reap(account: String? = "account", session: String? = "session", suspended: Boolean = false) {
leases.stale(account, session, suspended).forEach { it.close() }
}
@Test fun guestPreparationRequiresAnUnexpiredAccountPermit() {
assertThrows(IllegalStateException::class.java) { leases.begin("game", "account", "session") }
leases.authorize("game", "account")
assertThrows(IllegalStateException::class.java) { leases.begin("game", "other", "session") }
leases.authorize("game", "account")
time = 180_000
@Test fun steamLaunchCanCreateASessionBoundLease() {
val token = leases.begin("game", "account", "session")
assertTrue(leases.active("game"))
assertFalse(leases.renew(token, "game", "account", "other"))
assertThrows(IllegalStateException::class.java) { leases.begin("game", "account", "session") }
}
@Test fun releaseIsIdempotentAndCannotDecrementANewLaunch() {
@@ -65,13 +62,15 @@ class XboxLaunchLeasesTest {
assertEquals(1, closed)
assertTrue(leases.active("game"))
}
@Test fun lateBackendCannotAttachAfterStop() {
leases.authorize("game", "account")
@Test fun stopRemovesLeaseAndRejectsLateAttachment() {
val token = leases.begin("game", "account", "session")
leases.clear().forEach { it.close() }
assertFalse(leases.attach(token, Closeable { closed++ }))
assertFalse(leases.active("game"))
assertThrows(IllegalStateException::class.java) { leases.begin("game", "account", "session") }
val next = leases.begin("game", "account", "new-session")
assertTrue(leases.active("game"))
assertFalse(leases.attach(token, Closeable { closed++ }))
assertTrue(leases.attach(next, Closeable { closed++ }))
}
@Test fun suspensionKeepsLiveLeasesUntilResume() {
val token = launch()
+4 -3
View File
@@ -32,9 +32,10 @@ not Xbox console emulation or UWP/APPX packages.
of showing the "Steam picks the game up when it next starts" toast.
A launch taking over 20 seconds should not produce a duplicate Steam launch
or a "Game already running" dialog while licensing is still preparing it.
Steam/session startup uses the selected ARM64 Proton. Launch through
DroidDeck's Play action: it authorizes one account-bound preparation. Direct
Steam launches without that authorization fail with a retry-in-DroidDeck error.
Steam/session startup uses the selected ARM64 Proton. Launch the installed
Xbox game from either DroidDeck or Steam; both paths should prepare the same
account-bound game service and licensed view while keeping account credentials
inside the Android-owned backend.
During preparation, opening the Xbox detail/content UI must remain responsive.
Update / verify must report a problem if the game starts after its button was
enabled, rather than crashing the app.
+6 -6
View File
@@ -36,15 +36,15 @@ authentication checks the mapped backend image instead. A socket name alone gran
copy of Xodus started by the guest.
Licensed launch-view preparation runs in an Android-owned Xodus child, which
never starts Wine or a game. An in-memory, single-use Play authorization is
required before the guest can request preparation. The reply contains a random
launch lease, a materialized executable path, a game-service socket and the
existing PlayFab game token; it contains no account credential endpoint.
never starts Wine or a game. Steam and DroidDeck launch paths can request
preparation for an installed Xbox title during a live session with an Xbox
account. The reply contains a random launch lease, a materialized executable
path, a game-service socket and the existing PlayFab game token; it contains no
account credential endpoint.
Leases bind product, account and session, expire without heartbeats, and release
idempotently. Cancellation, session stop and account changes revoke leases;
closing the child's stdin lets it remove its private view. Suspension preserves
live leases. Launch Xbox games through DroidDeck's Play action; an unsolicited
launch from inside Steam has no Play authorization.
live leases.
The Proton initialization and game processes do not inherit the raw credential
channel or command-file environment variables. The authenticated GDK bridge
remains available to the game. Like the other stores, games share DroidDeck's