fix: forward Steam maintenance navigation

This commit is contained in:
Kurt Himebauch committed 2026-10-28 17:50:58 -04:00
1 parent 2229dbc0a8
commit 48ad5506b6
7 files changed
+92 -2

No files matched your search

@@ -1036,9 +1036,28 @@ class FrontEndActivity : ComponentActivity() {
onPlay = { playSteam() },
onPlaySteamVr = { playSteamVr() },
onSteamUrl = { url ->
if (!SessionState.running) startSession(
if (!com.droiddeck.launcher.session.SteamSessionUrl.isSupported(url)) {
android.widget.Toast.makeText(this, R.string.steam_navigation_failed, android.widget.Toast.LENGTH_LONG).show()
} else if (!SessionState.running) startSession(
Intent(this, SessionActivity::class.java).putExtra(SessionService.EXTRA_STEAM_URL, url), steamSession = true,
)
) else if (SessionState.mode != SessionService.MODE_STEAM) {
android.widget.Toast.makeText(this, R.string.steam_navigation_switch_mode, android.widget.Toast.LENGTH_LONG).show()
} else if (SessionState.stopRequested) {
android.widget.Toast.makeText(this, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show()
} else {
if (SessionState.suspended) SessionService.resume(this)
val context = applicationContext
Thread({
val opened = runCatching {
com.droiddeck.launcher.agent.AgentGuest.openSteamUrl(context, url)
}.isSuccess
ui.post {
if (opened) startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP))
else android.widget.Toast.makeText(this, R.string.steam_navigation_failed, android.widget.Toast.LENGTH_LONG).show()
}
}, "steam-navigation").start()
}
},
onPlayDesktopUi = {
startSession(Intent(this, SessionActivity::class.java)
@@ -12,6 +12,7 @@ import android.util.Log
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.SessionEvents
import com.droiddeck.launcher.session.SessionState
import com.droiddeck.launcher.session.SteamSessionUrl
import org.json.JSONObject
import java.io.File
import java.util.UUID
@@ -96,6 +97,15 @@ object AgentGuest {
fun focus(context: Context): JSONObject? =
if (SessionState.running) readJson(File(dir(context), "focus.json")) else null
fun openSteamUrl(context: Context, url: String): JSONObject {
require(SteamSessionUrl.isSupported(url)) { "Unsupported Steam navigation URL" }
val result = call(context, JSONObject().put("kind", "steam-url").put("url", url), 8_000, trusted = true)
check(SteamSessionUrl.wasOpened(result.optBoolean("ok"), result.optBoolean("launched"))) {
"Steam did not accept the navigation request"
}
return result
}
fun selectedSteamAppId(context: Context): Long? {
val result = call(context, JSONObject().put("kind", "steam-selection"), 6_000)
if (!result.optBoolean("ok") || result.isNull("appId")) return null
@@ -0,0 +1,9 @@
package com.droiddeck.launcher.session
object SteamSessionUrl {
private val allowed = Regex("steam://(?:open/downloads|nav/library|uninstall/[1-9][0-9]{0,9})")
fun isSupported(url: String): Boolean = allowed.matches(url)
internal fun wasOpened(ok: Boolean, launched: Boolean): Boolean = ok && launched
}
+2
View File
@@ -1346,6 +1346,8 @@
<string name="game_link_missing">This game is no longer in your DroidDeck library.</string>
<string name="game_link_session_busy">Stop the current session before launching a Steam game.</string>
<string name="game_link_failed">Could not send the game to Steam. Try launching it again.</string>
<string name="steam_navigation_switch_mode">Switch to Steam mode to open Steam navigation.</string>
<string name="steam_navigation_failed">Could not open that Steam page. Return to Steam mode and try again.</string>
<string name="setup_retry_removal">Retry removal</string>
<string name="runtime_removing">Removing</string>
<string name="runtime_removal_incomplete">Removal incomplete</string>
@@ -0,0 +1,23 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class SteamSessionUrlTest {
@Test
fun onlySupportedSteamNavigationRoutesAreAccepted() {
listOf("steam://open/downloads", "steam://nav/library", "steam://uninstall/12345")
.forEach { assertTrue(it, SteamSessionUrl.isSupported(it)) }
listOf("steam://open/settings", "steam://uninstall/0", "steam://uninstall/01",
"steam://open/downloads\n--exec", "https://example.com")
.forEach { assertFalse(it, SteamSessionUrl.isSupported(it)) }
}
@Test
fun bridgeMustConfirmLaunch() {
assertTrue(SteamSessionUrl.wasOpened(ok = true, launched = true))
assertFalse(SteamSessionUrl.wasOpened(ok = false, launched = true))
assertFalse(SteamSessionUrl.wasOpened(ok = true, launched = false))
}
}