diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt index 509004ba7e..06e901fd73 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreGameSidecar.kt @@ -60,7 +60,7 @@ class StoreGameSidecar( put("title", title) if (exe.isNotEmpty()) put("exe", exe) if (state != STATE_INSTALLED) put("state", state) - if (store == Store.EPIC) put("epic", JSONObject().put("v", EpicOptions.VERSION).put("eos", epic.eos).put("offline", epic.offline).put("overlay", epic.overlay)) + if (store == Store.EPIC) put("epic", JSONObject().put("eos", epic.eos).put("offline", epic.offline)) if (!launcher.isNullOrEmpty()) put("launcher", launcher) if (args.isNotEmpty()) put("args", JSONArray(args)) if (env.isNotEmpty()) put("env", JSONObject(env as Map<*, *>)) @@ -133,12 +133,8 @@ class StoreGameSidecar( hero = o.optString("hero", "").ifEmpty { null }, extra = extra, state = state, - epic = o.optJSONObject("epic")?.let { e -> - // Before v2 the overlay was on by default and written so without anyone choosing - // it; the overlay crashed games, so those read as off. From v2 it is a choice. - val chosen = e.optInt("v", 1) >= EpicOptions.VERSION - EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false), overlay = chosen && e.optBoolean("overlay", false)) - } ?: EpicOptions(), + // An "overlay" (or "v") field from an earlier build is read past: there is no overlay. + epic = o.optJSONObject("epic")?.let { e -> EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false)) } ?: EpicOptions(), ) } @@ -151,15 +147,8 @@ class StoreGameSidecar( /** * An Epic game's launch choices. [eos]: pass a fresh exchange code (Epic sign-in). [offline]: start * with the Epic identity arguments only, no code - for a game that will not start when sign-in fails. - * [overlay]: point the game's prefix at Epic's EOS overlay - off by default: with it on, a game can - * exit while loading on this stack (Metalstorm did, twice; off, it signs in and runs). */ -data class EpicOptions(val eos: Boolean = true, val offline: Boolean = false, val overlay: Boolean = false) { +data class EpicOptions(val eos: Boolean = true, val offline: Boolean = false) { /** Whether a launch asks for a code at all. */ val wantsCode: Boolean get() = eos && !offline - - companion object { - /** v2: the overlay is off unless chosen (Metalstorm exits while loading with it on). */ - const val VERSION = 2 - } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt index d3244e335d..f29e105298 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt @@ -60,13 +60,7 @@ object StoreLaunchRequests { if (id.isEmpty()) JSONObject().put("ok", false).put("reason", "no-id") else { val code = StoreLaunch.epicCode(app, id) - // The overlay is placed once and shared; the launch writes the prefix's pointer. - val overlay = com.droiddeck.launcher.stores.epic.EpicOverlay.installedVersion(app) - val wanted = StoreInstallRoot.gameFolders(app).firstNotNullOfOrNull { f -> StoreGameSidecar.read(f)?.takeIf { it.store == Store.EPIC && it.id == id } }?.epic?.overlay == true - Log.i(TAG, "epic overlay installed=${overlay ?: "no"} wanted=$wanted prefix=${request.optString("prefix").ifEmpty { "?" }}") - // Fetched only for a game that has the overlay on (656 MB; off by default). - if (overlay == null && wanted) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(app) - JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason).put("overlay", overlay ?: "") + JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason) } } // A browser a game opens inside the session (an EOS device sign-in, a store page): diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt index 4d15d2f149..0b6ed682b7 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt @@ -226,6 +226,9 @@ object StoresState { fun init(context: Context) { appContext = context.applicationContext StoreLogFiles.prune(context) + // The EOS overlay an earlier build downloaded (656 MB) is gone with the feature. + val overlay = java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.local/share/droiddeck/epic-overlay") + if (overlay.exists()) Thread({ overlay.deleteRecursively(); Log.i(TAG, "removed the old EOS overlay download") }, "epic-overlay-cleanup").start() } internal fun post(block: () -> Unit) = main.post(block) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicOverlay.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicOverlay.kt deleted file mode 100644 index 986185f77a..0000000000 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicOverlay.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Epic Online Services (EOS) overlay provisioning for DroidDeck. - * - * Credits: the provisioning MECHANISM - download Epic's own overlay component - * ("EpicOnlineServicesOverlay") and point a game's bundled EOS SDK at it through a single HKCU - * registry value - comes from Legendary's legendary/lfs/eos.py, by way of The GameNative Team's - * work (https://github.com/utkarshdalal/GameNative) and Bannerlator's EpicOverlayManager. The Epic - * app identifiers, the registry key and the EOSOVH-Win64-Shipping.dll name are public facts from - * Epic / Legendary. Original implementation. - * - * Reference: https://github.com/derrod/legendary - legendary/lfs/eos.py - * Reference: https://github.com/utkarshdalal/GameNative - * - * Provision only: Epic's signed component is placed once, shared by every prefix, and each Epic - * game's prefix gets the one pointer (written by droiddeck-store-launch before Proton starts, where - * the prefix is known). The game's EOS SDK loads it itself - which is what lets a "corrective - * action" (a consent Epic wants once per product) show in game instead of waiting on a browser. - */ -package com.droiddeck.launcher.stores.epic - -import android.content.Context -import android.util.Log -import com.droiddeck.launcher.runtime.LinuxRuntime -import com.droiddeck.launcher.stores.StoresState -import java.io.File -import java.util.concurrent.atomic.AtomicBoolean - -object EpicOverlay { - private const val TAG = "EpicOverlay" - - // Epic's "EpicOnlineServicesOverlay" app (public, from Legendary). - private const val OVERLAY_APP = "98bc04bc842e4906993fd6d6644ffb8d" - private const val OVERLAY_NAMESPACE = "302e5ede476149b1bc3e4fe6ae45e50e" - private const val OVERLAY_CATALOG_ITEM = "cc15684f44d849e89e9bf4cec0508b68" - const val OVERLAY_DLL = "EOSOVH-Win64-Shipping.dll" - - /** Inside the session: `/root/.local/share/droiddeck/epic-overlay`, which every prefix reaches as Z:. droiddeck-store-launch names the same path. */ - const val GUEST_DIR = "/root/.local/share/droiddeck/epic-overlay" - private const val VERSION_FILE = "droiddeck-version" - - private val busy = AtomicBoolean(false) - - fun dir(context: Context): File = File(LinuxRuntime.rootDir(context), GUEST_DIR.removePrefix("/")) - - /** The installed overlay's build, or null when it is not there. */ - fun installedVersion(context: Context): String? { - val d = dir(context) - if (!File(d, OVERLAY_DLL).let { it.isFile && it.length() > 0 }) return null - return runCatching { File(d, VERSION_FILE).readText().trim() }.getOrNull()?.ifEmpty { null } ?: "unknown" - } - - /** Starts the download in the background when the overlay is missing; nothing when it is there or under way. */ - fun ensureAsync(context: Context) { - val app = context.applicationContext - if (installedVersion(app) != null || !busy.compareAndSet(false, true)) return - Thread({ - try { ensure(app) } finally { busy.set(false) } - }, "epic-overlay").start() - } - - /** Blocking: downloads Epic's overlay component when it is missing. True when it is in place afterwards. */ - fun ensure(context: Context): Boolean { - val app = context.applicationContext - if (installedVersion(app) != null) return true - return try { - val token = EpicCredentialStore.getValidAccessToken(app) ?: return false.also { Log.i(TAG, "overlay: not signed in") } - val manifest = EpicApiClient.getManifestApiJson(token, OVERLAY_NAMESPACE, OVERLAY_CATALOG_ITEM, OVERLAY_APP) - ?: return false.also { Log.w(TAG, "overlay: manifest not fetched") } - val target = dir(app).apply { mkdirs() } - StoresState.logLine("epic: fetching the EOS overlay") - val result = EpicDownloadManager.install(app, manifest, target.path, "", null, AtomicBoolean(false), object : EpicDownloadManager.Callback { - override fun onProgress(message: String, pct: Int) {} - override fun onLog(line: String) { StoresState.logLine(line) } - }) - val ok = result != null && File(target, OVERLAY_DLL).isFile - if (ok) File(target, VERSION_FILE).writeText(result!!.buildVersion.ifEmpty { "unknown" }) - Log.i(TAG, "overlay: " + if (ok) "installed ${result!!.buildVersion}" else "install did not produce $OVERLAY_DLL") - ok - } catch (e: Exception) { - Log.w(TAG, "overlay: ${e.javaClass.simpleName}: ${e.message}") - false - } - } -} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index ce5503becc..3da6c61afe 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -508,7 +508,7 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost /** Epic's account page behind its sign-in: signing in there presents any step the account still owes. */ private const val EPIC_RESOLVE_URL = "https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Faccount%2Fpersonal" -/** The Epic card: sign-in, offline and overlay switches, read from and written to the game's sidecar. */ +/** The Epic card: the sign-in and offline switches, read from and written to the game's sidecar, and Resolve Epic sign-in. */ @Composable private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) { val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext @@ -517,7 +517,6 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) { val value = buildList { if (options.offline) add(stringResource(R.string.epic_card_offline)) else if (options.eos) add(stringResource(R.string.epic_card_eos)) - if (options.overlay) add(stringResource(R.string.epic_card_overlay)) }.ifEmpty { listOf(stringResource(R.string.epic_card_none)) }.joinToString(" · ") // Each switch goes straight to the sidecar on disk - both launch paths read it there - and the // card shows what was read back, so a write that did not take is never shown as done. @@ -525,8 +524,7 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) { Thread({ val written = runCatching { com.droiddeck.launcher.stores.StoreGameSidecar.updateEpic(folder, change) } .onFailure { android.util.Log.w("EpicLaunchCard", "could not write ${folder.name}: ${it.message}") }.getOrNull() - if (written != null) android.util.Log.i("EpicLaunchCard", "epic options ${written.id} eos=${written.epic.eos} offline=${written.epic.offline} overlay=${written.epic.overlay}") - if (written?.epic?.overlay == true) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(appContext) + if (written != null) android.util.Log.i("EpicLaunchCard", "epic options ${written.id} eos=${written.epic.eos} offline=${written.epic.offline}") else android.util.Log.w("EpicLaunchCard", "epic options not saved for ${folder.name}") com.droiddeck.launcher.stores.StoresState.post { sidecar = written ?: com.droiddeck.launcher.stores.StoreGameSidecar.read(folder) } }, "epic-options").start() @@ -537,7 +535,6 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) { AnchoredMenu(host.open == "epic", onDismiss = { if (host.open == "epic") host.open = null }, title = stringResource(R.string.epic_card_title)) { first -> MenuItem(stringResource(R.string.epic_eos), checked = options.eos, focusRequester = first) { set { it.copy(eos = !it.eos) } } MenuItem(stringResource(R.string.epic_offline), checked = options.offline) { set { it.copy(offline = !it.offline) } } - MenuItem(stringResource(R.string.epic_overlay), checked = options.overlay) { set { it.copy(overlay = !it.overlay) } } // Epic asks some accounts to accept something once (privacy policy, EULA) before a game may // sign in - EOS's "corrective action". Signing in on Epic's site shows it. MenuItem(stringResource(R.string.epic_resolve), checked = false) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08ae047f7b..c014722c49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2015,11 +2015,9 @@ Epic EOS Offline - Overlay Off Epic sign-in (EOS) Launch offline - Epic overlay Resolve Epic sign-in installed in your library diff --git a/app/src/test/java/com/droiddeck/launcher/stores/StoreGameSidecarTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/StoreGameSidecarTest.kt index 9217075500..1171bce1a7 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/StoreGameSidecarTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/StoreGameSidecarTest.kt @@ -47,31 +47,28 @@ class StoreGameSidecarTest { @Test fun epicLaunchChoicesRoundTripAndDefaultOn() { val plain = StoreGameSidecar.parse(StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe").toJson().toString())!! - assertEquals(EpicOptions(eos = true, offline = false, overlay = false), plain.epic) + assertEquals(EpicOptions(eos = true, offline = false), plain.epic) assertTrue(plain.epic.wantsCode) - val set = StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe", epic = EpicOptions(eos = true, offline = true, overlay = false)) + val set = StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe", epic = EpicOptions(eos = true, offline = true)) val back = StoreGameSidecar.parse(set.toJson().toString())!! - assertEquals(EpicOptions(eos = true, offline = true, overlay = false), back.epic) + assertEquals(EpicOptions(eos = true, offline = true), back.epic) assertFalse(back.epic.wantsCode) - // A sidecar from before the choices existed reads as the defaults: sign-in on, overlay off. + // A sidecar from before the choices existed reads as the defaults. assertEquals(EpicOptions(), StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe"}""")!!.epic) - // The old default wrote overlay=true without a version: nobody chose it, so it reads as off. - assertFalse(StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe","epic":{"eos":true,"offline":false,"overlay":true}}""")!!.epic.overlay) - // Chosen from v2 on, it stays. - val on = StoreGameSidecar.parse(StoreGameSidecar(Store.EPIC, "m", "M", "M.exe", epic = EpicOptions(overlay = true)).toJson().toString())!! - assertTrue(on.epic.overlay) + // An earlier build's overlay field is read past. + assertEquals(EpicOptions(), StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe","epic":{"v":2,"eos":true,"offline":false,"overlay":true}}""")!!.epic) } @Test fun aSwitchOnTheEpicCardChangesTheSidecarOnDisk() { val folder = java.io.File(org.robolectric.RuntimeEnvironment.getApplication().filesDir, "Games/Stores/Epic/Metalstorm").apply { mkdirs() } StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "Metalstorm.exe", launcher = ".droiddeck-launch.bat").write(folder) - val written = StoreGameSidecar.updateEpic(folder) { it.copy(overlay = true) }!! - assertTrue(written.epic.overlay) + val written = StoreGameSidecar.updateEpic(folder) { it.copy(offline = true) }!! + assertTrue(written.epic.offline) // What the Steam-launch helper reads: the file itself. val onDisk = org.json.JSONObject(java.io.File(folder, StoreGameSidecar.FILE_NAME).readText()) - assertTrue(onDisk.getJSONObject("epic").getBoolean("overlay")) - assertEquals(EpicOptions.VERSION, onDisk.getJSONObject("epic").getInt("v")) + assertTrue(onDisk.getJSONObject("epic").getBoolean("offline")) assertTrue(onDisk.getJSONObject("epic").getBoolean("eos")) + assertFalse(onDisk.getJSONObject("epic").has("overlay")) // Everything else in it stays. assertEquals(".droiddeck-launch.bat", StoreGameSidecar.read(folder)!!.launcher) assertEquals(null, StoreGameSidecar.updateEpic(java.io.File(folder, "missing")) { it }) diff --git a/docs/development/stores.md b/docs/development/stores.md index a6013fdbfd..95f7880d60 100644 --- a/docs/development/stores.md +++ b/docs/development/stores.md @@ -88,10 +88,32 @@ A Steam shortcut names an exe and nothing more, and the listing carries no launc game that needs arguments or environment gets `.droiddeck-launch.bat` (`StoreLaunch.launcherText`): `cd` into the exe's folder, `set` each variable, start the exe with the arguments and wait. Proton's `steam.exe` shim hands a `.bat` to Wine's `cmd`. For Epic the script also reads -`.droiddeck-epic-code` when present, deletes it, and appends -`-AUTH_LOGIN=unused -AUTH_PASSWORD= -AUTH_TYPE=exchangecode`; `StoreLaunch.prepare` mints the -code right before a launch from the Stores page or the Games tab (the Steam client's own Play -button gets the offline identity arguments only). +`.droiddeck-epic-code` when present, deletes it, and passes +`-AUTH_LOGIN=unused -AUTH_PASSWORD= -AUTH_TYPE=exchangecode` on the game's command line only; +the variable it read the code into is cleared on that same line, so nothing of it is left in the +game's environment. A launcher from an earlier build is rewritten before the next Epic launch. + +The code is minted for every launch, wherever it starts. The Games tab and Stores call +`StoreLaunch.prepare` before they launch; the compat tool (`droiddeck-proton`, +`droiddeck-proton-wrap`) runs `droiddeck-store-launch` before Proton on every real launch, the Steam +client's Play button included. It finds the store launcher among Steam's arguments, reads the +sidecar beside it, and for an Epic game asks the app through `/stores/req` and `resp` +(`StoreLaunchRequests` → `StoreLaunch.epicCode`), waiting up to 5 s; the app writes the code into +the game's folder itself. Each attempt logs `epic launch id=… code=yes|no reason=…`, never the code. + +An Epic game's launch choices are the Epic card in the Games tab's launch settings - "Epic sign-in +(EOS)" (on) and "Launch offline" (off), stored in the sidecar's `epic` block so both launch paths +read the same thing - and "Resolve Epic sign-in", which opens Epic's account page behind its +sign-in in Android's browser. + +A game's web links reach Android: `droiddeck-store-launch` sets the prefix's +`HKCU\Software\Wine\WineBrowser` `Browsers` to `/usr/local/bin/droiddeck-open-url`, which is also +`xdg-open` first on the game's PATH, and hands http(s) addresses to the app, which opens them in +Android's browser. EOS uses this when a sign-in needs a one-time step ("corrective action"): it +falls back to a browser, the user approves on the phone, and the game signs in. `BL_DEBUG_BROWSER=1` +in droiddeck-env adds `WINEDEBUG=+shell,+winebrowser`. Epic's EOS overlay is not provisioned (with +it games exited while loading); an `OverlayPath` an earlier build wrote is removed at launch. The +parked overlay work is on the branch `park/epic-eos-overlay`. ## Downloads diff --git a/docs/progress-log.md b/docs/progress-log.md index ad538e46a8..e087f4ba52 100644 --- a/docs/progress-log.md +++ b/docs/progress-log.md @@ -144,6 +144,14 @@ without it and Setup says "Stores engine not built"). (`token`, `__token__`, `f_token`, `hdnts`, access/refresh/id tokens, `code=`) and Authorization / Cookie headers are blanked outside URLs too. `StoreLogTest` covers a GOG secure link and an Epic Akamai URL. The engine's own logcat lines (tag `EpicNative` etc.) are written on the native side. +- **Epic sign-in device-proven without the overlay (AYANEO Pocket FIT, `bf81104`, Metalstorm):** EOS's + corrective-action browser flow → `droiddeck xdg-open: https://www.epicgames.com` → Chrome + `epicgames.com/id/authorize?user_code=…` → approved → `[eos] got logged in`, product user id + created, the game in its hangar at 92 fps. The EOS overlay crashed the game on every overlay-on + launch, so it is removed (user decision): no overlay switch, no download, no `OverlayPath`; a + launch removes a pointer an earlier build wrote, and the app deletes an earlier 656 MB download + once. The work is parked on `park/epic-eos-overlay` (at `bf81104`). Kept: the browser hand-off, + the Epic card (sign-in, offline, Resolve Epic sign-in) and `BL_DEBUG_BROWSER`. - **A game launched from the Games tab with no session running sat at "Launching"** (device, 2026-10-09-04-steam, and 2026-10-08-05 before it). The session put `steam://rungameid/` on the client's command line; the client took it seconds before its interface was up (focus went to diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch index 2c5c0d473c..60c59a3da4 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch @@ -18,11 +18,10 @@ here - and the launcher .bat reads and deletes it. No answer within TIMEOUT seco with its offline identity. A code file older than STALE_SECONDS is removed first, so a code left by an earlier launch is never used. -The game's prefix also gets the EOS overlay's pointer, HKCU\Software\Epic Games\EOS "OverlayPath" -(the mechanism from Legendary's lfs/eos.py), naming the one copy the app keeps at OVERLAY_DIR; with -it the game's EOS SDK can show Epic's own sign-in steps in game (a consent Epic asks for once per -product) instead of waiting on a browser. Wine's browser is set to droiddeck-open-url, which hands -web addresses to Android. +The game's prefix gets Wine's browser set to droiddeck-open-url, which hands web addresses to +Android: an EOS sign-in step that falls back to a browser (a consent Epic asks for once per product) +is finished there. An EOS overlay pointer (HKCU\Software\Epic Games\EOS "OverlayPath") an earlier +build wrote is removed - with it the game exited while loading. droiddeck-store-launch """ @@ -38,10 +37,8 @@ SIDECAR = ".droiddeck-store.json" EPIC_CODE = ".droiddeck-epic-code" TIMEOUT = 5.0 STALE_SECONDS = 300 -OVERLAY_DIR = "/root/.local/share/droiddeck/epic-overlay" SERVER_WAIT = 8.0 BROWSER = "/usr/local/bin/droiddeck-open-url" -OVERLAY_DLL = "EOSOVH-Win64-Shipping.dll" EOS_KEY = "[Software\\\\Epic Games\\\\EOS]" BROWSER_KEY = "[Software\\\\Wine\\\\WineBrowser]" @@ -137,20 +134,6 @@ def set_value(reg, key, name, value, now=None): return True -def overlay_version(overlay_dir=OVERLAY_DIR): - """The overlay build the app placed, or None when it is not there.""" - d = Path(overlay_dir) - try: - if not (d / OVERLAY_DLL).is_file(): - return None - except OSError: # unreadable is the same as not there - return None - try: - return (d / "droiddeck-version").read_text().strip() or "unknown" - except OSError: - return "unknown" - - def remove_value(reg, key, name): """Drops every `"name"=` line under `key` in user.reg; True when one was there.""" if not reg.is_file(): @@ -173,10 +156,7 @@ def remove_value(reg, key, name): def options(sidecar): """An Epic game's launch choices from its sidecar, as the Games tab's Epic card sets them.""" e = sidecar.get("epic") if isinstance(sidecar.get("epic"), dict) else {} - # The overlay is off unless chosen (v2 on): the old default wrote overlay=true without a version, - # and with it on a game could exit while loading. The app's EpicOptions reads it the same way. - chosen = isinstance(e.get("v"), int) and e.get("v") >= 2 - return {"eos": e.get("eos", True) is not False, "offline": e.get("offline", False) is True, "overlay": chosen and e.get("overlay") is True} + return {"eos": e.get("eos", True) is not False, "offline": e.get("offline", False) is True} def server_socket(pfx): @@ -219,8 +199,8 @@ def has_value(reg, key, name, value=None): return value is None or last == '"%s"="%s"' % (name, reg_escape(value)) -def provision_prefix(compat_data, overlay_dir=OVERLAY_DIR, overlay=False, wait=SERVER_WAIT): - """The EOS overlay pointer (or its removal, when [overlay] is off) and Wine's browser, in the game's prefix.""" +def provision_prefix(compat_data, wait=SERVER_WAIT): + """Wine's browser set to the hand-off, and an earlier build's EOS overlay pointer removed.""" if not compat_data: return "no-prefix" pfx = Path(compat_data) / "pfx" @@ -232,16 +212,10 @@ def provision_prefix(compat_data, overlay_dir=OVERLAY_DIR, overlay=False, wait=S # winebrowser starts the first entry it can; an absolute path does not depend on the PATH Wine # hands it. set_value(reg, BROWSER_KEY, "Browsers", BROWSER + ",xdg-open") - if not overlay: - remove_value(reg, EOS_KEY, "OverlayPath") - state = "overlay-off" if not has_value(reg, EOS_KEY, "OverlayPath") else "overlay-still-set" - elif overlay_version(overlay_dir) is None: - return "overlay-missing" - else: - target = windows_path(overlay_dir) - set_value(reg, EOS_KEY, "OverlayPath", target) - # Read back, so the log says what the file holds, not what was meant. - state = "overlay-set" if has_value(reg, EOS_KEY, "OverlayPath", target) else "overlay-not-written" + removed = remove_value(reg, EOS_KEY, "OverlayPath") + state = "browser-set" if has_value(reg, BROWSER_KEY, "Browsers", BROWSER + ",xdg-open") else "browser-not-written" + if removed: + state += " old-overlay-removed" return state + (" server-running" if busy else "") @@ -274,8 +248,7 @@ def main(argv): else: got = bool(answer.get("code")) log("epic launch id=%s code=%s reason=%s" % (game, "yes" if got else "no", answer.get("reason", ""))) - done = provision_prefix(compat_data, overlay=choice["overlay"]) - log("epic overlay installed=%s prefix=%s %s" % (overlay_version() or "no", prefix_id or "?", done)) + log("epic prefix=%s %s" % (prefix_id or "?", provision_prefix(compat_data))) return 0 diff --git a/tools/tests/test_store_launch.py b/tools/tests/test_store_launch.py index e83bfbf9f8..e79b286edd 100644 --- a/tools/tests/test_store_launch.py +++ b/tools/tests/test_store_launch.py @@ -119,30 +119,29 @@ class Prefix(unittest.TestCase): (self.compat / 'pfx').mkdir(parents=True) self.reg = self.compat / 'pfx/user.reg' self.reg.write_text('WINE REGISTRY Version 2\n\n[Software\\\\Wine] 1\n"Version"="win10"\n') - self.overlay = root / 'epic-overlay' - self.overlay.mkdir() def tearDown(self): self.tmp.cleanup() - def test_the_overlay_pointer_names_the_shared_copy_through_z(self): - (self.overlay / store.OVERLAY_DLL).write_bytes(b'MZ') - (self.overlay / 'droiddeck-version').write_text('1.0.42') - self.assertEqual('overlay-set', store.provision_prefix(str(self.compat), str(self.overlay), overlay=True)) + def test_wines_browser_is_the_hand_off_by_its_path(self): + self.assertEqual('browser-set', store.provision_prefix(str(self.compat))) text = self.reg.read_text() - self.assertIn('[Software\\\\Epic Games\\\\EOS] ', text) - self.assertIn('"OverlayPath"="Z:' + str(self.overlay).replace('/', '\\\\') + '"', text) + self.assertIn('[Software\\\\Wine\\\\WineBrowser] ', text) self.assertIn('"Browsers"="/usr/local/bin/droiddeck-open-url,xdg-open"', text) # A second launch adds nothing: the last word already says so. - store.provision_prefix(str(self.compat), str(self.overlay), overlay=True) + store.provision_prefix(str(self.compat)) self.assertEqual(text, self.reg.read_text()) - self.assertEqual('1.0.42', store.overlay_version(str(self.overlay))) - def test_no_overlay_yet_or_no_prefix_yet(self): - self.assertEqual('overlay-missing', store.provision_prefix(str(self.compat), str(self.overlay), overlay=True)) - self.assertNotIn('OverlayPath', self.reg.read_text()) - self.assertEqual('prefix-not-created', store.provision_prefix(self.tmp.name + '/compatdata/1', str(self.overlay))) - self.assertEqual('no-prefix', store.provision_prefix('', str(self.overlay))) + def test_an_earlier_builds_overlay_pointer_is_removed(self): + self.reg.write_text(self.reg.read_text() + '\n[Software\\\\Epic Games\\\\EOS] 2\n"OverlayPath"="Z:\\\\x"\n"Other"="kept"\n') + self.assertEqual('browser-set old-overlay-removed', store.provision_prefix(str(self.compat))) + text = self.reg.read_text() + self.assertNotIn('OverlayPath', text) + self.assertIn('"Other"="kept"', text) + + def test_no_prefix_yet(self): + self.assertEqual('prefix-not-created', store.provision_prefix(self.tmp.name + '/compatdata/1')) + self.assertEqual('no-prefix', store.provision_prefix('')) class Choices(unittest.TestCase): @@ -150,11 +149,10 @@ class Choices(unittest.TestCase): with tempfile.TemporaryDirectory() as root: folder = game(root) sidecar = json.loads((folder / '.droiddeck-store.json').read_text()) - self.assertEqual({'eos': True, 'offline': False, 'overlay': False}, store.options(sidecar)) - # The old default (no version) never turns it on; a v2 choice does. - self.assertFalse(store.options({'epic': {'eos': True, 'offline': False, 'overlay': True}})['overlay']) - self.assertTrue(store.options({'epic': {'v': 2, 'overlay': True}})['overlay']) - sidecar['epic'] = {'eos': True, 'offline': True, 'overlay': False} + self.assertEqual({'eos': True, 'offline': False}, store.options(sidecar)) + # An earlier build's overlay field is read past. + self.assertEqual({'eos': True, 'offline': False}, store.options({'epic': {'v': 2, 'overlay': True}})) + sidecar['epic'] = {'eos': True, 'offline': True} (folder / '.droiddeck-store.json').write_text(json.dumps(sidecar)) (folder / '.droiddeck-epic-code').write_text('left over') compat = Path(root) / 'compatdata/1' @@ -168,7 +166,7 @@ class Choices(unittest.TestCase): finally: del os.environ['BL_LAUNCH_DIR'] del os.environ['STEAM_COMPAT_DATA_PATH'] - # Offline: no request was made and no code is left; overlay off: the pointer is gone. + # Offline: no request was made and no code is left; the old overlay pointer is gone. self.assertFalse((Path(root) / 'session/stores/req').exists()) self.assertFalse((folder / '.droiddeck-epic-code').exists()) text = reg.read_text()