Fix Steam closing between game launches

This commit is contained in:
EnzoDLofi committed 2026-11-13 22:16:13 -04:00
1 parent 462b779892
commit c7c1eaec3e
1 file changed
+17 -7
@@ -1630,13 +1630,22 @@ class SessionService : Service() {
}
private fun returnAfterGame(gameId: String, gen: Int, token: Int) {
if (token != gameExitWatchToken || gen != sessionGen || !SessionState.running ||
SessionState.stopRequested || SessionState.mode != MODE_STEAM || !SessionPrefs.returnAfterGame(this)) return
val written = runCatching { File(LinuxRuntime.sessionRoot(this), "steam-stop").writeText("") }
.onFailure { Log.w(TAG, "could not ask the client to exit after game $gameId", it) }.isSuccess
if (!written) return
SessionEvents.record("steam.return_after_game", mapOf("gameId" to gameId))
Log.i(TAG, "game $gameId closed: asking the client to exit and returning to the launcher")
mainHandler.postDelayed({
if (token != gameExitWatchToken || gen != sessionGen || !SessionState.running ||
SessionState.stopRequested || SessionState.mode != MODE_STEAM ||
!SessionPrefs.returnAfterGame(this) || SessionState.gameId != gameId ||
pendingSteamGameId != null || SteamGameProcess.running()) {
Log.i(TAG, "keeping Steam open after $gameId: another game is running or queued")
return@postDelayed
}
val written = runCatching { File(LinuxRuntime.sessionRoot(this), "steam-stop").writeText("") }
.onFailure { Log.w(TAG, "could not ask the client to exit after game $gameId", it) }.isSuccess
if (!written) return@postDelayed
SessionEvents.record("steam.return_after_game", mapOf("gameId" to gameId))
Log.i(TAG, "game $gameId closed: asking the client to exit and returning to the launcher")
}, GAME_EXIT_CONFIRM_MS)
}
private fun steamGameRunning(gameId: String): Boolean =
@@ -2484,6 +2493,7 @@ class SessionService : Service() {
private const val GAME_URL_PREFIX = "steam://rungameid/"
private const val GAME_START_TIMEOUT_MS = 20 * 60_000L
private const val GAME_EXIT_GRACE_MS = 10_000L
private const val GAME_EXIT_CONFIRM_MS = 2_000L
private const val GAME_EXIT_POLL_MS = 2_000L
private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad"
private const val NO_UINPUT_SWITCH = "Download/droiddeck-no-uinput"