From 80a62cd0f078f5437607324f9dba062c0b21a351 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:46:35 -0400 Subject: [PATCH] Restore Xbox launches from Steam (#1170) --- .../droiddeck/launcher/stores/StoreLaunch.kt | 4 ---- .../launcher/stores/xbox/XboxLaunchLeases.kt | 6 ------ .../launcher/stores/xbox/XboxRuntime.kt | 7 ------- .../stores/xbox/XboxLaunchLeasesTest.kt | 19 +++++++++---------- docs/development/xbox-store.md | 7 ++++--- tools/xbox/README.md | 12 ++++++------ 6 files changed, 19 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt index 68560621f1..e17aac578b 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt @@ -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({ diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeases.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeases.kt index 67f0c5b84e..6caba84509 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeases.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeases.kt @@ -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() private val leases = HashMap() - @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 { - permits.clear() return leases.values.mapNotNull { it.child }.also { leases.clear() } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt index b75d8fd54b..28d6c12d99 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt @@ -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 }) diff --git a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeasesTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeasesTest.kt index 51bc4f3212..d5a5d553b6 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeasesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/xbox/XboxLaunchLeasesTest.kt @@ -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() diff --git a/docs/development/xbox-store.md b/docs/development/xbox-store.md index 6a75655595..47ccb769e3 100644 --- a/docs/development/xbox-store.md +++ b/docs/development/xbox-store.md @@ -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. diff --git a/tools/xbox/README.md b/tools/xbox/README.md index 7f700fd2a3..b06825748b 100644 --- a/tools/xbox/README.md +++ b/tools/xbox/README.md @@ -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