From fd93a35b72d8dfb3b94ab95e1f710ff2a3e1dc61 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sun, 29 Nov 2026 15:02:11 -0500 Subject: [PATCH] Start Steam by itself when first-run setup finishes (#3430) --- .../droiddeck/launcher/FrontEndActivity.kt | 19 +++++++++++++++++++ .../droiddeck/launcher/session/Onboarding.kt | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index c9f4161d55..ba4cb16ef6 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -2020,6 +2020,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet SessionPrefs.setMicAsked(this) } if (wanted.isNotEmpty()) requestPermissions(wanted.toTypedArray(), 1) + com.droiddeck.launcher.session.Onboarding.onFirstRunReady = firstRunReady Thread({ com.droiddeck.launcher.stores.StoreAccounts.encryptAll(this) }, "store-credentials").start() if (!SessionState.running) Thread({ com.droiddeck.launcher.session.LogMigration.run(this) @@ -2299,7 +2300,22 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet return super.dispatchGenericMotionEvent(event) } + @Volatile private var inFront = false + private var autoSteamPending = false + + /** Runs on the worker thread that finishes setup, so the foreground state is read as setup completes, not when the UI thread gets to it. */ + private val firstRunReady: () -> Unit = { + val front = inFront + runOnUiThread { if (front) autoStartSteam() } + } + + private fun autoStartSteam() { + if (isFinishing || isDestroyed || SessionState.running || !inFront) return + if (busy) autoSteamPending = true else playSteam() + } + override fun onPause() { + inFront = false stopRightStickScroll() compatLaunchVisible = false if (android.os.Build.VERSION.SDK_INT >= 29) com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, true) @@ -2308,6 +2324,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onResume() { super.onResume() + inFront = true if (!homeChoiceOpen) { HomeApp.releaseUnusedHomeEntry(this) refreshHomeAppState() @@ -2443,6 +2460,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onDestroy() { // The queued launch was saved before this; a restored activity keeps its copy, and this one must not start it too. + if (com.droiddeck.launcher.session.Onboarding.onFirstRunReady === firstRunReady) com.droiddeck.launcher.session.Onboarding.onFirstRunReady = null queuedLaunchRunner.destroy() triggerKeys.cancel() launchCoordinator.cancelAll() @@ -3742,6 +3760,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet refresh() com.droiddeck.launcher.agent.AgentHost.refresh(this) if (ok == true && LinuxRuntime.isInstalled(this)) { protons.checkUpdates(); protons.ensureSteamClient() } + if (autoSteamPending) { autoSteamPending = false; autoStartSteam() } } }, "runtime-operation").start() } diff --git a/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt b/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt index 2d18a84a30..bbfa7bfc29 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt @@ -29,6 +29,10 @@ object Onboarding { /** The setup screens belong to the first run; later runtime, Proton and Steam client updates keep the usual Play button. */ val firstRun = MutableStateFlow(true) + /** Called once, when this process finishes the first-run downloads itself; not when everything was already in place. */ + @Volatile var onFirstRunReady: (() -> Unit)? = null + @Volatile private var worked = false + fun attach(context: Context) { appContext = context.applicationContext val prefs = context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE) @@ -52,8 +56,10 @@ object Onboarding { private fun markFirstRunDone() { val context = appContext ?: return + val live = firstRun.value && worked context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(KEY_FIRST_RUN_DONE, true).apply() firstRun.value = false + if (live) onFirstRunReady?.invoke() } /** Keeps the process in the foreground, with one notification, while a step downloads and the runtime installer is not already doing so. */ @@ -90,6 +96,7 @@ object Onboarding { } fun report(step: Step, label: String, percent: Int) { + worked = true failed.value = failed.value - step active.value = active.value + (step to Progress(label, percent)) keepAlive()