fix(frontend): a restored front end no longer relaunches the game from its old link (#3295)

* fix(frontend): a restored front end no longer relaunches the game from its old link

When the system kills the app while a game started from a droiddeck:// link
is running, reopening the task restores the front end with that same link
and starts the game again. The link is now dropped when a new process
restores the activity or Recents reopens it, so only a fresh link launches.

* fix(frontend): judge every restored front end by the process that saved it

* Keep restored settings links working

Only game links are dropped when a restored front end replays its intent; droiddeck://settings links still open their page.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-26 18:23:25 -05:00
1 parent aff81a13e3
commit ffb2a3d6e6
3 files changed
+26

No files matched your search

@@ -20,6 +20,22 @@ class GameLaunchIntentTest {
}
}
@Test fun aLinkIsReplayedOnlyWhenANewProcessRestoresItOrRecentsReopensIt() {
val link = Intent(Intent.ACTION_VIEW)
assertFalse(GameLaunchIntent.replayed(link, restored = false, savedProcess = null, process = "b"))
assertFalse(GameLaunchIntent.replayed(link, restored = true, savedProcess = "b", process = "b"))
assertTrue(GameLaunchIntent.replayed(link, restored = true, savedProcess = "a", process = "b"))
assertTrue(GameLaunchIntent.replayed(link, restored = true, savedProcess = null, process = "b"))
val fromRecents = Intent(link).addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
assertTrue(GameLaunchIntent.replayed(fromRecents, restored = false, savedProcess = null, process = "b"))
assertTrue(GameLaunchIntent.replayed(fromRecents, restored = true, savedProcess = "b", process = "b"))
val settings = Intent(Intent.ACTION_VIEW, android.net.Uri.parse("droiddeck://settings/storage"))
.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
assertFalse(GameLaunchIntent.replayed(settings, restored = true, savedProcess = "a", process = "b"))
assertTrue(GameLaunchIntent.replayed(Intent(Intent.ACTION_VIEW, android.net.Uri.parse("droiddeck://game/620")),
restored = true, savedProcess = "a", process = "b"))
}
@Test fun longAndStringIdsPreserveUnsignedShortcutIds() {
listOf("2147483648", "18446744073709551615").forEach { id ->
assertEquals(id, GameLaunchIntent.readExtras(Intent(GameLaunchIntent.ACTION).putExtra("app_id", id))?.id)