From 37164559945edda89bb8e98dcfccee6083acbb47 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Thu, 3 Dec 2026 18:00:24 -0500 Subject: [PATCH] fix(stores): let a newer game link supersede opening the Nexon Launcher Take the launch ticket before the worker resolves the Nexon entry and pass it on, so a game link that arrives meanwhile wins. Drop the Battle.net wrappers the client refactor left unused, and clear the test runtime root without following links. --- .../main/java/com/droiddeck/launcher/FrontEndActivity.kt | 3 ++- .../main/java/com/droiddeck/launcher/runtime/BattleNet.kt | 6 ------ .../java/com/droiddeck/launcher/runtime/WindowsClient.kt | 6 +++--- .../droiddeck/launcher/stores/battlenet/BattleNetStore.kt | 1 - .../java/com/droiddeck/launcher/runtime/BattleNetTest.kt | 4 ++-- .../com/droiddeck/launcher/runtime/WindowsClientTest.kt | 5 ++++- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index f792cf2d1b..7dbdb14897 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -2802,10 +2802,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private fun openNexon() { val app = applicationContext + val ticket = beginUiLaunch() Thread({ val entry = com.droiddeck.launcher.runtime.Nexon.entry(app) if (entry == null) com.droiddeck.launcher.stores.SetupDownload.openOrFetch(app, com.droiddeck.launcher.runtime.Nexon.CLIENT) - else ui.post { if (!isDestroyed) launchWithoutSteam(entry, false) } + else ui.post { if (!isDestroyed && launchCoordinator.isCurrent(ticket)) launchWithoutSteam(entry, false, ticket = ticket) } }, "nexon-open").start() } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt b/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt index cb1272b83f..72d6f17cb4 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/BattleNet.kt @@ -143,12 +143,6 @@ object BattleNet { fun installed(context: Context) = CLIENT.installed(context) - fun profile(context: Context): Pair? = CLIENT.profile(context) - - fun icon(context: Context): File? = CLIENT.icon(context) - - fun launcherEntry(installed: Boolean, art: File? = null): com.droiddeck.launcher.frontend.Library.SteamGame? = CLIENT.launcherEntry(installed, art) - internal fun title(uid: String): Title? { val id = uid.lowercase() TITLES.firstOrNull { it.uid == id }?.let { return it } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/WindowsClient.kt b/app/src/main/java/com/droiddeck/launcher/runtime/WindowsClient.kt index e6eca7ed8f..e68426f9c1 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/WindowsClient.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/WindowsClient.kt @@ -28,7 +28,7 @@ class WindowsClient( fun setup(context: Context) = File(LinuxRuntime.rootDir(context), setupPath) - val guestPrefix: String get() = "/$COMPATDATA/$appId" + private val guestPrefix: String get() = "/$COMPATDATA/$appId" val guestLauncher: String get() = "$guestPrefix/pfx/drive_c/$launcherPath" @@ -37,9 +37,9 @@ class WindowsClient( fun profile(context: Context): Pair? = (appId.toString() to context.getString(nameRes)).takeIf { installed(context) } - fun launcherEntry(installed: Boolean, art: File? = null): Library.SteamGame? = + fun launcherEntry(installed: Boolean): Library.SteamGame? = if (!installed) null - else Library.SteamGame(appId = appId.toInt(), name = store.label, art = art, library = library, gameId = appId, source = store.id) + else Library.SteamGame(appId = appId.toInt(), name = store.label, art = null, library = library, gameId = appId, source = store.id) fun icon(context: Context): File? { val out = File(context.filesDir, "${store.id}-art/launcher/icon.png") diff --git a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt index 2214a9128d..d4af27255e 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt @@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicLong object BattleNetClient { private const val TAG = "BattleNetClient" - val DOWNLOAD_KEY: String get() = BattleNet.CLIENT.downloadKey const val REQUEST = "battlenet-request" private const val CONFIG = "pfx/drive_c/users/steamuser/AppData/Roaming/Battle.net/Battle.net.config" private val work = Executors.newSingleThreadExecutor { r -> Thread(r, "battlenet-client") } diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/BattleNetTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/BattleNetTest.kt index 35bedaee0b..517bca8f6d 100644 --- a/app/src/test/java/com/droiddeck/launcher/runtime/BattleNetTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/runtime/BattleNetTest.kt @@ -80,9 +80,9 @@ class BattleNetTest { } @Test fun theEnvironmentEditorNamesBattleNetsProfileOnceItIsInstalled() { - assertNull(BattleNet.profile(context)) + assertNull(BattleNet.CLIENT.profile(context)) launcher().apply { parentFile!!.mkdirs(); writeText("MZ") } - assertEquals(BattleNet.APP_ID.toString() to "Battle.net", BattleNet.profile(context)) + assertEquals(BattleNet.APP_ID.toString() to "Battle.net", BattleNet.CLIENT.profile(context)) } @Test fun removeTakesThePrefixItsMenuEntryAndCacheButNothingItLinksTo() { diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/WindowsClientTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/WindowsClientTest.kt index c78b73fdd8..8cbdeed53e 100644 --- a/app/src/test/java/com/droiddeck/launcher/runtime/WindowsClientTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/runtime/WindowsClientTest.kt @@ -18,7 +18,10 @@ import org.robolectric.RuntimeEnvironment import org.robolectric.annotation.Config import java.io.File import java.util.zip.CRC32 +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.deleteRecursively +@OptIn(ExperimentalPathApi::class) @RunWith(RobolectricTestRunner::class) @Config(sdk = [28], manifest = Config.NONE) class WindowsClientTest { @@ -26,7 +29,7 @@ class WindowsClientTest { @Before fun setUp() { context = RuntimeEnvironment.getApplication() - LinuxRuntime.rootDir(context).deleteRecursively() + LinuxRuntime.rootDir(context).toPath().deleteRecursively() } @Test fun eachClientHasItsOwnShortcutIdPrefixAndDownload() {