From 369e218afb1a659c4d82392cbe3f3a83d75d9502 Mon Sep 17 00:00:00 2001 From: xXJsonDeruloXx Date: Mon, 5 Oct 2026 21:34:36 -0400 Subject: [PATCH] Return frontend-launched sessions to Android Home --- .../main/java/com/droiddeck/launcher/MainActivity.kt | 6 ++++-- .../java/com/droiddeck/launcher/SessionActivity.kt | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index f34544b1..9c743938 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -440,7 +440,7 @@ class MainActivity : ComponentActivity() { } } - private fun launchGame(game: Library.SteamGame): Boolean { + private fun launchGame(game: Library.SteamGame, returnHome: Boolean = false): Boolean { if (protons.protonBusyId != null || ProtonExtras.installInProgress || pkgStage != null) { android.widget.Toast.makeText(this, "Wait for the install to finish before launching a game", android.widget.Toast.LENGTH_SHORT).show() return false @@ -455,10 +455,12 @@ class MainActivity : ComponentActivity() { return false } startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME) + .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)) return true } return startSession(Intent(this, SessionActivity::class.java) + .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) .putExtra(SessionService.EXTRA_STEAM_URL, com.droiddeck.launcher.frontend.GameLaunchLink.steamUrl(game.gameIdString)), steamSession = true) } @@ -473,7 +475,7 @@ class MainActivity : ComponentActivity() { intent.action = Intent.ACTION_MAIN intent.removeExtra(GameLaunchIntent.EXTRA_APP_ID) android.widget.Toast.makeText(this, R.string.game_link_missing, android.widget.Toast.LENGTH_LONG).show() - } else if (launchGame(game)) { + } else if (launchGame(game, returnHome = true)) { pendingGameLink = null intent.data = null intent.action = Intent.ACTION_MAIN diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 1d5ed29b..6564d80d 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -1145,6 +1145,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { // the request landed in this instance's onNewIntent and went with its finish(). SessionState.relaunch?.let { next -> SessionState.relaunch = null + next.putExtra(EXTRA_RETURN_HOME, intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) setIntent(next) recreate() return@runOnUiThread @@ -1906,6 +1907,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { recreate() return } + // Home/notification resumes must retain the external frontend's return destination. + if (this.intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) intent.putExtra(EXTRA_RETURN_HOME, true) setIntent(intent) if (intent.action == SessionService.ACTION_HOME_GUIDE) { handleHomeGuideIntent(intent) @@ -2046,6 +2049,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { * off, it just closes. */ override fun finish() { + if (isFinishing) return if (!quitFlooded && !closeAtOnce && com.droiddeck.launcher.ui.Motion.scale != 0f && lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.RESUMED)) { if (!leaving) { @@ -2056,6 +2060,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { return } super.finish() + if (!closeAtOnce && intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) { + com.droiddeck.launcher.ui.QuitFlood.take() + com.droiddeck.launcher.ui.LaunchOrigin.flooding = null + startActivity(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) + } if (quitFlooded) overridePendingTransition(0, 0) else overridePendingTransition(R.anim.session_hold, R.anim.session_sink) } @@ -2071,6 +2081,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } companion object { + const val EXTRA_RETURN_HOME = "returnHome" /** How long the leaving flood may take before the session closes without it. */ private const val LEAVE_TIMEOUT_MS = 1_500L private const val TAG = "SessionActivity"